• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction Vocation change - Health, mana and cap changes too!

Alcik

ots.tibiaserver.pl
Joined
Mar 12, 2009
Messages
177
Reaction score
4
Location
Ireland/Polish
Hey. I wrote a script that changes your vocation.

Script changes vocation and takes 35 levels for that. The player needs to have an specified item in the bp for it to work. After the change the player gets the right amount of health, mana, and cap that he would have at that level.

Everything can be changed in config.


Warning: If you have changed the vocations.xml file so that players get more health/mana/cap each level you must configure that in the script.



SCRIPT HAS BEEN TESTED AND WORKS FINE



Lua:
--SCRIPT BY AlcikOTS----tibiaserver.pl--BEST SERVER ONLINE--
-----------------------CONFIG---START-----------------------------------------
local config = {
	removelevel = 35, -- Amount of level taken away.
	itemid = 8982, -- Item ID.
	efekt = 2, -- Effect shown.
	skilafter = 10, -- What skill will the player have after change.
	minimumlevel = 100, -- What will be min level required? 
	magafter = 2, -- What magic level will he recive after change? 
	--Change only if you have edited your vocations.xml so players get more mana/health/cap each level.
	sorcincrease = {5, 30, 10}, --The amount of health/mana/cap that increases when Sorcerer levels up.
	druidincrease = {5, 30, 10}, --The amount of health/mana/cap that increases when Druid levels up.
	paladinincrease = {10, 10, 20}, --The amount of health/mana/cap that increases when Paladin levels up.
	knightincrease = {15, 5, 25} --The amount of health/mana/cap that increases when Knight levels up.
}
-----------------------CONFIG---END-------------------------------------------
 
function onSay(cid, words, param)
 
if(param == "") then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must say what vocation you want change to.")
		return TRUE
    end
 if(param == "sorcerer") or (param == "druid") or (param == "knight") or (param == "paladin") or (param == "Paladin") or (param == "Druid") or (param == "Sorcerer") or (param == "Knight") or (param == "sorc") or (param == "Sorc") then
		if getPlayerLevel(cid) >= config.minimumlevel then
			if getPlayerItemCount(cid, config.itemid) >= 1 then
				if(param == "sorcerer") or (param == "Sorcerer") or (param == "sorc") or (param == "Sorc") then	
					if getPlayerVocation(cid) > 1 then
					doPlayerAddLevel(cid, -(config.removelevel))
						doPlayerSetVocation(cid, 1) -- Sorc
						setCreatureMaxHealth(cid, (185+(config.sorcincrease[1]*((getPlayerLevel(cid)-8)))))
						setCreatureMaxMana(cid, (35+(config.sorcincrease[2]*((getPlayerLevel(cid)-8)))))
						doPlayerSetMaxCapacity(cid, (470+(config.sorcincrease[3]*((getPlayerLevel(cid)-8)))))
						doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your vocation has been changed to sorcerer.")
					else doPlayerSendCancel(cid, "You are already a sorcerer.")
					doSendMagicEffect(getCreaturePosition(cid), 2)
					return TRUE
					end		
				end
 
				if(param == "druid") or (param == "Druid") then
					if getPlayerVocation(cid) == 1 or getPlayerVocation(cid) > 2 then
					doPlayerAddLevel(cid, -(config.removelevel))
						doPlayerSetVocation(cid, 2) -- Druid
						setCreatureMaxHealth(cid, (185+(config.druidincrease[1]*((getPlayerLevel(cid)-8)))))
						setCreatureMaxMana(cid, (35+(config.druidincrease[2]*((getPlayerLevel(cid)-8)))))
						doPlayerSetMaxCapacity(cid, (470+(config.druidincrease[3]*((getPlayerLevel(cid)-8)))))				
						doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your vocation has been changed to druid.")	
					else doPlayerSendCancel(cid, "You are already a druid.")
					doSendMagicEffect(getCreaturePosition(cid), 2)
					return TRUE
					end	
				end
 
				if(param == "paladin") or (param == "Paladin") then
					if getPlayerVocation(cid) < 3 or getPlayerVocation(cid) > 3 then
					doPlayerAddLevel(cid, -(config.removelevel))
					doPlayerSetVocation(cid, 3) -- Sorc
						setCreatureMaxHealth(cid, (185+(config.paladinincrease[1]*((getPlayerLevel(cid)-8)))))
						setCreatureMaxMana(cid, (35+(config.paladinincrease[2]*((getPlayerLevel(cid)-8)))))
						doPlayerSetMaxCapacity(cid, (470+(config.paladinincrease[3]*((getPlayerLevel(cid)-8)))))
						doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your vocation has been changed to paladin.")
					else doPlayerSendCancel(cid, "You are already a paladin.")
					doSendMagicEffect(getCreaturePosition(cid), 2)
					return TRUE
					end
				end	
 
				if(param == "knight") or (param == "Knight") then
					if getPlayerVocation(cid) < 4 then
					doPlayerAddLevel(cid, -(config.removelevel))
					doPlayerSetVocation(cid, 4) -- Sorc
						setCreatureMaxHealth(cid, (185+(config.knightincrease[1]*((getPlayerLevel(cid)-8)))))
						setCreatureMaxMana(cid, (35+(config.knightincrease[2]*((getPlayerLevel(cid)-8)))))	
						doPlayerSetMaxCapacity(cid, (470+(config.knightincrease[3]*((getPlayerLevel(cid)-8)))))
						doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your vocation has been changed to knight.")		
					else doPlayerSendCancel(cid, "You are already a knight.")
					doSendMagicEffect(getCreaturePosition(cid), 2)
					return TRUE
					end
				end
				
				doPlayerRemoveItem(cid, config.itemid, 1)
				doPlayerAddMagLevel(cid, -((getPlayerMagLevel(cid))-config.magafter))
				doSendMagicEffect(getCreaturePosition(cid), config.efekt)
				doCreatureAddMana(cid, -((getCreatureMana(cid))-(getCreatureMaxMana(cid))))
				doCreatureAddHealth(cid, -((getCreatureHealth(cid))-(getCreatureMaxHealth(cid))))
							for a = 0,6 do
								doPlayerAddSkill(cid, a, -(getPlayerSkillLevel(cid, a)-config.skilafter))
							end	
				
			else doPlayerSendCancel(cid, "You need "..getItemNameById(config.itemid).." to change your vocation.")
			doSendMagicEffect(getCreaturePosition(cid), 2)
			end
		else doPlayerSendCancel(cid, "You don't have enough level. Your level must be "..(config.minimumlevel).." or higher.")
		doSendMagicEffect(getCreaturePosition(cid), 2)
		end
