Ir para conteúdo
Banner com Efeitos

(Resolvido){Resolvido} Ganhar recompensa ao matar player em "X" lugar

Featured Replies

Resolvido por Dwarfer

Ir para solução
Postado

Em creaturescripts/scripts:

 

killarea.lua

 

Spoiler

local area = {{x = 1, y = 1, z = 1},{x = 1, y = 1, z = 1}} -- canto superior esquerdo, canto inferior direito da área
local items = {{2160,2}, {2148,7}} -- {id, quantidade}

function onKill(cid, target, damage, flags)
    if not isPlayer(target) or not isPlayer(cid) then return true end
    if isInRange(getPlayerPosition(target), area[1], area[2]) then
        for i = 1, #items do
            doPlayerAddItem(cid, items[i][1], items[i][2])
        end
    end
    return true
end

 

 

No creaturescripts.xml: <event type="kill" name="KillArea" event="script" value="killinarea.lua"/>

 

No login.lua: registerCreatureEvent(cid, "KillArea")

Contato:

 

Postado
  • Autor
23 minutos atrás, Dwarfer disse:

Em creaturescripts/scripts:

 

killarea.lua

 

  Ocultar conteúdo


local area = {{x = 1, y = 1, z = 1},{x = 1, y = 1, z = 1}} -- canto superior esquerdo, canto inferior direito da área
local items = {{2160,2}, {2148,7}} -- {id, quantidade}

function onKill(cid, target, damage, flags)
    if not isPlayer(target) or not isPlayer(cid) then return true end
    if isInRange(getPlayerPosition(target), area[1], area[2]) then
        for i = 1, #items do
            doPlayerAddItem(cid, items[i][1], items[i][2])
        end
    end
    return true
end

 

 

No creaturescripts.xml: <event type="kill" name="KillArea" event="script" value="killinarea.lua"/>

 

No login.lua: registerCreatureEvent(cid, "KillArea")


@Dwarfer Se no caso a area tenha um piso superior, as coordenadas ali coloco o floor 7 mesmo e ela abrange a parte de cima ou teria que fazer um separado com as coordenadas do floor 6?

Postado
  • Solução
Spoiler

local area = {{x = 1, y = 1, z = 1},{x = 1, y = 1, z = 1}} -- canto superior esquerdo, canto inferior direito da área
local items = {{2160,2}, {2148,7}} -- {id, quantidade}

function onKill(cid, target, damage, flags)
    if not isPlayer(target) or not isPlayer(cid) then return true end
    local players = playersInArea(area[1],area[2])
    if isInArray(players, target) then
        for i = 1, #items do
            doPlayerAddItem(cid, items[i][1], items[i][2])
        end
    end
    return true
end

function playersInArea(fromPosition, toPosition)
    local players = {}
    for _, pid in ipairs(getPlayersOnline()) do
        local f = {x = fromPosition.x, y = fromPosition.y, z = fromPosition.z}
        local t = {x = toPosition.x, y = toPosition.y, z = toPosition.z}
        local min = (fromPosition.z > toPosition.z and toPosition.z or fromPosition.z)
        for index = 0, math.abs(toPosition.z - fromPosition.z) do
            f.z = min + index
            t.z = min + index
            if isInRange(getPlayerPosition(pid), f, t) then
                table.insert(players, pid)
            end
        end    
    end
    return players
end

 

 

Contato:

 

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

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo