• 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 promotion problem

carre

Advanced OT User
Joined
Apr 23, 2013
Messages
881
Solutions
1
Reaction score
158
Location
Sweden
when i make my char to get promotion and i say promotion npc say
King Tibianus: Do you want to be promoted in your vocation for 20000 gold?
Baxter: yes
King Tibianus: You need a premium account in order to get promoted
please help me repp++
 
@carre
Paste code in [ CODE ] tags!

Example:
[code]
code here...
[/c
ode]

Will create this:
Code:
code here...

Using code tags will make sure your post is not too long since the code will be wrapped up, and etc smily icons are disabled inside code tags, so you do not obscure the script.
 
i did add Add premium = false, still say King Tibianus: You need a premium account in order to get promoted please help me ):
 
Last edited:
here



local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() end

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, premium = true, 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})

npcHandler:addModule(FocusModule:new())
 
Did you save the script, reloaded npcs or restart and are you sure you changed the right script?

Change
Code:
premium = true
to
Code:
premium = false

Use code tags.
[ code] your script [/code]
 
@Limos
I am using latest TFS 1.0 vers.
I added premium = false to my promotion.lua but I still need premium.

promotion.lua
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({'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, premium = false, 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})

npcHandler:addModule(FocusModule:new())
part of modules.lua
Code:
    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 parameters.premium and player:isPremium() then
            if player:getStorageValue(Storage.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
                player:setVocation(Vocation(player:getVocation():getPromotionId()))
                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
What's wrong?
 
@Limos
Console error:
Code:
Lua Script Error: [Npc interface]
data/npc/scripts/promotion.lua:onCreatureSay
data/npc/lib/npcsystem/modules.lua:86: attempt to index global 'Storage' (a nil
value)
stack traceback:
        [C]: in function '__index'
        data/npc/lib/npcsystem/modules.lua:86: in function 'callback'
        data/npc/lib/npcsystem/keywordhandler.lua:26: in function 'processMessag
e'
        data/npc/lib/npcsystem/keywordhandler.lua:135: in function 'processNodeM
essage'
        data/npc/lib/npcsystem/keywordhandler.lua:103: in function 'processMessa
ge'
        data/npc/lib/npcsystem/npchandler.lua:407: in function 'onCreatureSay'
        data/npc/scripts/promotion.lua:7: in function <data/npc/scripts/promotio
n.lua:7>
 
Only change the line I posted, don't add or remove anything else, you can undo the changes and try again or post your modules.
 
I changed only this one line. Take a look.
Code:
    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 parameters.premium == false or player:isPremium() then
            if player:getStorageValue(Storage.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
                player:setVocation(Vocation(player:getVocation():getPromotionId()))
                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

@Limos btw my modules.lua
http://pastebin.com/AR613Nk9
 
Code:
if player:getStorageValue(30018) == 1 then
And add this under npcHandler:say(parameters.text, cid)
Code:
player:setStorageValue(30018, 1)
 
Should it look like this?

Code:
    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 parameters.premium == false or player:isPremium() then
            if player:getStorageValue(30018) == 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
                player:setVocation(Vocation(player:getVocation():getPromotionId()))
                npcHandler:say(parameters.text, cid)
                player:setStorageValue(30018, 1)
            end
        else
            npcHandler:say("You need a premium account in order to get promoted.", cid)
        end
        npcHandler:resetNpc(cid)
        return true
    end
@Limos I got error :/
Code:
Lua Script Error: [Npc interface]
data/npc/scripts/promotion.lua:onCreatureSay
data/npc/lib/npcsystem/modules.lua:93: attempt to call method 'getPromotionId' (
a nil value)
stack traceback:
        [C]: in function 'getPromotionId'
        data/npc/lib/npcsystem/modules.lua:93: in function 'callback'
        data/npc/lib/npcsystem/keywordhandler.lua:26: in function 'processMessag
e'
        data/npc/lib/npcsystem/keywordhandler.lua:135: in function 'processNodeM
essage'
        data/npc/lib/npcsystem/keywordhandler.lua:103: in function 'processMessa
ge'
        data/npc/lib/npcsystem/npchandler.lua:407: in function 'onCreatureSay'
        data/npc/scripts/promotion.lua:7: in function <data/npc/scripts/promotio
n.lua:7>
 
Last edited:
Back
Top