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

Promote NPC

fokuleh

New Member
Joined
Oct 25, 2007
Messages
156
Reaction score
0
how to do that king ask you items for the promote, like 100 iron ore for the elite knight or something?, and how to personalize the npc?, like to put, if the voc id is 4 change voc id to 11????, i make new npc that gives you custom vocations if you are the correct =P, plz help!
 
how to do that king ask you items for the promote, like 100 iron ore for the elite knight or something?, and how to personalize the npc?, like to put, if the voc id is 4 change voc id to 11????, i make new npc that gives you custom vocations if you are the correct =P, plz help!

Well i can give u an example just wait a sec and i'll edit this post and add it it's only an example


try this

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

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	if(npcHandler.focus ~= cid) then
		return false
	end

		promo_need_premium = 'Sorry, you need a premium account to get addons.'
		promo_have_already = 'Sorry, you already have this addon.'
		promo_have_not_items = 'Sorry, you dont have these items.'
		

------------------------------------------------ addon ------------------------------------------------
		if msgcontains(msg, 'promotion') then
			if isPremium(cid) then
				if getPlayerItemCount(cid,5880) >= 100 then
					selfSay('Did you bring me 100 iron ore?')
					talk_state = 1
				else
					selfSay('I need 100 iron ore.')
					talk_state = 0
				end
			else
				selfSay(promo_need_premium)
				talk_state = 0
			end
------------------------------------------------ confirm yes ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 1 then
			talk_state = 0
			if getPlayerItemCount(cid,5880) >= 100 then
			if getPlayerVocation(cid) == 4 then
					if doPlayerTakeItem(cid,5850,100) == 0 then
					if doPlayerSetVocation(cid, 11) then
						selfSay(addon_give)
					end
				else
					selfSay(addon_have_already)
				end
			else
				selfSay(addon_have_not_items)
			end
------------------------------------------------ confirm no ------------------------------------------------
		elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 2) then
			selfSay('Ok than.')
			talk_state = 0
		end
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
when i put the script the npc disappear xD
Code:
[/Warning: [NpcScript::NpcScript] Can not load script. data/npc/scripts/ninja.lua
data/npc/scripts/ninja.lua:62: 'end' expected (to close 'function' at line 12) near '<eof>'

i was using this but don't work xD, and it ask money, no items xD:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)



-- OTServ event handling functions start
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
-- OTServ event handling functions end

local node1 = keywordHandler:addKeyword({'evolv'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to evolve to destroyer for a little fee of 30k?'})
	node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, promotions = {[4] = 11}, cost = 30000, level = 20, text = 'Congratulations! You are now a destroyer.'})
	node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Allright then. Come back when you are ready.', reset = true})

npcHandler:addModule(FocusModule:new())
 
Last edited:
try this

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

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	if(npcHandler.focus ~= cid) then
		return false
	end

		promo_need_premium = 'Sorry, you need a premium account to get addons.'
		promo_have_already = 'Sorry, you already have this addon.'
		promo_have_not_items = 'Sorry, you dont have these items.'
		

------------------------------------------------ addon ------------------------------------------------
		if msgcontains(msg, 'promotion') then
			if isPremium(cid) then
				if getPlayerItemCount(cid,5880) >= 100 then
					selfSay('Did you bring me 100 iron ore?')
					talk_state = 1
				else
					selfSay('I need 100 iron ore.')
					talk_state = 0
				end
			else
				selfSay(promo_need_premium)
				talk_state = 0
			end
------------------------------------------------ confirm yes ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 1 then
			talk_state = 0
			if getPlayerItemCount(cid,5880) >= 100 then
			if getPlayerVocation(cid) == 4 then
					if doPlayerTakeItem(cid,5850,100) == 0 then
					if doPlayerSetVocation(cid, 11) then
						selfSay(addon_give)
					end
				else
					selfSay(addon_have_already)
				end
			else
				selfSay(addon_have_not_items)
			end
------------------------------------------------ confirm no ------------------------------------------------
		elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 2) then
			selfSay('Ok than.')
			talk_state = 0
		end
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	return true
end
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
uhm try this
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	if(npcHandler.focus ~= cid) then
		return false
	end

		promo_need_premium = 'Sorry, you need a premium account to get addons.'
		promo_have_already = 'Sorry, you already have this addon.'
		promo_have_not_items = 'Sorry, you dont have these items.'
		

------------------------------------------------ addon ------------------------------------------------
		if msgcontains(msg, 'promotion') then
			if isPremium(cid) then
					selfSay('Did you bring me 100 iron ore?')
					talk_state = 1
			else
				selfSay(promo_need_premium)
				talk_state = 0
			end
