local focus = 0
local talk_start = 0
local target = 0
local days = 0
function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Nara, ' .. creatureGetName(cid) .. '!')
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('Elo ' .. creatureGetName(cid) .. '! zamieniam itemy.')
focus = cid
talk_start = os.clock()
elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Sorry, ' .. creatureGetName(cid) .. '! Pogadam z toba za minute.')
elseif focus == cid then
talk_start = os.clock()
if msgcontains(msg, 'nightmare shield') or msgcontains(msg, 'shield') then
selfSay('Chcesz zamienic 300 demonic essence na Nightmare Shield?')
talk_state = 1
elseif msgcontains(msg, 'magican hat') or msgcontains(msg, 'hat') then
selfSay('Chcesz zamienic dracolas eye, countess sorrows frozen tear, 100 entached small sapphire i 10 blue poc na magican hat?')
talk_state = 2
elseif talk_state == 1 then
if msgcontains(msg, 'yes') or msgcontains(msg, 'tak') then
if getPlayerItemCount(cid, 6500) > 299 then
doPlayerRemoveItem(cid, 6500, 300)
doPlayerAddItem(cid, 6391, 1)
selfSay('Dzieki! Oto twoja tarcza!')
else
selfSay('Nie masz itemow!')
end
end
talk_state = 0
elseif talk_state == 2 then
if msgcontains(msg, 'yes') or msgcontains(msg, 'tak') then
if getPlayerItemCount(cid, 6549) > 0 and getPlayerItemCount(cid, 6536) > 0 and getPlayerItemCount(cid, 7759) > 99 and getPlayerItemCount(cid, 5912) > 9 then
doPlayerRemoveItem(cid, 6546, 1)
doPlayerRemoveItem(cid, 6536, 1)
doPlayerRemoveItem(cid, 7759, 100)
doPlayerRemoveItem(cid, 5912, 10)
doPlayerAddItem(cid, 2662, 1)
selfSay('Dzieki! Oto twoj magican hat!')
else
selfSay('Nie masz itemow!')
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 onCreatureChangeOutfit(creature)
end
function onThink()
doNpcSetCreatureFocus(focus)
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('Nastepny noob...')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Spadaj.')
focus = 0
end
end
end