Hello I have a problem with a Script. GM/Admins can change outfits by the command /outfit.
Example: /outfit Name, 2 (Orc Warlord)
Now I wanted to add a NPC who changes outfits with this command. The problem is that when the npc says this command, the server crashs.
With Admin or GM it works. The NPC has also the same access.
This is the script:
Example: /outfit Name, 2 (Orc Warlord)
Now I wanted to add a NPC who changes outfits with this command. The problem is that when the npc says this command, the server crashs.
With Admin or GM it works. The NPC has also the same access.
This is the script:
Lua:
focus = 0
talk_start = 0
target = 0
following = false
attacking = false
function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Good bye then.')
focus = 0
talk_start = 0
end
end
function onCreatureTurn(creature)
end
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('Hiho ' .. creatureGetName(cid) .. '! Welcome to the gm shop, here you can buy more hp, mana, or change your outfit.')
focus = cid
talk_start = os.clock()
elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.')
elseif focus == cid then
talk_start = os.clock()
if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
selfSay('Hiho ' .. creatureGetName(cid) .. '! Welcome to the gm shop, here you can buy more hp, mana, or change your outfit.')
focus = cid
talk_start = os.clock()
elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.')
elseif focus == cid then
talk_start = os.clock()
if msgcontains(msg, 'health') or msgcontains(msg, 'hp') then
if pay(cid,10000000) then
selfSay('/health ' .. creatureGetName(cid) .. '')
end
elseif msgcontains(msg, 'mana') then
if pay(cid,10000000) then
selfSay('/mana ' .. creatureGetName(cid) .. '')
end
elseif msgcontains(msg, '2') then
monsterName = 'orc warlord'
if pay(cid,40000000) then
selfSay('/outfit ' .. creatureGetName(cid) .. ', ' .. monsterName .. '')
end
elseif msgcontains(msg, '3') then
monsterName = 'war wolf'
if pay(cid,40000000) then
selfSay('/outfit ' .. creatureGetName(cid) .. ', ' .. monsterName .. '')
end
elseif string.find(msg, '(%a*)bye(%a*)') and focus == cid and getDistanceToCreature(cid) < 3 then
selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
focus = 0
talk_start = 0
end
end
end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('Next Please...')
end
focus = 0
end
end