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

Solved Npc Selling First & Second Promotion - problem

xardas33

New Member
Joined
Jan 28, 2010
Messages
83
Reaction score
0
Hello guys, I have problem with my script. Npc should sell two promotions:
No voc -> Rookstayer
Rookstayer -> Legendary Rookstayer

Script working but not as it should... Look first at script:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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

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

npcHandler:addModule(FocusModule:new())

So the problem is:
When i first time say "Promote" it's normally promoting me to rookstayer for 10,000 gp, when I second time say "Promote" it's promoting me to legendary rookstayer for 10,000 gp.
When i first time say "Legend" it's promoting me to rookstayer for 100,000 gp, when I second time say "Legend" it's promoting me normally to legendary rookstayer for 100,000 gp.

Main problem is why buying first promotion doesn't blocking promoting for 10,000 gp? Or i can be promoted both with pay 10,000 gp or 100,000 gp?
 
Code:
--Usage:
     -- 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

     if(isPlayerPremiumCallback == nil or isPlayerPremiumCallback(cid) == true or parameters.premium == false) then
       local promotedVoc = getPromotedVocation(getPlayerVocation(cid))
       if(getPlayerStorageValue(cid, 30018) == 1) then
         npcHandler:say("You are already promoted!", cid)
       elseif(getPlayerLevel(cid) < parameters.level) then
         npcHandler:say("I am sorry, but I can only promote you once you have reached level " .. parameters.level .. ".", cid)
       elseif(doPlayerRemoveMoney(cid, parameters.cost) ~= TRUE) then
         npcHandler:say("You do not have enough money!", cid)
       else
         doPlayerSetVocation(cid, promotedVoc)
         npcHandler:say(parameters.text, cid)
       end
     else
       npcHandler:say("You need a premium account in order to get promoted.", cid)
     end
     npcHandler:resetNpc(cid)
     return true
   end

I'm using TFS 1.0 under 10.41.
 
Code:
    if isPlayerPremiumCallback == nil or isPlayerPremiumCallback(cid) == true or parameters.premium == false then
         local promotedVoc = getPromotedVocation(getPlayerVocation(cid))
         if getPlayerStorageValue(cid, 30018) == (parameters.promotion -1) or getPlayerStorageValue(cid, 30018) >= 1 then
             npcHandler:say("You are already promoted!", cid)
         elseif getPlayerStorageValue(cid, 30018) == -1 and parameters.promotion == 2 then
             npcHandler:say("You need the first promotion first!", cid)
         elseif getPlayerLevel(cid) < parameters.level then
             npcHandler:say("I am sorry, but I can only promote you once you have reached level " .. parameters.level .. ".", cid)
         elseif doPlayerRemoveMoney(cid, parameters.cost) ~= TRUE then
             npcHandler:say("You do not have enough money!", cid)
         else
             doPlayerSetVocation(cid, promotedVoc)
             npcHandler:say(parameters.text, cid)
             setPlayerStorageValue(cid, 30018, getPlayerStorageValue(cid, 30018) + 1)
         end
     else
         npcHandler:say("You need a premium account in order to get promoted.", cid)
     end
 
Back
Top