Last active
December 13, 2019 11:53
-
-
Save u3games/10018593 to your computer and use it in GitHub Desktop.
L2j-Server Script: Anti-Bots (Autolevel)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This program is free software: you can redistribute it and/or modify it under | |
* the terms of the GNU General Public License as published by the Free Software | |
* Foundation, either version 3 of the License, or (at your option) any later | |
* version. | |
* | |
* This program is distributed in the hope that it will be useful, but WITHOUT | |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
* details. | |
* | |
* You should have received a copy of the GNU General Public License along with | |
* this program. If not, see <http://www.gnu.org/licenses/>. | |
*/ | |
package handlers.voicedcommandhandlers; | |
import java.util.concurrent.ScheduledFuture; | |
import com.l2jserver.gameserver.handler.IVoicedCommandHandler; | |
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; | |
/** | |
* @author xban1x, swarlog | |
*/ | |
public final class AntiBot implements IVoicedCommandHandler | |
{ | |
private final String[] COMMANDS = new String[] | |
{ | |
"antibot", | |
}; | |
@Override | |
public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params) | |
{ | |
if (command.equals("antibot") && activeChar.getVariables().hasVariable("BOT_KICK_TASK")) | |
{ | |
// Eliminar efectos: | |
activeChar.getVariables().getObject("BOT_KICK_TASK", ScheduledFuture.class).cancel(true); | |
activeChar.getVariables().remove("BOT_KICK_TASK"); | |
// Mensaje: | |
activeChar.sendMessage("Thanks for your collaboration!"); | |
return true; | |
} | |
return false; | |
} | |
@Override | |
public String[] getVoicedCommandList() | |
{ | |
return COMMANDS; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This program is free software: you can redistribute it and/or modify it under | |
* the terms of the GNU General Public License as published by the Free Software | |
* Foundation, either version 3 of the License, or (at your option) any later | |
* version. | |
* | |
* This program is distributed in the hope that it will be useful, but WITHOUT | |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
* details. | |
* | |
* You should have received a copy of the GNU General Public License along with | |
* this program. If not, see <http://www.gnu.org/licenses/>. | |
*/ | |
package custom.AutoLevel; | |
import ai.npc.AbstractNpcAI; | |
import com.l2jserver.gameserver.ThreadPoolManager; | |
import com.l2jserver.gameserver.datatables.NpcData; | |
import com.l2jserver.gameserver.model.actor.L2Npc; | |
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; | |
import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate; | |
/** | |
* Simple Anti Bot script for Auto Level. | |
* @author St3eT, swarlog | |
*/ | |
public final class AutoLevel extends AbstractNpcAI | |
{ | |
// Chance for show htm after kill monster: | |
private static final int CHANCE = 1; | |
// Time for write the command in chat: (minutes) | |
private static final int TIME = 1; | |
private AutoLevel() | |
{ | |
super(AutoLevel.class.getSimpleName(), "custom"); | |
for (L2NpcTemplate npc : NpcData.getInstance().getAllNpcOfClassType("L2Monster")) | |
{ | |
addKillId(npc.getId()); | |
} | |
} | |
private final class BotKickTask implements Runnable | |
{ | |
private final L2PcInstance _player; | |
public BotKickTask(L2PcInstance player) | |
{ | |
_player = player; | |
} | |
@Override | |
public void run() | |
{ | |
if (_player != null) | |
{ | |
_player.logout(true); | |
} | |
} | |
} | |
@Override | |
public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon) | |
{ | |
if (getRandom(100) < CHANCE) | |
{ | |
// Effect : | |
if (!killer.getVariables().hasVariable("BOT_KICK_TASK")) | |
{ | |
killer.getVariables().set("BOT_KICK_TASK", ThreadPoolManager.getInstance().scheduleAi(new BotKickTask(killer), TIME * 1000 * 60)); | |
} | |
// Sample window: | |
return "index.htm"; | |
} | |
return super.onKill(npc, killer, isSummon); | |
} | |
public static void main(String[] args) | |
{ | |
new AutoLevel(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html noscrollbar> | |
<head> | |
<title>..:: AntiBot - Auto Level ::..</title> | |
<body> | |
<table border=0 cellpadding=0 cellspacing=0 width=292 height=358 background="L2UI_CH3.refinewnd_back_Pattern"> | |
<tr><td valign="top" align="center"> | |
<!-- Emblem --> | |
<table border=0 cellpadding=0 cellspacing=0> | |
<tr><td width=256 height=185 background="L2UI_CT1.OlympiadWnd_DF_GrandTexture"></td></tr> | |
</table> | |
<!-- //Emblem --> | |
<table border=0 cellpadding=0 cellspacing=0> | |
<tr><td align=center>System Protection</td></tr> | |
<tr><td height=19></td></tr> | |
<tr><td align=center>You have <font color="LEVEL">60 seconds</font> to write to the chat</td></tr> | |
<tr><td height=19></td></tr> | |
<tr><td align=center>the command <font color="LEVEL">.antibot</font> or you will be expelled.</td></tr> | |
<tr><td height=19></td></tr> | |
</table> | |
</td></tr> | |
</table> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment