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

TFS 1.3 Kill Reward

Adorius Black

Advanced OT User
Joined
Mar 31, 2020
Messages
307
Solutions
3
Reaction score
181
Hi does anybody know script for Reward after Kill player. When I kill player I will get [itemID] to my backpack. When 10 people kill one player, all 10 people gets [itemID]
when player kill player with same IP dont get punish -500exp and dont get [itemID].

I found some threads but noone work for me.
Here is example:
Kill Reward (https://otland.net/threads/kill-reward.227917/)
 
Lua:
local itemAmount = 5

function onDeath(player, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)

    local damageMap = player:getDamageMap()
    local i = 0

    for pid, _ in pairs(damageMap) do
        i = i + 1
        if isPlayer(pid) then
            if getPlayerIp(pid) ~= getPlayerIp(player) then
                Player(pid):addItem(ITEM_PLATINUM_COIN, itemAmount)
           end
        end
    end

    if mostDamageKiller then
        if mostDamageKiller:isPlayer() then
            mostDamageKiller:say("KILLER!", TALKTYPE_MONSTER_SAY)
        end
    end

    return true
end
 
Lua:
local itemAmount = 5

function onDeath(player, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)

    local damageMap = player:getDamageMap()
    local i = 0

    for pid, _ in pairs(damageMap) do
        i = i + 1
        if isPlayer(pid) then
            if getPlayerIp(pid) ~= getPlayerIp(player) then
                Player(pid):addItem(ITEM_PLATINUM_COIN, itemAmount)
           end
        end
    end

    if mostDamageKiller then
        if mostDamageKiller:isPlayer() then
            mostDamageKiller:say("KILLER!", TALKTYPE_MONSTER_SAY)
        end
    end

    return true
end
Where should I register it please?
 
Lua:
function Player.sendTibiaTime(self, hours, minutes)
    local msg = NetworkMessage()
    msg:addByte(0xEF)
    msg:addByte(hours)
    msg:addByte(minutes)
    msg:sendToPlayer(self)
    msg:delete()
    return true
end

local function onMovementRemoveProtection(cid, oldPosition, time)
    local player = Player(cid)
    if not player then
        return true
    end

    local playerPosition = player:getPosition()
    if (playerPosition.x ~= oldPosition.x or playerPosition.y ~= oldPosition.y or playerPosition.z ~= oldPosition.z) or player:getTarget() then
        player:setStorageValue(Storage.combatProtectionStorage, 0)
        return true
    end

    addEvent(onMovementRemoveProtection, 1000, cid, oldPosition, time - 1)
end

function onLogin(player)

    -- Outfit bonus
    local bonusCondition = getBonusCondition(player:getOutfit().lookType)
    if bonusCondition then
        player:addCondition(bonusCondition)
    end
    -- Outfit bonus
    local loginStr = 'Welcome to ' .. configManager.getString(configKeys.SERVER_NAME) .. '!'
    if player:getLastLoginSaved() <= 0 then
        loginStr = loginStr .. ' Please choose your outfit.'
        player:sendOutfitWindow()
    else
        if loginStr ~= "" then
            player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
        end

        loginStr = string.format('Your last visit was on %s.', os.date('%a %b %d %X %Y', player:getLastLoginSaved()))
    end

    player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)

    local playerId = player:getId()

    --daily reward
    player:initDailyRewardSystem()

    player:loadSpecialStorage()

    --[[-- Maintenance mode
    if (player:getGroup():getId() < 2) then
        return false
    else

    end--]]

    if (player:getGroup():getId() >= 4) then
        player:setGhostMode(true)
    end

    -- Stamina
    nextUseStaminaTime[playerId] = 1

    -- EXP Stamina
    nextUseXpStamina[playerId] = 1

    if (player:getAccountType() == ACCOUNT_TYPE_TUTOR) then
        local msg = [[:: Tutor Rules
            1 *> 3 Warnings you lose the job.
            2 *> Without parallel conversations with players in Help, if the player starts offending, you simply mute it.
            3 *> Be educated with the players in Help and especially in the Private, try to help as much as possible.
            4 *> Always be on time, if you do not have a justification you will be removed from the staff.
            5 *> Help is only allowed to ask questions related to tibia.
            6 *> It is not allowed to divulge time up or to help in quest.
            7 *> You are not allowed to sell items in the Help.
            8 *> If the player encounters a bug, ask to go to the website to send a ticket and explain in detail.
            9 *> Always keep the Tutors Chat open. (required).
            10 *> You have finished your schedule, you have no tutor online, you communicate with some CM in-game or ts and stay in the help until someone logs in, if you can.
            11 *> Always keep a good Portuguese in the Help, we want tutors who support, not that they speak a satanic ritual.
            12 *> If you see a tutor doing something that violates the rules, take a print and send it to your superiors. "
            - Commands -
            Mute Player: / mute nick, 90. (90 seconds)
            Unmute Player: / unmute nick.
            - Commands -]]
        player:popupFYI(msg)
    end

     -- OPEN CHANNELS
    if table.contains({"Rookgaard", "Dawnport"}, player:getTown():getName())then
        player:openChannel(3) -- world chat
        player:openChannel(6) -- advertsing rook main
    else
        player:openChannel(3) -- world chat
        player:openChannel(5) -- advertsing main
    end

    -- Rewards
    local rewards = #player:getRewardList()
    if(rewards > 0) then
        player:sendTextMessage(MESSAGE_INFO_DESCR, string.format("You have %d %s in your reward chest.", rewards, rewards > 1 and "rewards" or "reward"))
    end

    -- Update player id
    local stats = player:inBossFight()
    if stats then
        stats.playerId = player:getId()
    end

     if player:getStorageValue(Storage.combatProtectionStorage) < 1 then
        player:setStorageValue(Storage.combatProtectionStorage, 1)
        onMovementRemoveProtection(playerId, player:getPosition(), 10)
    end

    -- Set Client XP Gain Rate
    local baseExp = 100
    if Game.getStorageValue(GlobalStorage.XpDisplayMode) > 0 then
        baseExp = Game.getExperienceStage(player:getLevel())
    end
    local staminaMinutes = player:getStamina()
    local doubleExp = false -- pode mudar pra true se tiver double no server
    local staminaBonus = (staminaMinutes > 2400) and 150 or ((staminaMinutes < 840) and 50 or 100)

    if doubleExp then
        baseExp = baseExp * 2
    end

    player:setStaminaXpBoost(staminaBonus)
    player:setBaseXpGain(baseExp)

    if player:getClient().version > 1110 then
        local worldTime = getWorldTime()
        local hours = math.floor(worldTime / 60)
        local minutes = worldTime % 60
        player:sendTibiaTime(hours, minutes)
    end
    
    if player:getStorageValue(Storage.isTraining) == 1 then -- redefinir storage de exercise weapon
        player:setStorageValue(Storage.isTraining,0)
    end
    return true
