Hello. I've written my first LUA script and I have a little problem with it.
Unfortunately when I try use "!heal" or "!mana" I get those errors :
What is wrong with this code ?
#Edit - I'm using TFS 0.2.15.r102 [9.81 tibia]
PHP:
-- uh/mana with commands in-game.
function onSay(cid, words, param)
local playerInfo = {currentHp = getCreatureHealth(cid), maxHp = getCreatureMaxHealth(cid), currentMana = getPlayerMana(cid), maxMana = getPlayerMaxMana(cid), playerSoul = getPlayerSoul(cid)}
if words == "!heal" and playerInfo[1] < playerInfo[2] and playerInfo[5] > 9 then
if doCreatureAddHealth(cid, 50) then
doPlayerAddSoul(cid, playerInfo[5]-9)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Agrhhh!")
--
else
doPlayerSendCancel(cid, "You do not have soul for this!")
end
elseif words == "!mana" and playerInfo[3] < playerInfo[4] and playerInfo[5] > 7 then
if doPlayerAddMana(cid, 45) then
doPlayerAddSoul(cid, playerInfo[5]-7)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Ahhhh!")
else
doPlayerSendCancel(cid, "You do not have soul for this!")
end
end
return TRUE
end
Unfortunately when I try use "!heal" or "!mana" I get those errors :
Code:
Lua Script Error: [TalkAction Interface]
[17/06/2013 23:29:24] data/talkactions/scripts/healtandmana.lua:onSay
[17/06/2013 23:29:24] data/talkactions/scripts/healtandmana.lua:5: attempt to compare two nil values
[17/06/2013 23:29:24] stack traceback:
[17/06/2013 23:29:24] [C]: in function '__lt'
[17/06/2013 23:29:24] data/talkactions/scripts/healtandmana.lua:5: in function <data/talkactions/scripts/healtandmana.lua:2>
#Edit - I'm using TFS 0.2.15.r102 [9.81 tibia]
Last edited: