Ir para conteúdo

Pergunta

Boa Tarde amigos do XTIBIA, estou com um probleminha no meu NPC, ele fica dando o seguinte ERRO no console, quando diz: yes:

 

  Citar
[25/07/2012 22:39:55] [Error - Npc interface]

[25/07/2012 22:39:55] data/npc/scripts/Reborn.lua:onCreatureSay

[25/07/2012 22:39:55] Description:

[25/07/2012 22:39:55] data/npc/scripts/Reborn.lua:59: attempt to index local 'voc' (a nil value)

[25/07/2012 22:39:55] stack traceback:

[25/07/2012 22:39:55] data/npc/scripts/Reborn.lua:59: in function 'callback'

[25/07/2012 22:39:55] data/npc/lib/npcsystem/npchandler.lua:383: in function 'onCreatureSay'

[25/07/2012 22:39:55] data/npc/scripts/Reborn.lua:7: in function <data/npc/scripts/Reborn.lua:7>

 

SCRIPT:

 

  Citar
local keywordHandler = KeywordHandler:new()

local npcHandler = NpcHandler:new(keywordHandler)

NpcSystem.parseParameters(npcHandler)

local talkState = {}

function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end

function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end

function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end

function onThink() npcHandler:onThink() end

local config = {

--[Vocation] = ( Nova Vocation, New Outfit )

[21] = { 22, 137},

[254] = { 255, 351},

[36] = { 37, 148},

[51] = { 52, 144},

[65] = { 66, 152},

[378] = { 379, 451},

[80] = { 81, 150},

[93] = { 94, 150},

[107] = { 108, 509},

[118] = { 119, 118},

[131] = { 132, 34},

[144] = { 145, 15},

[155] = { 156, 15},

[167] = { 168, 173},

[179] = { 180, 178},

[191] = { 192, 184},

[205] = { 206, 190},

[217] = { 218, 221},

[229] = { 230, 281},

[242] = { 243, 60},

[254] = { 255, 351},

[265] = { 266, 334},

[275] = { 276, 80},

[286] = { 287, 338},

[296] = { 297, 198},

 

}

function creatureSayCallback(cid, type, msg)

if(not npcHandler:isFocused(cid)) then

return false

end

 

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

 

if msgcontains(msg, 'reborn') and getPlayerStorageValue(cid,30025) == 4 then

selfSay('You are reborn.', cid)

focus = 0

talk_start = 0

 

elseif msgcontains(msg, 'reborn') and getPlayerLevel(cid) < 250 and getPlayerStorageValue(cid,30025) ~= 4 then

selfSay('Hehe, I say If you READY. You do not have 250 level.', cid)

 

elseif msgcontains(msg, 'reborn') then

selfSay('Are you sure? {yes}', cid)

talkState[talkUser] = 2

 

elseif msgcontains(msg, 'yes') and talkState[talkUser] ==2 and getPlayerLevel(cid) == 250 then

local voc = config[getPlayerVocation(cid)]

doPlayerSetVocation(cid, voc[1])

local outfit = {lookType = voc[2]}

doCreatureChangeOutfit(cid, outfit)

doPlayerAddExp(cid, -(getPlayerExperience(cid)-getExperienceForLevel(1)))

setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)+20000)

setCreatureMaxMana(cid, getCreatureMaxMana(cid)+30000)

doCreatureAddHealth(cid, getCreatureMaxHealth(cid))

doCreatureAddMana(cid, getCreatureMaxMana(cid))

setPlayerStorageValue(cid,30025,4)

talkState[talkUser] = 0

 

elseif msgcontains(msg, 'yes') and getPlayerLevel(cid) ~= 250 then

selfSay('Desculpe, ' .. getCreatureName(cid) .. '! You need level 250 to reborn.', cid)

talkState[talkUser] = 0

 

elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then

selfSay('Sorry, ' .. getCreatureName(cid) .. '! You must revert or transform to reborn.', cid)

talkState[talkUser] = 0

 

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

selfSay('Good bye.', cid)

focus = 0

talk_start = 0

end

 

return true

end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

ALGUEM PODERIA AJUDAR PORFAVOR, VALENDO +REP

Editado por Flaah
Link para o comentário
https://xtibia.com/forum/topic/190577-ajuda-npc-reborn-854-ajuda/
Compartilhar em outros sites

  • Respostas 49
  • Created
  • Última resposta

Top Posters For This Question

Posts Recomendados

  • 0

iaeuaiue, fiz um bagui errado ali... e esse é o Login.lua dele ...

tpw, eu tava com 1 problema igual o dele, ai eu fiz isso e deu certo... não tava ficando a vocation tbm ;x

 

 

  Mostrar conteúdo oculto

 

tenta isso man, em seu Login.lua

Editado por MaatheeuusYuurii
Link para o comentário
https://xtibia.com/forum/topic/190577-ajuda-npc-reborn-854-ajuda/page/3/#findComment-1302813
Compartilhar em outros sites

  • 0

newnaruto = 317 -- outfit apos reborn ----- nova outfit

getPlayerVocation(cid) == 50 then ----- Vocação Atual

doPlayerSetVocation(cid, 95) ----- Nova Vocação

getPlayerLevel(cid) >= 200 ----- Level Nescessario

db.executeQuery("UPDATE `players` SET `looktype`="..newnaruto.." WHERE `players`.`id`= ".. playerid .."") >>>newnaruto<<<< Nome da outfit registrada anteriormente

 

 

Para adicionar um novo personagem para reborn é so copiar esta parte.

e colar abaixo do talk_start = 0, dando duas linhas de espaço

 

 

  Mostrar conteúdo oculto

 

 

no reborn.lua coloca isso

-- SCRIPT FEITO POR YUNIE
-- config
minlevel = 200 -- level para resetar
price = 5000
newlevel = 8 -- level após reset
newexp = 4200 -- nova experiencia após reset
newnaruto = 317 -- outfit apos reborn
-- end config
function addReset(cid)
resets = getResets(cid)
setPlayerStorageValue(cid,1020,resets+1)
return true
end
function getResets(cid)
resets = getPlayerStorageValue(cid,1020)
if resets < 0 then
resets = 0
end
return resets
end
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if msgcontains(msg, 'reborn') and getPlayerStorageValue(cid,30025) == 4 then
		selfSay('Voçe Não Pode Mais Rebornar.')
	 focus = 0
	 talk_start = 0
	 elseif msgcontains(msg, 'reborn') and getPlayerLevel(cid) < 200 and getPlayerStorageValue(cid,30025) ~= 4 then
		   selfSay('So Pode Rebornar Lv 200 Desculpe...kkk que otario')
	 elseif msgcontains(msg, 'reborn') then
		   selfSay('Entao o grande aventureiro gostaria de renascer? {yes}')
							 talk_state = 2
elseif msgcontains(msg, 'yes') and talk_state ==2 and getPlayerLevel(cid) >= 200 and getPlayerVocation(cid) == 50 then
doPlayerSetVocation(cid, 95)
addReset(cid)
playerid = getPlayerGUID(cid)
setPlayerStorageValue(cid,30025,4)
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `level`="..newlevel..",`experience`="..newexp.." WHERE `players`.`id`= ".. playerid .."")
db.executeQuery("UPDATE `players` SET `looktype`="..newnaruto.." WHERE `players`.`id`= ".. playerid .."")
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 2 then
selfSay('Sorry, ' .. getCreatureName(cid) .. '! You must revert or transform, Voce deve transformar ou reverter.')
  elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
	 selfSay('Good bye. Deslogue e logue Por Favor!!!!')
	 focus = 0
	 talk_start = 0
  end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

 

favor manter nome do scripter original do script (YUNIE). eu apenas adicionei umas duas coisinhas. como a parada da outfit, que nao tinha.

Espero que funcione

Editado por CoyoteStark
Link para o comentário
https://xtibia.com/forum/topic/190577-ajuda-npc-reborn-854-ajuda/page/3/#findComment-1303755
Compartilhar em outros sites

  • 0