end

registerCreatureEvent(cid, "Killer")
registerCreatureEvent(cid, "TopFrags")
registerCreatureEvent(cid, "RTopFrags")
registerCreatureEvent(cid, "GoldOnKillPlayer")
 
creaturescripts XML
Lua:
    <event type="death" name="GoldOnKillPlayer" script="goldonkillplayer.lua" />

creaturescripts login.lua register event.
Code:
player:registerEvent("GoldOnKillPlayer")
sorry to bump, could you convert it to tfs 1.5? or revscript? registered the script but is not working
i want something really simple onkill or frag gain 2 platinum
 
Lua:
local itemAmount = 5

function onDeath(player, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)

    local damageMap = player:getDamageMap()
    local i = 0

    for pid, _ in pairs(damageMap) do
        i = i + 1
        if isPlayer(pid) then
            if getPlayerIp(pid) ~= getPlayerIp(player) then
                Player(pid):addItem(ITEM_PLATINUM_COIN, itemAmount)
           end
        end
    end

    if mostDamageKiller then
        if mostDamageKiller:isPlayer() then
            mostDamageKiller:say("KILLER!", TALKTYPE_MONSTER_SAY)
        end
    end

    return true
end
Can this text be selected for level 500 and above
 
Lua:
function Player.sendTibiaTime(self, hours, minutes)
    local msg = NetworkMessage()
    msg:addByte(0xEF)
    msg:addByte(hours)
    msg:addByte(minutes)
    msg:sendToPlayer(self)
    msg:delete()
    return true
