• 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.3 Minimum level

Adorius Black

Advanced OT User
Joined
Mar 31, 2020
Messages
309
Solutions
3
Reaction score
181
Hi. Know anybody how to add function minimum level please? When you die at 13lvl you will not lose expirience but when you are higher lvl than 13 you lose expirience
Like noobwar system.
 
Solution
in player events. on experience loss if level <=13 then return 0.

Code:
function Player:onLoseExperience(exp)
    if self:getLevel() <= 13 then
        return 0
    else
        return exp
    end
end
Maybe add bless onlogin? to players <= 13, You can add and try this in your login.lua
Lua:
    if player:getLevel() <= 13 and not player:hasBlessing(1) then
        for b = 1, 5 do
            player:addBlessing(b)
        end
    return true
    end
Edited it, First one was for older TFS version now its supposed to work.
 
Maybe add bless onlogin? to players <= 13, You can add and try this in your login.lua
Lua:
    if player:getLevel() <= 13 and not player:hasBlessing(1) then
        for b = 1, 5 do
            player:addBlessing(b)
        end
    return true
    end
Edited it, First one was for older TFS version now its supposed to work.
it not work I dead and i am 12 lvl now.
 
Create a new script and add this to it.
Lua:
local freeBlessMaxLevel = 13  
function onLogin(player)
    if player:getLevel() <= freeBlessMaxLevel and not player:hasBlessing(1) then
        for b = 1, 5 do
            player:addBlessing(b)
        end
        player:say("You got free bless, because your level lower than ".. freeBlessMaxLevel .."", TALKTYPE_MONSTER_SAY)
        player:getPosition():sendMagicEffect(CONST_ME_HOLYDAMAGE)

        elseif player:hasBlessing(1) then
            player:say("You are blessed!", TALKTYPE_MONSTER_SAY)
        else
            player:say("You are not blessed.", TALKTYPE_MONSTER_SAY)
    end
    return true
end
then add this to your creaturescripts.xml
XML:
<event type="login" name="Lowlevelbless" script="Lowlevelbless.lua" />
and register it in your login.lua
Lua:
player:registerEvent("Lowlevelbless")
You can remove the player:say if you don't want any message to appear to players.
 
Create a new script and add this to it.
Lua:
local freeBlessMaxLevel = 13 
function onLogin(player)
    if player:getLevel() <= freeBlessMaxLevel and not player:hasBlessing(1) then
        for b = 1, 5 do
            player:addBlessing(b)
        end
        player:say("You got free bless, because your level lower than ".. freeBlessMaxLevel .."", TALKTYPE_MONSTER_SAY)
        player:getPosition():sendMagicEffect(CONST_ME_HOLYDAMAGE)

        elseif player:hasBlessing(1) then
            player:say("You are blessed!", TALKTYPE_MONSTER_SAY)
        else
            player:say("You are not blessed.", TALKTYPE_MONSTER_SAY)
    end
    return true
end
then add this to your creaturescripts.xml
XML:
<event type="login" name="Lowlevelbless" script="Lowlevelbless.lua" />
and register it in your login.lua
Lua:
player:registerEvent("Lowlevelbless")
You can remove the player:say if you don't want any message to appear to players.
but its only bless ye? I need lose 0 expirience when player is 13 lvl
 
There are probably at least a few ways to do this. One way is to use onLogin and add exp to the player if they are less then level 13. Do you care about preventing skill lose? You could use onPrepareDeath check the player's level, when they are level 13 add HP and teleport them to temple thus preventing their death.

Look at add_skill.lua talkaction for an example of how to add exp. Look at a pvp arena script for using onPrepareDeath to heal and teleport the player.
 
I dont care about skills. I care about level. I say example: When you create account, you are automatic 13lvl. World is PVP Enfo so you gain exp on player death. You also get item when you kill player as reward. for example gold coin. You can change 100 gold coins for 25 eggs in NPC every Egg give you 300exp. so you get exp by killing people and by buying eggs. but you create character with level 13 and this is minimum level. When you die with new (13lvl) character you will not lose exp. I dont care about skills. It is just prevent that people cant be less lvl than 13 but when you are lvl for example 16 then you lose exp like in normal game.
 
in player events. on experience loss if level <=13 then return 0.

Code:
function Player:onLoseExperience(exp)
    if self:getLevel() <= 13 then
        return 0
    else
        return exp
    end
end
 
Last edited:
Solution
in player events. on experience loss if level <=13 then return 0.

Code:
function Player:onLoseExperience(exp)
    if player:getLevel() <= 13 then
        return 0
    else
        return exp
    end
end
No work.
I register it events.xml
Lua:
   <event class="Player" method="onLoseExperience" enabled="1" />
then scripts/player.lua
Lua:
function Player:onLoseExperience(exp)
    if player:getLevel() <= 13 then
        return 0
    else
        return exp
    end
end

And i have this error on line
Lua:
function Player:onLoseExperience(exp)
adqdq.png
 
Last edited:
My TFS 1.x release The Forgotten War Server has this built in with easy configuration etc.
You can add the following to your login.lua though:

Lua:
        if player:getLevel() < 13 then
            player:addExperience(getExpForLevel(13) - player:getExperience())
        end
this look good but there is only datapack and configs. I compiled TFS what is in your post but it doesnt work with your datapack
Post automatically merged:

sorry. self not player.
no work
 
this look good but there is only datapack and configs. I compiled TFS what is in your post but it doesnt work with your datapack
Post automatically merged:


no work
how doesn't it work? What error do you get.
If the player is level 13 or under it won't lose any experience.

Lua:
return (self:getLevel() <= 50 and 0 or exp)
just tested this and it stops level 50s losing experience.
 
how doesn't it work? What error do you get.
If the player is level 13 or under it won't lose any experience.

Lua:
return (self:getLevel() <= 50 and 0 or exp)
just tested this and it stops level 50s losing experience.
ah sorry. yes it works :D i was level 12 and i was just looking that after dead it didnt bring me level 13 :D but it realy works :D when i am =>13 i dont lose expirience and when i am 14 and more i lost :D thank you very much :)
 
Guys, i've tried:

Lua:
function Player:onLoseExperience(exp)
    if player:getLevel() <= 75 then
        return 0
    else
        return exp
    end
end

Code:
function Player:onLoseExperience(exp)
        return (self:getLevel() <= 75 and 0 or exp)
    end

Code:
function Player:onLoseExperience(exp)
        return (player:getLevel() <= 75 and 0 or exp)
    end

Lua:
function Player:onLoseExperience(exp)
    if player:getLevel() <= 75 then
        return (self:getLevel() <= 75 and 0 or exp)
    else
        return exp
    end
end


none of those worked, my events.xml has the function enabled:
Code:
    <event class="Player" method="onLoseExperience" enabled="1" />
 
Last edited:
Back
Top