else doPlayerSendCancel(cid, "You must say what vocation you want change to.")
doSendMagicEffect(getCreaturePosition(cid), 2)
end
end




XML:
<talkaction words="!changevoc" event="script" value="vocations.lua"/>




If you have any ideas or special requests let me know so I will try and add them.
 
Last edited:
I see no comments ;/
It would be helpful if someone test it and report any bugs.

If you have any ideas or "special needs" let me know. I will try and add it to the script.
 
My reaction when i saw if(param == "sorcerer") or (param == "druid") or (param == "knight") or (param == "paladin") or (param == "Paladin") or (param == "Druid") or (param == "Sorcerer") or (param == "Knight") or (param == "sorc") or (param == "Sorc") then
wtf-photos-videos-its-magic.gif
 
lol it crashed my serv.

it crash high exp servers with rebirths??
 
Last edited by a moderator:
It can be shortened but nice nevertheless

It was much longer :D
I wrote that script few months ago, so now when my scripting skills improved I decided to "fix" that script. By the way, I will be improving this script again, and again so it will work for everyone.
 
PHP:
################# SCRIPTED BY Bartastkd http://hellice.pl/ XP ####################

function onSay(cid, words, param, channel)

local config = {
sorcerer = {hp = 5, mp = 30, cap = 10},
druid = {hp = 5, mp = 30, cap = 10},
paladin = {hp = 10, mp = 15, cap = 20},
knight = {hp = 15, mp = 5, cap = 25}
   
}

