Skylinx
Game Programmer
Heres the script.
Basically, just trades 1 ANNICOIN (Christmas token) for demon armor.
Heres the error I get.
Basically, just trades 1 ANNICOIN (Christmas token) for demon armor.
Code:
function msgcontains(txt, str)
return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function onCreatureSay(cid, type, msg)
msg = string.lower(msg)
if (msgcontains(msg, 'hi') and focus == 0) and getDistanceToCreature(cid) < 4 then
selfSay('Hello ' .. getCreatureName(cid) .. '! say magic sword or the anni reward you want!')
focus = cid
talk_start = os.clock()
elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk with you in one minute.')
-- Demon armor
elseif msgcontains(msg, 'demon armor') then
selfSay('Do you want to trade one Annilator Token for demon armor?')
talk_state = 1
talk_start = os.clock()
elseif talk_state == 1 and msgcontains(msg, 'yes') then
if getPlayerItemCount(cid,6527) >= 1 then
if doPlayerRemoveItem(cid,6527,1) then
selfSay('There you go, No refunds.')
doPlayerAddItem(cid,2494,1)
end
else
selfSay('I\'m afraid you don\'t have an Anni-Token')
end
-- Sov
elseif msgcontains(msg, 'magic sword') then
selfSay('Do you want to trade one Annilator Token for magic sword?')
talk_state = 1
talk_start = os.clock()
elseif talk_state == 1 and msgcontains(msg, 'yes') then
if getPlayerItemCount(cid,6527) >= 1 then
if doPlayerRemoveItem(cid,6527,1) then
selfSay('There you go, No refunds.')
doPlayerAddItem(cid,2400,1)
end
else
selfSay('I\'m afraid you don\'t have an Anni-Token')
end
-- SCA
elseif msgcontains(msg, 'stone cutter axe') then
selfSay('Do you want to trade one Annilator Token, for stone cutter axe?')
talk_state = 1
talk_start = os.clock()
elseif talk_state == 1 and msgcontains(msg, 'yes') then
if getPlayerItemCount(cid,6527) >= 1 then
if doPlayerRemoveItem(cid,6527,1) then
selfSay('There you go, No refunds.')
doPlayerAddItem(cid,2431,1)
end
else
selfSay('I\'m afraid you don\'t have an Anni-Token')
end
end
end
Heres the error I get.
Code:
[22/02/2009 15:36:00] data/npc/scripts/AnniToken.lua:39: attempt to compare nil with number
[22/02/2009 15:36:00] stack traceback:
[22/02/2009 15:36:00] data/npc/scripts/AnniToken.lua:39: in function <data/npc/scripts/AnniToken.lua:36>
[/B]
Im using [B][U]The Forgotten Server, version 0.3 (Beta 3)[/U][/B]
Last edited: