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

How to change price for promotion in npc?

vexler222

Active Member
Joined
Apr 22, 2012
Messages
714
Solutions
15
Reaction score
46
Hi, i want add more items what i need to got promotion, but i don't know where?
I found only one line where we can see what the script checking, i added there a itemid but it not working, still what i needed is only a 2cc
Im searching something in others npc files/libs but i found nothing

npc/lib/modules.lua
Code:
elseif not player:removeTotalMoney(parameters.cost) and player:removeItem(10022, 1) then
 
Solution
node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, itemidpay = 12345, itemname = 'xxxxx', level = 20, text = 'message'}

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() or not parameters.premium then
            local promotion = player:getVocation():getPromotion()
            if player:getStorageValue(STORAGEVALUE_PROMOTION) == 1 then...
Hi, i want add more items what i need to got promotion, but i don't know where?
I found only one line where we can see what the script checking, i added there a itemid but it not working, still what i needed is only a 2cc
Im searching something in others npc files/libs but i found nothing

npc/lib/modules.lua
Code:
elseif not player:removeTotalMoney(parameters.cost) and player:removeItem(10022, 1) then
data/npc/promotion.lua

Here it is.
 
data/npc/promotion.lua

Here it is.

In promotion.lua i has only node's and messages, with global value "cost", but how to add items to the "cost"?

Code:
node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 20, text = 'message'})
 
I don't know what your script template is, but if it's the same, put the item you want on that line

Lua:
if(isPremium(cid) or not getBooleanFromString(getConfigValue('premiumForPromotion'))) then
            if(getPlayerPromotionLevel(cid) >= parameters.promotion) 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(not doPlayerRemoveMoney(cid, parameters.cost)) then
                npcHandler:say('You do not have enough money!', cid)
            else
                doPlayerSetPromotionLevel(cid, parameters.promotion)
                npcHandler:say(parameters.text, cid)
                doPlayerAddItem(cid, 1993, 1)                     ---------put here your script add item!!---------------------
            end
        else
            npcHandler:say("You need a premium account in order to get promoted.", cid)
        end

        npcHandler:resetNpc(cid)
        return true
    end
 
I don't know what your script template is, but if it's the same, put the item you want on that line

Lua:
if(isPremium(cid) or not getBooleanFromString(getConfigValue('premiumForPromotion'))) then
            if(getPlayerPromotionLevel(cid) >= parameters.promotion) 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(not doPlayerRemoveMoney(cid, parameters.cost)) then
                npcHandler:say('You do not have enough money!', cid)
            else
                doPlayerSetPromotionLevel(cid, parameters.promotion)
                npcHandler:say(parameters.text, cid)
                doPlayerAddItem(cid, 1993, 1)                     ---------put here your script add item!!---------------------
            end
        else
            npcHandler:say("You need a premium account in order to get promoted.", cid)
        end

        npcHandler:resetNpc(cid)
        return true
    end

You don't understand me :D I don't want add ITEM to player when he get promotion, i want add item to PRICE for promotion, if player want got promotion he must pay 2cc and ITEM ID 10022
There is my script template:
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 player:isPremium() or not parameters.premium 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:removeTotalMoney(parameters.cost) and player:removeItem(10022, 1) 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
 
In promotion.lua i has only node's and messages, with global value "cost", but how to add items to the "cost"?

Code:
node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 20, text = 'message'})
Just make normal function inside NPC script, using
Lua:
msgcontains(msg, "promotion")
 
node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, itemidpay = 12345, itemname = 'xxxxx', level = 20, text = 'message'}

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() or not parameters.premium 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:removeTotalMoney(parameters.cost) then
                npcHandler:say("You do not have enough money!", cid)
            elseif not player:removeItem(parameters.itemidpay, 1) then
                npcHandler:say("You do not have " .. parameters.itemname .. " item as payment!", 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
 
Solution
Hi, i want add more items what i need to got promotion, but i don't know where?
I found only one line where we can see what the script checking, i added there a itemid but it not working, still what i needed is only a 2cc
Im searching something in others npc files/libs but i found nothing

npc/lib/modules.lua
Code:
elseif not player:removeTotalMoney(parameters.cost) and player:removeItem(10022, 1) then
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

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

function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
  
local player = Player(cid)
local playerVocation = (player:getVocation():getId())
local vocation = {1, 2, 3, 4} -- Define basic vocations, as much as you want
local item_1 = player:getItemCount(2147) -- Put something here, i put Small ruby for test
local money = player:getMoney()
if msgcontains(msg, "promotion") then
if isInArray(vocation, playerVocation) and item_1 >= 5 and money >= 20000 then -- Define how many items and moneys, you can add more items
            player:removeItem(item_1, 5)
            player:removeMoney(20000)
                        npcHandler:say('Congratulations! You are now promoted.', player)
                        player:setVocation(playerVocation + 4) -- Try to make Sorcerer = 1 then Master Sorcerer will be 5
        else
            npcHandler:say('You dont have all the ingredients', player)
            return true
    end
else
                        return true
    end
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Take work code, just upgrade it like you want :p
 
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

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

function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
 
local player = Player(cid)
local playerVocation = (player:getVocation():getId())
local vocation = {1, 2, 3, 4} -- Define basic vocations, as much as you want
local item_1 = player:getItemCount(2147) -- Put something here, i put Small ruby for test
local money = player:getMoney()
if msgcontains(msg, "promotion") then
if isInArray(vocation, playerVocation) and item_1 >= 5 and money >= 20000 then -- Define how many items and moneys, you can add more items
            player:removeItem(item_1, 5)
            player:removeMoney(20000)
                        npcHandler:say('Congratulations! You are now promoted.', player)
                        player:setVocation(playerVocation + 4) -- Try to make Sorcerer = 1 then Master Sorcerer will be 5
        else
            npcHandler:say('You dont have all the ingredients', player)
            return true
    end
else
                        return true
    end
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Take work code, just upgrade it like you want :p

Thanks, but i used @chucky91 code, its so easy and it work so :D
 
Back
Top