Joriku
Working in the mines, need something?
Hi,
so trying to lock this away from other vocations except for id 0. How do I I check if the vocation is id 0 and if not send a cancel message?
Either that or just seprate so that if id is 0 then put the character to id 9 if level is 250 and cash is 25k then the rest is normal. level 20, 20k for the promotion.
Now that I think about it, the second option is better. If id is 0 then promote to id 9 if level is 250 and payment is 25k
Version 2
Third try
Last try for now..
so trying to lock this away from other vocations except for id 0. How do I I check if the vocation is id 0 and if not send a cancel message?
Either that or just seprate so that if id is 0 then put the character to id 9 if level is 250 and cash is 25k then the rest is normal. level 20, 20k for the promotion.
Now that I think about it, the second option is better. If id is 0 then promote to id 9 if level is 250 and payment is 25k
Lua:
-- Promotion
if player:getVocation():getId() == 0 then
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? test msg'})
node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, toVoc = 9, cost = 20000, level = 250, text = 'Congratulations! You are now promoted. test msg'})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})
else
npcHandler:say("Sorry, this is not the right promotion for you.", npc, creature)
npcHandler:setTopic(playerId, 1)
return false
end
Version 2
Lua:
local cost = 20000
local level = 20
local championLevel = 250
local promotion = player:getVocation():getPromotion()
if MsgContains(message, 'promotion') then
if player:getStorageValue(STORAGEVALUE_PROMOTION) == 1 then
elseif player:getStorageValue(STORAGEVALUE_PROMOTION) == 1 then
npcHandler:say("You are already promoted!", npc, player)
elseif player:getVocation() == 0 and player:getLevel() < championLevel then
selfSay("Test", cid)
npcHandler:say("I am sorry, but I can only promote you once you have reached level 250.", npc, player)
elseif player:getLevel() < level then
npcHandler:say(string.format("I am sorry, but I can only promote you once you have reached level %d.", level), npc, player)
elseif not player:removeMoneyBank(cost) then
npcHandler:say("You do not have enough money!", npc, player)
else
npcHandler:say("You've been promoted.")
player:setVocation(promotion)
player:setStorageValue(STORAGEVALUE_PROMOTION, 1)
npcHandler:setTopic(playerId, 1)
end
end
Third try
Lua:
local function creatureSayCallback(npc, creature, type, message)
local player = Player(creature)
local playerId = player:getId()
local vocId = player:getVocation()
if not npcHandler:checkInteraction(npc, creature) then
return false
end
-- Promotion
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?'})
if vocId == VOCATION_NONE and player:getLevel() < 250 then
npcHandler:say("Sorry, but I can only promote you once you have reached level 250.")
return true
else
node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, 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})
end
end
Last try for now..
Lua:
local function creatureSayCallback(npc, creature, type, message)
local player = Player(creature)
local playerId = player:getId()
local vocId = player:getVocation()
if not npcHandler:checkInteraction(npc, creature) then
return false
end
-- Promotion
if player and player:getVocation() == 0 and player:getLevel() < 250 then
npcHandler:say("Sorry, but I can only promote you once you have reached level 250.", npc, creature)
return false
else
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, 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})
end
end
Last edited: