Jump to content

Level system advanced


-Doc-

Recommended Posts

Posted
Hey guys i wanna make new level system. Can someone help? I want that my level system when level up to be 0. For example when i level up 799/800 and then 0/1200 how i can do that ? and look like this http://imgur.com/t4yqYHz Can anyone help? :)

try to do it by yourself and post your code here and we will help you.

  • 1 month later...
Posted
To save level and experience in account data

MySQL (save level and experience into a database).

setAccountData (save level and experience in account data).

Posted
I need a example how to make level system please just a example

I am not familiar with the sql funcions, i think you just retrive the data from sql data base, the current level and exp, for example you are level 7, and you have 200 exp. lvl 7 to lvl 8 needs 500 exp, so your position is 200 / 500. Now everytime you get exp you save it in sql database, and before that you do a calculation, see if the ammount of exp you got exceed the ammount needed to lvl up. For example you got 200 exp 500 - 200 = 300 ( the ammount of exp needed to lvl up) 300 - 200 = 100 so this havnt exceed the ammount of exp needed to lvl up. If you get 500 exp 500 - 300 = 200, the ammount of exp you got exceed by 200 of the ammount of exp you need. So you make this player lvl up and save it in database, and after lvl up add 200 to his current exp progress, e.g. now he is lvl 8 and he needs 800 to lvl up, now his pos is 200 / 800.

Posted
I need a example just a simple example ~_~

What you call an "example" is pretty much asking for a whole script. I doubt anyone will make it for free.

If you want basic Lua scripts, look around the wiki.

Posted
You need a example? why don't you download some level system resources from the community and see how they work?

^^^

this guy isn't looking for help, he is looking for scripts, please have this topic locked.

Posted

Server

function givePlayerXP ( source, valve ) 
    local finalXP = valve 
    local currXP = getElementData ( source, "xp" ) or 0  
    local level = getElementData ( source, "level" ) 
    local nextXP = 50*level 
    setElementData ( source, "xp", currXP + finalXP ) 
    if currXP+finalXP > nextXP then 
        setElementData ( source, "xp", 0 ) 
        setElementData ( source, "level", level + 1 ) 
        outputChatBox ("Rank up"..tostring(level+1), source, 255, 25, 0, true)) 
  
    end 
end 

give xp use: givePlayerXP (killer,10)

Client:

    local level = getElementData ( localPlayer, "level" ) 
    local xp = getElementData ( localPlayer, "xp" ) 
    dxDrawText ("Level: "..level, 15, y-50, 200, y, tocolor ( 100, 255, 100, 200 ), 1.1, "default-bold" ) 
    dxDrawText ("XP: "..xp.."/"..tostring(level*50), 15, y-25, 200, y, tocolor ( 100, 255, 100, 200 ), 1.02, "default-bold" ) 

I wore it once, do not remember the author's name only remember who posted on a Russian forum

Posted
But if i want change exp needed and max level?
local nextXP = 50*level 

This means 50 divided by the level you have. So increase the 50 if you want the player to require more xp for a level, or decrease it if you want to have less.

Posted
i wanna make it in tables and put in tables exp needed and make max level 100

Why don't you do it by yourself?

Just saying, you always ask people to do your work or you try to get help with scripts which you don't own, You will never learn if you keep doing like that.

Posted
But if i want change exp needed and max level?

Dude, you really need to do it on yourself, you can't always rely on other people, specially when you are developing a server

Posted
But if i want change exp needed and max level?

Dude, you really need to do it on yourself, you can't always rely on other people, specially when you are developing a server

Why do you need to go to every single topic like this, and tell people this? No offense.

Posted
But if i want change exp needed and max level?

Dude, you really need to do it on yourself, you can't always rely on other people, specially when you are developing a server

Why do you need to go to every single topic like this, and tell people this? No offense.

That's a hobby of some MTA forum members.

OT:

  
levels = { 
 {exp=100}, 
 {exp=250}, 
 {exp=500}, 
 {exp=600} 
} 
 maxlvl = 4 
    function givePlayerXP ( source, valve ) 
        local finalXP = valve 
        local currXP = getElementData ( source, "xp" ) or 0 
        local level = getElementData ( source, "level" ) or 1 
        local nextXP = levels[level].exp 
        
        if currXP+finalXP >= nextXP and maxlvl > level then 
            setElementData ( source, "xp", 0 ) 
            setElementData ( source, "level", level + 1 ) 
            outputChatBox ("Rank up"..tostring(level+1), source, 255, 25, 0, true)) 
       else 
            setElementData ( source, "xp", currXP + finalXP ) 
        end 
    end 
  

I used tables then I edited #Thug's function.

Change maxlvl, and don't forget to add levels into the table like what I did.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...