Hi guys,
I need some help, I need an NPC to exchange certain items.
I will post a npcs base of ot ...
ITEMS:
Trading system
Script should work this way
magic longsword > hammer of wrath > great halberd
hammer of wrath > magic longsword > great halberd
great halberd > magic longsword > hammer of wrath
an example how it should work:
PLAYER: Hi
NPC
'Hello ' PLAYER .. '! I exchange the quest items, say {change}!')
PLAYER: change
NPC:I can exchange the following items, magic longsword, hammer of wrath, great halberd!
PLAYER: magic longsword
NPC: Do you want to change "magic longsword" by what item?
PLAYER: hammer of wrath
NPC: His longsword magic was traded by hammer of wrath.
data/npc
data/npc/scripts/Konddor/a sweaty cyclops.lua
39/5000
Thank you in advance for helping me!
I need some help, I need an NPC to exchange certain items.
I will post a npcs base of ot ...
ITEMS:
- magic longsword ID: 2390
- hammer of wrath ID: 2444
- great halberd ID: 2443
Trading system
Script should work this way
magic longsword > hammer of wrath > great halberd
hammer of wrath > magic longsword > great halberd
great halberd > magic longsword > hammer of wrath
an example how it should work:
PLAYER: Hi
NPC
PLAYER: change
NPC:I can exchange the following items, magic longsword, hammer of wrath, great halberd!
PLAYER: magic longsword
NPC: Do you want to change "magic longsword" by what item?
PLAYER: hammer of wrath
NPC: His longsword magic was traded by hammer of wrath.
data/npc
XML:
<?xml version="1.0"?>
<npc name="A Sweaty Cyclops" script="data/npc/scripts/Konddor/a sweaty cyclops.lua" access="3">
<look type="22" head="0" body="0" legs="0" feet="0" addons="0"/>
</npc>
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('Hello ' .. creatureGetName(cid) .. '! I exchange the quest items, say {change}!')
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 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
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
39/5000
Thank you in advance for helping me!
