• 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 only for Premium Acc

Raschu

New Member
Joined
Aug 2, 2011
Messages
69
Reaction score
1
Hi guys
On this minute on my server everyone can buy promotion but iwant to promoted only premium players. please see my modules.lua maby you can see what is wrong:

Lua:
-- local node1 = keywordHandler:addKeyword({"promot"}, StdModule.say, {npcHandler = npcHandler, 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, text = "Allright then. Come back when you are ready."}, reset = true)
    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: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
 
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() 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
 
Back
Top