Ir para conteúdo
Entre para seguir isso  
alisonjf

[8.21+] Trainers Automáticos

Recommended Posts

alisonjf    2
alisonjf

Nome: Trainers automáticos via scripts de action

Versão: 8.21+

Tipo de Script: Action

Servidor Testado: Nenhum

Créditos: Macroman

-----------------------------------------------------------------------

 

Bom. É um script meio fútil mas eu uso porque nunca vi um server usar então acho bem legal e até meio que útil para se colocar em um server. O que você precisa fazer é adicionar os ids de action: 9001 (norte) / 9002 (leste) / 9003 (sul) / 9004 (oeste) para qualquer porta que você prefirir. Não adicione trainers pelo map editor porque esse script vai sumonar 2 trainers manualmente toda vez que 1 player entrar na sala. Quando alguém sai, eles somem. Você não poderá entrar na sala se tiver alguém la. E uma outra característica é que o script salva o nome do último player que usou a sala com os trainers. Script:

 

 

Na pasta data/actions/scripts crie duas pastas booths/training, depois crie um arquivo chamado east.lua e adicione:

  -- Check where the player is located at.
   if ( charPos.x == doorPos.x - 1 and charPos.z == doorPos.z ) then
       -- Check if someone already uses the training booth.
       if isPlayer(getThingfromPos(checkPlayer).uid) == TRUE then
           doPlayerSendTextMessage(cid, 24, "Someone is already using this booth.")
           doSendMagicEffect(getCreaturePos(cid), 2)
       else
           -- Teleport player.
           doTeleportThing(cid, doorPos)
           doMoveCreature(cid, newDir)
           -- Summon training monks.
           doSummonCreature("Trainer", monkOne)
           doSummonCreature("Trainer", monkTwo)
       end
   else
       -- Teleport player.
       doTeleportThing(cid, doorPos)
       doMoveCreature(cid, oldDir)
       -- Remove training monks.
       doRemoveCreature(getThingfromPos({x = monkOne.x, y = monkOne.y, z = monkOne.z, stackpos = 253}).uid)
       doRemoveCreature(getThingfromPos({x = monkTwo.x, y = monkTwo.y, z = monkTwo.z, stackpos = 253}).uid)
       -- Send magic effect.
       doSendMagicEffect(monkOne, 2)
       doSendMagicEffect(monkTwo, 2)
       -- Define last character.
       local charName = getCreatureName(cid)
       doSetItemSpecialDescription(getThingfromPos(doorPos).uid, "Last one to use this booth was player:\n" .. charName .. ".")
   end
   return TRUE

end

 

Nessa mesma pasta crie um arquivo chamado south.lua e adicione:

function onUse(cid, item, fromPosition, itemEx, toPosition)

   -- Define positions.
   local charPos = getCreaturePosition(cid)
   local doorPos = getThingPos(item.uid)
   local monkOne = {x = doorPos.x - 1, y = doorPos.y + 2, z = doorPos.z}
   local monkTwo = {x = doorPos.x + 1, y = doorPos.y + 2, z = doorPos.z}
   local checkPlayer = {x = doorPos.x, y = doorPos.y + 1, z = doorPos.z, stackpos = 253}
   -- Define directions.
   local newDir  = 2
   local oldDir  = 0

   -- Check where the player is located at.
   if ( charPos.y == doorPos.y - 1 and charPos.z == doorPos.z ) then
       -- Check if someone already uses the training booth.
       if isPlayer(getThingfromPos(checkPlayer).uid) == TRUE then
           doPlayerSendTextMessage(cid, 24, "Someone is already using this booth.")
           doSendMagicEffect(getCreaturePos(cid), 2)
       else
           -- Teleport player.
           doTeleportThing(cid, doorPos)
           doMoveCreature(cid, newDir)
           -- Summon training monks.
           doSummonCreature("Trainer", monkOne)
           doSummonCreature("Trainer", monkTwo)
       end
   else
       -- Teleport player.
       doTeleportThing(cid, doorPos)
       doMoveCreature(cid, oldDir)
       -- Remove training monks.
       doRemoveCreature(getThingfromPos({x = monkOne.x, y = monkOne.y, z = monkOne.z, stackpos = 253}).uid)
       doRemoveCreature(getThingfromPos({x = monkTwo.x, y = monkTwo.y, z = monkTwo.z, stackpos = 253}).uid)
       -- Send magic effect.
       doSendMagicEffect(monkOne, 2)
       doSendMagicEffect(monkTwo, 2)
   end
   return TRUE

end

 

Depois crie west.lua e adicione:

