Ir para conteúdo

Posts Recomendados

Olá.

Eu tenho 2 npcs que levam o player para hunt se ele tiver algumas storages (2124,1 2124,2 2124,3), se o player morrer ou sair, outro player poderá ir para a hunt (Caso contrario ninguem poderá na hunt).

Olhem ae

 

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)

local pos = {x=753, y=1159, z=7} -- Local da hunt

local posreturn = {x=796, y=1155, z=2} -- Posiçao onde o player sera teleportado quando acabar o tempo

local money = 10000 --- Quanto de dinheiro sera removido

 

config = {

time = 6, ---Tempo que ele vai ficar na hunt sabendo que cada numeral equivale a um minuto-----

str = 2124, --- Storage que ele necessita

msg = "Você não é um ninja rank C" --- Mensagem que irá aparecer se ele não tiver a storage

}

function doReturnPos()

doTeleportThing(cid, posreturn)

setGlobalStorageValue(24688, 0)

setGlobalStorageValue(24686, none)

setPlayerStorageValue(cid, 28680, 0)

end

if(not npcHandler:isFocused(cid)) then

return false

end

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

if msgcontains(msg, 'chuunin') then

if getPlayerStorageValue(cid, config.str) <= 0 or getPlayerStorageValue(cid, config.str) >= 4 then

doPlayerSendTextMessage(cid,22, config.msg)

return true

end

if getGlobalStorageValue(24688) == 1 then

doPlayerSendTextMessage(cid,22,"O player "..getGlobalStorageValue(24686).." esta fazendo o teste")

return true

end

if not doPlayerRemoveMoney(cid, money) then

doPlayerSendTextMessage(cid,22,""..getPlayerName(cid).." precisa de "..money.." para fazer o chuunin teste")

return true

end

doPlayerRemoveMoney(cid, money)

doPlayerSendTextMessage(cid,22,"Obrigado "..getPlayerName(cid).." foi teleportado.")

doTeleportThing(cid, pos)

setGlobalStorageValue(24688, 1)

setGlobalStorageValue(24686, getPlayerName(cid))

setPlayerStorageValue(cid, 28680, 1)

addEvent(doReturnPos, config.time*60*1000)

else

selfSay('Diga chuunin', cid)

end

return true

end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

Agora eu to tentando criar um npc igualzinho só que com todas storages diferentes, só que quando o player morre a storage continua no player, e ninguem pode entrar na hunt.

Olhem o NPC como ficou...

 

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)

local pos = {x=442, y=1268, z=6} -- Local da hunt

local posreturn = {x=743, y=1374, z=9} -- Posiçao onde o player sera teleportado quando acabar o tempo

local money = 30000 --- Quanto de dinheiro sera removido

 

config = {

time = 10, ---Tempo que ele vai ficar na hunt sabendo que cada numeral equivale a um minuto-----

str = 2124, --- Storage que ele necessita

msg = "Você não é um ninja rank B" --- Mensagem que irá aparecer se ele não tiver a storage

}

function doReturnPos()

doTeleportThing(cid, posreturn)

setGlobalStorageValue(24689, 0)

setGlobalStorageValue(24687, none)

setPlayerStorageValue(cid, 28681, 0)

end

if(not npcHandler:isFocused(cid)) then

return false

end

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

if msgcontains(msg, 'jounnin') then

if getPlayerStorageValue(cid, config.str) <= 5 or getPlayerStorageValue(cid, config.str) >= 8 then

doPlayerSendTextMessage(cid,22, config.msg)

return true

end

if getGlobalStorageValue(24689) == 1 then

doPlayerSendTextMessage(cid,22,"O player "..getGlobalStorageValue(24687).." esta fazendo o teste")

return true

end

if not doPlayerRemoveMoney(cid, money) then

doPlayerSendTextMessage(cid,22,""..getPlayerName(cid).." precisa de "..money.." para fazer o jounnin teste")

return true

end

doPlayerRemoveMoney(cid, money)

doPlayerSendTextMessage(cid,22,"Obrigado "..getPlayerName(cid).." foi teleportado.")

doTeleportThing(cid, pos)

setGlobalStorageValue(24689, 1)

setGlobalStorageValue(24687, getPlayerName(cid))

setPlayerStorageValue(cid, 28681, 1)

addEvent(doReturnPos, config.time*60*1000)

else

selfSay('Diga jounnin', cid)

end

return true

end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

E no creaturescripts tem la no primeiro npchunt

 

function onDeath(cid, corpse, killer)

function doReturnDeath()

setGlobalStorageValue(24688, 0)

setGlobalStorageValue(24686, none)

setPlayerStorageValue(cid, 28680, 0)

end

if getPlayerStorageValue(cid, 28680) == 1 then

doReturnDeath()

end

return TRUE

end

 

No segundo ta assim

 

function onDeath(cid, corpse, killer)

function doReturnDeath()

setGlobalStorageValue(24689, 0)

setGlobalStorageValue(24687, none)

setPlayerStorageValue(cid, 28681, 0)

end

if getPlayerStorageValue(cid, 28681) == 1 then

doReturnDeath()

end

return TRUE

end

Alguem me ajuda a resolver esse problema! O primeiro npc funciona perfeitamente, agora o segundo não funciona, se eu morrer o npc fala que tem gente fazendo o teste ainda :/

Obs: eu me baseei esse npc nesse link aqui http://www.xtibia.co...87179-npc-hunt/

Quem conserguir REP+

Editado por Allangod
Link para o comentário
https://xtibia.com/forum/topic/204036-ajuda-com-esse-npc/
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...