• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

RevScripts check pt

alcapone

Member
Joined
Jan 13, 2021
Messages
247
Reaction score
19
LUA:
onDeath(creature, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)

 
    if not creature:isMonster() or creature:getMaster() then
        return true
    end
      
    if not corpse or type(corpse) ~= 'userdata' or not corpse:isContainer() or creature:getType():isRewardBoss() then
        return true
    end

    local owner = mostDamage
    if not mostDamage and killer and killer:isPlayer() then
        owner = killer
    end
 
    if owner and owner:getMaster() and owner:getMaster():isPlayer() then
        owner = owner:getMaster()
    end

    if not owner or not owner:isPlayer() then
        return
    end

 
    return true
end


'm trying to create a check for this auto loot for when a team is in pt it only works for the pt leader currently it's only working for whoever gave the biggest attack
 
Solution
X
if not creature:isMonster() or creature:getMaster() then
return true
end

if not corpse or type(corpse) ~= 'userdata' or not corpse:isContainer() or creature:getType():isRewardBoss() then
return true
end

local owner = mostDamage

-- check party
local party = owner:getParty()
if party then
local leader = party:getLeader()
addEvent(scanContainer, 10, leader:getId(), creature:getPosition())
return true
end
-- check party

if not mostDamage and killer and killer:isPlayer() then
owner = killer
end

if owner and owner:getMaster() and owner:getMaster():isPlayer() then
owner = owner:getMaster()
end

if not owner or not...
Not exactly sure what you're going for..
But this should get you started.

LUA:
function onDeath(creature, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    if not creature:isMonster() or creature:getMaster() then
        return true
    end
    
    if not corpse or type(corpse) ~= 'userdata' or not corpse:isContainer() or creature:getType():isRewardBoss() then
        return true
    end
    
    local owner = mostDamage
    if not mostDamage and killer and killer:isPlayer() then
        owner = killer
    end
    
    if owner and owner:getMaster() and owner:getMaster():isPlayer() then
        owner = owner:getMaster()
    end
    
    if not owner or not owner:isPlayer() then
        return
    end
    
    -- if in party
    local party = owner:getParty()
    if party then
        local leader = party:getLeader()
        -- leader:sendAutoLoot() ??
        return true
    end
    
    return true
end
 
Not exactly sure what you're going for..
But this should get you started.

LUA:
function onDeath(creature, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    if not creature:isMonster() or creature:getMaster() then
        return true
    end
   
    if not corpse or type(corpse) ~= 'userdata' or not corpse:isContainer() or creature:getType():isRewardBoss() then
        return true
    end
   
    local owner = mostDamage
    if not mostDamage and killer and killer:isPlayer() then
        owner = killer
    end
   
    if owner and owner:getMaster() and owner:getMaster():isPlayer() then
        owner = owner:getMaster()
    end
   
    if not owner or not owner:isPlayer() then
        return
    end
   
    -- if in party
    local party = owner:getParty()
    if party then
        local leader = party:getLeader()
        -- leader:sendAutoLoot() ??
        return true
    end
   
    return true
end
if not creature:isMonster() or creature:getMaster() then
return true
end

if not corpse or type(corpse) ~= 'userdata' or not corpse:isContainer() or creature:getType():isRewardBoss() then
return true
end

local owner = mostDamage

-- check party
local party = owner:getParty()
if party then
local leader = party:getLeader()
addEvent(scanContainer, 10, leader:getId(), creature:getPosition())
return true
end
-- check party

if not mostDamage and killer and killer:isPlayer() then
owner = killer
end

if owner and owner:getMaster() and owner:getMaster():isPlayer() then
owner = owner:getMaster()
end

if not owner or not owner:isPlayer() then
return
end


addEvent(scanContainer, 10, owner:getId(), creature:getPosition())
return true
end



I put the addEvent there and it worked in the case the problem now would be the distance the members of the pt are cities far from the leader and the loot is going to him
 
if not creature:isMonster() or creature:getMaster() then
return true
end

if not corpse or type(corpse) ~= 'userdata' or not corpse:isContainer() or creature:getType():isRewardBoss() then
return true
end

local owner = mostDamage

-- check party
local party = owner:getParty()
if party then
local leader = party:getLeader()
addEvent(scanContainer, 10, leader:getId(), creature:getPosition())
return true
end
-- check party

if not mostDamage and killer and killer:isPlayer() then
owner = killer
end

if owner and owner:getMaster() and owner:getMaster():isPlayer() then
owner = owner:getMaster()
end

if not owner or not owner:isPlayer() then
return
end


addEvent(scanContainer, 10, owner:getId(), creature:getPosition())
return true
end



I put the addEvent there and it worked in the case the problem now would be the distance the members of the pt are cities far from the leader and the loot is going to him
LUA:
local maxLeaderDistance = 30

function onDeath(creature, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    if not creature:isMonster() or creature:getMaster() then
        return true
    end
 
    if not corpse or type(corpse) ~= 'userdata' or not corpse:isContainer() or creature:getType():isRewardBoss() then
        return true
    end
 
    local owner = mostDamage
    if not mostDamage and killer and killer:isPlayer() then
        owner = killer
    end
 
    if owner and owner:getMaster() and owner:getMaster():isPlayer() then
        owner = owner:getMaster()
    end
 
    if not owner or not owner:isPlayer() then
        return
    end
 
    -- if in party
    local party = owner:getParty()
    if party then
        local leader = party:getLeader()
        if leader then
            if leader:getPosition():getDistance(corpse:getPosition()) <= maxLeaderDistance then
                -- leader get's loot
                return true
            end
        end
    end
    
    -- non-leader get's loot
    return true
end
 
Solution

Similar threads

Replies
1
Views
160
Back
Top