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

Lua Add bounty system onlook player

Madusa

Active Member
Joined
Sep 8, 2022
Messages
109
Reaction score
30
Location
Egypt
I already have this system and it works fine but I have two other systems onlook player like kill death and another
Therefore, I want to add bounty here only because if I add all the functions, one thing appears on the player, which is the bounty
Here is my script player onlook
Lua:
function Player:onLook(thing, position, distance)
    local description = "You see " .. thing:getDescription(distance)
    if self:getGroup():getAccess() then
        if thing:isItem() then
            description = string.format("%s\nItem ID: %d", description, thing:getId())

            local actionId = thing:getActionId()
            if actionId ~= 0 then
                description = string.format("%s, Action ID: %d", description, actionId)
            end

            local uniqueId = thing:getAttribute(ITEM_ATTRIBUTE_UNIQUEID)
            if uniqueId > 0 and uniqueId < 65536 then
                description = string.format("%s, Unique ID: %d", description, uniqueId)
            end

            local itemType = thing:getType()

            local transformEquipId = itemType:getTransformEquipId()
            local transformDeEquipId = itemType:getTransformDeEquipId()
            if transformEquipId ~= 0 then
                description = string.format("%s\nTransforms to: %d (onEquip)", description, transformEquipId)
            elseif transformDeEquipId ~= 0 then
                description = string.format("%s\nTransforms to: %d (onDeEquip)", description, transformDeEquipId)
            end

            local decayId = itemType:getDecayId()
            if decayId ~= -1 then
                description = string.format("%s\nDecays to: %d", description, decayId)
            end
        elseif thing:isCreature() then
            local str = "%s\nHealth: %d / %d"
            if thing:isPlayer() and thing:getMaxMana() > 0 then
                str = string.format("%s, Mana: %d / %d", str, thing:getMana(), thing:getMaxMana())
            end
            description = string.format(str, description, thing:getHealth(), thing:getMaxHealth()) .. "."
        end

        local position = thing:getPosition()
        description = string.format(
            "%s\nPosition: %d, %d, %d",
            description, position.x, position.y, position.z
        )

        if thing:isCreature() then
            if thing:isPlayer() then
                description = string.format("%s\nIP: %s.", description, Game.convertIpToString(thing:getIp()))
            end
        end
    end
if thing:isCreature() and thing:isPlayer() then
    local killStorage = 3000
    local deathStorage = 3001
    local killAmount, deathAmount = thing:getStorageValue(killStorage), thing:getStorageValue(deathStorage)
    if killAmount == -1 then killAmount = 0 end
    if deathAmount == -1 then deathAmount = 0 end
    description = description .. '\nHe has killed: [' ..killAmount..'] Player' .. '\nHe has died: ['..deathAmount..'] Times'
    local damagePrct = thing:getStorageValue(845215)
    if damagePrct then
        description = description .. '\n Damage Character [+%' ..damagePrct.. '].'
    else
        description = description .. '.'
    end
end
    self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end
This is the other text in which the bounty was added. I want to combine the two\/
Code:
function Player:onLook(thing, position, distance)
    local description = "You see " .. thing:getDescription(distance)
    if self:getGroup():getAccess() then
        if thing:isItem() then
            description = string.format("%s\nItem ID: %d", description, thing:getId())

            local actionId = thing:getActionId()
            if actionId ~= 0 then
                description = string.format("%s, Action ID: %d", description, actionId)
            end

            local uniqueId = thing:getAttribute(ITEM_ATTRIBUTE_UNIQUEID)
            if uniqueId > 0 and uniqueId < 65536 then
                description = string.format("%s, Unique ID: %d", description, uniqueId)
            end

            local itemType = thing:getType()

            local transformEquipId = itemType:getTransformEquipId()
            local transformDeEquipId = itemType:getTransformDeEquipId()
            if transformEquipId ~= 0 then
                description = string.format("%s\nTransforms to: %d (onEquip)", description, transformEquipId)
            elseif transformDeEquipId ~= 0 then
                description = string.format("%s\nTransforms to: %d (onDeEquip)", description, transformDeEquipId)
            end

            local decayId = itemType:getDecayId()
            if decayId ~= -1 then
                description = string.format("%s\nDecays to: %d", description, decayId)
            end
        elseif thing:isCreature() then
            local str = "%s\nHealth: %d / %d"
            if thing:getMaxMana() > 0 then
                str = string.format("%s, Mana: %d / %d", str, thing:getMana(), thing:getMaxMana())
            end
            description = string.format(str, description, thing:getHealth(), thing:getMaxHealth()) .. "."
        end

        local position = thing:getPosition()
        description = string.format(
            "%s\nPosition: %d, %d, %d",
            description, position.x, position.y, position.z
        )

        if thing:isCreature() then
            if thing:isPlayer() then
                description = string.format("%s\nIP: %s.", description, Game.convertIpToString(thing:getIp()))
            end
        end
    end
    if thing:isPlayer() then
        local pronoun, posess, user = thing:getSex() == PLAYERSEX_MALE and 'He' or 'She', 'has', thing
        if thing == self then
            pronoun = 'You'
            posess = 'have'
            user = self
        end
        local bounty = user:getStorageValue(bountyStorage)
        description = description .. string.format('\n%s %s a bounty of %d gold coins.', pronoun, posess, bounty)
    end
    self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end
I already tried it but failed
Thanks to all
Post automatically merged:

I did it problem solved
 
Last edited:
Back
Top