focus = 0
talk_start = 0
target = 0
following = false
attacking = false
talk_state = 0
cname = ''
vocation = 0
mainlevel = 30
function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Do widzenia.')
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)
cname = creatureGetName(cid)
msg = string.lower(msg)
if (msgcontains(msg, 'siema') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
selfSay('Witaj. Czy jestes gotowy, aby znalezc sie w drugim swiecie?')
talk_state = 0
focus = cid
talk_start = os.clock()
elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Do kolejki, juz!')
elseif msgcontains(msg, 'nara') and focus == cid and getDistanceToCreature(cid) < 4 then
selfSay('Na razie'!')
talk_state = 0
focus = 0
talk_start = 0
elseif focus == cid then
talk_start = os.clock()
if talk_state == 0 then
if msgcontains(msg, 'tak') then -- wanna go to mainland
level = getPlayerLevel(cname)
if level >= mainlevel then
selfSay('Kim chcesz zostac? a knight, a paladin, a sorcerer or a druid?')
talk_state = 1
else
selfSay('Nie masz takiego lvl.')
talk_state = 0
end
else
selfSay('Na razie idz lvl wbic.')
talk_state = 0
end
elseif talk_state == 1 then -- telling vocation
talk_state = 2
if msgcontains(msg, 'sorcerer') then
selfSay('Na pewno Sorcerer')
vocation = 1
elseif msgcontains(msg, 'druid') then
selfSay('Na pewno Druid?')
vocation = 2
elseif msgcontains(msg, 'paladin') then
selfSay('Na pewno Paladyn??')
vocation = 3
elseif msgcontains(msg, 'knight') then
selfSay('Na pewno Knight??')
vocation = 4
else
selfSay('Sorry, there is no such vocation.')
vocation = 0
talk_state = 1
end
elseif talk_state == 2 then -- confirming vocation
if msgcontains(msg, 'yes') then
selfSay('Idzesz tylko do miasta City. Czy jestes gotow?')
talk_state = 3
else
selfSay('What vocation do you want then?')
talk_state = 1
end
elseif talk_state == 3 then -- telling city name
if msgcontains(msg, 'city') then
selfSay('Narazie!')
setPlayerVocation(cid,vocation)
setPlayerMasterPos(cid,160,54,7)
selfSay('/send ' .. cname .. ', 160 54 7')
talk_state = 0
focus = 0
talk_start = 0
else
selfSay('E zle city wybrales !.')
talk_state = 3
end
end
end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
if (os.clock() - talk_start) > 45 then
if focus > 0 then
selfSay('Nastepny Prosze !...')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Nara Ziomex.')
focus = 0
end
end
end