end

local function onMovementRemoveProtection(cid, oldPosition, time)
    local player = Player(cid)
    if not player then
        return true
    end

    local playerPosition = player:getPosition()
    if (playerPosition.x ~= oldPosition.x or playerPosition.y ~= oldPosition.y or playerPosition.z ~= oldPosition.z) or player:getTarget() then
        player:setStorageValue(Storage.combatProtectionStorage, 0)
        return true
    end

    addEvent(onMovementRemoveProtection, 1000, cid, oldPosition, time - 1)
end

function onLogin(player)

    -- Outfit bonus
    local bonusCondition = getBonusCondition(player:getOutfit().lookType)
    if bonusCondition then
        player:addCondition(bonusCondition)
    end
    -- Outfit bonus
    local loginStr = 'Welcome to ' .. configManager.getString(configKeys.SERVER_NAME) .. '!'
    if player:getLastLoginSaved() <= 0 then
        loginStr = loginStr .. ' Please choose your outfit.'
        player:sendOutfitWindow()
    else
        if loginStr ~= "" then
            player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
        end

        loginStr = string.format('Your last visit was on %s.', os.date('%a %b %d %X %Y', player:getLastLoginSaved()))
    end

    player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)

    local playerId = player:getId()

    --daily reward
    player:initDailyRewardSystem()

    player:loadSpecialStorage()

    --[[-- Maintenance mode
    if (player:getGroup():getId() < 2) then
        return false
    else

    end--]]

    if (player:getGroup():getId() >= 4) then
        player:setGhostMode(true)
    end

    -- Stamina
    nextUseStaminaTime[playerId] = 1

    -- EXP Stamina
    nextUseXpStamina[playerId] = 1

    if (player:getAccountType() == ACCOUNT_TYPE_TUTOR) then
        local msg = [[:: Tutor Rules
            1 *> 3 Warnings you lose the job.
            2 *> Without parallel conversations with players in Help, if the player starts offending, you simply mute it.
            3 *> Be educated with the players in Help and especially in the Private, try to help as much as possible.
            4 *> Always be on time, if you do not have a justification you will be removed from the staff.
            5 *> Help is only allowed to ask questions related to tibia.
            6 *> It is not allowed to divulge time up or to help in quest.
            7 *> You are not allowed to sell items in the Help.
            8 *> If the player encounters a bug, ask to go to the website to send a ticket and explain in detail.
            9 *> Always keep the Tutors Chat open. (required).
            10 *> You have finished your schedule, you have no tutor online, you communicate with some CM in-game or ts and stay in the help until someone logs in, if you can.
            11 *> Always keep a good Portuguese in the Help, we want tutors who support, not that they speak a satanic ritual.
            12 *> If you see a tutor doing something that violates the rules, take a print and send it to your superiors. "
            - Commands -
            Mute Player: / mute nick, 90. (90 seconds)
            Unmute Player: / unmute nick.
            - Commands -]]
        player:popupFYI(msg)
    end

     -- OPEN CHANNELS
    if table.contains({"Rookgaard", "Dawnport"}, player:getTown():getName())then
        player:openChannel(3) -- world chat
        player:openChannel(6) -- advertsing rook main
    else
        player:openChannel(3) -- world chat
        player:openChannel(5) -- advertsing main
    end

    -- Rewards
    local rewards = #player:getRewardList()
    if(rewards > 0) then
        player:sendTextMessage(MESSAGE_INFO_DESCR, string.format("You have %d %s in your reward chest.", rewards, rewards > 1 and "rewards" or "reward"))
    end

    -- Update player id
    local stats = player:inBossFight()
    if stats then
        stats.playerId = player:getId()
    end

     if player:getStorageValue(Storage.combatProtectionStorage) < 1 then
        player:setStorageValue(Storage.combatProtectionStorage, 1)
        onMovementRemoveProtection(playerId, player:getPosition(), 10)
    end

    -- Set Client XP Gain Rate
    local baseExp = 100
    if Game.getStorageValue(GlobalStorage.XpDisplayMode) > 0 then
        baseExp = Game.getExperienceStage(player:getLevel())
    end
    local staminaMinutes = player:getStamina()
    local doubleExp = false -- pode mudar pra true se tiver double no server
    local staminaBonus = (staminaMinutes > 2400) and 150 or ((staminaMinutes < 840) and 50 or 100)

    if doubleExp then
        baseExp = baseExp * 2
    end

    player:setStaminaXpBoost(staminaBonus)
    player:setBaseXpGain(baseExp)

    if player:getClient().version > 1110 then
        local worldTime = getWorldTime()
        local hours = math.floor(worldTime / 60)
        local minutes = worldTime % 60
        player:sendTibiaTime(hours, minutes)
    end
 
    if player:getStorageValue(Storage.isTraining) == 1 then -- redefinir storage de exercise weapon
        player:setStorageValue(Storage.isTraining,0)
    end
    return true
