• 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+ Promotion lost upon death (You're already promoted)

Joriku

Working in the mines, need something?
Joined
Jul 16, 2016
Messages
1,084
Solutions
15
Reaction score
379
Location
Sweden
YouTube
Joriku
Hi,
I am using "The forgotten king" which defaults comes with the TFS 1.3 package.
Once I died on my character, I lost the promotion and I am unable to regain it with the npc.
Why is this caused?

The forgotten king.lua - promotion.lua <- Original name
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid)         end
function onCreatureSay(cid, type, msg)      npcHandler:onCreatureSay(cid, type, msg)    end
function onThink()                          npcHandler:onThink()                        end

local node1 = keywordHandler:addKeyword({'promot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for 200000 gold coins. Do you want me to promote you?'})
    node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 200000, level = 20, text = 'Congratulations! You are now promoted.'})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})

npcHandler:addModule(FocusModule:new())

Edit: Now when I check, using MyAcc. I have no "Promotion" table, Ideas?
 
Solution
If you are unsure of what file may be causing you trouble, and you have suspicious files, I would suggest to replace those file with ones that are working 100% and have not been modified, that way you will know which file is causing you problems!

Just rename the files to something else and paste in fully working ones and test :)
I found the issue, the account was a non-premium account which was updated not too long ago to auto-demote a non-prem account

For anyone with the same issue, remove those lines in login.php to keep your vocation as a non-prem acc if you have free premium off in config.lua
Lua:
    -- Promotion
    local...
Hi,
I am using "The forgotten king" which defaults comes with the TFS 1.3 package.
Once I died on my character, I lost the promotion and I am unable to regain it with the npc.
Why is this caused?

The forgotten king.lua - promotion.lua <- Original name
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid)         end
function onCreatureSay(cid, type, msg)      npcHandler:onCreatureSay(cid, type, msg)    end
function onThink()                          npcHandler:onThink()                        end

local node1 = keywordHandler:addKeyword({'promot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for 200000 gold coins. Do you want me to promote you?'})
    node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 200000, level = 20, text = 'Congratulations! You are now promoted.'})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})

npcHandler:addModule(FocusModule:new())
I had a similar issue once, do you have scripts interrupting any type of vocation change on login maybe?
 
I had a similar issue once, do you have scripts interrupting any type of vocation change on login maybe?
Not what I know about, havn't imported anything that changes the vocations.
What I did find tho is that my MyAcc table doesn't have an "promotion" table in the "Players" database. Can that be why?
+ I do have an FragReward system which is based upon login I think
 
Might be a different problem than what I had, but it is frustrating to deal with those kinds of problems.

I think you could at least check if it has something to do when login by manually changing the vocation in the database to something else, at login it should change to something different than what you wanted, if you have a script that would cause a problem that is.

But if you are able to manually change the vocation and it works no problem then you at least know it might not be related to having a script with onlogin changes :)
 
Might be a different problem than what I had, but it is frustrating to deal with those kinds of problems.

I think you could at least check if it has something to do when login by manually changing the vocation in the database to something else, at login it should change to something different than what you wanted, if you have a script that would cause a problem that is.

But if you are able to manually change the vocation and it works no problem then you at least know it might not be related to having a script with onlogin changes :)
Alright, probebly an onLogin then.
Changed vocation from 3 to 7. Logged in and it's a paladin but database says 7 even on reload.
Upon death vocation in database goes back to 3
Will check onLogin functions that I got, weirdly I don't have anything that edits that..
Removed a few revscripts but none of them changed it. Checking more

Just now when I think of it, upon death you don't lose anything at all. Exept skills that'll be, even if I didn't edit that.
playerdeath.lua
Lua:
local deathListEnabled = true
local maxDeathRecords = 5

