TFS 1.X+ Promotion only for Premium Acc

Raschu

Member
Joined
Aug 2, 2011
Messages
70
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
 

Ochman

Premium User
Premium User
Joined
Feb 27, 2016
Messages
207
Reaction score
132
Simple delete
"not player:isPremium(cid) or" from 15th line
 
OP
R

Raschu

Member
Joined
Aug 2, 2011
Messages
70
Reaction score
1
I leave like that :
Code:
if player:isPremium(cid) then
and that promote players anyway
 

flaviiojr

Active Member
Joined
Jan 20, 2017
Messages
230
Reaction score
35
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
 
Top