local czas = 1 
local storage = 4544
local proma = getPlayerPromotionLevel(cid)
local rookedGUID = getPlayerGUID(cid)
local lvl = getPlayerLevel(cid)
local so = {hp = (config.sorcerer.hp * lvl) + 180, mp = (config.sorcerer.mp * lvl) + 35, cap = (config.sorcerer.cap * lvl) + 430}
local dr = {hp = (config.druid.hp * lvl) + 180, mp = (config.druid.mp * lvl) + 35, cap = (config.druid.cap * lvl) + 430}
local pa = {hp = (config.paladin.hp * lvl) + 180, mp = (config.paladin.mp * lvl) + 35, cap = (config.paladin.cap * lvl) + 430}
local kn = {hp = (config.knight.hp * lvl) + 180, mp = (config.knight.mp * lvl) + 35, cap = (config.knight.cap * lvl) + 430}

	if exhaustion.get(cid, storage) == FALSE then
		exhaustion.set(cid, storage, czas)
	else
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Musisz czekac " .. exhaustion.get(cid, storage) .. " sekund.") 
		return true
	end  
  
	if param == 'sorcerer' then
			if proma == 1 then
				if getPlayerItemCount(cid,8983) >= 1 then
                          		  if (getCreatureCondition(cid, CONDITION_INFIGHT) == FALSE) then
					doPlayerRemoveItem(cid, 8983, 1)
					setCreatureMaxHealth(cid, so.hp)
					setCreatureMaxMana(cid, so.mp)
					doCreatureAddHealth(cid, so.hp)
					doCreatureAddMana(cid, so.mp)
					doPlayerSetMaxCapacity(cid, so.cap)
					doPlayerSetVocation(cid, 1)	
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are now a sorcerer")
					doRemoveCreature(cid)
					db.executeQuery("UPDATE `players` SET `maglevel` = '1', `manaspent` = '0' WHERE `id` = " .. rookedGUID .. ";")
					db.executeQuery("UPDATE `player_skills` SET `value` = '10', `count` = '0' WHERE `player_id` = " .. rookedGUID .. " LIMIT 7;")
                     else
					doCreatureSay(cid, "Masz Pz Ziam !", TALKTYPE_ORANGE_1)
				end
				else
					doPlayerSendTextMessage(cid,22,"Nie masz runy to zmiany profesji")
					doSendMagicEffect(getPlayerPosition(cid),4)
				end
			else
				doPlayerSendTextMessage(cid,22,"You dont have promotion")
				doSendMagicEffect(getPlayerPosition(cid),4)
			end
	end

if param == 'druid' then
			if proma == 1 then
				if getPlayerItemCount(cid,8983) >= 1 then
                          		  if (getCreatureCondition(cid, CONDITION_INFIGHT) == FALSE) then
					doPlayerRemoveItem(cid, 8983, 1)
					setCreatureMaxHealth(cid, dr.hp)
					setCreatureMaxMana(cid, dr.mp)
					doCreatureAddHealth(cid, dr.hp)
					doCreatureAddMana(cid, dr.mp)
					doPlayerSetMaxCapacity(cid, dr.cap)
					doPlayerSetVocation(cid, 2)
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are now a druid")
					doRemoveCreature(cid)
					db.executeQuery("UPDATE `players` SET `maglevel` = '1', `manaspent` = '0' WHERE `id` = " .. rookedGUID .. ";")
					db.executeQuery("UPDATE `player_skills` SET `value` = '10', `count` = '0' WHERE `player_id` = " .. rookedGUID .. " LIMIT 7;")
			else
					doCreatureSay(cid, "Masz Pz Ziam !", TALKTYPE_ORANGE_1)
				end
				else
					doPlayerSendTextMessage(cid,22,"Nie masz runy to zmiany profesji")
					doSendMagicEffect(getPlayerPosition(cid),4)
				end
			else
				doPlayerSendTextMessage(cid,22,"You dont have promotion")
				doSendMagicEffect(getPlayerPosition(cid),4)
			end
	end
if param == 'paladin' then
			if proma == 1 then
				if getPlayerItemCount(cid,8983) >= 1 then
					if (getCreatureCondition(cid, CONDITION_INFIGHT) == FALSE) then
					doPlayerRemoveItem(cid, 8983, 1)
					setCreatureMaxHealth(cid, pa.hp)
					setCreatureMaxMana(cid, pa.mp)
					doCreatureAddHealth(cid, pa.hp)
					doCreatureAddMana(cid, pa.mp)
					doPlayerSetMaxCapacity(cid, pa.cap)
					doPlayerSetVocation(cid, 3)
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are now a paladin")
					doRemoveCreature(cid)
					db.executeQuery("UPDATE `players` SET `maglevel` = '1', `manaspent` = '0' WHERE `id` = " .. rookedGUID .. ";")
					db.executeQuery("UPDATE `player_skills` SET `value` = '10', `count` = '0' WHERE `player_id` = " .. rookedGUID .. " LIMIT 7;")
			else
					doCreatureSay(cid, "Masz Pz Ziam !", TALKTYPE_ORANGE_1)
				end
				else
					doPlayerSendTextMessage(cid,22,"Nie masz runy to zmiany profesji")
					doSendMagicEffect(getPlayerPosition(cid),4)
				end
			else
				doPlayerSendTextMessage(cid,22,"You dont have promotion")
				doSendMagicEffect(getPlayerPosition(cid),4)
			end
	end
