• 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!

Lua Event error in console

shadowsin

New Member
Joined
Jul 26, 2011
Messages
20
Reaction score
1
I need help with this script, in the part of the function botMagic (params) I tried to put this line but it didn't work.


Lua:
if not isPlayer (cid) then
return true
end

several errors appear when the character logs out.

1588360928090.png



Lua:
local eat = {}
local heal = {}
local magic = {}
local foods = {
    {8, "Crunch.", 2362},
    {15, "Munch.", 2666},
    {12, "Munch.", 2667},
    {10, "Mmmm.", 2668},
    {17, "Munch.", 2669},
    {4, "Gulp.", 2670},
    {30, "Chomp.", 2671},
    {60, "Chomp.", 2672},
    {5, "Yum.", 2673},
    {6, "Yum.", 2674},
    {13, "Yum.", 2675},
    {8, "Yum.", 2676},
    {1, "Yum.", 2677},
    {18, "Slurp.", 2678},
    {1, "Yum.", 2679},
    {2, "Yum.", 2680},
    {9, "Yum.", 2681},
    {20, "Yum.", 2682},
    {17, "Munch.", 2683},
    {8, "Crunch.", 2684},
    {6, "Munch.", 2685},
    {9, "Crunch.", 2686},
    {2, "Crunch.", 2687},
    {9, "Munch.", 2688},
    {10, "Crunch.", 2689},
    {3, "Crunch.", 2690},
    {8, "Crunch.", 2691},
    {6, "Munch.", 2792},
    {9, "Munch.", 2793},
    {6, "Gulp.", 2695},
    {9, "Smack.", 2696},
    {9, "Munch.", 2787},
    {4, "Munch.", 2788},
    {22, "Munch.", 2789},
    {30, "Munch.", 2790},
    {30, "Munch.", 2791},
    {6, "Munch.", 2792},
    {3, "Munch.", 2794},
    {36, "Munch.", 2795},
    {5, "Munch.", 2796},
    {9, "Munch.", 2793}
  
}

function botInfo(cid)
    doPlayerPopupFYI(cid, "Auto Maker\n" ..
    "--Tools--\n" ..
    "--AutoCast and AutoFood--\n" ..
    "!auto cast, spellname, mananeeded\n" ..
    "(example: !auto cast, utevo lux, 25)\n" ..
    "!auto stopcast\n" ..
    ""
    )
end

function botEat(cid)
if not isPlayer(cid) then
     return true
end
    local food = nil
    for _, v in ipairs(foods) do
        if getPlayerItemCount(cid, v[3]) > 0 then
            food = v
            break
        end
    end

    if food ~= nil then
        if((getPlayerFood(cid) + food[1]) >= 400) then
            doPlayerSendCancel(cid, "You are full.")
            eat[getPlayerGUID(cid)] = addEvent(botEat, 20000, cid)
            return
        end
        doPlayerFeed(cid, food[1] * 4)
        doCreatureSay(cid, food[2], TALKTYPE_ORANGE_1)
        doPlayerRemoveItem(cid, food[3], 1)
    end
    eat[getPlayerGUID(cid)] = addEvent(botEat, 20000, cid)
    return true
end



function botMagic(params)
    if getCreatureMana(params[1]) < tonumber(params[3]) then
        magic[getPlayerGUID(params[1])] = addEvent(botMagic, 1500, params)
        return true
        else
      
        doPlayerCastSpell(params[1], params[2])
        magic[getPlayerGUID(params[1])] = addEvent(botMagic, 1500, params)
        return true
        end
    end



