• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Heavily modified promotion npc needed. [Solved - With solution posted.]

Vyze

New Member
Joined
Sep 12, 2009
Messages
2
Reaction score
0
Hey, i've been trying for a few hour to create an npc that ONLY PROMOTES A CERTAIN VOCATION (13). It should also buy it through an item, (5909).

I also need a promotion npc that promotes everyone except that certain vocation (13).

My problems: I cant find a promotion command that allows lets me promote right off the bat.

Here is my best shot at building my own:

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

function creatureSayCallback(cid, type, msg)

    if(npcHandler.focus ~= cid) then
        return false
    end
    
    if msgcontains(msg,'grace') then
        if getPlayerVocation(cid) == 13 then
            selfSay('Do you wish me to imbibe you with your grace? This will cost you a fee of 20000 gold.')
		talkState[talkUser] = 2
   elseif talkState[talkUser] == 2 then
        if msgcontains(msg, 'yes') then
                npcHandler:say('You have been imbibed with your grace.', cid)
	            if doPlayerRemoveItem(cid,5904,1) == TRUE then
                talkState[talkUser] = 3
                else
                npcHandler:say('Sorry...but you dont have your grace. Come back when you have it.', cid)
            end
            end
            end
    return true
end

        else
            selfSay('Sorry, I can only grant disgraced angels their grace.')
        end
    end
return 1    
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
 
 
local node1 = keywordHandler:addKeyword({'grace'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can imbibe your grace into you for 20000 gold coins. Do you want me to proceed?'})
	node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 50, promotion = 1, text = 'Congratulations! I was successful in inserting your grace.'})
	node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})

npcHandler:addModule(FocusModule:new())

That wont even run, so dont even try :p
But it might make someone out there understand what im trying to achieve

An alternative method could be to have an item promote the vocation

Ok, worked some more on this today and ended up with this:
Code:
 keywordHandler = KeywordHandler:new()
 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

promoted    = 'I have imbibed your grace into you!'
noitems        = 'You are either not a disgraced angel, or you do not have your grace.'
noitems2    = 'This message should never appear.'
already        = 'You have already recived your grace!'
    
-- CITIZEN START --
function CitizenFirst(cid, message, keywords, parameters, node)

    if(not npcHandler:isFocused(cid)) then
        return false
    end

    if isPremium(cid) then
        if getPlayerVocation(cid) == 13 then
        if getPlayerItemCount(cid,5904) >= 1 and getPlayerItemCount(cid,5942) >= 1 then
        if doPlayerRemoveItem(cid,5904,1) and doPlayerRemoveItem(cid,5942,1) then
	doPlayerSetVocation(cid,17)
            selfSay(promoted)
            doSendMagicEffect(getCreaturePosition(cid), 13)
        end
        else
            selfSay(noitems)
        end
    else
        selfSay(already)
    end
    end

end

-- CITIZEN END --


