• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua [GLOBALEVENTS] Antibot system (change target)

Dibis

Member
Joined
Dec 1, 2022
Messages
73
Reaction score
16
Location
POLAND
Hello.
I need function when my antibot waiting for answer i need :

1.) target change looktype to ...
2.) target change max HP to ...
3.) target (monster) not attack others players only this one.

-[SORRY FOR MY BAD ENG]-
 
TFS version?


Target = the player who gets the anti-bot check?

You want the player who is getting anti-bot check to be safe from monsters till he answers?
[TFS 0.3.7]

1 / 2 - not needed if step 3 is successful.
3 - Yes, that best option for me.

1.) Safe from monsters and can't attack monsters.
2.) Only can't attack monsters.

This is my globalevents script:

LUA:
local tp = {
         {x =xxxx , y = xxxx, z = x},
         {x = xxxx, y = xxxx, z = x}, --- where anti afk monster
         {x =xxxx, y = xxxx, z = x}
            }
    
function onThink()
    for _, cid in ipairs(getPlayersOnline()) do
        local t = getCreatureStorage(cid, 128)
        if t ~= -1 then
            if os.time() >= t then
                for i = 125, 128 do
                    doCreatureSetStorage(cid, i)
                end
                --[[
                doBroadcastMessage(getCreatureName(cid) .. ' has been banned for 2 days for afk botting.')
                doAddAccountBanishment(getPlayerAccountId(cid), getPlayerGUID(cid), os.time() + 2 * 86400, 12, 2, 'Banished by Antibot System', 0)
                doRemoveCreature(cid)
                ]]
                doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, 200)
                doTeleportThing(cid, tp[math.random(#tp)])
            else
                 doSendAnimatedText(getThingPos(cid), tostring(getCreatureStorage(cid, 126)):sub(2) ..' = ?', COLOR_RED, cid)
                --[[local my = getThingPos(cid)
                for _, p in ipairs(getArea(my, 1, 1)) do
                    if doComparePositions(my, p) == false then
                        doSendMagicEffect(p, 31)
                    end
                end
                ]]
            end
        end
    end
    return true
end
 
You can use the storage given to players by anti-bot check in other scripts like this.

To protect players from being damaged:
LUA:
function onStatsChange(cid, attacker, type, combat, value)
    if getPlayerStorageValue(cid, 128) ~= -1 then
        if type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS then
            return false
        end
    end
    return true
end
XML:
<event type="statschange" name="player_protection" event="script" value="player_protection.lua"/>
and register it to login.lua registerCreatureEvent(cid, "player_protection")
To disable player damaging other players or monsters during anti-afk check:
LUA:
function onCombat(cid, target)
    if getPlayerStorageValue(cid, 128) ~= -1 then
        doPlayerSendCancel(cid, "You cannot attack.")
        return false
    end
    return true
end
XML:
<event type="combat" name="disable_combat" event="script" value="disable_combat.lua"/>
and register it to login.lua registerCreatureEvent(cid, "disable_combat")
Hope I didn't forget anything been a while since I used 0.x
 
You can use the storage given to players by anti-bot check in other scripts like this.

To protect players from being damaged:
LUA:
function onStatsChange(cid, attacker, type, combat, value)
    if getPlayerStorageValue(cid, 128) ~= -1 then
        if type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS then
            return false
        end
    end
    return true
end
XML:
<event type="statschange" name="player_protection" event="script" value="player_protection.lua"/>
and register it to login.lua registerCreatureEvent(cid, "player_protection")
To disable player damaging other players or monsters during anti-afk check:
LUA:
function onCombat(cid, target)
    if getPlayerStorageValue(cid, 128) ~= -1 then
        doPlayerSendCancel(cid, "You cannot attack.")
        return false
    end
    return true
end
XML:
<event type="combat" name="disable_combat" event="script" value="disable_combat.lua"/>
and register it to login.lua registerCreatureEvent(cid, "disable_combat")
Hope I didn't forget anything been a while since I used 0.x

I try check this and I'll let you know if it works ! Thank you !
 
You can use the storage given to players by anti-bot check in other scripts like this.

To protect players from being damaged:
LUA:
function onStatsChange(cid, attacker, type, combat, value)
    if getPlayerStorageValue(cid, 128) ~= -1 then
        if type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS then
            return false
        end
    end
    return true
end
XML:
<event type="statschange" name="player_protection" event="script" value="player_protection.lua"/>
and register it to login.lua registerCreatureEvent(cid, "player_protection")
To disable player damaging other players or monsters during anti-afk check:
LUA:
function onCombat(cid, target)
    if getPlayerStorageValue(cid, 128) ~= -1 then
        doPlayerSendCancel(cid, "You cannot attack.")
        return false
    end
    return true
end
XML:
<event type="combat" name="disable_combat" event="script" value="disable_combat.lua"/>
and register it to login.lua registerCreatureEvent(cid, "disable_combat")
Hope I didn't forget anything been a while since I used 0.x

Working perfect! Thank you.
I try add this, to your disable_combat: doPlayerSetNoMove(cid, TRUE), but i can move and walk.
How i can add function - cannot attack and cannot walking ? Please help :(
 
You can use the storage given to players by anti-bot check in other scripts like this.

To protect players from being damaged:
LUA:
function onStatsChange(cid, attacker, type, combat, value)
    if getPlayerStorageValue(cid, 128) ~= -1 then
        if type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS then
            return false
        end
    end
    return true
end
XML:
<event type="statschange" name="player_protection" event="script" value="player_protection.lua"/>
and register it to login.lua registerCreatureEvent(cid, "player_protection")
To disable player damaging other players or monsters during anti-afk check:
LUA:
function onCombat(cid, target)
    if getPlayerStorageValue(cid, 128) ~= -1 then
        doPlayerSendCancel(cid, "You cannot attack.")
        return false
    end
    return true
end
XML:
<event type="combat" name="disable_combat" event="script" value="disable_combat.lua"/>
and register it to login.lua registerCreatureEvent(cid, "disable_combat")
Hope I didn't forget anything been a while since I used 0.x

@m0master - how add protection for players but only for 1 minute?
 
@m0master - how add protection for players but only for 1 minute?
Maybe set a timed storage in your anti_bot script and then check it above in the protection script. That's one way to do it.
setPlayerStorageValue(cid, yourStorage, os.time() + 60)
 
Last edited:
Back
Top