AL
pedido

Colocar NPC para teleportar se tiver storage

Por Allangod, 16 de dez. de 2012 em Scripts

resolvido
6
1k
AllangodA
16 de dezembro de 2012 às 12:08

Olá, esse meu pc teleporta o player para uma hunt que você só sai dela se seu tempo acabar ou se você morrer (Só da para um player entrar nela, se outro tentar vai falar que ja tem gente la). Gostaria de colocar assim... O player só pode falar com esse npc se tiver a tal storage, ta ae o npc

 

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=1039, y=1072, z=7} -- Local da hunt

local posreturn = {x=1039, y=1072, z=7} -- Posiçao onde o player sera teleportado quando acabar o tempo

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

 

 

config = {

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

 

}

 

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

Vlws

caoticC
16 de dezembro de 2012 às 18:29
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=1039, y=1072, z=7} -- Local da hunt
local posreturn = {x=1039, y=1072, z=7} -- Posiçao onde o player sera teleportado quando acabar o tempo
local money = 400000 --- Quanto de dinheiro sera removido

config = {
time = 1, ---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 pode entrar" --- 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) ~= 1 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())

Editado Dezembro 17 por caotic

AllangodA
17 de dezembro de 2012 às 10:07

Não funcionou :/

Alem de ele tirar aquela parada de nao fazer o player voltar, ele ainda nao pede a storage.

caoticC
17 de dezembro de 2012 às 10:22

Cometi um pequeno erro.

Deixei a verificação por igualdade sendo que e diferença :S.

 

Já editei pega o script que postei

AllangodA
17 de dezembro de 2012 às 10:29

Funcionou perfeitamente jaja dou REP+ pra vc, é que eu dei rep+ ontem e era umas 13h.

Vlws msm, podem mover o topico.

caoticC
17 de dezembro de 2012 às 10:32

Tópico movido para a seção de dúvidas e pedidos resolvidos.