[Resolvido] Npc que teleporta aleatoriamente

JeanCristian
em Resolvidos

JeanCristian

ADM MiHawk
avatar
Visconde
Visconde

INFOS

Grupo: ViscondeRegistrado: 12/04/12Posts: 328Char no Tibia: ADM MiHawk

olá galerinha do xtibia, queria um script facil que nao sou bom o suficiente para fazer, ele é simples o npc vai teleportar o player para lugar x ou y aleatoriamente tendo 50% de chance para os 2 ou pode ser 3 lugares tambem, a diferença é que esse npc ele checa o level, por exemplo eu quero que o player seja transportado por stage, players do level 50 ao 100 vao ser teleportados aleatoriamente para outro lugar diferente dos players 8 ao 49, tambem gostaria que só pude-se usar esse npc de teleporte a cada 23 horas. desde já agradeço e reputo quem me ajudar com isso!

Acadêmico: 5 Post[x]

Gennin: 15 Posts[x]

Chunnin: 40 Posts[x]

Jounnin: 60 Posts[x]

Jounnin Tokubetsu: 80 Posts[x]

ANBU: 100 Posts[X]

ANBU Elite: 130 Posts[ ]

Kage: 160 Posts[ ]

Sannin: 200 Posts[ ]

Sannin Lendário: 250 Posts[ ]

Sannin Mundial: 300 Posts[ ]

 

th_Ichigo_Mugetsu-1.gifth_BleachMovie4-SkullCladIchigo.gifth_HollowTransformation.gif

Fjinst

avatar
Visconde
Visconde

INFOS

Grupo: ViscondeRegistrado: 26/04/08Posts: 251Gênero: MasculinoChar no Tibia: Senhor Mithril

Qual a versão do script?

 

Fiz um aqui baseado no 8.54 - não testei

 

 local keywordHandler = KeywordHandler:new()local npcHandler = NpcHandler:new(keywordHandler)NpcSystem.parseParameters(npcHandler)local talkState = {} function onCreatureDisappear(cid)                       npcHandler:onCreatureDisappear(cid)                     endfunction onCreatureSay(cid, type, msg)                  npcHandler:onCreatureSay(cid, type, msg)                endfunction 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 config1 = {cooldown = 82800, }  if msgcontains(msg, 'teleport') or msgcontains(msg, 'tp') or msgcontains(msg, 'quest') or msgcontains(msg, 'help')  then npcHandler:say('Hahaha, eu posso leva-lo a um local mistico, voce quer ir {transportar}?.', cid)talkState[talkUser] = 2elseif  msgcontains(msg, 'transportar') or msgcontains(msg, 'yes') and (talkState[talkUser] == 2)  thentalkState[talkUser] = 0if os.time() - getPlayerStorageValue(cid, 28126) >= config1.cooldown then -------- AQUI SÃO OS JOGADORES DO LEVEL 1 A 49if getPlayerLevel(cid) >= 1 and getPlayerLevel(cid) <= 49 thenlocal sorte = math.random(1,3)--- POSIÇÃO DOS LOCAIS NO QUAL O JOGADOR SERÁ TELETRANSPORTADOlocal teleport1 = {x=1074, y=654, z=7}local teleport2 = {x=1074, y=654, z=7}local teleport3 = {x=1074, y=654, z=7}if sorte == 1 thennpcHandler:say('Hahaha, boa viagem meu caro.', cid)doTeleportThing(cid, teleport1)talkState[talkUser] = 0elseif sorte == 2 thennpcHandler:say('Hahaha, boa viagem meu caro.', cid)doTeleportThing(cid, teleport2)talkState[talkUser] = 0elseif sorte == 3 thennpcHandler:say('Hahaha, boa viagem meu caro.', cid)doTeleportThing(cid, teleport3)talkState[talkUser] = 0endendend----- #FIM DOS TPS DO JOGADOR LEVEL 1 A49-------- AQUI SÃO OS JOGADORES DO LEVEL 1 A 49if getPlayerLevel(cid) >= 50 and getPlayerLevel(cid) <= 100 thenlocal sorte = math.random(1,3)--- POSIÇÃO DOS LOCAIS NO QUAL O JOGADOR SERÁ TELETRANSPORTADOlocal teleport4 = {x=1074, y=654, z=7}local teleport5 = {x=1074, y=654, z=7}local teleport6 = {x=1074, y=654, z=7}if sorte == 1 thennpcHandler:say('Hahaha, boa viagem meu caro.', cid)doTeleportThing(cid, teleport4)talkState[talkUser] = 0elseif sorte == 2 thennpcHandler:say('Hahaha, boa viagem meu caro.', cid)doTeleportThing(cid, teleport5)talkState[talkUser] = 0elseif sorte == 3 thennpcHandler:say('Hahaha, boa viagem meu caro.', cid)doTeleportThing(cid, teleport6)talkState[talkUser] = 0endend----- #FIM DOS TPS DO JOGADOR LEVEL 1 A49if getPlayerLevel(cid) >= 101 thennpcHandler:say('Somente jogadores entre o nivel 8 a 100 podem utilizar esse servico.', cid)talkState[talkUser] = 0endelsenpcHandler:say('Voce ja foi teletransportado, espere '..(config1.cooldown - (os.time() - getPlayerStorageValue(cid, 28126)))..' segundos para poder ser transportado novamente.')endendnpcHandler:setCallback(CALLBACK_ONTHINK, thinkCallback)npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)npcHandler:addModule(FocusModule:new())

 

