Level question
#1

So, i made a simple level system for my server:

Player[playerid][Level].

I have a question, i wanna show a message like:

"You need 50 exp to level up at level %d (level number)".

I'm sure i need to do it with arrays, but how?
Reply
#2

just get next level required xp and sub the current player xp.

example from my old script

PHP код:
GetLevelXP(level)
{
    switch(
level)
    {
        case 
1: return 0;
        case 
2: return 51;
        case 
3: return 126;
        case 
4: return 351;
        case 
5: return 751;
        case 
6: return 2151;
        case 
7: return 5401;
        case 
8: return 9001;
        case 
9: return 15001;
        case 
10: return 30001;
        case 
11: return 60001;
        case 
12: return 97570;
        case 
13: return 135771;
        case 
14: return 180001;
        case 
15: return 350001;
    }
    return 
0;
}
CMD:nextlevel(playerid)
{
    new 
string[40];
    
format(stringsizeof(str), "You need %d xp more to level up"GetLevelXP(Player[playerid][Level]+1)-Player[playerid][XP]);
    return 
1;

Reply
#3

Yes but i need an example..
Reply
#4

I think Lokii told you everything, what example you want?
Reply
#5

Quote:
Originally Posted by Shinja
Посмотреть сообщение
I think Lokii told you everything, what example you want?
His message before was just "just get next level required xp and sub the current player xp." then he edited it after.
Reply
#6

you could also create algorithm what counts xp from level.
Reply
#7

What do you mean?
Reply
#8

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
What do you mean?
You need 4 experiencies to up at every level. We need to start with the level 0:
Lvl 0 need 10 (you can replace 10 by what you want, this is an example) xp and lvl 1 need 14xp (10+4).

You start at level 1.
To up lvl 2, you need 18 xp (+4)
To up lvl 3, you need 22 xp (+4)
To up lvl 4, you need 24 xp (+4)
That's called an arithmetic sum (https://en.wikipedia.org/wiki/Arithmetic_progression)

Let's say you need to know the amount of xp for the level 34:
Код:
un = u0 + rn
u34 = 10 + (4 * 34)
u34 = 146

I hope I'm correct and you understood everything
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)