• 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+ 1.3 Vocation have different life (change vocation script that change HP/MP)

roriscrave

Advanced OT User
Joined
Dec 7, 2011
Messages
1,188
Solutions
34
Reaction score
200
HI! In my game the vocations have life/mana gain different. exemple:
Healer on gain 1 lvl (gain 5 HP, 25MP).
Blocker on gain 1 lvl gain (30HP, 10 MP).
Rager on gain 1 lvl gain (25HP, 15MP).

I want to create a item that player can chage a vocation, how can i make it to set the new life/mana at this player?
 
Solution
player need to be kicked for this action?
Yes.
Alternatively, you could try this:
Lua:
local vocs = {
    ['healer'] = {healthmax = 5, manamax = 25}
}

local voc = voc['healer']

player:setMaxHealth(voc.healthmax)
player:addHealth(voc.healthmax)
player:setMaxMana(voc.manamax)
player:addMana(voc.manamax)
player:save()
But I think it's safer to do this using db queries to avoid any trouble.
Example:

Lua:
local vocs = {
    ['healer'] = {healthmax = 5, health = 5, manamax = 25, mana = 25}
}

local voc = voc['healer']

for k, v in pairs(voc) do
    string.format('ALTER TABLE `players` SET `%s` = %d WHERE `id` = %d;', key, val, player:getGuid())
end
 
Example:

Lua:
local vocs = {
    ['healer'] = {healthmax = 5, health = 5, manamax = 25, mana = 25}
}

local voc = voc['healer']

for k, v in pairs(voc) do
    string.format('ALTER TABLE `players` SET `%s` = %d WHERE `id` = %d;', key, val, player:getGuid())
end
player need to be kicked for this action?
exemple, need to add player:remove(), before:
Code:
 string.format('ALTER TABLE `players` SET `%s` = %d WHERE `id` = %d;', key, val, player:getGuid())
?
 
player need to be kicked for this action?
Yes.
Alternatively, you could try this:
Lua:
local vocs = {
    ['healer'] = {healthmax = 5, manamax = 25}
}

local voc = voc['healer']

player:setMaxHealth(voc.healthmax)
player:addHealth(voc.healthmax)
player:setMaxMana(voc.manamax)
player:addMana(voc.manamax)
player:save()
But I think it's safer to do this using db queries to avoid any trouble.
 
Solution
Yes.
Alternatively, you could try this:
Lua:
local vocs = {
    ['healer'] = {healthmax = 5, manamax = 25}
}

local voc = voc['healer']

player:setMaxHealth(voc.healthmax)
player:addHealth(voc.healthmax)
player:setMaxMana(voc.manamax)
player:addMana(voc.manamax)
player:save()
But I think it's safer to do this using db queries to avoid any trouble.
thx i'll try and back with answer
 
Yes.
Alternatively, you could try this:
Lua:
local vocs = {
    ['healer'] = {healthmax = 5, manamax = 25}
}

local voc = voc['healer']

player:setMaxHealth(voc.healthmax)
player:addHealth(voc.healthmax)
player:setMaxMana(voc.manamax)
player:addMana(voc.manamax)
player:save()
But I think it's safer to do this using db queries to avoid any trouble.
bro it worked fine, whitout need to logout the player.
do u think can i get a truble using it withou logou?
 
Back
Top