I dont nothing to show, if u see this, sorry for you lose you time

JeanCristian

ADM MiHawk
avatar
Visconde
Visconde

INFOS

Grupo: ViscondeRegistrado: 12/04/12Posts: 328Char no Tibia: ADM MiHawk

vou testar e te reputo desde já pela iniciativa

versão é 8.60

então, esta tudo certo e pah, só falta storage para o player nao teleportar infinitamente, tipo ele vai poder teleportar só uma vez a cada 23 horas

Acadêmico: 5 Post[x]

Gennin: 15 Posts[x]

Chunnin: 40 Posts[x]

Jounnin: 60 Posts[x]

Jounnin Tokubetsu: 80 Posts[x]

ANBU: 100 Posts[X]

ANBU Elite: 130 Posts[ ]

Kage: 160 Posts[ ]

Sannin: 200 Posts[ ]

Sannin Lendário: 250 Posts[ ]

Sannin Mundial: 300 Posts[ ]

 

th_Ichigo_Mugetsu-1.gifth_BleachMovie4-SkullCladIchigo.gifth_HollowTransformation.gif

Fjinst

avatar
Visconde
Visconde

INFOS

Grupo: ViscondeRegistrado: 26/04/08Posts: 251Gênero: MasculinoChar no Tibia: Senhor Mithril

Verdade, esqueci de adicionar, funciona em 8.60 também

 

local keywordHandler = KeywordHandler:new()local npcHandler = NpcHandler:new(keywordHandler)NpcSystem.parseParameters(npcHandler)local talkState = {} function onCreatureDisappear(cid)                       npcHandler:onCreatureDisappear(cid)                     endfunction onCreatureSay(cid, type, msg)                  npcHandler:onCreatureSay(cid, type, msg)                endfunction 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 config1 = {cooldown = 82800, }  if msgcontains(msg, 'teleport') or msgcontains(msg, 'tp') or msgcontains(msg, 'quest') or msgcontains(msg, 'help')  then npcHandler:say('Hahaha, eu posso leva-lo a um local mistico, voce quer ir {transportar}?.', cid)talkState[talkUser] = 2elseif  msgcontains(msg, 'transportar') or msgcontains(msg, 'yes') and (talkState[talkUser] == 2)  thentalkState[talkUser] = 0if os.time() - getPlayerStorageValue(cid, 28126) >= config1.cooldown then -------- AQUI SÃO OS JOGADORES DO LEVEL 1 A 49if getPlayerLevel(cid) >= 1 and getPlayerLevel(cid) <= 49 thenlocal sorte = math.random(1,3)--- POSIÇÃO DOS LOCAIS NO QUAL O JOGADOR SERÁ TELETRANSPORTADOlocal teleport1 = {x=1074, y=654, z=7}local teleport2 = {x=1074, y=654, z=7}local teleport3 = {x=1074, y=654, z=7}if sorte == 1 thennpcHandler:say('Hahaha, boa viagem meu caro.', cid)doTeleportThing(cid, teleport1)talkState[talkUser] = 0elseif sorte == 2 thennpcHandler:say('Hahaha, boa viagem meu caro.', cid)doTeleportThing(cid, teleport2)talkState[talkUser] = 0elseif sorte == 3 thennpcHandler:say('Hahaha, boa viagem meu caro.', cid)doTeleportThing(cid, teleport3)talkState[talkUser] = 0endendend----- #FIM DOS TPS DO JOGADOR LEVEL 1 A49-------- AQUI SÃO OS JOGADORES DO LEVEL 1 A 49if getPlayerLevel(cid) >= 50 and getPlayerLevel(cid) <= 100 thenlocal sorte = math.random(1,3)--- POSIÇÃO DOS LOCAIS NO QUAL O JOGADOR SERÁ TELETRANSPORTADOlocal teleport4 = {x=1074, y=654, z=7}local teleport5 = {x=1074, y=654, z=7}local teleport6 = {x=1074, y=654, z=7}if sorte == 1 thennpcHandler:say('Hahaha, boa viagem meu caro.', cid)doTeleportThing(cid, teleport4)talkState[talkUser] = 0elseif sorte == 2 thennpcHandler:say('Hahaha, boa viagem meu caro.', cid)doTeleportThing(cid, teleport5)talkState[talkUser] = 0elseif sorte == 3 thennpcHandler:say('Hahaha, boa viagem meu caro.', cid)doTeleportThing(cid, teleport6)talkState[talkUser] = 0endendsetPlayerStorageValue(cid, 28126, os.time())----- #FIM DOS TPS DO JOGADOR LEVEL 1 A49if getPlayerLevel(cid) >= 101 thennpcHandler:say('Somente jogadores entre o nivel 8 a 100 podem utilizar esse servico.', cid)talkState[talkUser] = 0endelsenpcHandler:say('Voce ja foi teletransportado, espere '..(config1.cooldown - (os.time() - getPlayerStorageValue(cid, 28126)))..' segundos para poder ser transportado novamente.')endendnpcHandler:setCallback(CALLBACK_ONTHINK, thinkCallback)npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)npcHandler:addModule(FocusModule:new())

 

