Olá pessoal, hoje vou postar um npc para tíbia. Ele faz com que o player seja teleporta para uma hunt (posição definida no script) e pega um pouco da mana do player, e ele é meio doidinho. Acho que vão gostar dele.
Vamos lá. Crie um arquivo .XML em data/npc, chamado profLuki e cole isso dentro:
E na pasta data/npc/scripts crie um arquivo chamdo profLuck.lua e cole isso dentro:
local config = {
posHunt = { x = 1235, y = 540, z = 7 }, -- Posição para aonde o player vai ser teleportado
mana = 200, -- Quanto de mana vai tirar
efeito = 29, -- Efeito que vai mandar emquanto o mago estiver fazendo a magia
tempo = 2, -- Tempo para o npc terminar a poção e teleportar o player, em segundos.
}
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function doBuyPokemonWithCasinoCoins(cid, poke) npcHandler:onSellpokemon(cid) end
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
if(msgcontains(msg, 'teleport')) then
selfSay("You are prepared for one great {hunt}?", cid)
talkState[cid] = 1
elseif(msgcontains(msg, 'hunt')) and talkState[cid] == 1 then
selfSay("Ok "..getCreatureName(cid)..", but i need a take your mana. You accept?", cid)
talkState[cid] = 2
elseif(msgcontains(msg, 'yes')) and talkState[cid] == 2 then
if getCreatureMana(cid) >= config.mana then else selfSay("Sorry, i need mana for potion.") talkState[cid] = 0 return true end
doCreatureAddMana(cid, -config.mana)
selfSay(""..getCreatureName(cid)..", Tank you!", cid)
selfSay("I'm realyd a potion for you teleport. Wath one seconds.", cid)
doSendMagicEffect(getThingPos(cid), 21)
addEvent(doTeleportThing, config.tempo * 1000, cid, config.posHunt, false)
addEvent(selfSay, config.tempo * 1000, "Eu conseguii!!!!! HAhahahah.", cid)
elseif (msgcontains(msg, 'no')and talkState[cid] == 2) then
selfSay("So good bye...", cid)
talkState[cid] = 0
return false
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Pronto pessoal, fiz esse npc pra não ficar fazendo scripts só para pokemon. Espero que gostem.
info
Grupo: Conde
Registrado: 25/01/12
Posts: 963
Reputação: +265
Olá pessoal, hoje vou postar um npc para tíbia. Ele faz com que o player seja teleporta para uma hunt (posição definida no script) e pega um pouco da mana do player, e ele é meio doidinho. Acho que vão gostar dele.
Vamos lá. Crie um arquivo .XML em data/npc, chamado profLuki e cole isso dentro:
E na pasta data/npc/scripts crie um arquivo chamdo profLuck.lua e cole isso dentro:
local config = { posHunt = { x = 1235, y = 540, z = 7 }, -- Posição para aonde o player vai ser teleportado mana = 200, -- Quanto de mana vai tirar efeito = 29, -- Efeito que vai mandar emquanto o mago estiver fazendo a magia tempo = 2, -- Tempo para o npc terminar a poção e teleportar o player, em segundos. } local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function doBuyPokemonWithCasinoCoins(cid, poke) npcHandler:onSellpokemon(cid) end 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 if(msgcontains(msg, 'teleport')) then selfSay("You are prepared for one great {hunt}?", cid) talkState[cid] = 1 elseif(msgcontains(msg, 'hunt')) and talkState[cid] == 1 then selfSay("Ok "..getCreatureName(cid)..", but i need a take your mana. You accept?", cid) talkState[cid] = 2 elseif(msgcontains(msg, 'yes')) and talkState[cid] == 2 then if getCreatureMana(cid) >= config.mana then else selfSay("Sorry, i need mana for potion.") talkState[cid] = 0 return true end doCreatureAddMana(cid, -config.mana) selfSay(""..getCreatureName(cid)..", Tank you!", cid) selfSay("I'm realyd a potion for you teleport. Wath one seconds.", cid) doSendMagicEffect(getThingPos(cid), 21) addEvent(doTeleportThing, config.tempo * 1000, cid, config.posHunt, false) addEvent(selfSay, config.tempo * 1000, "Eu conseguii!!!!! HAhahahah.", cid) elseif (msgcontains(msg, 'no')and talkState[cid] == 2) then selfSay("So good bye...", cid) talkState[cid] = 0 return false end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())Pronto pessoal, fiz esse npc pra não ficar fazendo scripts só para pokemon. Espero que gostem.