TFS 1.X+ Promotion only for Premium Acc

Discussion in 'Support' started by Raschu, Oct 13, 2018.

  1. Raschu

    Raschu Member

    Joined:
    Aug 2, 2011
    Messages:
    45
    Likes Received:
    1
    Best Answers:
    0
    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:

    Code (Lua):
    1. -- 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?"})
    2.         -- node1:addChildKeyword({"yes"}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 20}, text = "Congratulations! You are now promoted.")
    3.         -- node1:addChildKeyword({"no"}, StdModule.say, {npcHandler = npcHandler, text = "Allright then. Come back when you are ready."}, reset = true)
    4.     function StdModule.promotePlayer(cid, message, keywords, parameters, node)
    5.         local npcHandler = parameters.npcHandler
    6.         if npcHandler == nil then
    7.             error("StdModule.promotePlayer called without any npcHandler instance.")
    8.         end
    9.  
    10.         if not npcHandler:isFocused(cid) then
    11.             return false
    12.         end
    13.  
    14.         local player = Player(cid)
    15.         if not player:isPremium(cid) or player:isPremium(cid) then
    16.             local promotion = player:getVocation():getPromotion()
    17.             if player:getStorageValue(STORAGEVALUE_PROMOTION) == 1 then
    18.                 npcHandler:say("You are already promoted!", cid)
    19.             elseif player:getLevel() < parameters.level then
    20.                 npcHandler:say("I am sorry, but I can only promote you once you have reached level " .. parameters.level .. ".", cid)
    21.             elseif not player:removeMoney(parameters.cost) then
    22.                 npcHandler:say("You do not have enough money!", cid)
    23.             else
    24.                 npcHandler:say(parameters.text, cid)
    25.                 player:setVocation(promotion)
    26.                 player:setStorageValue(STORAGEVALUE_PROMOTION, 1)
    27.             end
    28.         else
    29.             npcHandler:say("You need a premium account in order to get promoted.", cid)
    30.         end
    31.         npcHandler:resetNpc(cid)
    32.         return true
    33.     end
    34.  
     
  2. ochmar

    ochmar Member

    Joined:
    Feb 27, 2016
    Messages:
    85
    Likes Received:
    31
    Best Answers:
    1
    Simple delete
    "not player:isPremium(cid) or" from 15th line
     
  3. Raschu

    Raschu Member

    Joined:
    Aug 2, 2011
    Messages:
    45
    Likes Received:
    1
    Best Answers:
    0
    I leave like that :
    Code (Text):
    1. if player:isPremium(cid) then
    and that promote players anyway
     
  4. flaviiojr

    flaviiojr Active Member

    Joined:
    Jan 20, 2017
    Messages:
    224
    Likes Received:
    31
    Best Answers:
    13
    Code (Lua):
    1. function StdModule.promotePlayer(cid, message, keywords, parameters, node)
    2.     local npcHandler = parameters.npcHandler
    3.     if npcHandler == nil then
    4.         error("StdModule.promotePlayer called without any npcHandler instance.")
    5.     end
    6.  
    7.     if not npcHandler:isFocused(cid) then
    8.         return false
    9.     end
    10.  
    11.     local player = Player(cid)
    12.     if player:isPremium() then
    13.         local promotion = player:getVocation():getPromotion()
    14.         if player:getStorageValue(STORAGEVALUE_PROMOTION) == 1 then
    15.             npcHandler:say("You are already promoted!", cid)
    16.         elseif player:getLevel() < parameters.level then
    17.             npcHandler:say("I am sorry, but I can only promote you once you have reached level " .. parameters.level .. ".", cid)
    18.         elseif not player:removeMoney(parameters.cost) then
    19.             npcHandler:say("You do not have enough money!", cid)
    20.         else
    21.             npcHandler:say(parameters.text, cid)
    22.             player:setVocation(promotion)
    23.             player:setStorageValue(STORAGEVALUE_PROMOTION, 1)
    24.         end
    25.     else
    26.         npcHandler:say("You need a premium account in order to get promoted.", cid)
    27.     end
    28.    
    29.     npcHandler:resetNpc(cid)
    30.     return true
    31. end
     

Share This Page

Loading...