• 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.1 Look/Exp Broken

jperez42

New Member
Joined
Jul 29, 2013
Messages
18
Reaction score
2
Hello,

I'm using TFS 1.1 with the 10.76 client, and it seems to be pretty buggy (I guess that's to be expected). My main problem right now is that I can't 'look' at anything. No green text shows up upon looking at something, and nothing shows in the server log in the client, or the server log on the server side.

However, the green text will show when I kill a creature and see loot.

Is there any place I should begin to look at when I have no error codes to go off of?

Secondly, I'm having an issue where I can't adjust the exp rates. Whether I adjust them in config.lua and disable exp stages, or vice versa, exp rates remain normal. Am I missing something?

Thanks guys.
 
Hmm, looking not working??

data/events/events.xml:
Code:
<event class="Player" method="onLook" enabled="1" />

Code:
function Player:onBrowseField(position)
return true
end

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
self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end

function Player:onLookInBattleList(creature, distance)
local description = "You see " .. creature:getDescription(distance)
if self:getGroup():getAccess() then
local str = "%s\nHealth: %d / %d"
if 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

function Player:onMoveItem(item, count, fromPosition, toPosition)
return true
end

function Player:onMoveCreature(creature, fromPosition, toPosition)
return true
end

function Player:onTurn(direction)
return true
end

function Player:onTradeRequest(target, item)
return true
end

function Player:onTradeAccept(target, item, targetItem)
return true
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()
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 exp
end

function Player:onLoseExperience(exp)
return exp
end

function Player:onGainSkillTries(skill, tries)
if APPLY_SKILL_MULTIPLIER == false then
return tries
end

if skill == SKILL_MAGLEVEL then
return tries * configManager.getNumber(configKeys.RATE_MAGIC)
end
return tries * configManager.getNumber(configKeys.RATE_SKILL)
end
 
Hmm, looking not working??

data/events/events.xml:
Code:
<event class="Player" method="onLook" enabled="1" />

Code:
function Player:onBrowseField(position)
return true
end

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
self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end

function Player:onLookInBattleList(creature, distance)
local description = "You see " .. creature:getDescription(distance)
if self:getGroup():getAccess() then
local str = "%s\nHealth: %d / %d"
if 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

function Player:onMoveItem(item, count, fromPosition, toPosition)
return true
end

function Player:onMoveCreature(creature, fromPosition, toPosition)
return true
end

function Player:onTurn(direction)
return true
end

function Player:onTradeRequest(target, item)
return true
end

function Player:onTradeAccept(target, item, targetItem)
return true
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()
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 exp
end

function Player:onLoseExperience(exp)
return exp
end

function Player:onGainSkillTries(skill, tries)
if APPLY_SKILL_MULTIPLIER == false then
return tries
end

if skill == SKILL_MAGLEVEL then
return tries * configManager.getNumber(configKeys.RATE_MAGIC)
end
return tries * configManager.getNumber(configKeys.RATE_SKILL)
end

@Techrlz z Replacing my player.lua with this one seems to have fixed the looking issue. Thank you!

I'm still having issues with experience rates not being able to be adjusted. Does anyone know what would cause this?
 
Last edited:
data/XML/stages.xml.

Change this:
Code:
<config enabled="0"/>

to this:
Code:
<config enabled="1"/>

To make EXP Stages.
 
That didn't do it. I have tried that before posting, but no such luck. Please see below:

My stages.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<stages>
    <config enabled="1"/>
        <stage minlevel="1" maxlevel="7" multiplier="50"/>
        <stage minlevel="8" maxlevel="29" multiplier="150"/>
        <stage minlevel="30" maxlevel="49" multiplier="100"/>
        <stage minlevel="50" maxlevel="79" multiplier="80"/>
        <stage minlevel="80" maxlevel="119" multiplier="60"/>
        <stage minlevel="120" maxlevel="139" multiplier="40"/>
        <stage minlevel="140" maxlevel="159" multiplier="30"/>
        <stage minlevel="160" maxlevel="179" multiplier="20"/>
        <stage minlevel="180" maxlevel="219" multiplier="10"/>
        <stage minlevel="220" maxlevel="279" multiplier="8"/>
        <stage minlevel="280" maxlevel="319" multiplier="6"/>
        <stage minlevel="320" maxlevel="349" multiplier="4"/>
        <stage minlevel="350" multiplier="2"/>
</stages>

My config.lua (Password, username, database name, and IP removed for security)
Code:
worldType = "pvp"
hotkeyAimbotEnabled = "yes"
protectionLevel = 8
killsToRedSkull = 5
killsToBlackSkull = 8
pzLocked = 60000
removeAmmoWhenUsingDistanceWeapon = "yes"
removeChargesFromRunes = "yes"
timeToDecreaseFrags = 8 * 60 * 60 * 1000
whiteSkullTime = 15 * 60 * 1000
stairJumpExhaustion = 2000
experienceByKillingPlayers = "no"


