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

Lua [TFS 0.4] Don't lose skills for "X" vocations

boxxer321

Active Member
Joined
Nov 5, 2011
Messages
106
Reaction score
34
hey, how are you guys?

so, I was in need of a script in which certain vocations would not lose skills when they died, however, continue to lose experience ....

is it possible to do that?
 
Solution
E
i tried this and work it
Lua:
local vocationIDS = {13, 14, 15, 16}
function onDeath(cid, corpse, deathList)
    if isInArray(vocationIDS, getPlayerVocation(cid)) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_SKILLS, 0)
        doPlayerSetLossPercent(cid, PLAYERLOSS_MANA, 0)
    end
    return true
end
now i need one to not gain more skills in these vocations haaha can u help me?
yes, add to login.lua

Lua:
local vocationIDS = {13, 14, 15, 16}
if isInArray(vocationIDS, getPlayerVocation(cid)) then
    doPlayerSetRate(cid, SKILL_FIST, 0)
    doPlayerSetRate(cid, SKILL_CLUB, 0)
    doPlayerSetRate(cid, SKILL_SWORD, 0)
    doPlayerSetRate(cid, SKILL_AXE, 0)
    doPlayerSetRate(cid, SKILL_DISTANCE, 0)
    doPlayerSetRate(cid...
probably look in player.cpp, there is a Player::death function there that has different codes for skills, experience, etc...
You might want to do a "check" to see if the person is of a certain vocation, and if so, not lose any skill
 
Just create a Lua script here data\creaturescripts\scripts and name it whatever you want then add this to it and change yourvocationid to the id of your vocation.
Lua:
function onDeath(cid, corpse, deathList)
if getPlayerVocation(cid) == yourvocationid then
doPlayerSetLossPercent(cid, PLAYERLOSS_SKILLS, 0)
doPlayerSetLossPercent(cid, PLAYERLOSS_MAGIC, 0)
end
return true
end
then register it here data\creaturescripts\creaturescripts.xml like this and change Yourscriptname to your Lua script name.
XML:
<event type="death" name="PreventSkillloss" event="script" value="Yourscriptname.lua"/>
then add it here data\creaturescripts\scripts\login.lua like this
Lua:
registerCreatureEvent(cid, "PreventSkillloss")
 
Just create a Lua script here data\creaturescripts\scripts and name it whatever you want then add this to it and change yourvocationid to the id of your vocation.
Lua:
function onDeath(cid, corpse, deathList)
if getPlayerVocation(cid) == yourvocationid then
doPlayerSetLossPercent(cid, PLAYERLOSS_SKILLS, 0)
doPlayerSetLossPercent(cid, PLAYERLOSS_MAGIC, 0)
end
return true
end
then register it here data\creaturescripts\creaturescripts.xml like this and change Yourscriptname to your Lua script name.
XML:
<event type="death" name="PreventSkillloss" event="script" value="Yourscriptname.lua"/>
then add it here data\creaturescripts\scripts\login.lua like this
Lua:
registerCreatureEvent(cid, "PreventSkillloss")

and if i want to add more vocation i need to do this?

function onDeath(cid, corpse, deathList)
if getPlayerVocation(cid) >= 5 and getPlayerVocation(cid) <= 9 then
doPlayerSetLossPercent(cid, PLAYERLOSS_SKILLS, 0)
doPlayerSetLossPercent(cid, PLAYERLOSS_MAGIC, 0)
end
return true
end
 
Yeah like this, also if you don't need to use any Lua script you can instert SQL query like this one but your server should be offline when inserting the query so it applies for every player.
SQL:
UPDATE `players` SET `loss_skills` = 0 WHERE 'vocation' = 'vocation_id_here';
 
Just create a Lua script here data\creaturescripts\scripts and name it whatever you want then add this to it and change yourvocationid to the id of your vocation.
Lua:
function onDeath(cid, corpse, deathList)
if getPlayerVocation(cid) == yourvocationid then
doPlayerSetLossPercent(cid, PLAYERLOSS_SKILLS, 0)
doPlayerSetLossPercent(cid, PLAYERLOSS_MAGIC, 0)
end
return true
end
then register it here data\creaturescripts\creaturescripts.xml like this and change Yourscriptname to your Lua script name.
XML:
<event type="death" name="PreventSkillloss" event="script" value="Yourscriptname.lua"/>
then add it here data\creaturescripts\scripts\login.lua like this
Lua:
registerCreatureEvent(cid, "PreventSkillloss")

this is happening, the player is dying and has 0 health, mana etc.
Sem título.png
 
I can't understand what you mean with this screenshot? He died so OFC he'll have 0 health/mana
 
You are using Lua script or SQL query one? Does it happen only to the vocations you added on script? or every vocation?
 
You are using Lua script or SQL query one? Does it happen only to the vocations you added on script? or every vocation?
im using the lua script.... the SQL query I tested and it didn't work, the character with the vocation continued to lose his skills ...
this happen only to the vocations i added on script
 
remove the return true and retry, If it didn't work post here how your final script looks like.
 
remove the return true and retry, If it didn't work post here how your final script looks like.
did not work :(
Lua:
function onDeath(cid, corpse, deathList)
if getPlayerVocation(cid) >= 13 and getPlayerVocation(cid) <= 16 then
doPlayerSetLossPercent(cid, PLAYERLOSS_SKILLS, 0)
doPlayerSetLossPercent(cid, PLAYERLOSS_MAGIC, 0)
end
end
 
did not work :(
Lua:
function onDeath(cid, corpse, deathList)
if getPlayerVocation(cid) >= 13 and getPlayerVocation(cid) <= 16 then
doPlayerSetLossPercent(cid, PLAYERLOSS_SKILLS, 0)
doPlayerSetLossPercent(cid, PLAYERLOSS_MAGIC, 0)
end
end
try using an onPrepareDeath instead
Lua:
local vocationIDS = {5, 6, 7}
function onPrepareDeath(cid, deathList)
    if isInArray(vocationIDS, getPlayerVocation(cid)) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_SKILLS, 0)
        doPlayerSetLossPercent(cid, PLAYERLOSS_MAGIC, 0)
    end
    return true
end


btw there is really no need to add all this, you could just add the following to your onLogin script and it should work:

Lua:
    if isInArray({5, 6, 7}, getPlayerVocation(cid)) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_SKILLS, 0)
        doPlayerSetLossPercent(cid, PLAYERLOSS_MAGIC, 0)
    end
 
try using an onPrepareDeath instead
Lua:
local vocationIDS = {5, 6, 7}
function onPrepareDeath(cid, deathList)
    if isInArray(vocationIDS, getPlayerVocation(cid)) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_SKILLS, 0)
        doPlayerSetLossPercent(cid, PLAYERLOSS_MAGIC, 0)
    end
    return true
end


btw there is really no need to add all this, you could just add the following to your onLogin script and it should work:

Lua:
    if isInArray({5, 6, 7}, getPlayerVocation(cid)) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_SKILLS, 0)
        doPlayerSetLossPercent(cid, PLAYERLOSS_MAGIC, 0)
    end

I tested with preparedeath and the character stayed alive, but with life at 45 and mana at 0 bugged ... the magic level bugged at 0, however, the skills, club were not lost ....
 
oh I found a new function (new to me since I don't use 0.4 xD)

just add this on login and should work:

Lua:
if isInArray({5, 6, 7}, getPlayerVocation(cid)) then
        doPlayerSetLossSkill(cid, false)
    end
 
oh I found a new function (new to me since I don't use 0.4 xD)

just add this on login and should work:

Lua:
if isInArray({5, 6, 7}, getPlayerVocation(cid)) then
        doPlayerSetLossSkill(cid, false)
    end

now i'm losing everything, as if there was no script ... and without errors on the console
 
Try to use the parameter skillloss="false" on the specified vocations in vocations.xml
 
Back
Top