function onDeath(player, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    local playerId = player:getId()
    if nextUseStaminaTime[playerId] then
        nextUseStaminaTime[playerId] = nil
    end

    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You are dead.")
    if not deathListEnabled then
        return
    end

    local byPlayer = 0
    local killerName
    if killer then
        if killer:isPlayer() then
            byPlayer = 1
        else
            local master = killer:getMaster()
            if master and master ~= killer and master:isPlayer() then
                killer = master
                byPlayer = 1
            end
        end
        killerName = killer:getName()
    else
        killerName = "field item"
    end

    local byPlayerMostDamage = 0
    local mostDamageKillerName
    if mostDamageKiller then
        if mostDamageKiller:isPlayer() then
            byPlayerMostDamage = 1
        else
            local master = mostDamageKiller:getMaster()
            if master and master ~= mostDamageKiller and master:isPlayer() then
                mostDamageKiller = master
                byPlayerMostDamage = 1
            end
        end
        mostDamageName = mostDamageKiller:getName()
    else
        mostDamageName = "field item"
    end

    local playerGuid = player:getGuid()
    db.query("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `is_player`, `mostdamage_by`, `mostdamage_is_player`, `unjustified`, `mostdamage_unjustified`) VALUES (" .. playerGuid .. ", " .. os.time() .. ", " .. player:getLevel() .. ", " .. db.escapeString(killerName) .. ", " .. byPlayer .. ", " .. db.escapeString(mostDamageName) .. ", " .. byPlayerMostDamage .. ", " .. (lastHitUnjustified and 1 or 0) .. ", " .. (mostDamageUnjustified and 1 or 0) .. ")")
    local resultId = db.storeQuery("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. playerGuid)

    local deathRecords = 0
    local tmpResultId = resultId
    while tmpResultId ~= false do
        tmpResultId = result.next(resultId)
        deathRecords = deathRecords + 1
    end

    if resultId ~= false then
        result.free(resultId)
    end

    local limit = deathRecords - maxDeathRecords
    if limit > 0 then
        db.asyncQuery("DELETE FROM `player_deaths` WHERE `player_id` = " .. playerGuid .. " ORDER BY `time` LIMIT " .. limit)
    end

    if byPlayer == 1 then
        local targetGuild = player:getGuild()
        targetGuild = targetGuild and targetGuild:getId() or 0
        if targetGuild ~= 0 then
            local killerGuild = killer:getGuild()
            killerGuild = killerGuild and killerGuild:getId() or 0
            if killerGuild ~= 0 and targetGuild ~= killerGuild and isInWar(playerId, killer:getId()) then
                local warId = false
                resultId = db.storeQuery("SELECT `id` FROM `guild_wars` WHERE `status` = 1 AND ((`guild1` = " .. killerGuild .. " AND `guild2` = " .. targetGuild .. ") OR (`guild1` = " .. targetGuild .. " AND `guild2` = " .. killerGuild .. "))")
                if resultId ~= false then
                    warId = result.getNumber(resultId, "id")
                    result.free(resultId)
                end

                if warId ~= false then
                    db.asyncQuery("INSERT INTO `guildwar_kills` (`killer`, `target`, `killerguild`, `targetguild`, `time`, `warid`) VALUES (" .. db.escapeString(killerName) .. ", " .. db.escapeString(player:getName()) .. ", " .. killerGuild .. ", " .. targetGuild .. ", " .. os.time() .. ", " .. warId .. ")")
                end
            end
        end
    end
end

droploot.lua
Lua:
function onDeath(player, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    if player:hasFlag(PlayerFlag_NotGenerateLoot) or player:getVocation():getId() == VOCATION_NONE then
        return true
    end

    if not player:getSlotItem(CONST_SLOT_BACKPACK) then
        player:addItem(ITEM_BAG, 1, false, CONST_SLOT_BACKPACK)
    end
    return true
end

None of the promotion vocations works, could it be an damaged file?
 
Last edited:
If you are unsure of what file may be causing you trouble, and you have suspicious files, I would suggest to replace those file with ones that are working 100% and have not been modified, that way you will know which file is causing you problems!

Just rename the files to something else and paste in fully working ones and test :)
 
If you are unsure of what file may be causing you trouble, and you have suspicious files, I would suggest to replace those file with ones that are working 100% and have not been modified, that way you will know which file is causing you problems!

Just rename the files to something else and paste in fully working ones and test :)
I found the issue, the account was a non-premium account which was updated not too long ago to auto-demote a non-prem account

For anyone with the same issue, remove those lines in login.php to keep your vocation as a non-prem acc if you have free premium off in config.lua
Lua:
    -- Promotion
    local vocation = player:getVocation()
    local promotion = vocation:getPromotion()
    if player:isPremium() then
        local value = player:getStorageValue(PlayerStorageKeys.promotion)
        if not promotion and value ~= 1 then
            player:setStorageValue(PlayerStorageKeys.promotion, 1)
        elseif value == 1 then
            player:setVocation(promotion)
        end
 
Last edited:
Solution
Back
Top