ip = "xxxx"
bindOnlyGlobalAddress = "no"
loginProtocolPort = 7171
gameProtocolPort = 7172
statusProtocolPort = 7171
maxPlayers = "1000"
motd = "Welcome to JP Tibia"
onePlayerOnlinePerAccount = "yes"
allowClones = "no"
serverName = "JP Tibia"
statusTimeout = 60000
replaceKickOnLogin = "yes"
maxPacketsPerSecond = 300
pushCreatureDelay = 1 * 1000  


deathLosePercent = -1


housePriceEachSQM = 1000
houseRentPeriod = "never"


timeBetweenActions = 200
timeBetweenExActions = 1000


mapName = "realmap"
mapAuthor = "Thornia"


marketOfferDuration = 30 * 24 * 60 * 60
premiumToCreateMarketOffer = "yes"
checkExpiredMarketOffersEachMinutes = 60
maxMarketOffersAtATimePerPlayer = 100

mysqlHost = "localhost"
mysqlUser = "xxxx"
mysqlPass = "xxxx"
mysqlDatabase = "xxxx"
mysqlPort = 3306
mysqlSock = ""
passwordType = "sha1"

allowChangeOutfit = "yes"
freePremium = "yes"
kickIdlePlayerAfterMinutes = 200
maxMessageBuffer = 4
noDamageToSameLookfeet = "no"
emoteSpells = "no"


rateExp = 50
rateSkill = 200
rateLoot = 10
rateMagic = 7
rateSpawn = 1
experienceStages = "yes"

deSpawnRange = 2
deSpawnRadius = 50


staminaSystem = "yes"


defaultPriority = "high"
startupDatabaseOptimization = "no"

ownerName = ""
ownerEmail = ""
url = "http://otland.net/"
location = "Canada"
 
I did some further tweaking but nothing has come of it. I have tried editing this:
Code:
experienceStages = "yes"

I have tried editing that with any and all variation of yes or no, with or without the quotes. True, False, Yes, No, with or without quotes, but experience remains normal. I have also tried all of these changes with stages.xml config enabled 1 and 0. I guess TFS 1.1 experience is different than previous releases? I'm not really sure where else to check for this. Any ideas?
 
Code:
experienceStages = "yes"
This option doesn't exist in forgottenserver 1.1.

Probably your problem is caused by disabled or undefined method. To solve this issue you have to enable onGainExperience method for Player (it can be done in data\events\events.xml). Also your method cannot be undefined so you have to implement your own function or use default.

Here is this function taken from current version of forgottenserver:
Code:
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 exp
end
 
@oddake The code you posted already exists in my player.lua. I added the following to my events.xml, but no luck:
Code:
<event class="Player" method="onGainExperience" enabled="1"/>

Here is my player.lua - the sections you mentioned
Code:
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

However, there is now an error in the console, posted below:


Exp gain is still the normal amount, as well as skill gain. However, soul points seem to work now. What else can I be missing?
 
Probably your server (mainly scripts) are out-dated. This error is caused by old version of data/creaturescripts/scripts/login.lua but also files like data/global.lua and data/creaturescripts/scripts/logout.lua can be corrupted.

For example, login function should look like this:
Code:
function onLogin(player)
    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)

    -- Stamina
    nextUseStaminaTime[player.uid] = 0
  
    -- Promotion
    local vocation = player:getVocation()
    local promotion = vocation:getPromotion()
    if player:isPremium() then
        local value = player:getStorageValue(STORAGEVALUE_PROMOTION)
        if not promotion and value ~= 1 then
            player:setStorageValue(STORAGEVALUE_PROMOTION, 1)
        elseif value == 1 then
            player:setVocation(promotion)
        end
    elseif not promotion then
        player:setVocation(vocation:getDemotion())
    end

    -- Events
    player:registerEvent("PlayerDeath")
    player:registerEvent("DropLoot")
    return true
end

The best way to solve your problem is just update everything - compile executable file again from newest source code, swap data with the newest. Of course, later you have to move your scripts (some of them will require little update) and map from your old data.
 
Probably your server (mainly scripts) are out-dated. This error is caused by old version of data/creaturescripts/scripts/login.lua but also files like data/global.lua and data/creaturescripts/scripts/logout.lua can be corrupted.

For example, login function should look like this:
Code:
function onLogin(player)
    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)

    -- Stamina
    nextUseStaminaTime[player.uid] = 0
 
    -- Promotion
    local vocation = player:getVocation()
    local promotion = vocation:getPromotion()
    if player:isPremium() then
        local value = player:getStorageValue(STORAGEVALUE_PROMOTION)
        if not promotion and value ~= 1 then
            player:setStorageValue(STORAGEVALUE_PROMOTION, 1)
        elseif value == 1 then
            player:setVocation(promotion)
        end
    elseif not promotion then
        player:setVocation(vocation:getDemotion())
    end

    -- Events
    player:registerEvent("PlayerDeath")
    player:registerEvent("DropLoot")
    return true
end

The best way to solve your problem is just update everything - compile executable file again from newest source code, swap data with the newest. Of course, later you have to move your scripts (some of them will require little update) and map from your old data.
I re-compiled with the newest files, and most all of my issues are gone. Thanks for the advice. This thread can be marked as solved.
 
Back
Top