HA
pedido

NPC que teleporta se apenas estiver tal storage

Por Hamachine, 23 de dez. de 2013 em Scripts

resolvido
script
4
2.6k
HamachineH
23 de dezembro de 2013 às 19:15

Daew galera queria um script de o npc so teleporta o player que tiver a storage 13500 no caso e a storage do vip no ot!

 

quem tiver posta ae pf que eu edito a pos!

 

ja vih varios post mais nemhum deu certo!

Editado Dezembro 23 por Hamachine

zipter98Z
23 de dezembro de 2013 às 19:20

Em data/npc/scripts, crie um arquivo com extensão .lua, nomeie-o travelnpc, e coloque nele o seguinte conteúdo:

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
 
local cfg = {
    storage = 13500,   --Storage.
    pos = {x = x, y = y, z = z},    --Para onde o jogador será teleportado.
}
     
    if msgcontains(msg, "travel") or msgcontains(msg, "viajar") then
        selfSay("Você gostaria de viajar? Para isso, você precisa ser VIP.", cid)
        talkState[talkUser] = 1
        return true
    elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
        if getPlayerStorageValue(cid, cfg.storage) >= 1 then
            selfSay("Boa viajem!", cid)
            doTeleportThing(cid, cfg.pos)
            talkState[talkUser] = 0
            return true
        else
            selfSay("Desculpe, você não é VIP.", cid)
            talkState[talkUser] = 0
            return true
        end
    elseif msgcontains(msg, "no") and talkState[talkUser] == 1 then
        selfSay("Tudo bem, então...", cid)
        talkState[talkUser] = 0
        return true
    end
    return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Depois, em data/npc, crie um arquivo com extensão .xml, e adicione neste o seguinte conteúdo:

<?xml version="1.0" encoding="UTF-8"?>
 
<npc name="Nome do NPC" script="travelnpc.lua" walkinterval="0" floorchange="0" access="5" level="1" maglevel="1">
<health now="150" max="150"/>
<look type="523" head="114" body="119" legs="114" feet="114" corpse="2212"/>    
 
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|, would you like to {travel}?"/>
</parameters>
</npc>

OBS: Não se esqueça de alterar o nome e a outfit do NPC no arquivo acima.

Editado Dezembro 23 por zipter98

HamachineH
23 de dezembro de 2013 às 20:20

vllw ae manolo deu certin te amo s2 kk!

zipter98Z
23 de dezembro de 2013 às 20:25

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