Pro Warbringer
Retired with developing
Well ive started to make my NPC wich changes Life Crystal into an Life Ring but its hard
Can you help me out a bit since i need it badly..
Yeah i want it cost 500 gold's..
Kind Regard's,
Pro Warbringer
p.s. IT SHOULD TRADE LIFE CRYSTAL FOR LIFE RING
ILL REP!
Can you help me out a bit since i need it badly..
Lua:
focus = 0
talk_start = 0
target = 0
following = false
attacking = false
talk_state = 0
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 trade Life Crystals to Life Rings.')
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, 'Trade Life Crystal') then
if isTrade Life Crystal(cid) then
selfSay('Sorry, you dont have an Life Crystal.')
talk_state = 0
elseif getPlayerLevel(creatureGetName(cid)) < 8 then
selfSay('Sorry, you need level 8 to trade Life Crystals.')
talk_state = 0
elseif not isPremium(cid) then
selfSay('Sorry, you must be premium to trade Life Crystals.')
talk_state = 0
end
elseif msgcontains(msg, 'Trade Life Crystal') or msgcontains(msg, 'Trade Crystal') then
selfSay('Do you want to trade a Life Crystal?')
talk_state = 2
elseif talk_state == 1 then
if msgcontains(msg, 'yes') then
if pay(cid,500) then
selfSay('/i 2168 ' .. creatureGetName(cid))
selfSay('You traded the Life Crystal to an Life Ring.. THANKS!')
else
selfSay('Sorry, you do not have enough money You need 500 gold coins.')
end
end
talk_state = 0
elseif talk_state == 2 then
if msgcontains(msg, 'yes') then
if pay(cid,500) then
selfSay('/i 2168 ' .. creatureGetName(cid))
selfSay('You traded the Life Crystal to an Life Ring.. THANKS!')
else
selfSay('Sorry, you do not have enough money You need 500 gold coins.')
end
end
talk_state = 0
elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
focus = 0
talk_start = 0
end
end
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
Yeah i want it cost 500 gold's..
Kind Regard's,
Pro Warbringer
p.s. IT SHOULD TRADE LIFE CRYSTAL FOR LIFE RING
ILL REP!