keywordHandler:addKeyword({'grace'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I can offer to imbibe you with your grace for 15.000 gold."})
keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Type imbibe grace to continue!"})

node1 = keywordHandler:addKeyword({'imbibe'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you wish me to imbibe you with your grace for 15.000 gold?'})
    node1:addChildKeyword({'yes'}, CitizenFirst, {})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you are ready.', reset = true})


npcHandler:addModule(FocusModule:new())

Can anyone see the problem with it?

EDIT: Okay, i fixed it but it does still not work 100% (the promotion vanishes on relog) and if anyone else needs this, i am posting the finished script:

Code:
 keywordHandler = KeywordHandler:new()
 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

promoted    = 'I have imbibed your grace into you!'
noitems        = 'You are either not a disgraced angel, or you do not have your grace.'
already        = 'You have already recived your grace!'
    
-- FUNCTION START --
function AngelPromotion(cid, message, keywords, parameters, node)

    if getPlayerVocation(cid) == 13 then
        if getPlayerItemCount(cid,5904) >= 1 and getPlayerItemCount(cid,5942) >= 1 then
        if doPlayerRemoveItem(cid,5904,1) and doPlayerRemoveItem(cid,5942,1) then
			doPlayerSetVocation(cid,17)
            selfSay(promoted)
            doSendMagicEffect(getCreaturePosition(cid), 13)
        end
        else
            selfSay(noitems)
        end
    else
        selfSay(already)
    end
    end

-- FUNCTION END --


keywordHandler:addKeyword({'grace'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I can offer to imbibe you with your grace for 15.000 gold."})
keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Type 'imbibe' to continue!"})

node1 = keywordHandler:addKeyword({'imbibe'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you wish me to imbibe you with your grace for 15.000 gold?'})
    node1:addChildKeyword({'yes'}, AngelPromotion, {})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you are ready.', reset = true})


npcHandler:addModule(FocusModule:new())


SOLUTION FOUND TO ALL ISSUES -> Posting it in a new post for those who wants to know.
 
Last edited:
How i did it.

I started by creating a range of files as seen above, all of them are fruitless (The last one works, but it doesn't save the promotion)

To remedy that i create a new module i call StdModule.promotePlayerAngel and i created it from the original StdModule.promotePlayer module and i left parameters as is.

the code for that new function looked like this:
Code:
--[ Written by Vyze ]--
		function StdModule.promotePlayerAngel(cid, message, keywords, parameters, node)
		local npcHandler = parameters.npcHandler
		if(npcHandler == nil) then
			error('StdModule.promotePlayerAngel called without any npcHandler instance.')
		end

		if(not npcHandler:isFocused(cid)) then
			return false
		end

		if(isPlayerPremiumCallback(cid) or not getBooleanFromString(getConfigValue('premiumForPromotion')) or not(parameters.premium)) 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)
			elseif getPlayerVocation(cid) == 1 then
				npcHandler:say('You are not a disgraced angel!', cid)
			elseif getPlayerVocation(cid) == 2 then
				npcHandler:say('You are not a disgraced angel!', cid)
			elseif getPlayerVocation(cid) == 3 then
				npcHandler:say('You are not a disgraced angel!', cid)
			elseif getPlayerVocation(cid) == 4 then
				npcHandler:say('You are not a disgraced angel!', cid)
			elseif getPlayerVocation(cid) == 5 then
				npcHandler:say('You are not a disgraced angel!', cid)
			elseif getPlayerVocation(cid) == 6 then
				npcHandler:say('You are not a disgraced angel!', cid)
			elseif getPlayerVocation(cid) == 7 then
				npcHandler:say('You are not a disgraced angel!', cid)
			elseif getPlayerVocation(cid) == 8 then
				npcHandler:say('You are not a disgraced angel!', cid)
			else
				if doPlayerRemoveItem(cid,5904,1) and doPlayerRemoveItem(cid,5942,1) then
				setPlayerPromotionLevel(cid, parameters.promotion)
				npcHandler:say(parameters.text, cid)
			end
			end
		else
			npcHandler:say("You need a premium account in order to get promoted.", cid)
		end

		npcHandler:resetNpc()
		return true
	end
And using this function i created the npc script
Code:
--[ Written by Vyze ]--
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

keywordHandler:addKeyword({'grace'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I can offer to imbibe you with your grace for 15.000 gold."})
keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Type 'imbibe' to continue!"})

local node1 = keywordHandler:addKeyword({'promot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want me to imbibe your grace into you? This will take a one time fee of 15.000 gold.'})
	node1:addChildKeyword({'yes'}, StdModule.promotePlayerAngel, {npcHandler = npcHandler, cost = 15000, level = 50, promotion = 1, text = 'Congratulations! You have now united with your grace.'})
	node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})

npcHandler:addModule(FocusModule:new())

This made a functional npc capable of promoting a disgraced angel (vocation) for two kinds of items to its promoted state. Im sure someone out there can think of an alot more sophisticated way of doing this, though.

Also, to achieve the effect of angels only getting promoted this way, i edited the regular promotion module with an extra command
Code:
			elseif getPlayerVocation(cid) == 14 then
				npcHandler:say('I can not grant you your grace!', cid)
to reject angels trying to get promoted by this function.

If you want to replicate my results and need help, PM me and i'll get back to you (I dont read my pms alot :P)
 
Last edited:
Back
Top