christiandb
Member
Heya,
I got this so far:
It's probably really bugged and I heard it's using the old NPC-system. I'd appreciate it if someone can fix this (rep++ as well ofc).
Thanks in advance,
Chris~
I got this so far:
PHP:
local focus = 0
local talk_start = 0
local target = 0
local following = false
local 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)
end
if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
selfSay('Great to meet you again, ' .. creatureGetName(cid) .. '! I can exchange mystic turban for 1 blue piece of cloth, red robe for 1 red piece of cloth, green tunics for 1 green piece of cloth. And i can exchange a crown armor for piece of royal steel, devil helmet for piece of hell steel, dragon shield for piece of draconian steel, giant sword for huge chunk of crude iron, soul orb for 10 infernal bolts. Also warrior helmet for 1 flask warrior sweat and 10 giant spider silk for spool of yarn.')
focus = cid
talk_start = os.clock()
end
elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.')
end
elseif focus == cid then
talk_start = os.clock()
if msgcontains(msg, 'warrior helmet') then
selfSay('Do you want trade 4 warrior helmets for warrior sweat?')
talk_state = 1
end
elseif talk_state == 1 then
if msgcontains(msg, 'yes') then
doPlayerRemoveItem(cid, 2475, 4)
doPlayeraddItem(cid, 5885, )
selfSay('Here you go, warror sweat.')
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('Next Please...')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Good bye then.)
focus = 0
end
end
end
It's probably really bugged and I heard it's using the old NPC-system. I'd appreciate it if someone can fix this (rep++ as well ofc).
Thanks in advance,
Chris~