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

TalkAction Set player vocation to ...

Gelio

Lua PHP C++ programmer
Joined
Jun 13, 2008
Messages
61
Reaction score
4
Location
Poland, Lublin
Hello. Script sets player vocation to any you want. You need to say this:
/setVoc "Name of player,Voc
Voc can be:
Sorcerer
Druid
Paladin
Knight
Master Sorcerer
Elder Druid
Royal paladin
Elite Knight
promote
promote give player promotion if he/she is not promoted (if vocation is lower that 5)

Script:
data/talkactions/scripts/promote player.lua:
Code:
function onSay(cid, words, param)
local znajdz = string.find(param, ",")
local name = string.sub(param, 1, znajdz-1)
local profesja = string.sub(param, znajdz+1)
local player = getPlayerByName(name)
local jakiAccessMoze = 1

if (getPlayerAccess(cid) >= jakiAccessMoze) then
if isPlayer(player) then
	if (profesja == "Sorcerer") then
		doPlayerSetVocation(player,1)
	elseif (profesja == "Druid") then
		doPlayerSetVocation(player,2)
	elseif (profesja == "Paladin") then
		doPlayerSetVocation(player,3)
	elseif (prosefja == "Knight") then
		doPlayerSetVocation(player,4)
	elseif (profesja == "Master Sorcerer") then
		doPlayerSetVocation(player,5)
	elseif (profesja == "Elder Druid") then
		doPlayerSetVocation(player,6)
	elseif (profesja == "Royal Paladin") then
		doPlayerSetVocation(player,7)
	elseif (profesja == "Elite Knight") then
		doPlayerSetVocation(player,8)
	elseif (profesja == "promote") then
		if (getPlayerVocation(player) <= 4) then
		doPlayerSetVocation(player,getPlayerVocation(player)+4)
		else
		doPlayerSendCancel(cid,"Player ".. name .." is already promoted")
		end
	end
else
	doPlayerSendCancel(cid,"Player is offline")
end
else
	doPlayerSendCancel(cid,"You are not a gamemaster")
end
end
I'm polish and variables are with polish names. I will translate:
znajdz - find (it look for "," in param)
name - name of player (it is string from begin of param to ",")
profesja - vocation (it is string from "," to end)
jakiAccessMoze - which access can (player from that access can set somebody's vocation)
To talkactions.xml:
Code:
<talkaction words="/setVoc" script="promote player.lua" />
It run on TFS 0.2, 0.3 and on Devland (8.1)

I'm waiting for your comments.
Yours,
Gelio
 
How does it handle magic levels? What if you change a Sorc to a Pally.. Would the pally have like mg level 30?
 
In the latest TFS BETA2, there is a function for setting promotion = 2?
Because it doesnt works with vocation, it works with promotion.
 
this is pointless if it doesnt change the health, mana, cap, ml, skills...which is all possible, with a certain formula ;p
 
It only change vocation. It don't change hp, mana and others. It's my first script with multi-param variables :D

Yours,
Gelio
 
@up
It will be harder to make it change mana/hp with counting it from values in vocations.xml. But not impossible :D
 
you can reset mana,hp,and caps when resetting the vocation using negative values instead of positive ones

Getting the players level and for each level, reward player with like -5 hp, -30 mana, -10 caps per level

then set vocation
for each level give player +5 hp, +30 mana, +10 caps on new vocation

or something like that, it's not hard to do >.>..just finding the right functions takes some time
 
Umm... does lua even read xml files? I guess not :eek:

Make a formula for health, e.g:
Code:
local knightHealth = ((level - 8) * 15 + 185)

;o
 
hEY MAN...

I have a VIP system, with more eith vocations... how to me use this for my server????
 
Back
Top