function onUse(cid, item, fromPosition, itemEx, toPosition)

   -- Define positions.
   local charPos = getCreaturePosition(cid)
   local doorPos = getThingPos(item.uid)
   local monkOne = {x = doorPos.x - 2, y = doorPos.y - 1, z = doorPos.z}
   local monkTwo = {x = doorPos.x - 2, y = doorPos.y + 1, z = doorPos.z}
   local checkPlayer = {x = doorPos.x - 1, y = doorPos.y, z = doorPos.z, stackpos = 253}
   -- Define directions.
   local newDir  = 3
   local oldDir  = 1

   -- Check where the player is located at.
   if ( charPos.x == doorPos.x + 1 and charPos.z == doorPos.z ) then
       -- Check if someone already uses the training booth.
       if isPlayer(getThingfromPos(checkPlayer).uid) == TRUE then
           doPlayerSendTextMessage(cid, 24, "Someone is already using this booth.")
           doSendMagicEffect(getCreaturePos(cid), 2)
       else
           -- Teleport player.
           doTeleportThing(cid, doorPos)
           doMoveCreature(cid, newDir)
           -- Summon training monks.
           doSummonCreature("Trainer", monkOne)
           doSummonCreature("Trainer", monkTwo)
       end
   else
       -- Teleport player.
       doTeleportThing(cid, doorPos)
       doMoveCreature(cid, oldDir)
       -- Remove training monks.
       doRemoveCreature(getThingfromPos({x = monkOne.x, y = monkOne.y, z = monkOne.z, stackpos = 253}).uid)
       doRemoveCreature(getThingfromPos({x = monkTwo.x, y = monkTwo.y, z = monkTwo.z, stackpos = 253}).uid)
       -- Send magic effect.
       doSendMagicEffect(monkOne, 2)
       doSendMagicEffect(monkTwo, 2)
   end
   return TRUE

end

 

E por último crie north.lua e adicione:

function onUse(cid, item, fromPosition, itemEx, toPosition)

   -- Define positions.
   local charPos = getCreaturePosition(cid)
   local doorPos = getThingPos(item.uid)
   local monkOne = {x = doorPos.x - 1, y = doorPos.y - 2, z = doorPos.z}
   local monkTwo = {x = doorPos.x + 1, y = doorPos.y - 2, z = doorPos.z}
   local checkPlayer = {x = doorPos.x, y = doorPos.y - 1, z = doorPos.z, stackpos = 253}
   -- Define directions.
   local newDir  = 0
   local oldDir  = 2

   -- Check where the player is located at.
   if ( charPos.y == doorPos.y + 1 and charPos.z == doorPos.z ) then
       -- Check if someone already uses the training booth.
       if isPlayer(getThingfromPos(checkPlayer).uid) == TRUE then
           doPlayerSendTextMessage(cid, 24, "Someone is already using this booth.")
           doSendMagicEffect(getCreaturePos(cid), 2)
       else
           -- Teleport player.
           doTeleportThing(cid, doorPos)
           doMoveCreature(cid, newDir)
           -- Summon training monks.
           doSummonCreature("Trainer", monkOne)
           doSummonCreature("Trainer", monkTwo)
       end
   else
       -- Teleport player.
       doTeleportThing(cid, doorPos)
       doMoveCreature(cid, oldDir)
       -- Remove training monks.
       doRemoveCreature(getThingfromPos({x = monkOne.x, y = monkOne.y, z = monkOne.z, stackpos = 253}).uid)
       doRemoveCreature(getThingfromPos({x = monkTwo.x, y = monkTwo.y, z = monkTwo.z, stackpos = 253}).uid)
       -- Send magic effect.
       doSendMagicEffect(monkOne, 2)
       doSendMagicEffect(monkTwo, 2)
   end
   return TRUE

end

 

 

Agora vá até a pasta data/actions, abra o arquivo actions.xml e adicione:

    <!-- Training Booths -->
   <action actionid="9001" script="booths/training/north.lua" />
   <action actionid="9002" script="booths/training/east.lua" />
   <action actionid="9003" script="booths/training/south.lua" />
   <action actionid="9004" script="booths/training/west.lua" />

 

Isso é tudo. Bom divertimento.

--------------------------------------------------------------------------

 

Gostaram: Doem OT$ :)

Reclamações/Dúvidas: Postem

Compartilhar este post


Link para o post
Nord    2
Nord

Não é futil, gostei, porém por movements é mais "prático".

 

Aprovado

Compartilhar este post


Link para o post
Mock    32
Mock

gostei do script, ja vi em alguns outros ots e isso e bem util

Compartilhar este post


Link para o post
pepeto2009    0
pepeto2009

[12/08/2009 00:06:58] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/booths/training/east.lua)

[12/08/2009 00:06:58] data/actions/scripts/booths/training/east.lua:31: '<eof>' expected near 'end'

[12/08/2009 00:06:58] As actions foram recarregadas.

 

Pq TA Dando Isso, Fiz tudo Certinho do geito q tem no post ¬¬'

Compartilhar este post


Link para o post
Azuriath    0
Azuriath

@Pepeto tenta não reviver post antigos, mas esse realmente parece ter bug, tenta colocar na primeira linha de east.lua isso:

 

function onUse(cid, item, fromPosition, itemEx, toPosition)

Compartilhar este post


Link para o post
\o\ Wolf /o/    0
\o\ Wolf /o/

Se assemleha a ideia do Dark...Mas parece mais estruturado... Parabens

Hwoarang ~

Compartilhar este post


Link para o post
nippo_ot    0
nippo_ot

por favor, poderia arrumar este script estou precisando muito dele

porém o seu não está funcionando em nenhum TFS depois do 8.2x

 

aguardando

Compartilhar este post


Link para o post
Visitante
Este tópico está impedido de receber novos posts.
Entre para seguir isso  
  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×