• 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.X+ data/events/scripts/player.lua:Player@onLookInShop

Jeyci

Banned User
Joined
May 6, 2023
Messages
289
Solutions
3
Reaction score
36
Lua:
Lua Script Error: [Event Interface]
data/events/scripts/player.lua:Player@onLookInShop
data/events/scripts/player.lua:33: attempt to concatenate local 'description' (a nil value)
stack traceback:
        data/events/scripts/player.lua:33: in function <data/events/scripts/player.lua:32>

Lua Script Error: [Event Interface]
data/events/scripts/player.lua:Player@onLookInShop
data/events/scripts/player.lua:33: attempt to concatenate local 'description' (a nil value)
stack traceback:
        data/events/scripts/player.lua:33: in function <data/events/scripts/player.lua:32>
this is my payer.lua
Code:
function Player:onBrowseField(position)
    if hasEventCallback(EVENT_CALLBACK_ONBROWSEFIELD) then
        return EventCallback(EVENT_CALLBACK_ONBROWSEFIELD, self, position)
    end
    return true
end

function Player:onLook(thing, position, distance)
    local description = ""
    if hasEventCallback(EVENT_CALLBACK_ONLOOK) then
        description = EventCallback(EVENT_CALLBACK_ONLOOK, self, thing, position, distance, description)
    end
    self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end

function Player:onLookInBattleList(creature, distance)
    local description = ""
    if hasEventCallback(EVENT_CALLBACK_ONLOOKINBATTLELIST) then
        description = EventCallback(EVENT_CALLBACK_ONLOOKINBATTLELIST, self, creature, distance, description)
    end
    self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end

function Player:onLookInTrade(partner, item, distance)
    local description = "You see " .. item:getDescription(distance)
    if hasEventCallback(EVENT_CALLBACK_ONLOOKINTRADE) then
        description = EventCallback(EVENT_CALLBACK_ONLOOKINTRADE, self, partner, item, distance, description)
    end
    self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end

function Player:onLookInShop(itemType, count, description)
    local description = "You see " .. description
    if hasEventCallback(EVENT_CALLBACK_ONLOOKINSHOP) then
        description = EventCallback(EVENT_CALLBACK_ONLOOKINSHOP, self, itemType, count, description)
    end
    self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end