if param == 'knight' then
			if proma == 1 then
				if getPlayerItemCount(cid,8983) >= 1 then
					if (getCreatureCondition(cid, CONDITION_INFIGHT) == FALSE) then
					doPlayerRemoveItem(cid, 8983, 1)
					setCreatureMaxHealth(cid, kn.hp)
					setCreatureMaxMana(cid, kn.mp)
					doCreatureAddHealth(cid, kn.hp)
					doCreatureAddMana(cid, kn.mp)
					doPlayerSetMaxCapacity(cid, kn.cap)
					doPlayerSetVocation(cid, 4)
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are now a knight")
					doRemoveCreature(cid)
					db.executeQuery("UPDATE `players` SET `maglevel` = '1', `manaspent` = '0' WHERE `id` = " .. rookedGUID .. ";")
					db.executeQuery("UPDATE `player_skills` SET `value` = '10', `count` = '0' WHERE `player_id` = " .. rookedGUID .. " LIMIT 7;")
				else
					doCreatureSay(cid, "Masz Pz Ziam !", TALKTYPE_ORANGE_1)
				end
				else
					doPlayerSendTextMessage(cid,22,"Nie masz runy to zmiany profesji")
					doSendMagicEffect(getPlayerPosition(cid),4)
				end
			else
				doPlayerSendTextMessage(cid,22,"You dont have promotion")
				doSendMagicEffect(getPlayerPosition(cid),4)
			end
	end
return true
end

My old work ;p
 
PHP:
################# SCRIPTED BY Bartastkd http://hellice.pl/ XP ####################

function onSay(cid, words, param, channel)

local config = {
sorcerer = {hp = 5, mp = 30, cap = 10},
druid = {hp = 5, mp = 30, cap = 10},
paladin = {hp = 10, mp = 15, cap = 20},
knight = {hp = 15, mp = 5, cap = 25}
   
}

local czas = 1 
local storage = 4544
local proma = getPlayerPromotionLevel(cid)
local rookedGUID = getPlayerGUID(cid)
local lvl = getPlayerLevel(cid)
local so = {hp = (config.sorcerer.hp * lvl) + 180, mp = (config.sorcerer.mp * lvl) + 35, cap = (config.sorcerer.cap * lvl) + 430}
local dr = {hp = (config.druid.hp * lvl) + 180, mp = (config.druid.mp * lvl) + 35, cap = (config.druid.cap * lvl) + 430}
local pa = {hp = (config.paladin.hp * lvl) + 180, mp = (config.paladin.mp * lvl) + 35, cap = (config.paladin.cap * lvl) + 430}
local kn = {hp = (config.knight.hp * lvl) + 180, mp = (config.knight.mp * lvl) + 35, cap = (config.knight.cap * lvl) + 430}

	if exhaustion.get(cid, storage) == FALSE then
		exhaustion.set(cid, storage, czas)
	else
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Musisz czekac " .. exhaustion.get(cid, storage) .. " sekund.") 
		return true
	end  
  
	if param == 'sorcerer' then
			if proma == 1 then
				if getPlayerItemCount(cid,8983) >= 1 then
                          		  if (getCreatureCondition(cid, CONDITION_INFIGHT) == FALSE) then
					doPlayerRemoveItem(cid, 8983, 1)
					setCreatureMaxHealth(cid, so.hp)
					setCreatureMaxMana(cid, so.mp)
					doCreatureAddHealth(cid, so.hp)
					doCreatureAddMana(cid, so.mp)
					doPlayerSetMaxCapacity(cid, so.cap)
					doPlayerSetVocation(cid, 1)	
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are now a sorcerer")
					doRemoveCreature(cid)
					db.executeQuery("UPDATE `players` SET `maglevel` = '1', `manaspent` = '0' WHERE `id` = " .. rookedGUID .. ";")
					db.executeQuery("UPDATE `player_skills` SET `value` = '10', `count` = '0' WHERE `player_id` = " .. rookedGUID .. " LIMIT 7;")
                     else
					doCreatureSay(cid, "Masz Pz Ziam !", TALKTYPE_ORANGE_1)
				end
				else
					doPlayerSendTextMessage(cid,22,"Nie masz runy to zmiany profesji")
					doSendMagicEffect(getPlayerPosition(cid),4)
				end
			else
				doPlayerSendTextMessage(cid,22,"You dont have promotion")
				doSendMagicEffect(getPlayerPosition(cid),4)
			end
	end

