Everyone who has never used our Bots before, can test each one for 2 days without any limitation.
The trial is given automatically when you login on the Bot, but in some cases it wouldn't work (security reasons).
If this happens, send me a private message and i will be checking the failed trials manually and adding it for those who didn't get it.
We are looking for resellers who may accept payment methods different from ours, including classictibia's cash, realesta's cash, mastercores' cash, etc. Interested? Click here at anytime.



Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script - Auto detect attack = player damage
#1
Hello,
since player attack is not working correct as I would like, is it possible to fix me script like that?


since people are gfb'ing me out of screen I would like to check default if its player attack then enable cavebot (run to safespot)

thanks

#2
Hello.


This will not consider if it's a player or monster, just if you received any dmg.
if connected() then
    local Messages = getnewmessages()
    for _, msg in ipairs(Messages) do
        if msg.sender == '' and string.find(msg.content, 'hitpoints due to') then
            if getsettings('Cavebot/Enabled') == false then
                setsettings('Cavebot/Enabled', true)
            end
        end
    end
end

This will consider if it's a player and/or a monster. If it's a player, it will enable Cavebot. If it's a monster, it will do nothing.
local REGEX_DMG_TAKEN     = '^You lose (%d+) (%l+) due to an attack by ?a?n? (.-)%.$'
if connected() then
    local Messages = getnewmessages()
    for _, msg in ipairs(Messages) do
        if msg.sender == '' then
            local dmgAmount, dmgType, dmgCreature = msg.content:match(REGEX_DMG_TAKEN)
            if dmgCreature ~= nil then
                if dmgCreature:lower() == dmgCreature then
                    --Is monster...
                else
                    --Is player...
                    if getsettings('Cavebot/Enabled') == false then
                        setsettings('Cavebot/Enabled', true)
                    end
                end
            end
        end
    end
end



Forum Jump:



Forum software by © MyBB Theme © iAndrew 2016