Level question - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Level question (
/showthread.php?tid=658184)
Level question -
KinderClans - 26.08.2018
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?
Re: Level question -
Lokii - 26.08.2018
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(string, sizeof(str), "You need %d xp more to level up", GetLevelXP(Player[playerid][Level]+1)-Player[playerid][XP]);
return 1;
}
Re: Level question -
KinderClans - 26.08.2018
Yes but i need an example..
Re: Level question -
Shinja - 26.08.2018
I think Lokii told you everything, what example you want?
Re: Level question -
KinderClans - 26.08.2018
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.
Re: Level question -
CodeStyle175 - 26.08.2018
you could also create algorithm what counts xp from level.
Re: Level question -
KinderClans - 26.08.2018
What do you mean?
Re: Level question -
Dayrion - 26.08.2018
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:
u
34 = 10 + (4 * 34)
u
34 = 146
I hope I'm correct and you understood everything