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

TFS 1.X+ [tfs 1.2] getVocationClass

Solution
data/lib/core/vocation.lua

Add this:
LUA:
function Vocation.getClass(self)
	-- vocationId: className
	local classes = {
		1: 'Mage',
		2: 'Healer'
	}
	if classes[self:getId()] ~= nil then
		return classes[self:getId()]
	end
	return 'Unknown'
end

And extend the classes metatable with the class name for each vocation id.

Then you can do stuff like:
LUA:
player:getVocation():getClass() -- Mage

local myVocation = player:getVocation()
myVocation:getClass()

Alternatively?:
LUA:
function Vocation.getClass(vocationId)
	-- vocationId: className
	local classes = {
		1: 'Mage',
		2: 'Healer'
	}
	if classes[vocationId] ~= nil then
		return classes[vocationId]
	end
	return 'Unknown'
end

LUA:
local thisVocation = Vocation():getClass(...
data/lib/core/vocation.lua

Add this:
LUA:
function Vocation.getClass(self)
	-- vocationId: className
	local classes = {
		1: 'Mage',
		2: 'Healer'
	}
	if classes[self:getId()] ~= nil then
		return classes[self:getId()]
	end
	return 'Unknown'
end

And extend the classes metatable with the class name for each vocation id.

Then you can do stuff like:
LUA:
player:getVocation():getClass() -- Mage

local myVocation = player:getVocation()
myVocation:getClass()

Alternatively?:
LUA:
function Vocation.getClass(vocationId)
	-- vocationId: className
	local classes = {
		1: 'Mage',
		2: 'Healer'
	}
	if classes[vocationId] ~= nil then
		return classes[vocationId]
	end
	return 'Unknown'
end

LUA:
local thisVocation = Vocation():getClass( player:getVocation():getId() ) -- Mage
local healer = Vocation():getClass(2) -- Healer
myVocation:getClass()
 
Solution
Back
Top