I dont nothing to show, if u see this, sorry for you lose you time

JeanCristian

ADM MiHawk
avatar
Visconde
Visconde

INFOS

Grupo: ViscondeRegistrado: 12/04/12Posts: 328Char no Tibia: ADM MiHawk

vou testar aqui mais ja deixo o rep

npcHandler:say('Voce ja foi teletransportado, espere '..?config1.cooldown - (os.time() - getPlayerStorageValue(cid, 28126)))..' segundos para poder ser transportado novamente.')
 essa parte, da checagem, e falando tempo q falta , nao ta falando, ele nao tem a cancelmsg sei la o nome
quando fala yes ele nem responde

a msg do ultimo else, que seria o cancel, ele nao ta falano, entao se o player ja fez, ele simples ignora qd fala yes dnovo

Acadêmico: 5 Post[x]

Gennin: 15 Posts[x]

Chunnin: 40 Posts[x]

Jounnin: 60 Posts[x]

Jounnin Tokubetsu: 80 Posts[x]

ANBU: 100 Posts[X]

ANBU Elite: 130 Posts[ ]

Kage: 160 Posts[ ]

Sannin: 200 Posts[ ]

Sannin Lendário: 250 Posts[ ]

Sannin Mundial: 300 Posts[ ]

 

th_Ichigo_Mugetsu-1.gifth_BleachMovie4-SkullCladIchigo.gifth_HollowTransformation.gif

Fjinst

avatar
Visconde
Visconde

INFOS

Grupo: ViscondeRegistrado: 26/04/08Posts: 251Gênero: MasculinoChar no Tibia: Senhor Mithril

Pronto

