• 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!

On Kill A player Give Specific Exp Qty.

quirknepx

New Member
Joined
Aug 28, 2010
Messages
17
Reaction score
3
Hello I was wondering if someone could help me please with a script:

When you kill a player, as a reward it should give you a SPECIFIC experience amount like 20,000 exp points. Like if you were killing a monster :)

P.S. I don't want to use the config.lua settings (experience from players, min threshold , max threshold,) because they are based on %

Thanks for the attention Otland Community.
 
Untested.

Code:
local checkIP = true -- Do we want to check if player and killer have the same IP address?
local amount = 20000 -- Amount of experience to give the damage map.

function onDeath(cid, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    local player = Player(cid)
    if not player then
        return true
    end

    if player:getTile():hasFlag(TILESTATE_PVPZONE) then
        return true
    end

    local killer = Player(killer)
    if not killer then
        return true
    end

    if checkIP and player:getIp() == killer:getIp() then
        return true
    end

    local map = Creature(cid):getDamageMap()
    if map then
        for id, damage in pairs(map) do
            local c = Creature(id)
            if c and c:isPlayer() then
                c:addExperience(amount, true)
            end
        end
    end
    return true
end

Red
 
Last edited:
Untested.

Code:
local checkIP = true -- Do we want to check if player and killer have the same IP address?
local amount = 20000 -- Amount of experience to give the damage map.

function onDeath(cid, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    local player = Player(cid)
    if not player then
        return
    end

    if player:getTile():hasFlag(TILESTATE_PVPZONE) then
        return
    end

    local killer = Player(killer)
    if not killer then
        return
    end

    if checkIP and player:getIp() == killer:getIp() then
        return
    end

    local map = Creature(cid):getDamageMap()
    if map then
        for id, damage in pairs(map) do
            local c = Creature(id)
            if c and c:isPlayer() then
                c:addExperience(amount, true)
            end
        end
    end
    return
end

Red
this:
Code:
return
has to be:
Code:
return true
or it'll bug the character on death
 
Last edited:
Man thanks for the help and for promptly answering, I tested your script and it doesn't gives the player the Exp, I don't know if it helps to mention that is a HARCORE (Pvp-enforced) in config.lua I have worldtype="hardcore", and I am running TFS 0.4
 
You need to register all creaturescripts that should (only) work for players in login.lua except from login and logout scripts.
 
Untested.

Code:
local checkIP = true -- Do we want to check if player and killer have the same IP address?
local amount = 20000 -- Amount of experience to give the damage map.

function onDeath(cid, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    local player = Player(cid)
    if not player then
        return true
    end

    if player:getTile():hasFlag(TILESTATE_PVPZONE) then
        return true
    end

    local killer = Player(killer)
    if not killer then
        return true
    end

    if checkIP and player:getIp() == killer:getIp() then
        return true
    end

    local map = Creature(cid):getDamageMap()
    if map then
        for id, damage in pairs(map) do
            local c = Creature(id)
            if c and c:isPlayer() then
                c:addExperience(amount, true)
            end
        end
    end
    return true
end

Red
Quick question, if pvpe is enabled will this script override the experience you normally get from killing a player or will you get both the script's experience the normal experience killing a player @Limos ?
 
Quick question, if pvpe is enabled will this script override the experience you normally get from killing a player or will you get both the script's experience the normal experience killing a player @Limos ?

No. It won't override anything. You will receive both the pvp-enforced experience as well as the bonus amount specified in the script.

Red
 
Back
Top