end

registerCreatureEvent(cid, "Killer")
registerCreatureEvent(cid, "TopFrags")
registerCreatureEvent(cid, "RTopFrags")
registerCreatureEvent(cid, "GoldOnKillPlayer")
All of the registered events will not work, cid return nil the whole registerCreatureEvent shouldbe in onLogin function. here is a fix
Lua:
function Player.sendTibiaTime(self, hours, minutes)
    local msg = NetworkMessage()
    msg:addByte(0xEF)
    msg:addByte(hours)
    msg:addByte(minutes)
    msg:sendToPlayer(self)
    msg:delete()
    return true
end

local function onMovementRemoveProtection(cid, oldPosition, time)
    local player = Player(cid)
    if not player then
        return true
    end

    local playerPosition = player:getPosition()
    if (playerPosition.x ~= oldPosition.x or playerPosition.y ~= oldPosition.y or playerPosition.z ~= oldPosition.z) or player:getTarget() then
        player:setStorageValue(Storage.combatProtectionStorage, 0)
        return true
    end

    addEvent(onMovementRemoveProtection, 1000, cid, oldPosition, time - 1)
end

function onLogin(player)

    -- Outfit bonus
    local bonusCondition = getBonusCondition(player:getOutfit().lookType)
    if bonusCondition then
        player:addCondition(bonusCondition)
    end
    -- Outfit bonus
    local loginStr = 'Welcome to ' .. configManager.getString(configKeys.SERVER_NAME) .. '!'
    if player:getLastLoginSaved() <= 0 then
        loginStr = loginStr .. ' Please choose your outfit.'
        player:sendOutfitWindow()
    else
        if loginStr ~= "" then
            player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
        end

        loginStr = string.format('Your last visit was on %s.', os.date('%a %b %d %X %Y', player:getLastLoginSaved()))
    end

    player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)

    local playerId = player:getId()

    --daily reward
    player:initDailyRewardSystem()

    player:loadSpecialStorage()

    --[[-- Maintenance mode
    if (player:getGroup():getId() < 2) then
        return false
    else

    end--]]

    if (player:getGroup():getId() >= 4) then
        player:setGhostMode(true)
    end

    -- Stamina
    nextUseStaminaTime[playerId] = 1

    -- EXP Stamina
    nextUseXpStamina[playerId] = 1

    if (player:getAccountType() == ACCOUNT_TYPE_TUTOR) then
        local msg = [[:: Tutor Rules
            1 *> 3 Warnings you lose the job.
            2 *> Without parallel conversations with players in Help, if the player starts offending, you simply mute it.
            3 *> Be educated with the players in Help and especially in the Private, try to help as much as possible.
            4 *> Always be on time, if you do not have a justification you will be removed from the staff.
            5 *> Help is only allowed to ask questions related to tibia.
            6 *> It is not allowed to divulge time up or to help in quest.
            7 *> You are not allowed to sell items in the Help.
            8 *> If the player encounters a bug, ask to go to the website to send a ticket and explain in detail.
            9 *> Always keep the Tutors Chat open. (required).
            10 *> You have finished your schedule, you have no tutor online, you communicate with some CM in-game or ts and stay in the help until someone logs in, if you can.
            11 *> Always keep a good Portuguese in the Help, we want tutors who support, not that they speak a satanic ritual.
            12 *> If you see a tutor doing something that violates the rules, take a print and send it to your superiors. "
            - Commands -
            Mute Player: / mute nick, 90. (90 seconds)
            Unmute Player: / unmute nick.
            - Commands -]]
        player:popupFYI(msg)
    end

     -- OPEN CHANNELS
    if table.contains({"Rookgaard", "Dawnport"}, player:getTown():getName())then
        player:openChannel(3) -- world chat
        player:openChannel(6) -- advertsing rook main
    else
        player:openChannel(3) -- world chat
        player:openChannel(5) -- advertsing main
    end

    -- Rewards
    local rewards = #player:getRewardList()
    if(rewards > 0) then
        player:sendTextMessage(MESSAGE_INFO_DESCR, string.format("You have %d %s in your reward chest.", rewards, rewards > 1 and "rewards" or "reward"))
    end

    -- Update player id
    local stats = player:inBossFight()
    if stats then
        stats.playerId = player:getId()
    end

     if player:getStorageValue(Storage.combatProtectionStorage) < 1 then
        player:setStorageValue(Storage.combatProtectionStorage, 1)
        onMovementRemoveProtection(playerId, player:getPosition(), 10)
    end

    -- Set Client XP Gain Rate
    local baseExp = 100
    if Game.getStorageValue(GlobalStorage.XpDisplayMode) > 0 then
        baseExp = Game.getExperienceStage(player:getLevel())
    end
    local staminaMinutes = player:getStamina()
    local doubleExp = false -- pode mudar pra true se tiver double no server
    local staminaBonus = (staminaMinutes > 2400) and 150 or ((staminaMinutes < 840) and 50 or 100)

    if doubleExp then
        baseExp = baseExp * 2
    end

    player:setStaminaXpBoost(staminaBonus)
    player:setBaseXpGain(baseExp)

    if player:getClient().version > 1110 then
        local worldTime = getWorldTime()
        local hours = math.floor(worldTime / 60)
        local minutes = worldTime % 60
        player:sendTibiaTime(hours, minutes)
    end
  
    if player:getStorageValue(Storage.isTraining) == 1 then -- redefinir storage de exercise weapon
        player:setStorageValue(Storage.isTraining,0)
    end
  
  ---tbh in that version tfs u should use player:registerEvent("EVENT NAME")
    registerCreatureEvent(cid, "Killer")
    registerCreatureEvent(cid, "TopFrags")
    registerCreatureEvent(cid, "RTopFrags")
    registerCreatureEvent(cid, "GoldOnKillPlayer")

    return true
