• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua [Avesta 7.4] Level reset if lvl <50

Demnish

Tibian Hero
Joined
Sep 28, 2011
Messages
401
Solutions
2
Reaction score
63
Location
Sweden
Simply,
if I get under lvl 50, my experience and level should be reset to 50 on login.
Exp for lvl 50 is "1,847,300" if it helps.


Here is the script im using, lvl.lua:
Code:
function onLogin(cid)
    if getPlayerLevel(cid) < 50 then
        doPlayerAddExperience(cid, (getExperienceForLevel(50) - getPlayerExperience(cid)))
    end
    return TRUE
end

Along with the creaturescripts.xml:
Code:
<?xml version="1.0"?>

<creaturescripts>
<event type="login" name="lvl" event="script" value="lvl.lua"/>
<event type="login" name="login" event="script" value="login.lua"/>
</creaturescripts>

And last, login.lua:
Code:
function onLogin(cid)
registerCreatureEvent(cid, "lvl")
    return 1
end


It feels like it should be working, but apparently there is something wrong, hopefully someone may see the problem, I do have sources if that can help.

Thanks in advance.
 
Last edited:
Try it:
Code:
function onAdvance(cid, skill, oldLevel, newLevel)
    if skill == SKILL_LEVEL and newLevel > 50 then
        return false
    end

    return true
end


_
Regards,
sn3ejk
 
Try this :D

Code:
function onLogin(cid)
    if getPlayerLevel(cid) < 130 then
        doPlayerAddExperience(cid, (getExperienceForLevel(130) - getPlayerExperience(cid)))
    end
    return TRUE
end
 
creaturescripts are in my first post, what do you mean with "login.lua" isnt that just an ordinary script, or is it actually necessary?
 
Login.lua is used to load the script when you login I think.

/creaturescripts/scripts/login.lua

and add this:

Code:
registerCreatureEvent(cid, "NAME HERE")

Change the NAME HERE to the name you call it in the creaturescripts.xml.
 
like this?

creaturescripts.xml
Code:
<?xml version="1.0"?>

<creaturescripts>
<event type="login" name="lvl" event="script" value="lvl.lua"/>
<event type="login" name="login" event="script" value="login.lua"/>
</creaturescripts>

lvl.lua
Code:
function onLogin(cid)
    if getPlayerLevel(cid) < 50 then
        doPlayerAddExperience(cid, (getExperienceForLevel(50) - getPlayerExperience(cid)))
    end
    return TRUE
end

login.lua
Code:
function onLogin(cid)
registerCreatureEvent(cid, "lvl")
    return 1
end

Cuz it didnt work. :/
 
Back
Top