WE
dúvida

Erro em npc...

Por WExpert, 26 de fev. de 2013 em Scripts

resolvido
otserv
tibia
script
21
1.9k
WExpertW
26 de fevereiro de 2013 às 15:04

Bom, eu ligo o server de boa, ae quando falo hi pro npc ele n fala nada e no log do theforgottenserver aparece isso

 

[Error - Npc Interface]

data/npc/sripts/test.lua:39: attempt to compare boolean with number stack traceback:

data/npc/scripts/test.lua:39: in function <data/npc/scripts/test.lua:36>

 

Obs: O q tem na linha 36 do script do npc é "function onCreatureSay(cid, type, msg)" <--sem aspas

E na 39: if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 and getPlayerPz(cid) <= 0 then

 

Quem ajudar leva meu reP+ happy.png

RoksasR
26 de fevereiro de 2013 às 15:10

Cara, posta o script completo por favor :))

Usando spoilers pf.

26 de fevereiro de 2013 às 15:14

Duvida como eu fasso alguma coisa dentro de spoiler?

WExpertW
26 de fevereiro de 2013 às 15:19

 

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('Ahahha.')

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 and getPlayerPz(cid) <= 0 then

 

selfSay('Hahaha ' .. getCreatureName(cid) .. '! Can you death me? Ueeeee ueee')

focus = cid

talk_start = os.clock()

 

 

 

 

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then

selfSay('Sorry, ' .. getCreatureName(cid) .. '! hahahaha.')

 

elseif focus == cid then

talk_start = os.clock()

 

if msgcontains(msg, 'yes') then

if getPlayerStorageValue(cid,8000) >= 1 then

selfSay('Sorry You Cant Do this saga.')

else

travel(cid, 132, 610, 7)

selfSay('You death!')

focus = 0

talk_start = 0

 

 

end

 

 

 

 

 

elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then

selfSay('Good bye, ' .. getCreatureName(cid) .. '!')

focus = 0

talk_start = 0

end

end

end

 

function onThink()

doNpcSetCreatureFocus(focus)

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

 

Editado Fevereiro 26 por WExpert

RoksasR
26 de fevereiro de 2013 às 15:19

Sky, creio que isso seja flood. Mandasse PM ou criasse um tópico :))

Bom, faça assim:

 

 

COLOQUE SEU CODIGO AKI [/spoiler.]

 

ja era :)), essas 2 tags no começo e no fim do código

(SEM O PONTO NO FINAL

 

@@TOPICO

 

BOM, TENTE ASSIM:

 

 

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('Ahahha.')

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)) then

if getDistanceToCreature(cid) < 4 then

if getPlayerPz(cid) <= 0 then

 

selfSay('Hahaha ' .. getCreatureName(cid) .. '! Can you death me? Ueeeee ueee')

focus = cid

talk_start = os.clock()

 

 

 

 

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then

selfSay('Sorry, ' .. getCreatureName(cid) .. '! hahahaha.')

 

elseif focus == cid then

talk_start = os.clock()

 

if msgcontains(msg, 'yes') then

if getPlayerStorageValue(cid,8000) >= 1 then

selfSay('Sorry You Cant Do this saga.')

else

travel(cid, 132, 610, 7)

selfSay('You death!')

focus = 0

talk_start = 0

 

end

 

elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then

selfSay('Good bye, ' .. getCreatureName(cid) .. '!')

focus = 0

talk_start = 0

end

end

end

end

end

 

function onThink()

doNpcSetCreatureFocus(focus)

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

 

Editado Fevereiro 26 por Roksas

26 de fevereiro de 2013 às 15:26

Rep+

 

REP+

Editado Fevereiro 26 por SkyDarkyes

RoksasR
26 de fevereiro de 2013 às 15:35

cara

 

é só no final

 

no começo é

 

sem o /

;]

 

Funcionou o script?

WExpertW
26 de fevereiro de 2013 às 15:41

n funfou, eu tenho um script parecido aki e funfa olha ae:

 

 

 

 

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('Hey!.')

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('Do you want to finish Gt Saga??')

focus = cid

talk_start = os.clock()

 

 

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then

selfSay('Sorry, ' .. getCreatureName(cid) .. '! ????????.')

 

elseif focus == cid then

talk_start = os.clock()

 

 

if msgcontains(msg, 'yes') then

if getPlayerStorageValue(cid,8000) <= 53 then

 

selfSay('Sorry You Cant Do this saga.')

elseif msgcontains(msg, 'yes') then

if getPlayerStorageValue(cid,8000) >= 55 then

selfSay('Sorry You Cant Do this saga.')

 

else

if doPlayerAddItem(cid,5894,1) then

setPlayerStorageValue(cid,8000,55)

 

selfSay('Congratulations!')

focus = 0

talk_start = 0

 

 

end

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 onThink()

doNpcSetCreatureFocus(focus)

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

 

 

interessante q copiei e colei na script do outro e continuou com akele erro, mais na dele msm n tem erro nenhum, vc fala hi e ele fala you finish gt saga? '-'

Editado Fevereiro 26 por WExpert

SlicerS
26 de fevereiro de 2013 às 15:43

sabes oq essa funçao faz?

getPlayerPz(cid)

o resto da linha 39 parece esta correto, eu soh n sei oq essa funçao retorna entao pode ser ela q ta dando o erro.. sei la kk

WExpertW
26 de fevereiro de 2013 às 15:44

eu tentei tirar essa funçao ae e continua o erro :/

RoksasR
26 de fevereiro de 2013 às 15:49

Slicer, essa função coloquei assim:

 

if getPlayerPz(cid) <= 0 then

Ou seja

0 = NAO TA DENTRO PZ

1 = TA DENTRO PZ

 

Não sei se ele tem essa function na lib dele ;s

 

Experimente colocar isso no arquivo lib/050-function

 

 

function getPlayerPz(cid)

return (getTilePzInfo(getCreaturePosition(cid)) == TRUE)

end

 

Editado Fevereiro 26 por Roksas

26 de fevereiro de 2013 às 15:50

 

 

REP

 

 

Editado Fevereiro 26 por SkyDarkyes

SlicerS
26 de fevereiro de 2013 às 15:52

@rok

se essa eh a funçao entao tu flo errado.. ela retorna true e false e n 0 e 1 o.O e entao era esse o erro do script dele...

WExpertW
26 de fevereiro de 2013 às 16:02

eu ja tinha colokado essa função aki, mais parece q ta errada msm pq testei sem ela e deu serto....e foi mal ae eu me confundi com as pastas dos servers ae tava falando errado malz, se tiver como ajeitar essa função mi ajudem pois preciso dela..

 

eu colokei == na função e funfou

olha oq eu pensei..

ja q n existe numero a baixo de 0 na script eh por isso q ta dando erro pq ta assim <= intão colokei == mais so q o npc n quer transportar o player :s

 

e eu acho q o 1 n ta dentro de pz neh n ?

RoksasR
26 de fevereiro de 2013 às 16:03

Cara, não tem muito objetivo essa função. Seria melhor tirar mesmo, ela só verifica se o player ta na área PZ.