------------------------------------------------ confirm yes ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 1 then
			talk_state = 0
			if getPlayerItemCount(cid,5880) >= 100 and getPlayerVocation(cid) == 4 then
					if doPlayerTakeItem(cid,5850,100) then
					if doPlayerSetVocation(cid, 11) then
						selfSay(promo_give)
					end
				else
					selfSay(promo_have_already)
				end
			else
				selfSay(promo_have_not_items)
			end
------------------------------------------------ confirm no ------------------------------------------------
		elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 2) then
			selfSay('Ok than.')
			talk_state = 0
		end
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	return true
end


npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
00:30 Ninja Master: Hi Dios. I can evolve your paladin for a ninja, if you want to evolve only speak to me
00:30 Dios [103]: promotion
00:30 Ninja Master: Did you bring me 100 iron ore?
00:30 Dios [103]: yes
00:30 Ninja Master: Sorry, you dont have these items.

i change the 5850 to 5880 because is the correct id but is not working! o_O
Code:
if doPlayerTakeItem(cid,5850,100) then
 
You should use storagevalues to check if the player is already promoted + unnecessery line is
Code:
if getPlayerItemCount(blablabla

I will write working promote npc as u want later.
bcoz im at school now

I can tell you now a missing line:
Code:
getPlayerVocation(cid)

Without it, everyone will get vocation 11 o_O

<---------- EDIT ---------->

I tested it a little, if you find any bugs, let me know.
Here it is:

PHP:
--------------------------------------------------------------------------------------------
---------------------------- Advanced Promotion NPC for fokuleh ----------------------------
---------------------------------- Script made by Sinner -----------------------------------
--------------------------------------------------------------------------------------------

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

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do 

not have to take care of that yourself.
if(npcHandler.focus ~= cid) then
return false
end

	if msgcontains(msg, 'promotion') then
	if isPremium(cid) == TRUE then
	if getPlayerLevel(cid) >= 20 then
	voc = getPlayerVocation(cid)
	prom = getPlayerStorageValue(cid, 12345)
	if prom == -1 then
		selfSay('Do you want to buy promotion for 100 iron ores?')
		talk_state = 1
	
	else
	selfSay('You are already promoted.')
	talk_state = 0
	end

	else
	selfSay('Only characters of level 20 can become promoted.')
	talk_state = 0
	end
	else
	selfSay('Only premium account players can become promoted.')
	talk_state = 0
	end

	elseif msgcontains(msg, 'yes') and talk_state == 1 and voc == 1 then
	if doPlayerTakeItem(cid, 5880, 100) == 0 then
	selfSay('You are now promoted to Master Sorcerer!')
	doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_GREEN)
	doPlayerSetVocation(cid, 5)
	setPlayerStorageValue(cid, 12345, 1)
	else
	selfSay('Bring me 100 iron ores to get promoted.')
	talk_state = 0
	end

	elseif msgcontains(msg, 'yes') and talk_state == 1 and voc == 2 then
	if doPlayerTakeItem(cid, 5880, 100) == 0 then
	selfSay('You are now promoted to Elder Druid!')
	doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_GREEN)
	doPlayerSetVocation(cid, 6)
	setPlayerStorageValue(cid, 12345, 1)
	else
	selfSay('Bring me 100 iron ores to get promoted.')
	talk_state = 0
	end

	elseif msgcontains(msg, 'yes') and talk_state == 1 and voc == 3 then
	if doPlayerTakeItem(cid, 5880, 100) == 0 then
	selfSay('You are now promoted to Royal Paladin!')
	doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_GREEN)
	doPlayerSetVocation(cid, 7)
	setPlayerStorageValue(cid, 12345, 1)
	else
	selfSay('Bring me 100 iron ores to get promoted.')
	talk_state = 0
	end	

	elseif msgcontains(msg, 'yes') and talk_state == 1 and voc == 4 then
	if doPlayerTakeItem(cid, 5880, 100) == 0 then
	selfSay('You are now promoted to Elite Knight!')
	doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_GREEN)
	doPlayerSetVocation(cid, 8)
	setPlayerStorageValue(cid, 12345, 1)
	else
	selfSay('Bring me 100 iron ores to get promoted.')
	talk_state = 0
	end

	elseif msgcontains(msg, 'no') and talk_state == 1 then
	selfSay('Maybe another time.')
	talk_state = 0
end

	return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Hope you like it :)

Feel free to ask me how to add more items necessery for promotion.
 