end

@edit
didnt notice thats a post from 2020.. god damn, but maybe someone will get a hint in future with similar problem with not-registered events
 
Last edited:
@edit
didnt notice thats a post from 2020.. god damn, but maybe someone will get a hint in future with similar problem with not-registered events

still i didnt fix it so i will test later your solution. hope it will work :)
Post automatically merged:



Lua:
local itemAmount = 5

function onDeath(player, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)

    local damageMap = player:getDamageMap()
    local i = 0

    for pid, _ in pairs(damageMap) do
        i = i + 1
        if isPlayer(pid) then
            if getPlayerIp(pid) ~= getPlayerIp(player) then
                Player(pid):addItem(ITEM_PLATINUM_COIN, itemAmount)
           end
        end
    end

    if mostDamageKiller then
        if mostDamageKiller:isPlayer() then
            mostDamageKiller:say("KILLER!", TALKTYPE_MONSTER_SAY)
        end
    end

    return true
end
Code is working on tfs 1.4 but only half part. When I kill someone it said KILLER! but it didnt add item in my backpack
 
Last edited:
still i didnt fix it so i will test later your solution. hope it will work :)
Post automatically merged:




Code is working on tfs 1.4 but only half part. When I kill someone it said KILLER! but it didnt add item in my backpack

Lua:
                Player(pid):addItem(items id, itemAmount)
                Player(pid):addItem(2160, 10)
Try to change it and give it a try
It may not give you the items because you are using it Killer Mc...
 
Back
Top