local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false
local storage = 30001
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 selfsay2(a)
doCreatureSay(a.npc,"Me need 100 iron ore. Then need crude iron. Then after that 50 behemoth fangs. And 50 lizard leather. You understand?",TALKTYPE_SAY)
end
function selfsay3(a)
doCreatureSay(a.npc,"Help me yes or no?",TALKTYPE_SAY)
talk_state = 10
end
function onCreatureSay(cid, type, msg)
msg = string.lower(msg)
status = getPlayerStorageValue(cid,storage)
if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
if status == 1 then
selfSay('Whatcha do in my place?')
focus = cid
talk_start = os.clock()
elseif status >= 9 and status < 15 then
selfSay('Whatcha do in my place?')
focus = cid
talk_start = os.clock()
elseif status == 2 then
selfSay('You back. You know, you right. Brother is right. Fist not always good. Tell him that!')
elseif status == 3 then
selfSay('Whatcha do in my place?')
focus = cid
talk_start = os.clock()
talk_state = 6
else
selfSay('Whatcha do in my place?')
end
elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Im Bussy')
elseif focus == cid then
talk_start = os.clock()
if msgcontains(msg, 'mine') then
selfSay('YOURS? WHAT IS YOURS! NOTHING IS YOURS! IS MINE! GO AWAY, YES?!')
talk_state = 1
elseif msgcontains(msg, 'present') then
if status == 9 then
selfSay('Bron gave me present. Ugly, but nice from him. Me want to give present too. You help me?')
talk_state = 9
end
elseif msgcontains(msg, 'iron ore') then
if status == 10 then
selfSay('You bring 100 iron ore?')
talk_state = 11
end
elseif msgcontains(msg, 'crude iron') then
if status == 11 then
selfSay('You bring crude iron?')
talk_state = 12
end
elseif msgcontains(msg, 'behemoth fangs') then
if status == 12 then
selfSay('You bring 50 behemoth fangs?')
talk_state = 13
end
elseif msgcontains(msg, 'lizard leather') then
if status == 13 then
selfSay('You bring 50 lizard leather?')
talk_state = 14
end
elseif msgcontains(msg, 'axe') then
if status == 14 then
selfSay('Axe is done! For you. Take. Wear like me.')
setPlayerStorageValue(cid,storage, 15)
doPlayerAddAddon(cid, 143, 1)
doPlayerAddAddon(cid, 147, 1)
doSendMagicEffect(getPlayerPosition(cid), 14)
talk_state = 0
end
elseif talk_state == 1 then
if msgcontains(msg, 'no') then
selfSay('YOU STUPID! STUBBORN! I KILL YOU! WILL LEAVE NOW?!')
talk_state = 2
end
elseif talk_state == 2 then
if msgcontains(msg, 'no') then
selfSay('ARRRRRRRRRR! YOU ME DRIVE MAD! HOW I MAKE YOU GO??')
talk_state = 3
end
elseif talk_state == 3 then
if msgcontains(msg, 'no') then
selfSay('I GIVE YOU NO!')
talk_state = 4
end
elseif talk_state == 4 then
if msgcontains(msg, 'say please') then
selfSay('Please? What you mean please? Like I say please you say bye? Please?')
talk_state = 5
end
elseif talk_state == 5 then
if msgcontains(msg, 'yes') then
selfSay('Oh. Easy. Okay. Please is good. Now don\'t say anything. Head aches.')
setPlayerStorageValue(cid,storage, 2)
focus = 0
end
elseif talk_state == 6 then
if msgcontains(msg, 'gelagos') then
selfSay('Annoying kid. Bro hates him, but talking no help. Bro needs fighting spirit!')
talk_state = 7
end
elseif talk_state == 7 then
if msgcontains(msg, 'fighting spirit') then
selfSay('If you want to help bro, bring him fighting spirit. Magic fighting spirit. Ask Djinn.')
setPlayerStorageValue(cid,storage, 4)
focus = 0
end
elseif talk_state == 9 then
if msgcontains(msg, 'yes') then
selfSay('Good! Me make shiny weapon. If you help me, I make one for you too. Like axe I wear. I need stuff. Listen. ...')
a = {npc = getNpcCid()}
addEvent(selfsay2, 5000, a)
addEvent(selfsay3, 10000, a)
end
elseif talk_state == 10 then
if msgcontains(msg, 'yes') then
selfSay('Good. You get 100 iron ore first. Come back.')
setPlayerStorageValue(cid,storage, 10)
end
elseif talk_state == 11 then
if msgcontains(msg, 'yes') then
IO = getPlayerItemCount(cid,5880)
if IO >= 100 then
selfSay('Good! Now bring crude iron.')
setPlayerStorageValue(cid,storage, 11)
doPlayerRemoveItem(cid,5880,100)
else
selfSay('you don\'t have enough iron ores.')
end
end
elseif talk_state == 12 then
if msgcontains(msg, 'yes') then
CI = getPlayerItemCount(cid,5892)
if CI >= 1 then
selfSay('Good! Now bring 50 behemoth fangs.')
setPlayerStorageValue(cid,storage, 12)
doPlayerRemoveItem(cid,5892,1)
else
selfSay('you don\'t have ine crude iron.')
end
end
elseif talk_state == 13 then
if msgcontains(msg, 'yes') then
BF = getPlayerItemCount(cid,5893)
if BF >= 50 then
selfSay('Good! Now bring 50 lizard leather.')
setPlayerStorageValue(cid,storage, 13)
doPlayerRemoveItem(cid,5893,50)
else
selfSay('you don\'t have enough behemoth fangs.')
end
end
elseif talk_state == 14 then
if msgcontains(msg, 'yes') then
LL = getPlayerItemCount(cid,5876)
if LL >= 50 then
selfSay('Ah! All stuff there. I will start making axes now. Come later and ask me for axe.')
setPlayerStorageValue(cid,storage, 14)
doPlayerRemoveItem(cid,5876,50)
focus = 0
else
selfSay('you don\'t have enough lizard leathers.')
end
end
elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Good bye, ' .. getCreatureName(cid) .. '!')
focus = 0
talk_start = 0
end
end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
doNpcSetCreatureFocus(focus)
if (os.clock() - talk_start) > 60 then
if focus > 0 then
selfSay('Good bye then.')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Good bye then.')
focus = 0
end
end
end