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

Kill Player Reward Exp

I can be simple added to the playerdeath.lua in creaturescripts

If you are using TFS replace you creaturescripts/scripts/playerdeath.lua wuth this

LUA:
dofile("./config.lua")

function onDeath(cid, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)

local storage = XXXXX -- StorageID that the killer need to gain exp, it needs to be 1
local exp = XXXX -- Ammount of exp that tyhe player will win
local msg = "You got 1k exp for kill this player" -- Message showed to the killer
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You are dead.")
if deathListEnabled == "yes" then
local byPlayer = 0
if killer == 0 then
killerName = "field item"
else
if isPlayer(killer) then
byPlayer = 1
else
local master = getCreatureMaster(killer)
if master ~= killer and isPlayer(master) then
killer = master
byPlayer = 1
end
end
killerName = getCreatureName(killer)
end

local byPlayerMostDamage = 0
if mostDamage == 0 then
mostDamageName = "field item"
else
if isPlayer(mostDamage) == TRUE then
byPlayerMostDamage = 1
else
local master = getCreatureMaster(mostDamage)
if master ~= mostDamage and isPlayer(master) then
mostDamage = master
byPlayerMostDamage = 1
end
end
mostDamageName = getCreatureName(mostDamage)
end

db.query("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `is_player`, `mostdamage_by`, `mostdamage_is_player`, `unjustified`, `mostdamage_unjustified`) VALUES (" .. getPlayerGUID(cid) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", " .. db.escapeString(killerName) .. ", " .. byPlayer .. ", " .. db.escapeString(mostDamageName) .. ", " .. byPlayerMostDamage .. ", " .. unjustified .. ", " .. mostDamage_unjustified .. ")")
local resultId = db.storeQuery("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid))

local deathRecords = 0
local tmpResultId = resultId
while tmpResultId ~= false do
tmpResultId = result.next(resultId)
deathRecords = deathRecords + 1
end

if resultId ~= false then
result.free(resultId)
end

while deathRecords > maxDeathRecords do
db.query("DELETE FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1")
deathRecords = deathRecords - 1
end

if byPlayer == 1 then
local targetGuild = getPlayerGuildId(cid)
if targetGuild ~= 0 then
local killerGuild = getPlayerGuildId(killer)
if killerGuild ~= 0 and targetGuild ~= killerGuild and isInWar(cid, killer) == TRUE then
local warId = false
resultId = db.storeQuery("SELECT `id` FROM `guild_wars` WHERE `status` = 1 AND ((`guild1` = " .. killerGuild .. " AND `guild2` = " .. targetGuild .. ") OR (`guild1` = " .. targetGuild .. " AND `guild2` = " .. killerGuild .. "))")
if resultId ~= false then
warId = result.getDataInt(resultId, "id")
result.free(resultId)
end

if warId ~= false then
db.query("INSERT INTO `guildwar_kills` (`killer`, `target`, `killerguild`, `targetguild`, `time`, `warid`) VALUES (" .. db.escapeString(getCreatureName(killer)) .. ", " .. db.escapeString(getCreatureName(cid)) .. ", " .. killerGuild .. ", " .. targetGuild .. ", " .. os.time() .. ", " .. warId .. ")")
end
end
end
end
if getPlayerStorageValue(killer, storage) == 1 then
doPlayerAddExp(killer, exp)
doPlayerSendTextMessage(killer, 22, msg)
end
end
end

What this script do?, when some have the storage, and he kills ANY player, he will gain an ammount of exp, you should check the local configuration to do it as your like, or be more specific with what do you want
 
Back
Top