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

i mess up my player.luav help!

wafuboe

Member
Joined
Dec 24, 2010
Messages
884
Solutions
2
Reaction score
24
hello guys well i as trying to install a task system to my ot and in one of the steps was to add this to player.lua just before

Code:
self:sendTextMessage(MESSAGE_INFO_DESCR, description)
add:
Code:
if thing:isCreature() then
        if thing:isPlayer() then
            description = string.format("%s\nTask Rank: "..getRankTask(thing), description)
        end
    end
and i just did that on player.lua
Code:
-- Internal Use
STONE_SKIN_AMULET = 2197
GOLD_POUNCH = 26377
ITEM_STORE_INBOX = 26052
ITEM_PARCEL = 2595

-- No move items with actionID 8000
NOT_MOVEABLE_ACTION = 8000

-- Players cannot throw items on teleports if set to true
local blockTeleportTrashing = true

local titles = {
    {storageID = 14960, title = " Scout"},
    {storageID = 14961, title = " Sentinel"},
    {storageID = 14962, title = " Steward"},
    {storageID = 14963, title = " Warden"},
    {storageID = 14964, title = " Squire"},
    {storageID = 14965, title = " Warrior"},
    {storageID = 14966, title = " Keeper"},
    {storageID = 14967, title = " Guardian"},
    {storageID = 14968, title = " Sage"},
    {storageID = 14969, title = " Tutor"},
    {storageID = 14970, title = " Senior Tutor"},
    {storageID = 14971, title = " King"},
}

local exercise_ids = {31821,31822,31823,31824,31825,31826}

local function getTitle(uid)
    local player = Player(uid)
    if not player then return false end

    for i = #titles, 1, -1 do
        if player:getStorageValue(titles[i].storageID) == 1 then
            return titles[i].title
        end
    end

    return false
end

function Player:onBrowseField(position)
    return true
end

local function getHours(seconds)
    return math.floor((seconds/60)/60)
end

local function getMinutes(seconds)
    return math.floor(seconds/60)
end

local function getSeconds(seconds)
    return seconds%60
end

local function getTime(seconds)
    local hours, minutes = getHours(seconds), getMinutes(seconds)
    if (minutes > 59) then
        minutes = minutes-hours*60
    end

    if (minutes < 10) then
        minutes = "0" ..minutes
    end

    return hours..":"..minutes.. "h"
end

local function getTimeinWords(secs)
    local hours, minutes, seconds = getHours(secs), getMinutes(secs), getSeconds(secs)
    if (minutes > 59) then
        minutes = minutes-hours*60
    end

    local timeStr = ''

    if hours > 0 then
        timeStr = timeStr .. ' hours '
    end

    timeStr = timeStr .. minutes .. ' minutes and '.. seconds .. 'seconds.'

    return timeStr
end

function Player:onLook(thing, position, distance)
    local description = "You see "
    if thing:isItem() then
        if thing.actionid == 5640 then
            description = description .. "a honeyflower patch."
        elseif thing.actionid == 5641 then
            description = description .. "a banana palm."
        elseif thing.itemid >= ITEM_HEALTH_CASK_START and thing.itemid <= ITEM_HEALTH_CASK_END
        or thing.itemid >= ITEM_MANA_CASK_START and thing.itemid <= ITEM_MANA_CASK_END
        or thing.itemid >= ITEM_SPIRIT_CASK_START and thing.itemid <= ITEM_SPIRIT_CASK_END
        or thing.itemid >= ITEM_KEG_START and thing.itemid <= ITEM_KEG_END then
            description = description .. thing:getDescription(distance)
            local charges = thing:getCharges()
            if charges then
            description = string.format("%s\nIt has %d refillings left.", description, charges)
            end
        else
            description = description .. thing:getDescription(distance)
        end

        local itemType = thing:getType()
        if (itemType and itemType:getImbuingSlots() > 0) then
            local imbuingSlots = "Imbuements: ("
            for i = 1, itemType:getImbuingSlots() do
                local specialAttr = thing:getSpecialAttribute(i)
                local time = 0
                if (thing:getSpecialAttribute(i+3)) then
                    time = getTime(thing:getSpecialAttribute(i+3))
                end

                if (specialAttr and specialAttr ~= 0) then
                    if (i ~= itemType:getImbuingSlots()) then
                        imbuingSlots = imbuingSlots.. "" ..specialAttr.." " ..time..", "
                    else
                        imbuingSlots = imbuingSlots.. "" ..specialAttr.." " ..time..")."
                    end
                else
                    if (i ~= itemType:getImbuingSlots()) then
                        imbuingSlots = imbuingSlots.. "Empty Slot, "
                    else
                        imbuingSlots = imbuingSlots.. "Empty Slot)."
                    end
                end
            end
            description = string.gsub(description, "It weighs", imbuingSlots.. "\nIt weighs")
        end
    else
        description = description .. thing:getDescription(distance)
        if thing:isMonster() then
            local master = thing:getMaster()
            if master and table.contains({'thundergiant','grovebeast','emberwing','skullfrost'}, thing:getName():lower()) then
                description = description..' (Master: ' .. master:getName() .. '). It will disappear in ' .. getTimeinWords(master:getStorageValue(Storage.PetSummon) - os.time())
            end
        end
    end

    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() then
        if thing:isPlayer() then
            description = string.format("%s\nTask Rank: "..getRankTask(thing), description)
        end
    end
    self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end

function Player:onLookInBattleList(creature, distance)
    local description = "You see " .. creature:getDescription(distance)
    if creature:isMonster() then
        local master = creature:getMaster()
        if master and table.contains({'thundergiant','grovebeast','emberwing','skullfrost'}, creature:getName():lower()) then
            description = description..' (Master: ' .. master:getName() .. '). It will disappear in ' .. getTimeinWords(master:getStorageValue(Storage.PetSummon) - os.time())
        end
    end
    if self:getGroup():getAccess() then
        local str = "%s\nHealth: %d / %d"
        if creature:isPlayer() and creature:getMaxMana() > 0 then
            str = string.format("%s, Mana: %d / %d", str, creature:getMana(), creature:getMaxMana())
        end
        description = string.format(str, description, creature:getHealth(), creature:getMaxHealth()) .. "."

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

        if creature:isPlayer() then
            description = string.format("%s\nIP: %s", description, Game.convertIpToString(creature:getIp()))
        end
    end
    self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end

function Player:onLookInTrade(partner, item, distance)
    self:sendTextMessage(MESSAGE_INFO_DESCR, "You see " .. item:getDescription(distance))
end

function Player:onLookInShop(itemType, count)
    return true
end

and this error shows on console
34930
 
Back
Top