Ir para conteúdo
  • 0

[PDA] Duel System apenas em uma area pré-definida no mapa


Taiger

Pergunta

Ola amigos, sera que alguem poderia modificar meu duel system do PDA para poder mandar ou aceitar duel apenas em uma area do mapa, no caso criarei uma area destinada para duelos.

 

Duel do order em actions.

 

 



-------- DUEL SYSTEM ------------------------
if isPlayer(player) and player ~= cid and getPlayerStorageValue(player, 6598754) <= -1 and getPlayerStorageValue(player, 52480) <= -1 and not getCreatureCondition(cid, CONDITION_INFIGHT) then  
if getPlayerStorageValue(cid, 52480) <= -1 or (getPlayerStorageValue(cid, 52481) >= 1 and getPlayerStorageValue(cid, 52482) ~= -1) then                  
---
local canDuel = true
for s = 1, #storages do
    if getPlayerStorageValue(cid, storages) >= 1 or getPlayerStorageValue(player, storages) >= 1 then
        canDuel = false
        break
    end
end

if not canDuel then
    return doPlayerSendTextMessage(cid, 20, "You can't do that while is Flying, Riding, Surfing, Diving or mount a bike!") 
end

if getPlayerStorageValue(cid, 6598754) == 1 or getPlayerStorageValue(cid, 6598755) == 1 then
return doPlayerSendTextMessage(cid, 20, "You can't do that while in PVP zone!")
end
if getPlayerStorageValue(cid, INOUTLAND) == 1 then
return doPlayerSendTextMessage(cid, 20, "You can't do that while in Outland!")
end
if getPlayerStorageValue(cid, PLAYER_PVP_ARENA) > 0 then
return doPlayerSendTextMessage(cid, 20, "You can't duel while in Arena PvP. If you isn't in, please logout.")
end
if #getCreatureSummons(cid) < 1 then
return doPlayerSendTextMessage(cid, 20, "You need a pokemon to invit someone to duel!")
end
if getPlayerStorageValue(cid, 45765) > 0 then
doPlayerSendTextMessage(cid, 20, "Mew(two) don't want to duel.")
return true
end
if getTilePzInfo(getThingPos(cid)) or getTilePzInfo(getThingPos(player)) then
doPlayerSendTextMessage(cid, 20, "You can't duel in PZ.")
return true
end
--- 
if getPlayerStorageValue(cid, 52480) <= -1 then
   doPlayerSetVocation(cid, 7) 
   openChannelDialog(cid)   
   setPlayerStorageValue(cid, 52480, 1)
   setPlayerStorageValue(cid, 6598754, 5)           
   setPlayerStorageValue(cid, 52482, getCreatureNameWithProtect(cid)..",")                      
   setPlayerStorageValue(cid, 52483, getCreatureNameWithProtect(player)..",") 
   doCreatureSetSkullType(cid, 2)
   doSendAnimatedText(getThingPosWithDebug(cid), "FIRST TEAM", 215)
   return true
