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

Lua Second Promotion

DimitriKovarsk

New Member
Joined
Jun 19, 2016
Messages
26
Reaction score
0
Hello everyone. I have created a second promotion on a global otserver. The problem is, neither Queen Eloise, nor any vocation promoter NPC recognizes my new promotions. When I ask for the second promotion, they say that I'm already promoted.

I have already created them in vocations.xml and I tried to add these lines in Queen Eloise lua so she could recognize the second promotion, but it failed:

Lua:
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})
Lua:
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})
local node2 = keywordHandler:addKeyword({'second class'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for 100000 gold coins. Do you want me to promote you?'})
    node2:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 100000, level = 50, text = 'Congratulations! You are now promoted.'})
    node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})

Thanks in advance.
 
Solution
change it to this
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 not player:isPremium(cid) or player:isPremium(cid) then
        local promotion = player:getVocation():getPromotion()
        local promoLevel = parameters.promotion
        if player:getStorageValue(STORAGEVALUE_PROMOTION) >= promoLevel then
            npcHandler:say("You are already promoted!", cid)
        elseif player:getLevel() < parameters.level then...
could you search for StdModule.promotePlayer in your npc lib and post it here?

@Static_ check if it is this file

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 not player:isPremium(cid) or player:isPremium(cid) 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:removeMoneyNpc(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
 
change it to this
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 not player:isPremium(cid) or player:isPremium(cid) then
        local promotion = player:getVocation():getPromotion()
        local promoLevel = parameters.promotion
        if player:getStorageValue(STORAGEVALUE_PROMOTION) >= promoLevel 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:removeMoneyNpc(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, promoLevel)
        end
    else
        npcHandler:say("You need a premium account in order to get promoted.", cid)
    end
    npcHandler:resetNpc(cid)
    return true
end

Lua:
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, promotion = 1, 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})
local node2 = keywordHandler:addKeyword({'second class'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for 100000 gold coins. Do you want me to promote you?'})
    node2:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 100000, level = 50, promotion = 2, text = 'Congratulations! You are now promoted.'})
    node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})
 
Solution
Back
Top