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

NPC crashes server.

tatara

New Member
Joined
Jan 1, 2023
Messages
36
Reaction score
3
GitHub
Tatara
Hi everyone. I got a problem on a OT, that if you talk to NPC, it crashes whole server. Any ideas, what can cause that ?

Example : When i say hi -> hp or mp to NPC, server crashes.

NPC SCRIPT :
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 or mana.')
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,5000000) then
selfSay('/health ' .. creatureGetName(cid) .. '')
end

elseif msgcontains(msg, 'mana') then
if pay(cid,5000000) then
selfSay('/mana ' .. creatureGetName(cid) .. '')
end


elseif string.find(msg, '(%a*)bye(%a*)') and getDistanceToCreature(cid) < 4 then
selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
focus = 0
talk_start = 0
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
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Good bye then.')
focus = 0
end
end
end
 
function onCreatureTurn(creature)

end
function onCreatureChangeOutfit(creature)

end
maybe return false even this is just an empty function?
or remove them anyways and return false before the last end
e.g

end
return true
end
 
Back
Top