local keywordHandler = KeywordHandler:new()local npcHandler = NpcHandler:new(keywordHandler)NpcSystem.parseParameters(npcHandler)local talkState = {} function onCreatureDisappear(cid)                       npcHandler:onCreatureDisappear(cid)                     endfunction onCreatureSay(cid, type, msg)                  npcHandler:onCreatureSay(cid, type, msg)                endfunction 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 config1 = {cooldown = 82800, }  if msgcontains(msg, 'teleport') or msgcontains(msg, 'tp') or msgcontains(msg, 'quest') or msgcontains(msg, 'help')  then npcHandler:say('Hahaha, eu posso leva-lo a um local mistico, voce quer ir {transportar}?.', cid)talkState[talkUser] = 2elseif  msgcontains(msg, 'transportar') or msgcontains(msg, 'yes') and (talkState[talkUser] == 2)  thentalkState[talkUser] = 0if os.time() - getPlayerStorageValue(cid, 28126) >= config1.cooldown then -------- AQUI SÃO OS JOGADORES DO LEVEL 1 A 49if getPlayerLevel(cid) >= 1 and getPlayerLevel(cid) <= 49 thenlocal sorte = math.random(1,3)--- POSIÇÃO DOS LOCAIS NO QUAL O JOGADOR SERÁ TELETRANSPORTADOlocal teleport1 = {x=1495, y=1219, z=7}local teleport2 = {x=1495, y=1219, z=7}local teleport3 = {x=1495, y=1219, z=7}if sorte == 1 thennpcHandler:say('Hahaha, boa viagem meu caro.', cid)doTeleportThing(cid, teleport1)talkState[talkUser] = 0elseif sorte == 2 thennpcHandler:say('Hahaha, boa viagem meu caro.', cid)doTeleportThing(cid, teleport2)talkState[talkUser] = 0elseif sorte == 3 thennpcHandler:say('Hahaha, boa viagem meu caro.', cid)doTeleportThing(cid, teleport3)talkState[talkUser] = 0endend----- #FIM DOS TPS DO JOGADOR LEVEL 1 A49-------- AQUI SÃO OS JOGADORES DO LEVEL 1 A 49if getPlayerLevel(cid) >= 50 and getPlayerLevel(cid) <= 100 thenlocal sorte = math.random(1,3)--- POSIÇÃO DOS LOCAIS NO QUAL O JOGADOR SERÁ TELETRANSPORTADOlocal teleport4 = {x=1495, y=1219, z=7}local teleport5 = {x=1495, y=1219, z=7}local teleport6 = {x=1495, y=1219, z=7}if sorte == 1 thennpcHandler:say('Hahaha, boa viagem meu caro.', cid)doTeleportThing(cid, teleport4)talkState[talkUser] = 0elseif sorte == 2 thennpcHandler:say('Hahaha, boa viagem meu caro.', cid)doTeleportThing(cid, teleport5)talkState[talkUser] = 0elseif sorte == 3 thennpcHandler:say('Hahaha, boa viagem meu caro.', cid)doTeleportThing(cid, teleport6)talkState[talkUser] = 0endendsetPlayerStorageValue(cid, 28126, os.time())----- #FIM DOS TPS DO JOGADOR LEVEL 1 A49if getPlayerLevel(cid) >= 101 thennpcHandler:say('Somente jogadores entre o nivel 8 a 100 podem utilizar esse servico.', cid)talkState[talkUser] = 0endelsenpcHandler:say('Voce ja foi teletransportado, espere '..(config1.cooldown - (os.time() - getPlayerStorageValue(cid, 28126)))..' segundos para poder ser transportado novamente.')talkState[talkUser] = 0endendendnpcHandler:setCallback(CALLBACK_ONTHINK, thinkCallback)npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)npcHandler:addModule(FocusModule:new())

 

I dont nothing to show, if u see this, sorry for you lose you time

JeanCristian

ADM MiHawk
avatar
Visconde
Visconde

INFOS

Grupo: ViscondeRegistrado: 12/04/12Posts: 328Char no Tibia: ADM MiHawk

testando aqui

Acadêmico: 5 Post[x]

Gennin: 15 Posts[x]

Chunnin: 40 Posts[x]

Jounnin: 60 Posts[x]

Jounnin Tokubetsu: 80 Posts[x]

ANBU: 100 Posts[X]

ANBU Elite: 130 Posts[ ]

Kage: 160 Posts[ ]

Sannin: 200 Posts[ ]

Sannin Lendário: 250 Posts[ ]

Sannin Mundial: 300 Posts[ ]

 

th_Ichigo_Mugetsu-1.gifth_BleachMovie4-SkullCladIchigo.gifth_HollowTransformation.gif

JeanCristian

ADM MiHawk
avatar
Visconde
Visconde

INFOS

Grupo: ViscondeRegistrado: 12/04/12Posts: 328Char no Tibia: ADM MiHawk

vc nao tinha colocado um cid mais ficou firmeza deu tudo certo comenta ai para ganhar mais um rep

Acadêmico: 5 Post[x]

Gennin: 15 Posts[x]

Chunnin: 40 Posts[x]

Jounnin: 60 Posts[x]

Jounnin Tokubetsu: 80 Posts[x]

ANBU: 100 Posts[X]

ANBU Elite: 130 Posts[ ]

Kage: 160 Posts[ ]

Sannin: 200 Posts[ ]

Sannin Lendário: 250 Posts[ ]

Sannin Mundial: 300 Posts[ ]

 

th_Ichigo_Mugetsu-1.gifth_BleachMovie4-SkullCladIchigo.gifth_HollowTransformation.gif

Stigal

don't ever stop...
avatar
Herói
Herói

INFOS

Grupo: HeróiRegistrado: 28/11/10Posts: 3402Gênero: Masculino
O pedido neste tópico de foi atendido e/ou o autor do tópico resolveu sua duvida. Este tópico está fechado e foi movido para Pedidos - Resolvidos. Se você tiver outros pedidos, crie um novo tópico.

VI6MDIG.png

 

"O fracasso é a oportunidade de se começar de novo inteligentemente"

Minhas Redes Sociais: Youtube | Página & Grupo | Steam  | Discord Xtibia | Skype: @mrooger

 

OTpanel