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

does doPlayerSetVocation(cid,voc) work

Jgarder

Tprogramming Ex-Adm|n
Premium User
Joined
Jun 7, 2007
Messages
355
Reaction score
3
Location
Michigan
i beleive doPlayerSetVocation(cid,voc) is broken.. because i cant manage to get it to do anything.. no matter what i put.. Just want to hear if anyone else can get this to set you as a sorc or random or anything.. my scripts dont have any errors.. and yet it just doesnt work :(


Alright.. i got it to work again, it was that i accidently messed it up while i was TRYING to make promotion not premium only.
PS. if anyone knows what to change in the source so promotions are NOT premium only.. plz tell ;0
 
Last edited:
heres a npc if anyone wants to load it up into their 2.6 and test it out


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

		addon_need_premium = 'Sorry, you need a Higher Level'
		addon_have_already = 'Sorry, i have already knighted you'
		addon_have_not_items = 'Sorry, you don\'t have what i require to help you'
		addon_give = 'You are now promoted'
		player_gold = getPlayerItemCount(cid,2148)
		player_plat = getPlayerItemCount(cid,2152)*100
		player_crys = getPlayerItemCount(cid,2160)*10000
		player_money = player_gold + player_plat + player_crys
		
		if msgcontains(msg, 'power') then
			selfSay('I am the the king of this town and i can bless you and make you a Noble Guard of mine.')
		elseif msgcontains(msg, 'help') then
			selfSay('Say promote, and i will.')
------------------------------------------------ addon ------------------------------------------------
		elseif msgcontains(msg, 'promot') then
			
				if player_money >= 20000 then
					selfSay('Would you like to be promoted for 20000 gold peices?')
					talk_state = 1
				else
					selfSay('i will promote you for 20000 gold coins, nor more, no less!')
					talk_state = 0
				end
			
------------------------------------------------ confirm yes ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 1 then
			talk_state = 0
				addon = getPlayerStorageValue(cid,30018)
				if addon >= -1 then
					if  doPlayerRemoveMoney(cid, 20000) then
						voc = getPlayerVocation(cid)
						voc = 1					
						doPlayerSetVocation(cid,voc)
						setPlayerStorageValue(cid,30018,1)
						selfSay(addon_give)
	
					else
					selfSay(addon_have_not_items)
					end
			else
				selfSay(addon_have_already)
			end
			
			elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 34) 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())
 
try this

Code:
if  doPlayerRemoveMoney(cid, 20000) then
doPlayerSetVocation(cid,1)
setPlayerStorageValue(cid,30018,1)
selfSay(addon_give)
					else

if it dosen't work try this script made it fast i could have some typing errors

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
  
        local voc = 1 --------change the number 1 in the vocation you want him yo change to
		already_promote = 'Sorry, i have already knighted you'
		promote_player = 'You are now knighted'
		
		if msgcontains(msg, 'power') then
			selfSay('I am the the king of this town and i can bless you and make you a Noble Guard of mine.')
		elseif msgcontains(msg, 'help') then
			selfSay('Say promote, and i will.')
------------------------------------------------ addon ------------------------------------------------
		elseif msgcontains(msg, 'promot') then
					selfSay('Would you like to be promoted for 20000 gold peices?')
					talk_state = 1
				end
			
----------------------------------------------- confirm yes ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 1 then
			talk_state = 0
			if getPlayerVocation(cid) == voc then
			selfSay(already_promote)
			else
					if  doPlayerRemoveMoney(cid, 20000) then				
						doPlayerSetVocation(cid,voc)
						selfSay(promote_player)
					end
			
			elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 34) 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())


Alright.. i got it to work again, it was that i accidently messed it up while i was TRYING to make promotion not premium only.
PS. if anyone knows what to change in the source so promotions are NOT premium only.. plz tell ;0

It's not in the sources just remove this line
Code:
if isPremium(cid) then
 
Last edited:
Ofcourse it's posible!

in the promoter

Change:
Code:
isPremium = true

to

Code:
isPremium = false

now people with No premium can get promotion to!
 
Back
Top Bottom