Experience bar
#1

I have a problem with this exp bar created with textdraw. The bar is not precise, by this I mean that it does not increase depending on the variables of the player. There are also times where your exp is: "11/12" and the bar is not close to its full size (it is in the middle or simply lower). I have made several calculations but I can not achieve it.

PHP код:
new test PLAYER_LEVEL[playerid] * 12 //the exp increases depending on the player level
new Float:sizex 514.0 + (PLAYER_EXP[playerid] * 0.9);
PlayerTextDrawTextSize(playeridTD_HUD[playerid][4], sizex0.000000); //empty: 514, full: 604 (size x)
PlayerTextDrawShow(playeridTD_HUD[playerid][4]);
if(
PLAYER_EXP[playerid] >= test//If the current exp is equal to or greater than the one previously defined.
{
    
PLAYER_LEVEL[playerid] ++;
    
SendClientMessage(playerid, -1"new level");

Reply
#2

This include handles all this for you.
Reply
#3

I do not think this is recommended or constantly used. I have seen and downloaded several servers and in their game mode they use textdraw to create those bars (that's why I say that I do not think it's very used, I think they prefer to create textdraws for this).
Reply
#4

How do you think that includes creates those bars? Yeah, with textdraws ... It just does all the hard work for you, so you only have to use a few lines of code. You don't have to use it, I just recommend it. See a few pictures here.

EDIT:
Anyway, the calculation is wrong, here is the formula:
Код:
size = Xmin + (Xmax - Xmin)*(currentLevel/maxLevel)
Where Xmin is the x value for the empty bar, XMax is the x value for the full bar, currentLevel is the current level for that player and maxLevel is the maximum level a player can get.

EDIT2:
Oh wait, I think I understood wrong. My solution above displays the current level in the bar, not the experience of the current level. So this should be it:
Код:
size = Xmin + (Xmax - Xmin)*(currentXPForLevel/maxXPForLevel)
Where Xmin is the x value for the empty bar, XMax is the x value for the full bar, currentXPForLevel is the current experience for the current level for that player and maxXPForLevel is the maximum experience a player can get for the current level.
Reply
#5

The calculation you gave me is still not working.
Reply
#6

Well, if you're not going to provide any information about what numbers you plugged into the formula, how can people help you ...
Reply
#7

PHP код:
new testPLAYER_LEVEL[playerid] * 12;
new 
Float:size 514.0 + (604.0 514.0) * (PLAYER_EXP[playerid]/test); 
Reply
#8

Are you sure your 'test' variable is the actual maximum XP for that level? Because this is what you get when you use that:
Current level:Max XP per level:
11 * 12 = 12
22 * 12 = 24
33 * 12 = 36
44 * 12 = 48
55 * 12 = 60
66 * 12 = 72
77 * 12 = 84
88 * 12 = 96
99 * 12 = 108
1010 * 12 = 120
1111 * 12 = 132
1212 * 12 = 144
And so on ...
Reply
#9

Yes, because if you are level 1, then to go up to level 2 you need 12 of xp, and if you are level 2 you need 24 of xp to go up to level 3 and so on. Everything depends on the level of the player.

"PLAYER_LEVEL [playerid] * 12" is equal to 12 of "xp" needed to go up to level 2. In this case, the variable 'PLAYER_LEVEL [playerid]' of the player is '1' because it is his initial level.
Reply
#10

Quote:
Originally Posted by Volumen
Посмотреть сообщение
Yes, because if you are level 1, then to go up to level 2 you need 12 of xp, and if you are level 2 you need 24 of xp to go up to level 3 and so on. Everything depends on the level of the player.

"PLAYER_LEVEL [playerid] * 12" is equal to 12 of "xp" needed to go up to level 2. In this case, the variable 'PLAYER_LEVEL [playerid]' of the player is '1' because it is his initial level.
Then the formula I gave works exactly as I told you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)