Holá gente eu estava tentando fazer um npc para meu server 7.81, mas na hora de carregar aparece o erro
')' expected near 'So'
Agora olhem o script do meu npc e me ajudem a achar o erro:
focus = 0talk_start = 0
target = 0
following = false
attacking = false
talk_state = 20
cname = ''
vocation = 0
mainlevel = 8
gstat = 0 -- guild status
grank = '' -- guild rank
gname = '' -- guild name
pname = '' -- name of some other player
maxnamelen = 30
maxranklen = 20
maxnicklen = 20
leaderlevel = 50
NONE = 0
INVITED = 1
MEMBER = 2
VICE = 3
leader = 4
allow_pattern = '^[a-zA-Z0-9 -]+$'
function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Bye.')
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)
lastSpoken = os.time()
if ((string.find(msg, '(%a*)hi(%a*)')) and (focus == 0)) and getDistanceToCreature(cid) < 4 then
if getPlayerSex(cid) == 0 then
selfSay('Hi! ' .. cname .. '! Are you ready to leave from academy?')
talk_state = 20
focus = cid
talk_start = os.clock()
else
selfSay('Sorry, but you alredy chose your village. If not, talk to the Admin.')
talk_state = 0
focus = cid
end
elseif string.find(msg, '(%a*)hi(%a*)') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Sorry, ' .. cname .. '! I talk to you in a minute.')
elseif string.find(msg, '(%a*)bye(%a*)') and getDistanceToCreature(cid) < 4 then
selfSay('Cya, ' .. cname .. '!')
talk_state = 20
focus = 0
talk_start = 0 elseif focus == cid then
talk_start = os.clock()
if talk_state == 20 then
if msgcontains(msg, 'yes') then -- confirmando decisao
level = getPlayerLevel(cname)
if level >= mainlevel then
selfSay('Great! I have... 3 villages who is needing some Gennins. Konoha, Suna and Mist. What village do you want?')
talk_state = 1
else
selfSay('Sorry, you don\'t have all the requeriments to be a Gennin...')
talk_state = 20
end
else
-- selfSay('Sorry, come back when you have level '.. mainlevel ..'.')
talk_state = 20
end
elseif talk_state == 1 then -- telling vilage
talk_state = 2
if msgcontains(msg, 'konoha') then
selfSay('Good choice, are you sure?')
talk_state = 2
elseif msgcontains(msg, 'suna') then
selfSay('Good choice, are you sure?')
talk_state = 2
elseif msgcontains(msg, 'mist') then
selfSay('Good choice, are you sure?')
talk_state = 2
else
selfSay('Sorry, this village does not exists...')
vocation = 0
talk_state = 1
end
elseif talk_state == 2 then -- telling vilage
if msgcontains(msg, 'yes') then
selfSay(''So, Konoha village, say yes to go!')
talk_state = 4
elseif msgcontains(msg, 'yes') then
selfSay('Humm, Suna village, say yes to go!')
talk_state = 6
elseif msgcontains(msg, 'yes') then
selfSay('Right, Mist village, say yes to go!')
talk_state = 7
else
selfSay('Sorry, i could not execute this action.')
vocation = 0
talk_state = 2
end
elseif talk_state == 4 then -- confirming vocation
if msgcontains(msg, 'yes') and talk_state == 4 then
setPlayerVocation(cid,1)
buy(cid,2381,1,0)
setPlayerStorageValue(cid,200,1)
learnSpell(cid,'utevo lux',0)
setPlayerStorageValue(cid,5,1)
if getPlayerSex(cid) == 0 then
selfSay('/makesay ' .. creatureGetName(cid) .. ',/promotesex 32')
selfSay('/makesay ' .. creatureGetName(cid) .. ',!cmot3416 29')
setPlayerMasterPos(cid, 456, 141, 7)
Travel(cid, 0, 456, 141, 7)
talk_state = 20
focus = 0
else
selfSay('/makesay ' .. creatureGetName(cid) .. ',/promotesex 32')
selfSay('/makesay ' .. creatureGetName(cid) .. ',!cmot3416 23')
setPlayerMasterPos(cid, 456, 141, 7)
Travel(cid, 0, 456, 141, 7)
talk_state = 20
focus = 0
end
end
end
if talk_state == 6 then
if msgcontains(msg, 'yes') and talk_state == 6 then
setPlayerVocation(cid,1)
buy(cid,2461,1,0)
setPlayerStorageValue(cid,500,1)
learnSpell(cid,'utevo lux',0)
if getPlayerSex(cid) == 0 then
selfSay('/makesay ' .. creatureGetName(cid) .. ',/promotesex 32')
selfSay('/makesay ' .. creatureGetName(cid) .. ',!cmot3416 29')
setPlayerMasterPos(cid,411,1057,7)
Travel(cid, 0, 411, 1057, 7)
talk_state = 20
focus = 0
else
selfSay('/makesay ' .. creatureGetName(cid) .. ',/promotesex 32')
selfSay('/makesay ' .. creatureGetName(cid) .. ',!cmot3416 23')
setPlayerMasterPos(cid,411,1057,7)
Travel(cid, 0, 411, 1057, 7)
talk_state = 20
focus = 0
end
end
end
if talk_state == 7 then
if msgcontains(msg, 'yes') and talk_state == 7 then
setPlayerVocation(cid,1)
buy(cid,2471,1,0)
setPlayerStorageValue(cid,600,1)
learnSpell(cid,'utevo lux',0)
setPlayerStorageValue(cid,5,1)
if getPlayerSex(cid) == 0 then
selfSay('/makesay ' .. creatureGetName(cid) .. ',/promotesex 32')
selfSay('/makesay ' .. creatureGetName(cid) .. ',!cmot3416 29')
Travel(cid, 0, 799, 420, 7)
setPlayerMasterPos(cid,799,420,7)
talk_state = 20
focus = 0
else
selfSay('/makesay ' .. creatureGetName(cid) .. ',/promotesex 32')
selfSay('/makesay ' .. creatureGetName(cid) .. ',!cmot3416 23')
Travel(cid, 0, 799, 420, 7)
setPlayerMasterPos(cid,799,420,7)
talk_state = 20
focus = 0
end
end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
if focus > 0 then
x, y, z = creatureGetPosition(focus)
myx, myy, myz = selfGetPosition()
if ((myy-y==0) and (myx-x<=0 and myx-x>=-4)) then
selfTurn(0)
end
if ((myy-y==0) and (myx-x>=0 and myx-x<=4)) then
selfTurn(2)
end
if ((myx-x==0) and (myy-y<=0 and myy-y>=-4)) then
selfTurn(1)
end
if ((myx-x==0) and (myy-y>=0 and myy-y<=4)) then
selfTurn(3)
end
if ((myy-y==-2) and (myx-x>=-1 and myx-x<=1)) then
selfTurn(1)
end
if ((myy-y==2) and (myx-x>=-1 and myx-x<=1)) then
selfTurn(3)
end
if ((myx-x==2) and (myy-y>=-1 and myy-y<=1)) then
selfTurn(2)
end
if ((myx-x==-2) and (myy-y>=-1 and myy-y<=1)) then
selfTurn(0)
end
if ((myy-y==-3) and (myx-x>=-2 and myx-x<=2)) then
selfTurn(1)
end
if ((myy-y==3) and (myx-x>=-2 and myx-x<=2)) then
selfTurn(3)
end
if ((myx-x==3) and (myy-y>=-2 and myy-y<=2)) then
selfTurn(2)
end
if ((myx-x==-3) and (myy-y>=-2 and myy-y<=2)) then
selfTurn(0)
end
if ((myy-y==-4) and (myx-x>=-3 and myx-x<=3)) then
selfTurn(1)
end
if ((myy-y==4) and (myx-x>=-3 and myx-x<=3)) then
selfTurn(3)
end
if ((myx-x==4) and (myy-y>=-3 and myy-y<=3)) then
selfTurn(2)
end
if ((myx-x==-4) and (myy-y>=-3 and myy-y<=3)) then
selfTurn(0)
end
end
if focus == 0 then
randmove = math.random(1,50)
if randmove == 1 then
selfMove(0)
end
if randmove == 2 then
selfMove(1)
end
if randmove == 3 then
selfMove(2)
end
if randmove == 4 then
selfMove(3)
end
end
if (os.clock() - talk_start) > 45 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
end
end
Se alguem conseguir me dizer onde eu errei agradeço pois sou npc maker iniciante ainda.