DESCULPA A DEMORA. ;)

 

Ai CoyoteStark o script que vc me mando até funciona, reborna direitinho, mais n troca a vocation, vou coloca abaixo o script que vc me mando com as modificações, pra ver se eu fiz algo de errado.

 

  Citar
-- SCRIPT FEITO POR YUNIE

-- config

minlevel = 200 -- level para resetar

price = 5000

newlevel = 8 -- level após reset

newexp = 4200 -- nova experiencia após reset

newnaruto = 317 -- outfit apos reborn

 

minlevel = 200 -- level para resetar

price = 5000

newlevel = 8 -- level após reset

newexp = 4200 -- nova experiencia após reset

newsasuke = 19 -- outfit apos reborn

 

-- end config

function addReset(cid)

resets = getResets(cid)

setPlayerStorageValue(cid,1020,resets+1)

return true

end

function getResets(cid)

resets = getPlayerStorageValue(cid,1020)

if resets < 0 then

resets = 0

end

return resets

end

local keywordHandler = KeywordHandler:new()

local npcHandler = NpcHandler:new(keywordHandler)

NpcSystem.parseParameters(npcHandler)

local talkState = {}

function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end

function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end

function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end

function onThink() npcHandler:onThink() end

function creatureSayCallback(cid, type, msg)

if(not npcHandler:isFocused(cid)) then

return false

end

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

if msgcontains(msg, 'reborn') and getPlayerStorageValue(cid,30025) == 4 then

selfSay('Voçe Não Pode Mais Rebornar.')

focus = 0

talk_start = 0

elseif msgcontains(msg, 'reborn') and getPlayerLevel(cid) < 200 and getPlayerStorageValue(cid,30025) ~= 4 then

selfSay('So Pode Rebornar Lv 200 Desculpe...kkk que otario')

elseif msgcontains(msg, 'reborn') then

selfSay('Entao o grande aventureiro gostaria de renascer? {yes}')

talk_state = 2

elseif msgcontains(msg, 'yes') and talk_state ==2 and getPlayerLevel(cid) >= 200 and getPlayerVocation(cid) == 50 then

doPlayerSetVocation(cid, 95)

addReset(cid)

playerid = getPlayerGUID(cid)

setPlayerStorageValue(cid,30025,4)

doRemoveCreature(cid)

db.executeQuery("UPDATE `players` SET `level`="..newlevel..",`experience`="..newexp.." WHERE `players`.`id`= ".. playerid .."")

db.executeQuery("UPDATE `players` SET `looktype`="..newnaruto.." WHERE `players`.`id`= ".. playerid .."")

talk_state = 0

 

 

elseif msgcontains(msg, 'yes') and talk_state ==2 and getPlayerLevel(cid) >= 200 and getPlayerVocation(cid) == 1 then

doPlayerSetVocation(cid, 16)

addReset(cid)

playerid = getPlayerGUID(cid)

setPlayerStorageValue(cid,30025,4)

doRemoveCreature(cid)

db.executeQuery("UPDATE `players` SET `level`="..newlevel..",`experience`="..newexp.." WHERE `players`.`id`= ".. playerid .."")

db.executeQuery("UPDATE `players` SET `looktype`="..newsasuke.." WHERE `players`.`id`= ".. playerid .."")

talk_state = 0

elseif msgcontains(msg, 'yes') and talk_state == 2 then

selfSay('Sorry, ' .. getCreatureName(cid) .. '! You must revert or transform, Voce deve transformar ou reverter.')

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

selfSay('Good bye. Deslogue e logue Por Favor!!!!')

focus = 0

talk_start = 0

end

return true

end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

PS: Vc poderia manda o XML dele, é q to uzando de outro NPC ;P

 

ALGUEM PODERIA AJUDAR PORFAVOR, VALENDO +REP

Link para o comentário
https://xtibia.com/forum/topic/190577-ajuda-npc-reborn-854-ajuda/page/3/#findComment-1305136
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.

×
×
  • Criar Novo...