Ir para conteúdo
  • Cadastre-se

(Resolvido)[RESOLVIDO] Players vs Players


Ir para solução Resolvido por Vodkart,

Posts Recomendados

<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Guild For Arena Event" version="8.6" author="Vodkart" contact="" enabled="yes">
<config name="gfae_config"><![CDATA[
config = {
    positions = {
        {{x=44, y=279, z=7}, {x=21, y=480, z=7}},
        {{x=45, y=279, z=7}, {x=21, y=480, z=7}},
        {{x=44, y=280, z=7}, {x=21, y=480, z=7}},
        {{x=45, y=280, z=4}, {x=21, y=480, z=7}},
    },
    positions2 = {
        {{x=47, y=279, z=7}, {x=78, y=448, z=7}},
        {{x=48, y=279, z=7}, {x=78, y=448, z=7}},
        {{x=47, y=280, z=7}, {x=78, y=448, z=7}},
        {{x=48, y=280, z=7}, {x=78, y=448, z=7}},
    },
    money = 500,-- em k
    hours = 5, -- para voltar a arena
    storage = 889757,
    a = {x= 14, y=442, z=7}, -- pos começo da arena
    b = {x=87, y=492, z=7}, -- pos final da arena
    exit_pos = {x=154, y=160, z=7}
}
function getPlayersWithGuildInArena(from, to)
    local t = {}
    for _, pid in pairs(getPlayersOnline()) do
        if isInRange(getPlayerPosition(pid), from, to) then
            t[#t+1] = pid
        end
    end
    return t
end
function endArenaEvent(cid, p1, p2)
    for _, ret in pairs(getPlayersWithGuildInArena(p1, p2)) do
        if getPlayerGuildId(cid) ~= getPlayerGuildId(ret) then
            return false
        end
    end
return true
end
]]></config>
<event type="login" name="GuildForArenaLogin" event="script"><![CDATA[
domodlib('gfae_config')
function onLogin(cid)
registerCreatureEvent(cid, "GuildForArenaDeath")
    if getCreatureName(cid) ~= "Account Manager" and isInRange(getPlayerPosition(cid), config.a, config.b) then
        doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
    end
return true
end]]></event>
<event type="preparedeath" name="GuildForArenaDeath" event="script"><![CDATA[
domodlib('gfae_config')
function onPrepareDeath(cid, deathList, lastHitKiller, mostDamageKiller)
    if isPlayer(cid) and isInRange(getPlayerPosition(cid), config.a, config.b) then
        doTeleportThing(cid, config.exit_pos)
            if endArenaEvent(deathList[1], config.a, config.b) then -- qndo acaba o evento
                for _, ret in pairs(getPlayersWithGuildInArena(config.a, config.b)) do
                    doPlayerAddItem(ret, 1999, 1) -- premio
                    doTeleportThing(ret, config.exit_pos)
                end
                doBroadcastMessage("A guild  "..getPlayerGuildName(deathList[1]).." Foi a vencedora da arena!")
            end
    end
return true
end]]></event>
<action actionid="7124" event="script"><![CDATA[
domodlib('gfae_config')
function onUse(cid, item, fromPosition, item2, toPosition)
    if #getPlayersWithGuildInArena(config.a, config.b)  > 0 then
        return doPlayerSendCancel(cid, "espere, atualmente ha guilds batalhando.") and doSendMagicEffect(getThingPos(cid), 2)
    end
    for i = 1, #config.positions do
        local creature = getTopCreature(config.positions[1]).uid
        if not isPlayer(creature) then
            return doPlayerSendCancel(cid, "Nao existe players em todas as posicoes.") and doSendMagicEffect(getThingPos(cid), 2)
        end
        local guild1 = getPlayerGuildId(getTopCreature(config.positions[1][1]).uid)
        if getPlayerGuildId(creature) ~= guild1 then
            return doPlayerSendCancel(cid, "Algum player nao e da guild correta.") and doSendMagicEffect(getThingPos(cid), 2)
        end
        if getPlayerStorageValue(creature, config.storage) - os.time() > 0 then
            return doPlayerSendTextMessage(cid, 25, "o Jogador "..getPlayerName(creature) .." Você só poderá voltar na arena em "..os.date("%d %B %Y %X ", getPlayerStorageValue(creature, config.storage))..".")
        end
        if getPlayerMoney(creature) < (config.money * 1000) then
            return doPlayerSendCancel(cid, "Algum player nao tem "..config.money.."k.") and doSendMagicEffect(getThingPos(cid), 2)
        end
    end
    -- Checando posições 2
    for i = 1, #config.positions2 do
        local creature = getTopCreature(config.positions2[1]).uid
        if not isPlayer(creature) then
            return doPlayerSendCancel(cid, "Not enough players.") and doSendMagicEffect(getThingPos(cid), 2)
        end
        local guild2 = getPlayerGuildId(getTopCreature(config.positions2[1][1]).uid)
        if getPlayerGuildId(creature) ~= guild2 then
            return doPlayerSendCancel(cid, "Algum player nao e da guild correta.") and doSendMagicEffect(getThingPos(cid), 2)
        end
        if getPlayerStorageValue(creature, config.storage) - os.time() > 0 then
            return doPlayerSendTextMessage(cid, 25, "o Jogador "..getPlayerName(creature) .." Você só poderá voltar na arena em "..os.date("%d %B %Y %X ", getPlayerStorageValue(creature, config.storage))..".")
        end
        if getPlayerMoney(creature) < (config.money * 1000) then
            return doPlayerSendCancel(cid, "Algum player nao tem "..config.money.."k.") and doSendMagicEffect(getThingPos(cid), 2)
        end
    end
    doBroadcastMessage("Começou uma batalha entre ".. getPlayerGuildName(getTopCreature(config.positions[1][1]).uid) .." e ".. getPlayerGuildName(getTopCreature(config.positions2[1][1]).uid)..".")
    -- Teleportando posições 1
    for i = 1, #config.positions do
        local creature = getTopCreature(config.positions[1]).uid
        doTeleportThing(creature, config.positions[2])
        doPlayerSendTextMessage(creature, 27, "You started the quest.")
        doSendMagicEffect(getThingPos(creature), 33)
        doPlayerRemoveMoney(creature, (config.money * 1000))
        setPlayerStorageValue(creature, config.storage, os.time() + config.hours * 60 * 60)
    end
    -- Teleportando posições 2
    for i = 1, #config.positions2 do
        local creature = getTopCreature(config.positions2[1]).uid
        doTeleportThing(creature, config.positions2[2])
        doPlayerSendTextMessage(creature, 27, "You started the quest.")
        doSendMagicEffect(getThingPos(creature), 33)
        doPlayerRemoveMoney(creature, (config.money * 1000))
        setPlayerStorageValue(creature, config.storage, os.time() + config.hours * 60 * 60)
    end
    return true
end]]></action>
</mod>?

 

 

 

seu serve existe a função isInRange?

vodkart_logo.png

[*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*]

 

DISCORDvodkart#6090

 

Link para o post
Compartilhar em outros sites
  • Respostas 36
  • Created
  • Última resposta

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

#REMOVIDO CÓDIGO BUGADO   Só não esqueça na arena de colocar PVP TOOL e AREA NO LOGOUT

o meu bloco de notas bugou o código, apareceu uns caracteres especiais "?" dentro do código.   tenta assim:   <?xml version="1.0" encoding="ISO-8859-1"?> <mod name="Guild For Arena Event" version="8.6" author="Vodkart" contact="" enabled="yes"> <config name="gfae_config"><![CDATA[ config = { positions = { {{x=535, y=1597, z=4}, {x=535, y=2000, z=4}}, {{x=535, y=1597, z=4}, {x=535, y=2000, z=4}}, {{x=535, y=1597, z=4}, {x=535, y=2000, z=4}}, {{x=53

Faz no action um script de tempo também, digamos que você possa ficar no máximo 10 min na arena. Esse script é tipo do battlefield, a diferença que não precisaria colocar storage para diferenciar, a "storage"  seria a guild em questão... Só jogar 4 global storage e assim cada vez que matasse 1 a storage ia de 4 para 3 e assim sucessivamente. quando matasse o último dava a premiação para os jogadores que estiverem na arena.

Posted Images

2 minutos atrás, Vodkart disse:

<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Guild For Arena Event" version="8.6" author="Vodkart" contact="" enabled="yes">
<config name="gfae_config"><![CDATA[
config = {
    positions = {
        {{x=44, y=279, z=7}, {x=21, y=480, z=7}},
        {{x=45, y=279, z=7}, {x=21, y=480, z=7}},
        {{x=44, y=280, z=7}, {x=21, y=480, z=7}},
        {{x=45, y=280, z=4}, {x=21, y=480, z=7}},
    },
    positions2 = {
        {{x=47, y=279, z=7}, {x=78, y=448, z=7}},
        {{x=48, y=279, z=7}, {x=78, y=448, z=7}},
        {{x=47, y=280, z=7}, {x=78, y=448, z=7}},
        {{x=48, y=280, z=7}, {x=78, y=448, z=7}},
    },
    money = 500,-- em k
    hours = 5, -- para voltar a arena
    storage = 889757,
    a = {x= 14, y=442, z=7}, -- pos começo da arena
    b = {x=87, y=492, z=7}, -- pos final da arena
    exit_pos = {x=154, y=160, z=7}
}
function getPlayersWithGuildInArena(from, to)
    local t = {}
    for _, pid in pairs(getPlayersOnline()) do
        if isInRange(getPlayerPosition(pid), from, to) then
            t[#t+1] = pid
        end
    end
    return t
end
function endArenaEvent(cid, p1, p2)
    for _, ret in pairs(getPlayersWithGuildInArena(p1, p2)) do
        if getPlayerGuildId(cid) ~= getPlayerGuildId(ret) then
            return false
        end
    end
return true
end
]]></config>
<event type="login" name="GuildForArenaLogin" event="script"><![CDATA[
domodlib('gfae_config')
function onLogin(cid)
registerCreatureEvent(cid, "GuildForArenaDeath")
    if getCreatureName(cid) ~= "Account Manager" and isInRange(getPlayerPosition(cid), config.a, config.b) then
        doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
    end
return true
end]]></event>
<event type="preparedeath" name="GuildForArenaDeath" event="script"><![CDATA[
domodlib('gfae_config')
function onPrepareDeath(cid, deathList, lastHitKiller, mostDamageKiller)
    if isPlayer(cid) and isInRange(getPlayerPosition(cid), config.a, config.b) then
        doTeleportThing(cid, config.exit_pos)
            if endArenaEvent(deathList[1], config.a, config.b) then -- qndo acaba o evento
                for _, ret in pairs(getPlayersWithGuildInArena(config.a, config.b)) do
                    doPlayerAddItem(ret, 1999, 1) -- premio
                    doTeleportThing(ret, config.exit_pos)
                end
                doBroadcastMessage("A guild  "..getPlayerGuildName(deathList[1]).." Foi a vencedora da arena!")
            end
    end
return true
end]]></event>
<action actionid="7124" event="script"><![CDATA[
domodlib('gfae_config')
function onUse(cid, item, fromPosition, item2, toPosition)
    if #getPlayersWithGuildInArena(config.a, config.b)  > 0 then
        return doPlayerSendCancel(cid, "espere, atualmente ha guilds batalhando.") and doSendMagicEffect(getThingPos(cid), 2)
    end
    for i = 1, #config.positions do
        local creature = getTopCreature(config.positions[1]).uid
        if not isPlayer(creature) then
            return doPlayerSendCancel(cid, "Nao existe players em todas as posicoes.") and doSendMagicEffect(getThingPos(cid), 2)
        end
        local guild1 = getPlayerGuildId(getTopCreature(config.positions[1][1]).uid)
        if getPlayerGuildId(creature) ~= guild1 then
            return doPlayerSendCancel(cid, "Algum player nao e da guild correta.") and doSendMagicEffect(getThingPos(cid), 2)
        end
        if getPlayerStorageValue(creature, config.storage) - os.time() > 0 then
            return doPlayerSendTextMessage(cid, 25, "o Jogador "..getPlayerName(creature) .." Você só poderá voltar na arena em "..os.date("%d %B %Y %X ", getPlayerStorageValue(creature, config.storage))..".")
        end
        if getPlayerMoney(creature) < (config.money * 1000) then
            return doPlayerSendCancel(cid, "Algum player nao tem "..config.money.."k.") and doSendMagicEffect(getThingPos(cid), 2)
        end
    end
    -- Checando posições 2
    for i = 1, #config.positions2 do
        local creature = getTopCreature(config.positions2[1]).uid
        if not isPlayer(creature) then
            return doPlayerSendCancel(cid, "Not enough players.") and doSendMagicEffect(getThingPos(cid), 2)
        end
        local guild2 = getPlayerGuildId(getTopCreature(config.positions2[1][1]).uid)
        if getPlayerGuildId(creature) ~= guild2 then
            return doPlayerSendCancel(cid, "Algum player nao e da guild correta.") and doSendMagicEffect(getThingPos(cid), 2)
        end
        if getPlayerStorageValue(creature, config.storage) - os.time() > 0 then
            return doPlayerSendTextMessage(cid, 25, "o Jogador "..getPlayerName(creature) .." Você só poderá voltar na arena em "..os.date("%d %B %Y %X ", getPlayerStorageValue(creature, config.storage))..".")
        end
        if getPlayerMoney(creature) < (config.money * 1000) then
            return doPlayerSendCancel(cid, "Algum player nao tem "..config.money.."k.") and doSendMagicEffect(getThingPos(cid), 2)
        end
    end
    doBroadcastMessage("Começou uma batalha entre ".. getPlayerGuildName(getTopCreature(config.positions[1][1]).uid) .." e ".. getPlayerGuildName(getTopCreature(config.positions2[1][1]).uid)..".")
    -- Teleportando posições 1
    for i = 1, #config.positions do
        local creature = getTopCreature(config.positions[1]).uid
        doTeleportThing(creature, config.positions[2])
        doPlayerSendTextMessage(creature, 27, "You started the quest.")
        doSendMagicEffect(getThingPos(creature), 33)
        doPlayerRemoveMoney(creature, (config.money * 1000))
        setPlayerStorageValue(creature, config.storage, os.time() + config.hours * 60 * 60)
    end
    -- Teleportando posições 2
    for i = 1, #config.positions2 do
        local creature = getTopCreature(config.positions2[1]).uid
        doTeleportThing(creature, config.positions2[2])
        doPlayerSendTextMessage(creature, 27, "You started the quest.")
        doSendMagicEffect(getThingPos(creature), 33)
        doPlayerRemoveMoney(creature, (config.money * 1000))
        setPlayerStorageValue(creature, config.storage, os.time() + config.hours * 60 * 60)
    end
    return true
end]]></action>
</mod>?

poxa nao concheço essa funçao 

seu serve existe a função isInRange?

 

seu serve existe a função isInRange? 

Nao sei te informar se tem essa funçao onte eu onlho para te informar??

agora deu esse erro aki o

 

ADM has logged in.

[Error - CreatureScript Interface]
domodlib('gfae_config')
function onLogin(cid)
registerCreatureEvent(cid, "GuildForArenaDeath")
    if getCreatureName(cid) ~= "Account Manager" and isInRange(getPlayerPosition(cid), config.a, config.b) then
        doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
    end
return true
end:onLogin
Description:
data/lib/032-position.lua:2: attempt to index local 'fromPosition' (a nil value)
stack traceback:
        data/lib/032-position.lua:2: in function 'isInRange'
        [string "LuaInterface::loadBuffer"]:4: in function <[string "LuaInterface::loadBuffer"]:2>
ADM has logged out.

 

Link para o post
Compartilhar em outros sites

adc na sua lib:

 

 

function isInRange(pos, fromPosition, toPosition)
        return (position.x >= fromPosition.x and position.y >= fromPosition.y and position.z >= fromPosition.z and position.x <= toPosition.x and position.y <= toPosition.y and position.z <= toPosition.z)
end

 

dps fecha e abre o server

vodkart_logo.png

[*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*]

 

DISCORDvodkart#6090

 

Link para o post
Compartilhar em outros sites
2 horas atrás, Vodkart disse:

#REMOVIDO CÓDIGO BUGADO

 

Só não esqueça na arena de colocar PVP TOOL e AREA NO LOGOUT

 

vodkart tem que ver como ADms no Forum , pq qui tb ta assim , quando pego script dentro do Code[ ] ele ta vindo cheio de ??????/ pelo script....e uns acento em alguns numeros tb...

Link para o post
Compartilhar em outros sites
7 minutos atrás, Vodkart disse:

adc na sua lib:

 

 


function isInRange(pos, fromPosition, toPosition)
        return (position.x >= fromPosition.x and position.y >= fromPosition.y and position.z >= fromPosition.z and position.x <= toPosition.x and position.y <= toPosition.y and position.z <= toPosition.z)
end

 

dps fecha e abre o server

function isInRange(position, fromPosition, toPosition)
    return (position.x >= fromPosition.x and position.y >= fromPosition.y and position.z >= fromPosition.z
        and position.x <= toPosition.x and position.y <= toPosition.y and position.z <= toPosition.z)
end tem issu na primeira linha pode add o seu asim memo?

Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

  • Estatísticas dos Fóruns

    96849
    Tópicos
    519612
    Posts



×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo