local fromPos = {x = 4260, y = 5719, z = 6}
local toPos = {x = 4263, y = 5722, z = 6}
local function isInArena(pos)
return pos.x >= fromPos.x and pos.x <= toPos.x
and pos.y >= fromPos.y and pos.y <= toPos.y
and pos.z == fromPos.z
end
function onDeath(cid, corpse, deathList)
if not isPlayer(cid) then
return true
end
if not isInArena(getCreaturePosition(cid)) then
return true
end
local killer = deathList and deathList[1]
if not killer or not isPlayer(killer) then
return true
end
if getPlayerIp(killer) == getPlayerIp(cid) then
doPlayerSendTextMessage(killer, MESSAGE_STATUS_CONSOLE_RED, "You cannot gain rewards for killing a player with the same IP.")
return true
end
local itemId = 6527
local quantity = 10
local playerName = getPlayerName(killer)
local success = false
local backpack = getPlayerSlotItem(killer, CONST_SLOT_BACKPACK)
if backpack and backpack.uid > 0 and isContainer(backpack.uid) and getContainerSlotsFree(backpack.uid) > 0 then
local added = doAddContainerItem(backpack.uid, itemId, quantity)
if added and added > 0 then
doPlayerSendTextMessage(killer, MESSAGE_EVENT_ADVANCE, "You received " .. quantity .. " of item ID " .. itemId .. " in your backpack!")
success = true
end
end
if not success then
local parcel = doCreateItemEx(2595, 1)
if parcel then
doAddContainerItem(parcel, itemId, quantity)
doPlayerSendMailByName(playerName, parcel, getTownId(killer))
doPlayerSendTextMessage(killer, MESSAGE_EVENT_ADVANCE, "Your backpack was full. The reward was sent to your depot.")
else
doPlayerSendTextMessage(killer, MESSAGE_STATUS_CONSOLE_RED, "Failed to create parcel.")
end
end
return true
end