• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

exp 2x

MaR0

Banned User
Joined
Apr 16, 2018
Messages
272
Solutions
3
Reaction score
29
Hellow OTLanders!,
how to make a script to make 4 people of different vocations in the same party and standing next to each other get 2x exp and loot.
 
talked with OP in private.

Below script is for extra experience.
Regular monster experience + script experience.

As always, I don't know if this is the best way to do this, but it seems decent to me. -shrug-

basically just checks if player has a party, and if there is X amount of vocations within range of the player receiving the experience, (the player being checked counts as 1 vocation, of course.)

examples
knight + sorc, druid, paladin - in party, and in range of knight, give knight extra exp
knight + elite knight, druid, paladin = extra experience
knight + elite knight, sorcerer, master sorcer = extra experience

knight + paladin + druid + druid + knight = no extra experience.

Script is not tested as of writing this post.
LUA:
local config = {
    range_z = 1, -- 0 = same floor, 1 = +1 floor up or down, 2 et cetera
    range_xy = 15, -- 0 = everyone on same tile, 1 = exori, 2 = 5 by 5, 3 = 7 by 7, et cetera
    required_vocations = 4, -- 4 = yourself + 3 other vocations 
    experience_multiplier = 120000 -- multi * monster_exp
}

local function checkPartyRequirements(cid)
    local count = 1
    local vocations = {}
    table.insert(vocations, getPlayerVocation(cid))
    local party = getPlayerParty(cid)
    local cid_position = getThingPosition(cid)
    local cid_pos = {x = cid_position.x, y = cid_position.y, z = cid_position.z}
    if party then
        for _, pid in ipairs(getPartyMembers(party)) do
            local pid_position = getThingPosition(pid)
            local pid_pos = {x = pid_position.x, y = pid_position.y, z = pid_position.z}
            local add = 1
            for i = 1, #vocations do
                if getPlayerVocation(pid) == vocations[i] then
                    add = 0
                end
            end
            if pid_pos.z < (cid_pos.z - config.range_z) or pid_pos.z > (cid_pos.z + config.range_z) then
                add = 0
            end
            if pid_pos.y < (cid_pos.y - config.range_xy) or pid_pos.y > (cid_pos.y + config.range_xy) then
                add = 0
            end
            if pid_pos.x < (cid_pos.x - config.range_xy) or pid_pos.x > (cid_pos.x + config.range_xy) then
                add = 0
            end
            if add == 1 then
                table.insert(vocations, getPlayerVocation(pid))
                count = count + 1
            end
        end
    end
    return count
end

function onKill(cid, target, damage, flags)
    if not isMonster(target) then
        return true
    end
    if not isPlayer(cid) then
        return true
    end
    if checkPartyRequirements(cid) >= config.required_vocations then
        local target_name = getCreatureName(target)
        local experience_to_give = 120000 * getMonsterInfo(target_name).experience
        doPlayerAddExperience(cid, experience_to_give)
    end
    return true
end
 
Last edited by a moderator:
Back
Top