function onSay(cid, words, param, channel)

    if getPlayerStorageValue(cid,31234) >= 1 then
        doPlayerSendTextMessage(cid, 22, "AutoCast and EatFood has [DISABLED]")
        setPlayerStorageValue(cid,31234,0)
        stopEvent(magic[getPlayerGUID(cid)])
        stopEvent(eat[getPlayerGUID(cid)])
        return true
        end
    

    if param == "" then
        botInfo(cid)
    end
  

     local params = string.explode(param, ",")
     if params[1] == "eatfSoAod" then
         doPlayerSendTextMessage(cid, 22, "AutoCast and EatFood has [ON]")
        eat[getPlayerGUID(cid)] = addEvent(botEat, 100, cid)
        setPlayerStorageValue(cid,31234,1)

    elseif (params[1] == "cast" and #params == 3) then

        doPlayerSendTextMessage(cid, 22, "AutoCast and EatFood has [WORKING]")
        botMagic({cid, params[2], params[3]})
        setPlayerStorageValue(cid,31234,1)
        eat[getPlayerGUID(cid)] = addEvent(botEat, 100, cid)

    elseif (params[1] == "stopcast") then
        stopEvent(magic[getPlayerGUID(cid)])
             stopEvent(eat[getPlayerGUID(cid)])
        doPlayerSendTextMessage(cid, 22, "AutoCast and EatFood has [OFF]")
        setPlayerStorageValue(cid,31234,0)
     end   
     return true
end
 
Last edited:
I need help with this script, in the part of the function botMagic (params) I tried to put this line but it didn't work.


Lua:
if not isPlayer (cid) then
return true
end

several errors appear when the character logs out.

View attachment 45056



Lua:
local eat = {}
local heal = {}
local magic = {}
local foods = {
    {8, "Crunch.", 2362},
    {15, "Munch.", 2666},
    {12, "Munch.", 2667},
    {10, "Mmmm.", 2668},
    {17, "Munch.", 2669},
    {4, "Gulp.", 2670},
    {30, "Chomp.", 2671},
    {60, "Chomp.", 2672},
    {5, "Yum.", 2673},
    {6, "Yum.", 2674},
    {13, "Yum.", 2675},
    {8, "Yum.", 2676},
    {1, "Yum.", 2677},
    {18, "Slurp.", 2678},
    {1, "Yum.", 2679},
    {2, "Yum.", 2680},
    {9, "Yum.", 2681},
    {20, "Yum.", 2682},
    {17, "Munch.", 2683},
    {8, "Crunch.", 2684},
    {6, "Munch.", 2685},
    {9, "Crunch.", 2686},
    {2, "Crunch.", 2687},
    {9, "Munch.", 2688},
    {10, "Crunch.", 2689},
    {3, "Crunch.", 2690},
    {8, "Crunch.", 2691},
    {6, "Munch.", 2792},
    {9, "Munch.", 2793},
    {6, "Gulp.", 2695},
    {9, "Smack.", 2696},
    {9, "Munch.", 2787},
    {4, "Munch.", 2788},
    {22, "Munch.", 2789},
    {30, "Munch.", 2790},
    {30, "Munch.", 2791},
    {6, "Munch.", 2792},
    {3, "Munch.", 2794},
    {36, "Munch.", 2795},
    {5, "Munch.", 2796},
    {9, "Munch.", 2793}
 
}

function botInfo(cid)
    doPlayerPopupFYI(cid, "Auto Maker\n" ..
    "--Tools--\n" ..
    "--AutoCast and AutoFood--\n" ..
    "!auto cast, spellname, mananeeded\n" ..
    "(example: !auto cast, utevo lux, 25)\n" ..
    "!auto stopcast\n" ..
    ""
    )
end

function botEat(cid)
if not isPlayer(cid) then
     return true
end
    local food = nil
    for _, v in ipairs(foods) do
        if getPlayerItemCount(cid, v[3]) > 0 then
            food = v
            break
        end
    end

    if food ~= nil then
        if((getPlayerFood(cid) + food[1]) >= 400) then
            doPlayerSendCancel(cid, "You are full.")
            eat[getPlayerGUID(cid)] = addEvent(botEat, 20000, cid)
            return
        end
        doPlayerFeed(cid, food[1] * 4)
        doCreatureSay(cid, food[2], TALKTYPE_ORANGE_1)
        doPlayerRemoveItem(cid, food[3], 1)
    end
    eat[getPlayerGUID(cid)] = addEvent(botEat, 20000, cid)
    return true
end



function botMagic(params)
    if getCreatureMana(params[1]) < tonumber(params[3]) then
        magic[getPlayerGUID(params[1])] = addEvent(botMagic, 1500, params)
        return true
        else
     
        doPlayerCastSpell(params[1], params[2])
        magic[getPlayerGUID(params[1])] = addEvent(botMagic, 1500, params)
        return true
        end
    end



function onSay(cid, words, param, channel)

    if getPlayerStorageValue(cid,31234) >= 1 then
        doPlayerSendTextMessage(cid, 22, "AutoCast and EatFood has [DISABLED]")
        setPlayerStorageValue(cid,31234,0)
        stopEvent(magic[getPlayerGUID(cid)])
        stopEvent(eat[getPlayerGUID(cid)])
        return true
        end
   

    if param == "" then
        botInfo(cid)
    end
 

     local params = string.explode(param, ",")
     if params[1] == "eatfSoAod" then
         doPlayerSendTextMessage(cid, 22, "AutoCast and EatFood has [ON]")
        eat[getPlayerGUID(cid)] = addEvent(botEat, 100, cid)
        setPlayerStorageValue(cid,31234,1)

    elseif (params[1] == "cast" and #params == 3) then

        doPlayerSendTextMessage(cid, 22, "AutoCast and EatFood has [WORKING]")
        botMagic({cid, params[2], params[3]})
        setPlayerStorageValue(cid,31234,1)
        eat[getPlayerGUID(cid)] = addEvent(botEat, 100, cid)

    elseif (params[1] == "stopcast") then
        stopEvent(magic[getPlayerGUID(cid)])
             stopEvent(eat[getPlayerGUID(cid)])
        doPlayerSendTextMessage(cid, 22, "AutoCast and EatFood has [OFF]")
        setPlayerStorageValue(cid,31234,0)
     end  
     return true
end
What is you server version and from where you get this script?
 
Back
Top