Last edited:
PHP:
-------------------------------------------HAROUN MADE BY FENOL, ALL RIGHT RESERVED------------------------------------------
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    if(npcHandler.focus ~= cid) then
        return false
    end

    -- use the real conversation? (true/false)
    real = true
    
    if real == true then
        tradeMsg = 'I am willing to trade items with you.'
        flaskMsg = 'Very noble, I can make warrior sweat from 4 warrior helmets. Would you like to trade?'
        fightMsg = 'Great choice. I can make fighting spirit from 2 royal helmets. Do you want to trade?'
        magicMsg = 'Fine, I will make magic sulphur for 3 fire swords, ok?'
        wingsMsg = 'Ahh... Might chicken wings... I can give you one for each boots of haste, you accept that?'
	giantMsg = 'I will give you spool of yarn for 10 giant spider silks, you want to trade?'
        hasNoMsg = 'You do not have what I need.'
        noMsg = 'As you wish, human.'
    else
        tradeMsg = 'I am willing to trade items with you.'
        flaskMsg = 'Do you want to trade  4 warrior helmets for warrior sweat?'
        fightMsg = 'Do you want to trade  2 royal helmets for fighting spirit?'
        magicMsg = 'Do you want to trade  3 fire swords for magic sulphur?'
        wingsMsg = 'Do you want to trade  boots of haste for enchanted chicken wing?'
	giantMsg = 'Do you want to trade  10 giant spider slik for spool of yarn?'
        hasNoMsg = 'Come back when you have all ingredients.'
        noMsg = 'Ok.'
    end
        if msgcontains(msg, 'help') or msgcontains(msg, 'item') or msgcontains(msg, 'forge') then
            selfSay(tradeMsg)
        elseif msgcontains(msg, 'warrior sweat') or msgcontains(msg, 'sweat') or msgcontains(msg, 'warrior helmet') or msgcontains(msg, 'warriors') or msgcontains(msg, 'uth\'kean') then
            selfSay(flaskMsg)
            talk_state = 1
        elseif msgcontains(msg, 'fighting spirit') or msgcontains(msg, 'spirit') or msgcontains(msg, 'royal helmet') or msgcontains(msg, 'royal') or msgcontains(msg, 'za\'ralator') then
            selfSay(fightMsg)
            talk_state = 2
        elseif msgcontains(msg, 'magic sulphur') or msgcontains(msg, 'sulphur') or msgcontains(msg, 'fire sword') or msgcontains(msg, 'fire swords') or msgcontains(msg, 'uth\'lokr') then
            selfSay(magicMsg)
            talk_state = 3
        elseif msgcontains(msg, 'enchanted chicken wing') or msgcontains(msg, 'wing') or msgcontains(msg, 'wings') or msgcontains(msg, 'boh') or msgcontains(msg, 'boots of haste') or msgcontains(msg, 'uth\'prta') then
            selfSay(wingsMsg)
            talk_state = 4
                elseif msgcontains(msg, 'giant spider silk') or msgcontains(msg, 'spool of yarn') or msgcontains(msg, 'silk yarn') or msgcontains(msg, 'silk yarns') or msgcontains(msg, 'silks') then
            selfSay(giantMsg)
            talk_state = 5
------------------------------------------------ confirm yes ------------------------------------------------
        elseif msgcontains(msg, 'yes') and talk_state == 1 then
            if getPlayerItemCount(cid, 2475) >= 4 then
                if doPlayerTakeItem(cid, 2475, 4) == 0 then
                    selfSay('Here you are.')
                    doPlayerAddItem(cid, 5885, 1)
                end
            else
                selfSay(hasNoMsg)
            end
            talk_state = 0
        elseif msgcontains(msg, 'yes') and talk_state == 2 then
            if getPlayerItemCount(cid, 2498) >= 2 then
                if doPlayerTakeItem(cid, 2498, 2) == 0 then
                    selfSay('Here you are.')
                    doPlayerAddItem(cid, 5884, 1)
                end
            else
                selfSay(hasNoMsg)
            end
            talk_state = 0
        elseif msgcontains(msg, 'yes') and talk_state == 3 then
            if getPlayerItemCount(cid, 2392) >= 3 then
                if doPlayerTakeItem(cid, 2392, 3) == 0 then
                    selfSay('Here you are.')
                    doPlayerAddItem(cid, 5904, 1)
                end
            else
                selfSay(hasNoMsg)
            end
            talk_state = 0
        elseif msgcontains(msg, 'yes') and talk_state == 4 then
            if getPlayerItemCount(cid, 2195) >= 1 then
                if doPlayerTakeItem(cid, 2195, 1) == 0 then
                    selfSay('Here you are.')
                    doPlayerAddItem(cid, 5891, 1)
                end
            else
                selfSay(hasNoMsg)
            end
            talk_state = 0
        elseif msgcontains(msg, 'yes') and talk_state == 5 then
            if getPlayerItemCount(cid, 5879) >= 10 then
                if doPlayerTakeItem(cid, 5879, 10) == 0 then
                    selfSay('Here you are.')
                    doPlayerAddItem(cid, 5886, 1)
                end
            else
                selfSay(hasNoMsg)
            end
            talk_state = 0
------------------------------------------------ confirm no ------------------------------------------------
        elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
            selfSay(noMsg)
            talk_state = 0
        end
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end

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

Should be fine.
 
Back
Top