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

Change Vocation

Zer O

Banned User
Joined
Nov 18, 2010
Messages
504
Reaction score
5
I can't find a script to change the profession (vocation)

I need rune or some like this to :
When 200 elite knight use that :
and want master sorcerer
they write !master sorcerer
and him change all hp/mana/cap/vocation ...

Its possible ?
 
np something like that


Code:
local cfg = {
level = 200,
item = xxx,
itemName = "item",
startHp = 150,
startMana = 0,
}

local attr = {
sor ={mana = 30,
health = 5,
},

dru ={mana = 30,
health = 5,
},

pal ={
mana = 15,
health = 10,

},

kni ={
mana = 5,
health = 15,
},
}

function onSay(cid, words, param)
local pos = getPlayerPosition(cid),
local voc = getPlayerVocation(cid),
local pLevel = getPlayerLevel(cid)

if not getPlayerItemCount(cid, item) then
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need "..itemName.." to use this command.")
	return false
end

if pLevel < cfg.level then
	doSendMagicEffect(pos, 2)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your level is too low. Require level is " ..cfg.level.. "")
	return false
end

	if param = "" then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This command require vocation in param.") 
	   return false 
	  
	 elseif param = "knight" then
		hp = (pLevel - 1)*attr.kni.health
	    mp = (pLevel - 1)*attr.kni.mana

		setCreatureMaxHealth(cid, hp)
	    setCreatureMaxMana(cid, mp)
		doCreatureAddHealth(cid, hp)
		doCreatureAddMana(cid, mp)
		
		doPlayerSetVocation(cid, 4)	
	 elseif param = "paladin" then
		hp = (pLevel - 1)*attr.pal.health
	    mp = (pLevel - 1)*attr.pal.mana

		setCreatureMaxHealth(cid, hp)
	    setCreatureMaxMana(cid, mp)
		doCreatureAddHealth(cid, hp)
		doCreatureAddMana(cid, mp)	 
		doPlayerSetVocation(cid, 3)

	 elseif param = "druid" then
		hp = (pLevel - 1)*attr.dru.health
	    mp = (pLevel - 1)*attr.dru.mana

		setCreatureMaxHealth(cid, hp)
	    setCreatureMaxMana(cid, mp)
		doCreatureAddHealth(cid, hp)
		doCreatureAddMana(cid, mp)	
		
		doPlayerSetVocation(cid, 2)
	  elseif param = "mag" then
	  	hp = (pLevel - 1)*attr.mag.health
	    mp = (pLevel - 1)*attr.mag.mana

		setCreatureMaxHealth(cid, hp)
	    setCreatureMaxMana(cid, mp)
		doCreatureAddHealth(cid, hp)
		doCreatureAddMana(cid, mp)
		
		doPlayerSetVocation(cid, 1)
     end

return true

end
so tfs don't have lua function like "getVocGainmana/hp" i create config...
This code seens like good but if player change voc must relog if want to take promotion...

Uhh i forgotten...
Talkactions.xml:
Code:
	<talkaction words="!voc"  event="script" value="voc.lua" desc=""/>
Command in game:
Code:
!voc druid
 
...so delete it :
Code:
if pLevel < cfg.level then
	doSendMagicEffect(pos, 2)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your level is too low. Require level is " ..cfg.level.. "")
	return false
end
 
Short, no big config and Rep+

IMPORTANT:
Use talkactions.xml like this:
! or / + the vocation name (before promotion)
XML:
	<talkaction words="!sorcerer;!druid;!paladin;!knight"  event="script" value="script.lua"/>

LUA:
local config = {
	item = {xxxx, y},  -- xxxx = itemid, y = itemcount needed
	start = {hp = 150, mana = 0}, 
	leaveRook = 8 -- leave the character leaves rook - needed to set correct health/mana
}


function onSay(cid, words, param)
	local lvl, tovoc = getPlayerLevel(cid)

	for i = 1, 4 do
		if words:find(getVocationInfo(i).name:lower()) then
			tovoc = getVocationInfo(i)
			break
		end
		if i == 4 then return doPlayerSendCancel(cid, "ERROR: vocation not found") end
	end
	if getPlayerVocation(cid) == tovoc.id then
		return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are already a "..tovoc.name:lower().."!")
	end
	if not doPlayerRemoveItem(cid, config.item[1], config.item[2]) then 
		return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need "..config.item[2].."x "..getItemNameById(config.item[1]).." to change your vocation.")
	end
	
	local new = {health = (config.leaveRook >= lvl and (config.start.hp+(lvl-1)*getVocationInfo(0).healthGain) or (config.start.hp+(getVocationInfo(0).healthGain*(lvl-(lvl-config.leaveRook+1))+(lvl-config.leaveRook)*tovoc.healthGain))), mana = (config.leaveRook >= lvl and (config.start.mana+(lvl-1)*getVocationInfo(0).manaGain) or (config.start.mana+(getVocationInfo(0).manaGain*(lvl-(lvl-config.leaveRook+1))+(lvl-config.leaveRook)*tovoc.manaGain)))}
	setCreatureMaxHealth(cid, new.health)
	setCreatureMaxMana(cid, new.mana)
	doCreatureAddHealth(cid, new.health)
	doCreatureAddMana(cid, new.mana)	
	doPlayerSetVocation(cid, tovoc.id)	
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are now a "..tovoc.name:lower().."!")
	return true
end
 
Oki not perfect but i fixed it !
Rep ++
for Summ x2
and for Chev x1

Can one more give me fixed that to This Command take 250 ptk from sms shop ?
 
Bump who can fix that to if players change voc from :
Knight
Sorc/Druid -> Knight got 9 mlvl all skills 10
Paladin -> Knight got 9 mlvl all skills 10
Sorc/Druid
Knight -> Sorc/Druid got 70 mlvl all skills 10
Paladin -> Sorc/Druid got 70 mlvl all skills 10
Paladin
Sorc/Druid -> Paladin got 15 mlvl all skills 10
Knight -> Paladin got 15 mlvl all skills 10
 
Back
Top