Hi everyone, Im trying to figure out NPC who gonna change player skins with command,
Script :
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 skin shop, here you can change your skin to any monster you wish.')
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.')
if msgcontains(msg, 'Hero') then
monsterName = '73'
if pay(cid,40000) then
selfSay('/outfit ' .. creatureGetName(cid) .. ', ' .. monsterName .. '')
end
elseif msgcontains(msg, 'Gamemaster') then
monsterName = '75'
if pay(cid,40000) then
selfSay('/outfit ' .. creatureGetName(cid) .. ', ' .. monsterName .. '')
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
----------
The problem is that after saying hi, NPC responds as per script, but do not use further actions, any suggestions, what could be the issue ?
after saying Hero or Gamemaster npc just ignores message.
Perfect way of script is when player says Hero, npc uses command /outfit "playername", 73 and replies to him "Please relog to apply changes."
Can somebody help me figure it out ?
Script :
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 skin shop, here you can change your skin to any monster you wish.')
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.')
if msgcontains(msg, 'Hero') then
monsterName = '73'
if pay(cid,40000) then
selfSay('/outfit ' .. creatureGetName(cid) .. ', ' .. monsterName .. '')
end
elseif msgcontains(msg, 'Gamemaster') then
monsterName = '75'
if pay(cid,40000) then
selfSay('/outfit ' .. creatureGetName(cid) .. ', ' .. monsterName .. '')
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
----------
The problem is that after saying hi, NPC responds as per script, but do not use further actions, any suggestions, what could be the issue ?
after saying Hero or Gamemaster npc just ignores message.
Perfect way of script is when player says Hero, npc uses command /outfit "playername", 73 and replies to him "Please relog to apply changes."
Can somebody help me figure it out ?