if param == 'druid' then
			if proma == 1 then
				if getPlayerItemCount(cid,8983) >= 1 then
                          		  if (getCreatureCondition(cid, CONDITION_INFIGHT) == FALSE) then
					doPlayerRemoveItem(cid, 8983, 1)
					setCreatureMaxHealth(cid, dr.hp)
					setCreatureMaxMana(cid, dr.mp)
					doCreatureAddHealth(cid, dr.hp)
					doCreatureAddMana(cid, dr.mp)
					doPlayerSetMaxCapacity(cid, dr.cap)
					doPlayerSetVocation(cid, 2)
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are now a druid")
					doRemoveCreature(cid)
					db.executeQuery("UPDATE `players` SET `maglevel` = '1', `manaspent` = '0' WHERE `id` = " .. rookedGUID .. ";")
					db.executeQuery("UPDATE `player_skills` SET `value` = '10', `count` = '0' WHERE `player_id` = " .. rookedGUID .. " LIMIT 7;")
			else
					doCreatureSay(cid, "Masz Pz Ziam !", TALKTYPE_ORANGE_1)
				end
				else
					doPlayerSendTextMessage(cid,22,"Nie masz runy to zmiany profesji")
					doSendMagicEffect(getPlayerPosition(cid),4)
				end
			else
				doPlayerSendTextMessage(cid,22,"You dont have promotion")
				doSendMagicEffect(getPlayerPosition(cid),4)
			end
	end
if param == 'paladin' then
			if proma == 1 then
				if getPlayerItemCount(cid,8983) >= 1 then
					if (getCreatureCondition(cid, CONDITION_INFIGHT) == FALSE) then
					doPlayerRemoveItem(cid, 8983, 1)
					setCreatureMaxHealth(cid, pa.hp)
					setCreatureMaxMana(cid, pa.mp)
					doCreatureAddHealth(cid, pa.hp)
					doCreatureAddMana(cid, pa.mp)
					doPlayerSetMaxCapacity(cid, pa.cap)
					doPlayerSetVocation(cid, 3)
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are now a paladin")
					doRemoveCreature(cid)
					db.executeQuery("UPDATE `players` SET `maglevel` = '1', `manaspent` = '0' WHERE `id` = " .. rookedGUID .. ";")
					db.executeQuery("UPDATE `player_skills` SET `value` = '10', `count` = '0' WHERE `player_id` = " .. rookedGUID .. " LIMIT 7;")
			else
					doCreatureSay(cid, "Masz Pz Ziam !", TALKTYPE_ORANGE_1)
				end
				else
					doPlayerSendTextMessage(cid,22,"Nie masz runy to zmiany profesji")
					doSendMagicEffect(getPlayerPosition(cid),4)
				end
			else
				doPlayerSendTextMessage(cid,22,"You dont have promotion")
				doSendMagicEffect(getPlayerPosition(cid),4)
			end
	end
if param == 'knight' then
			if proma == 1 then
				if getPlayerItemCount(cid,8983) >= 1 then
					if (getCreatureCondition(cid, CONDITION_INFIGHT) == FALSE) then
					doPlayerRemoveItem(cid, 8983, 1)
					setCreatureMaxHealth(cid, kn.hp)
					setCreatureMaxMana(cid, kn.mp)
					doCreatureAddHealth(cid, kn.hp)
					doCreatureAddMana(cid, kn.mp)
					doPlayerSetMaxCapacity(cid, kn.cap)
					doPlayerSetVocation(cid, 4)
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are now a knight")
					doRemoveCreature(cid)
					db.executeQuery("UPDATE `players` SET `maglevel` = '1', `manaspent` = '0' WHERE `id` = " .. rookedGUID .. ";")
					db.executeQuery("UPDATE `player_skills` SET `value` = '10', `count` = '0' WHERE `player_id` = " .. rookedGUID .. " LIMIT 7;")
				else
					doCreatureSay(cid, "Masz Pz Ziam !", TALKTYPE_ORANGE_1)
				end
				else
					doPlayerSendTextMessage(cid,22,"Nie masz runy to zmiany profesji")
					doSendMagicEffect(getPlayerPosition(cid),4)
				end
			else
				doPlayerSendTextMessage(cid,22,"You dont have promotion")
				doSendMagicEffect(getPlayerPosition(cid),4)
			end
	end
return true
end

My old work ;p



I like the way you used db.executeQuery. My first script looked structurally like yours. I just did some things differently.
 
Back
Top Bottom