• 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 enabled for free accounts

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
1,492
Solutions
27
Reaction score
857
Location
Santiago - Chile
GitHub
ralke23
Twitch
ralke23
Hi again! I use tfs 1.4 by nekiro (8.60) and i'm having a little issue. When the players get promoted on my promotion NPC, they vocation changes to the promoted one. But the issue is that if they're free account and re-login, the vocation is switched back to the previous one (a elite knight turns back to knight for example). This make me think the NPC is working but the server is automatically setting up the vocation because the player is free account.

Here's Std.Module.promoteplayer function
Lua:
    function StdModule.promotePlayer(cid, message, keywords, parameters, node)
        local npcHandler = parameters.npcHandler
        if npcHandler == nil then
            error("StdModule.promotePlayer called without any npcHandler instance.")
        end

        if not npcHandler:isFocused(cid) then
            return false
        end

        local player = Player(cid)
        if player:isPremium() or not parameters.premium then
            local promotion = player:getVocation():getPromotion()
            if player:getStorageValue(STORAGEVALUE_PROMOTION) == 1 then
                npcHandler:say("You are already promoted!", cid)
            elseif player:getLevel() < parameters.level then
                npcHandler:say("I am sorry, but I can only promote you once you have reached level " .. parameters.level .. ".", cid)
            elseif not player:removeMoney(parameters.cost) then
                npcHandler:say("You do not have enough money!", cid)
            else
                npcHandler:say(parameters.text, cid)
                player:setVocation(promotion)
                player:setStorageValue(STORAGEVALUE_PROMOTION, 1)
            end
        else
            npcHandler:say("You need a premium account in order to get promoted.", cid)
        end
        npcHandler:resetNpc(cid)
        return true
    end

Tried to switch if player:isPremium() or not parameters.premium then to if not player:isPremium(cid) or player:isPremium(cid) then but that haven't worked.

Here's the NPC:
Lua:
local marks = {
    [1]={{x=1019,y=975,z=7},"Father Zuke",MAPMARK_TEMPLE},
    [2]={{x=1025,y=981,z=7},"Jassu",MAPMARK_STAR},
    [3]={{x=0979,y=0962,z=5},"Rin",MAPMARK_STAR},
    [4]={{x=989,y=964,z=5},"O'aka",MAPMARK_STAR},
    [5]={{x=989,y=971,z=5},"Keyakku",MAPMARK_STAR},
    [6]={{x=989,y=979,z=5},"Jassu",MAPMARK_STAR},
    [7]={{x=976,y=978,z=5},"Clasko",MAPMARK_STAR},
    [8]={{x=976,y=970,z=5},"Lucil",MAPMARK_STAR},
    [9]={{x=977,y=962,z=4},"Tromell",MAPMARK_STAR},
    [10]={{x=988,y=963,z=4},"Seymour",MAPMARK_STAR},
    [11]={{x=975,y=978,z=4},"Henricus",MAPMARK_QUESTION},
    [12]={{x=1022,y=977,z=8},"Amanda",MAPMARK_STAR},
    [13]={{x=986,y=1003,z=7},"Tim, The Guard",MAPMARK_QUESTION},
    [14]={{x=1048,y=999,z=7},"Walter, The Guard",MAPMARK_QUESTION},
    [15]={{x=1061,y=950,z=5},"Kulag, The Guard",MAPMARK_QUESTION},
    [16]={{x=1025,y=928,z=7},"Grof, The Guard",MAPMARK_QUESTION},
    [17]={{x=961,y=950,z=6},"Miles, The Guard",MAPMARK_QUESTION},
    [18]={{x=982,y=995,z=5},"Zaon",MAPMARK_STAR},
    [19]={{x=991,y=982,z=7},"Padreia",MAPMARK_QUESTION},
    [20]={{x=1168,y=1015,z=7},"Maroda",MAPMARK_QUESTION},
}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

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

function  creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
    return false
end

    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
     local player = Player(cid)
     if msg == "marks" then
      for i = 1, #marks do
      player:addMapMark(marks[i][1],marks[i][3],marks[i][2],marks[i][4],marks[i][5],marks[i][6],marks[i][7],marks[i][8],marks[i][9],marks[i][10],marks[i][11],marks[i][12],marks[i][13],marks[i][14],marks[i][15],marks[i][16],marks[i][17],marks[i][18],marks[i][19],marks[i][20])
      end
      selfSay('Your world map has been marked with non-playable characters location.', cid)
      player:getPosition():sendMagicEffect(CONST_ME_STEPSVERTICAL)
      talkState[talkUser] = 0
      elseif msg == "home" then
      player:setTown(Town(1))
      selfSay('From now on you have become a citizen of Kilika.', cid)
      player:getPosition():sendMagicEffect(CONST_ME_YALAHARIGHOST)
      talkState[talkUser] = 0
      elseif msg == "mark" then
      for i = 1, #marks do
      ------------- 
      player:addMapMark(marks[i][1],marks[i][3],marks[i][2],marks[i][4],marks[i][5],marks[i][6],marks[i][7],marks[i][8],marks[i][9],marks[i][10],marks[i][11],marks[i][12],marks[i][13],marks[i][14],marks[i][15],marks[i][16],marks[i][17],marks[i][18],marks[i][19],marks[i][20])
      end
      selfSay('Your world map has been marked with non-playable characters location.', cid)
      player:getPosition():sendMagicEffect(CONST_ME_STEPSVERTICAL)
      talkState[talkUser] = 0
      elseif msg == "hometown" then
      player:setTown(Town(1))
      selfSay('From now on you have become a citizen of Kilika.', cid)
      player:getPosition():sendMagicEffect(CONST_ME_YALAHARIGHOST)
      talkState[talkUser] = 0
     else
    selfSay('I can only {mark} your world map, change your {hometown} or give you a {promotion}.', cid)
    talkState[talkUser] = 0
   end
   return true
end

local node1 = keywordHandler:addKeyword({'promot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for 20000 gold coins. Do you want me to promote you?'})
    node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, 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:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

I'm 99% sure that this must be related to the server sources. If someone can tell me which lines to edit i'll be gratefull!! Thanks in advance. Regards!
 
Back
Top