elseif getPlayerStorageValue(cid, 52481) >= 1 and getPlayerStorageValue(cid, 52482) ~= -1 then 
   local t1 = string.explode(getPlayerStorageValue(cid, 52482), ",")
   local t2 = string.explode(getPlayerStorageValue(cid, 52483), ",")
   
   if (#t1 >= getPlayerStorageValue(cid, 52480) and #t2 >= getPlayerStorageValue(cid, 52480)) or (isInArray(t1, getCreatureNameWithProtect(player)) or isInArray(t2, getCreatureNameWithProtect(player))) then 
   return true 
   end
   
   local sto2, sto3, name = getPlayerStorageValue(cid, 52482), getPlayerStorageValue(cid, 52483), getCreatureNameWithProtect(player)
   if getPlayerStorageValue(cid, 52480) == 2 then
      setPlayerStorageValue(cid, 52483, sto3.. name..",") --time adversario 
      doSendAnimatedText(getThingPosWithDebug(player), "SECOND TEAM", 215)  
   elseif getPlayerStorageValue(cid, 52480) == 3 and #t1 < 3 then
      setPlayerStorageValue(cid, 52482, sto2.. name..",") --time aliado
      doSendAnimatedText(getThingPosWithDebug(player), "FIRST TEAM", 215)
   elseif getPlayerStorageValue(cid, 52480) == 3 and #t1 >= 3 then
      setPlayerStorageValue(cid, 52483, sto3.. name..",") --time adversario 
      doSendAnimatedText(getThingPosWithDebug(player), "SECOND TEAM", 215)  
   end  
     
   setPlayerStorageValue(player, 52481, getPlayerStorageValue(cid, 52481))
   setPlayerStorageValue(player, 52485, getCreatureNameWithProtect(cid))
   
   local players, pokes = getPlayerStorageValue(cid, 52480), getPlayerStorageValue(cid, 52481) 
   
   local str = {}
   table.insert(str, getCreatureNameWithProtect(cid).." is inviting you to a duel! Use order in him to accept it!\n")
   table.insert(str, "Info Battle: Duel "..players.."x"..players.." - "..pokes.." pokes.")     --alterado aki

   doPlayerSendTextMessage(player, 20, table.concat(str))
   return true
end
end
---   
elseif isPlayer(player) and player ~= cid and getPlayerStorageValue(player, 6598754) == 5 and getPlayerStorageValue(player, 52481) >= 1 then

local t1 = string.explode(getPlayerStorageValue(player, 52482), ",")
local t2 = string.explode(getPlayerStorageValue(player, 52483), ",")
---
if not isInArray(t1, getCreatureNameWithProtect(cid)) and not isInArray(t2, getCreatureNameWithProtect(cid)) then
return true
end
---
for s = 1, #storages do
    if getPlayerStorageValue(cid, storages) >= 1 then
       return doPlayerSendTextMessage(cid, 20, "You can't do that while is Flying, Riding, Surfing, Diving or mount a bike!") 
    end
end
if getPlayerStorageValue(cid, PLAYER_PVP_ARENA) > 0 then
return doPlayerSendTextMessage(cid, 20, "You can't duel while in Arena PvP. If you isn't in, please logout.")
end
if getPlayerStorageValue(cid, INOUTLAND) == 1 then
return doPlayerSendTextMessage(cid, 20, "You can't do that while in Outland. Please, heal with nurse.")
end
if getPlayerStorageValue(cid, 6598754) == 1 or getPlayerStorageValue(cid, 6598755) == 1 then
return doPlayerSendTextMessage(cid, 20, "You can't do that while in PVP zone!")
end
local pokes = getLivePokeballs(cid, getPlayerSlotItem(cid, 3).uid, true) 
if #pokes < getPlayerStorageValue(player, 52481) then
return doPlayerSendTextMessage(cid, 20, "You need atleast ".. getPlayerStorageValue(player, 52481).." pokemons to duel with this person!")
end
if getPlayerStorageValue(cid, 52482) ~= -1 then
return doPlayerSendTextMessage(cid, 20, "You already invit someone to duel!")
end 
if #getCreatureSummons(cid) < 1 then
return doPlayerSendTextMessage(cid, 20, "You need a pokemon to accept a duel!")
end
---  
   setPlayerStorageValue(cid, 52480, getPlayerStorageValue(player, 52480))
   setPlayerStorageValue(player, 52484, getPlayerStorageValue(player, 52484)-1)
   if getPlayerStorageValue(player, 52484) == 0 then   
      for a = 1, #t1 do
          local pid, sid = getPlayerByName(t1[a]), getPlayerByName(t2[a])
          if not isCreature(pid) or getPlayerStorageValue(pid, 52480) <= -1 then
             removeFromTableDuel(player, t1[a])
          else
             doCreatureSetSkullType(pid, 1)
          end
          if not isCreature(sid) or getPlayerStorageValue(sid, 52480) <= -1 then
             removeFromTableDuel(player, t2[a])
          else
             doCreatureSetSkullType(sid, 1)
          end
      end
      beginDuel(player, 6)
   else
      doCreatureSetSkullType(cid, 2)
   end
   doSendAnimatedText(getThingPos(cid), "BATTLE", COLOR_ELECTRIC)
   return true
   
elseif isPlayer(player) and player == cid and getPlayerStorageValue(player, 52480) >= 1 then
   doEndDuel(cid, true)
   return true
end

 

Duel System da lib.



        local fightcondition = createConditionObject(CONDITION_INFIGHT)
        setConditionParam(fightcondition, CONDITION_PARAM_TICKS, 3 * 1000)
storagesDuel = {52480, 52481, 52482, 52482, 52483, 52484, 52485, 6598754}
--[[ Lista das storages Duel!
52480 = sto de duelo e do modo de duel;
52481 = sto de pokes no duel;
52482 = sto do seu time;
52483 = sto do time adversario;
52484 = sto de aceitaçao de duel e do começo do duel;
52485 = sto do nome do 'invitador';
6598754 = sto do canAttackOther; 
]]

function beginDuel(cid, n)
if getPlayerStorageValue(cid, 52482) == -1 or getPlayerStorageValue(cid, 52483) == -1 then
return true
end
local t1 = string.explode(getPlayerStorageValue(cid, 52482), ",")
local t2 = string.explode(getPlayerStorageValue(cid, 52483), ",")
local sto2, sto3 = getPlayerStorageValue(cid, 52482), getPlayerStorageValue(cid, 52483)

if n == 0 then
   for i = 1, #t1 do
       local pid, sid = getPlayerByName(t1), getPlayerByName(t2)
       if isCreature(pid) and getPlayerStorageValue(pid, 52480) >= 1 then
          setPlayerStorageValue(pid, 6598754, 5)
          setPlayerStorageValue(pid, 52482, sto2)
          setPlayerStorageValue(pid, 52483, sto3)
          setPlayerStorageValue(pid, 52484, 10)
       end
       ---
       if isCreature(sid) and getPlayerStorageValue(sid, 52480) >= 1 then
          setPlayerStorageValue(sid, 6598754, 10)
          setPlayerStorageValue(sid, 52482, sto2)
          setPlayerStorageValue(sid, 52483, sto3)
          setPlayerStorageValue(sid, 52484, 10)
       end
       ---
       doSendAnimatedText(getThingPosWithDebug(pid), "START", 215)
       doSendAnimatedText(getThingPosWithDebug(sid), "START", 215)
       doBattleLoop(pid, true)
       doBattleLoop(sid, true)
   end  
   return true                                                    
else  
   for i = 1, #t1 do
       local pid, sid = getPlayerByName(t1), getPlayerByName(t2
       if isCreature(pid) and getPlayerStorageValue(pid, 52480) >= 1 then
          doSendAnimatedText(getThingPosWithDebug(pid), (n == 6 and "" or ""..n.."!"), 215)
       end
       if isCreature(sid) and getPlayerStorageValue(sid, 52480) >= 1 then
          doSendAnimatedText(getThingPosWithDebug(sid), (n == 6 and "" or ""..n.."!"), 215)
       end
   end
   n = n-1
end
addEvent(beginDuel, 1000, cid, n)
end


function removeFromTableDuel(cid, value)
if not isCreature(cid) then return true end
local t1 = string.explode(getPlayerStorageValue(cid, 52482), ",")
local t2 = string.explode(getPlayerStorageValue(cid, 52483), ",") 

table.remove(t1, table.find(t1, value) or -1)
table.remove(t2, table.find(t2, value) or -1)
---
local str1, str2 = "", ""
for i = 1, 3 do
    if t1 then  str1 = str1..(t1 or "").."," end
    if t2 then  str2 = str2..(t2 or "").."," end
end
setPlayerStorageValue(cid, 52482, str1) 
setPlayerStorageValue(cid, 52483, str2)
return true
end

function isDuelingAgainst(cid, pid)
if not isCreature(cid) or not isCreature(pid) then return false end
-----
local t1 = string.explode(getPlayerStorageValue(cid, 52482), ",")
local t2 = string.explode(getPlayerStorageValue(cid, 52483), ",")
-----
local name1, name2 = getCreatureNameWithProtect(cid), getCreatureNameWithProtect(pid)
-----
if table.find(t1, name1) ~= nil and table.find(t2, name2) ~= nil then
   return true
elseif table.find(t2, name1) ~= nil and table.find(t1, name2) ~= nil then
   return true
end
return false
end

function doEndDuel(cid, desisto)
if isCreature(cid) then
if getPlayerStorageValue(cid, 52482) ~= -1 then
   t1 = string.explode(getPlayerStorageValue(cid, 52482), ",")
   t2 = string.explode(getPlayerStorageValue(cid, 52483), ",")
end

local invit = getPlayerByName(getPlayerStorageValue(cid, 52485))
if isCreature(invit) then
   table1 = string.explode(getPlayerStorageValue(invit, 52482), ",") 
   table2 = string.explode(getPlayerStorageValue(invit, 52483), ",")
end

if getPlayerStorageValue(cid, 52484) ~= 10 then
   if getPlayerStorageValue(cid, 52482) ~= -1 then
      for a = 1, 3 do
          local pid, sid = getPlayerByName(t1[a]), getPlayerByName(t2[a])
          if isCreature(pid) then doCreatureSetSkullType(pid, 0) doRemoveCondition(pid, CONDITION_INFIGHT) end
          if isCreature(sid) then doCreatureSetSkullType(sid, 0) doRemoveCondition(sid, CONDITION_INFIGHT) end 
          for i = 1, #storagesDuel do
              if isCreature(pid) then setPlayerStorageValue(pid, storagesDuel, -1) end
              if isCreature(sid) then setPlayerStorageValue(sid, storagesDuel, -1) end
          end
      end
   else
       for i = 1, #storagesDuel do
           setPlayerStorageValue(cid, storagesDuel, -1)
       end
       doCreatureSetSkullType(cid, 0) 
       doRemoveCondition(cid, CONDITION_INFIGHT)
       ---------------------------------   
       if table2 then
          local numero = 0
          for i = 1, #table2 do
              local ppid = getPlayerByName(table2)              
              if not isCreature(ppid) or getPlayerStorageValue(ppid, 52480) ~= -1 then
                 numero = numero+1
              end
          end
          if numero == 0 then doEndDuel(invit) sendMsgToPlayer(invit, 20, "The opponents are give up! Duel is canceled!") end
       end
       --------------------------------
   end
   if desisto then doSendAnimatedText(getThingPosWithDebug(cid), "GIVE UP", COLOR_BLUE) doStopBattleLoop(cid) end
   return true
end 

   for a = 1, #t1 do
       local pid, sid = getPlayerByName(t1[a]), getPlayerByName(t2[a])
       removeFromTableDuel(pid, getCreatureNameWithProtect(cid))
       removeFromTableDuel(sid, getCreatureNameWithProtect(cid))
   end 
   
   local t3 = string.explode(getPlayerStorageValue(cid, 52482), ",")
   local t4 = string.explode(getPlayerStorageValue(cid, 52483), ",")
   if (#t3 == 0 and #t4 >= 1) or (#t4 == 0 and #t3 >= 1) then  
      
      for j = 1, (#t3 > 0 and #t3 or #t4) do
          local winner = #t3 > 0 and getPlayerByName(t3[j]) or getPlayerByName(t4[j])
          if isCreature(winner) then
             addEvent(doSendAnimatedText, 500, getThingPosWithDebug(winner), "WIN", COLOR_ELECTRIC) 
             doStopBattleLoop(winner)
             for i = 1, #storagesDuel do
                 setPlayerStorageValue(winner, storagesDuel, -1)
             end
             -- tournament -- 
             if getPlayerStorageValue(cid, IS_IN_TOURNAMENT) == 1 then
             addEvent(doSendAnimatedText, 500, getThingPosWithDebug(winner), "WIN TOURNAMENT DUEL", COLOR_ELECTRIC) 
             doStopBattleLoop(winner)
             end
             -- tournament -- 
             doCreatureSetSkullType(winner, 0)
             doRemoveCondition(winner, CONDITION_INFIGHT)
          end
      end
      addEvent(doSendAnimatedText, 500, getThingPosWithDebug(cid), "LOSE", COLOR_BURN)
      doStopBattleLoop(cid)
      for i = 1, #storagesDuel do
          setPlayerStorageValue(cid, storagesDuel, -1)
      end
      -- tournament -- 
                   if getPlayerStorageValue(cid, IS_IN_TOURNAMENT) == 1 then
                 local tp = string.explode(getGlobalStorageValue(PLAYER_IN_TOURNAMENT), ",")
                 for x=1, #tp do
                 if tp[x] == getCreatureNameWithProtect(cid) then
                 table.remove(tp, X):
                 setGlobalStorageValue(PLAYER_IN_TOURNAMENT, tp)
                 end
                 end
             addEvent(doSendAnimatedText, 500, getThingPosWithDebug(winner), "LOSE TOURNAMENT Duel", COLOR_ELECTRIC) 
             doStopBattleLoop(winner)
             local tpp = string.explode(getGlobalStorageValue(PLAYER_IN_TOURNAMENT), ",")
             if #tp < 2 then
             local winner = tp[1]
             addEvent(doPlayerSendTextMessage, 700, cid,  20, tp[1].." Ganhou") 
             end
             end
    -- tournament -- 
      doCreatureSetSkullType(cid, 0)
      doRemoveCondition(cid, CONDITION_INFIGHT)
      doStopBattleLoop(cid)
      doStopBattleLoop(winner)
   else 
      for i = 1, #storagesDuel do
          setPlayerStorageValue(cid, storagesDuel, -1)
      end
      doCreatureSetSkullType(cid, 0)
      doRemoveCondition(cid, CONDITION_INFIGHT)
      if desisto then
         doSendAnimatedText(getThingPosWithDebug(cid), "GIVE UP", COLOR_BLUE)
         doStopBattleLoop(cid)
      else
         addEvent(doSendAnimatedText, 500, getThingPosWithDebug(cid), "LOSE", COLOR_BURN)
         doStopBattleLoop(cid)
      end
   end
end
end

function checkDuel(cid)
if getPlayerStorageValue(cid, 52484) ~= 10 then return true end
if getPlayerStorageValue(cid, 52481) >= 1 then
   setPlayerStorageValue(cid, 52481, getPlayerStorageValue(cid, 52481)-1)
   doSendAnimatedText(getThingPosWithDebug(cid), "POKE DOWN", 65)
end
if getPlayerStorageValue(cid, 52481) == 0 then           
   doEndDuel(cid)
   doStopBattleLoop(cid)
end         
end
--/////////////////////////////////////////////////////////////////////////////////////////////--
function doBattleLoop(cid, force)
    if isCreature(cid) then
        local sto = 196866
        if force then
            setPlayerStorageValue(cid, sto, -1)
        end
        local stop = getPlayerStorageValue(cid, sto) and getPlayerStorageValue(cid, sto) == 1
        if stop then
            return true
        end
        doAddConditionWithProtect(cid, fightcondition)
        addEvent(doBattleLoop, 3000, cid, stop, false)
    end
end

function doStopBattleLoop(cid)
    if isCreature(cid) then
        setPlayerStorageValue(cid, 196866, 1)
    end
end

 

Basicamente acho eu seria colocar uma tabela de x, y, z das cordenadas da area que poderia se mandar ou aceitar o duel. kkk só acho, sou noob em scripts.

 

Desde ja agradeço e rep+

Link para o comentário
Compartilhar em outros sites

3 respostass a esta questão

Posts Recomendados

  • 0

Segue um exemplo de como você pode fazer.

Spoiler

 

local area = {x=0, y=0, z=0} -- posição central da area de duelo

local range = 10 --distância maxima do centro da areade duelo, até o fim dela.

local pos = getCreaturePosition (cid)

 

if (pos.x >= area.x-range and pos.x <= area.x+range) and (pos.y >= area.y-range and pos.y <= area.y+range) and (pos.z == area.z) then

Execute o sistema

else

 retorna mensagem: você tem que esta na area tal.

end

 

 

Link para o comentário
Compartilhar em outros sites

  • 0

Põe abaixo dessa linha.

Citar

local canDuel = true

 

Fiz uma adaptação para esse código:

Citar

local area = {x=0, y=0, z=0} -- posição central da area de duelo

local range = 10 --distância maxima do centro da areade duelo, até o fim dela.

local pos = getCreaturePosition (cid)

 

if not(pos.x >= area.x-range and pos.x <= area.x+range) or not(pos.y >= area.y-range and pos.y <= area.y+range) or not(pos.z == area.z) then

return doPlayerSendTextMessage(cid, 20, "voce tem que esta na area de duelo.")

end

 

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...