function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if hasEventCallback(EVENT_CALLBACK_ONMOVEITEM) then
        return EventCallback(EVENT_CALLBACK_ONMOVEITEM, self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    end
    return true
end

function Player:onItemMoved(item, count, fromPosition, toPosition, fromCylinder, toCylinder)

    if EventCallback.onItemMoved then
        EventCallback.onItemMoved(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)

    end
end

function Player:onMoveCreature(creature, fromPosition, toPosition)
    if hasEventCallback(EVENT_CALLBACK_ONMOVECREATURE) then
        return EventCallback(EVENT_CALLBACK_ONMOVECREATURE, self, creature, fromPosition, toPosition)
    end
    return true
end

function Player:onReportRuleViolation(targetName, reportType, reportReason, comment, translation)
    if hasEventCallback(EVENT_CALLBACK_ONREPORTRULEVIOLATION) then
        EventCallback(EVENT_CALLBACK_ONREPORTRULEVIOLATION, self, targetName, reportType, reportReason, comment, translation)
    end
end

function Player:onReportBug(message, position, category)
    if hasEventCallback(EVENT_CALLBACK_ONREPORTBUG) then
        return EventCallback(EVENT_CALLBACK_ONREPORTBUG, self, message, position, category)
    end
    return true
end

--function Player:onTurn(direction) codigo original en caso de error
    --if hasEventCallback(EVENT_CALLBACK_ONTURN) then
        --return EventCallback(EVENT_CALLBACK_ONTURN, self, direction)
    --end
    --return true
--end

function Player:onTurn(direction)
    if self:getDirection() == direction and self:getGroup():getAccess() then
        local nextPosition = self:getPosition()
        nextPosition:getNextPosition(direction)

        self:teleportTo(nextPosition, true)
    end
    return true
end

function Player:onTradeRequest(target, item)
    if hasEventCallback(EVENT_CALLBACK_ONTRADEREQUEST) then
        return EventCallback(EVENT_CALLBACK_ONTRADEREQUEST, self, target, item)
    end
    return true
end

function Player:onTradeAccept(target, item, targetItem)
    if hasEventCallback(EVENT_CALLBACK_ONTRADEACCEPT) then
        return EventCallback(EVENT_CALLBACK_ONTRADEACCEPT, self, target, item, targetItem)
    end
    return true
end

function Player:onTradeCompleted(target, item, targetItem, isSuccess)
    if hasEventCallback(EVENT_CALLBACK_ONTRADECOMPLETED) then
        EventCallback(EVENT_CALLBACK_ONTRADECOMPLETED, self, target, item, targetItem, isSuccess)
    end
end

local soulCondition = Condition(CONDITION_SOUL, CONDITIONID_DEFAULT)
soulCondition:setTicks(4 * 60 * 1000)
soulCondition:setParameter(CONDITION_PARAM_SOULGAIN, 1)

local function useStamina(player)
    local staminaMinutes = player:getStamina()
    if staminaMinutes == 0 then
        return
    end

    local playerId = player:getId()
    if not nextUseStaminaTime[playerId] then
        nextUseStaminaTime[playerId] = 0
    end

    local currentTime = os.time()
    local timePassed = currentTime - nextUseStaminaTime[playerId]
    if timePassed <= 0 then
        return
    end

    if timePassed > 60 then
        if staminaMinutes > 2 then
            staminaMinutes = staminaMinutes - 2
        else
            staminaMinutes = 0
        end
        nextUseStaminaTime[playerId] = currentTime + 120
    else
        staminaMinutes = staminaMinutes - 1
        nextUseStaminaTime[playerId] = currentTime + 60
    end
    player:setStamina(staminaMinutes)
end

function Player:onGainExperience(source, exp, rawExp)
    if not source or source:isPlayer() then
        return exp
    end

    -- Soul regeneration
    local vocation = self:getVocation()
    if self:getSoul() < vocation:getMaxSoul() and exp >= self:getLevel() then
        soulCondition:setParameter(CONDITION_PARAM_SOULTICKS, vocation:getSoulGainTicks() * 1000)
        self:addCondition(soulCondition)
    end

    -- Apply experience stage multiplier
    exp = exp * Game.getExperienceStage(self:getLevel())

    -- Stamina modifier
    if configManager.getBoolean(configKeys.STAMINA_SYSTEM) then
        useStamina(self)

        local staminaMinutes = self:getStamina()
        if staminaMinutes > 2400 and self:isPremium() then
            exp = exp * 1.5
        elseif staminaMinutes <= 840 then
            exp = exp * 0.5
        end
    end

    return hasEventCallback(EVENT_CALLBACK_ONGAINEXPERIENCE) and EventCallback(EVENT_CALLBACK_ONGAINEXPERIENCE, self, source, exp, rawExp) or exp
end

function Player:onLoseExperience(exp)
    return hasEventCallback(EVENT_CALLBACK_ONLOSEEXPERIENCE) and EventCallback(EVENT_CALLBACK_ONLOSEEXPERIENCE, self, exp) or exp
end

function Player:onGainSkillTries(skill, tries)
    if APPLY_SKILL_MULTIPLIER == false then
        return hasEventCallback(EVENT_CALLBACK_ONGAINSKILLTRIES) and EventCallback(EVENT_CALLBACK_ONGAINSKILLTRIES, self, skill, tries) or tries
    end

    if skill == SKILL_MAGLEVEL then
        tries = tries * configManager.getNumber(configKeys.RATE_MAGIC)
        return hasEventCallback(EVENT_CALLBACK_ONGAINSKILLTRIES) and EventCallback(EVENT_CALLBACK_ONGAINSKILLTRIES, self, skill, tries) or tries
    end
    tries = tries * configManager.getNumber(configKeys.RATE_SKILL)
    return hasEventCallback(EVENT_CALLBACK_ONGAINSKILLTRIES) and EventCallback(EVENT_CALLBACK_ONGAINSKILLTRIES, self, skill, tries) or tries
end

function Player:onWrapItem(item)
    local topCylinder = item:getTopParent()
    if not topCylinder then
        return
    end

    local tile = Tile(topCylinder:getPosition())
    if not tile then
        return
    end

    local house = tile:getHouse()
    if not house then
        self:sendCancelMessage("You can only wrap and unwrap this item inside a house.")
        return
    end

    if house ~= self:getHouse() and not string.find(house:getAccessList(SUBOWNER_LIST):lower(), "%f[%a]" .. self:getName():lower() .. "%f[%A]") then
        self:sendCancelMessage("You cannot wrap or unwrap items from a house, which you are only guest to.")
        return
    end

    local wrapId = item:getAttribute("wrapid")
    if wrapId == 0 then
        return
    end

    if not hasEventCallback(EVENT_CALLBACK_ONWRAPITEM) or EventCallback(EVENT_CALLBACK_ONWRAPITEM, self, item) then
        local oldId = item:getId()
        item:remove(1)
        local item = tile:addItem(wrapId)
        if item then
            item:setAttribute("wrapid", oldId)
        end
    end
end

function Player:onInventoryUpdate(item, slot, equip)
    if hasEventCallback(EVENT_CALLBACK_ONINVENTORYUPDATE) then
        EventCallback(EVENT_CALLBACK_ONINVENTORYUPDATE, self, item, slot, equip)
    end
end

the code giving problems in console
Code:
function Player:onLookInShop(itemType, count, description)
    local description = "You see " .. description
    if hasEventCallback(EVENT_CALLBACK_ONLOOKINSHOP) then
        description = EventCallback(EVENT_CALLBACK_ONLOOKINSHOP, self, itemType, count, description)
    end
    self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end
 
TRY.
Lua:
function Player:onLookInShop(itemType, count, description)
    if hasEventCallback(EVENT_CALLBACK_ONLOOKINSHOP) then
        description = EventCallback(EVENT_CALLBACK_ONLOOKINSHOP, self, itemType, count, description)
    end
    self:sendTextMessage(MESSAGE_INFO_DESCR, "You see " .. description)
end
 
Last edited:
Back
Top