How can I convert exp to percentage? -
zowzow - 21.11.2018
PHP код:
forward PlayerCheck();
public PlayerCheck()
{
static
str[128];
foreach (new i : Player)
{
new exp_max = 50 + (Player[playerid][Level] - 2) * 50 + 50;
format(str, sizeof(str), "%d", PlayerInfo[i][pLevel]);
PlayerTextDrawSetString(i, pTextDraws[i][4], str);
format(str, sizeof(str), "(%d%c)", PlayerInfo[i][pExp], '%');
PlayerTextDrawSetString(i, pTextDraws[i][3], str);
PlayerTextDrawTextSize(i, pTextDraws[i][1], PlayerInfo[i][pExp]*1.09, 15.749994); // max progress = 109.559906
PlayerTextDrawShow(i, pTextDraws[i][1]);
if(PlayerInfo[i][pExp] >= exp_max)
{
PlayerTextDrawTextSize(i, pTextDraws[i][1], 0.0, 15.749994);
PlayerTextDrawShow(i, pTextDraws[i][1]);
PlayerInfo[i][pLevel]++;
PlayerInfo[i][pExp] = 0;
}
}
return 1;
}
Here is the code
Level 1 = 50 exp and *2 after every next level
Re: How can I convert exp to percentage? -
PT - 21.11.2018
you just need to do some maths..
example:
100 EXP (max exp variable) = 100%
20 EXP = X
just convert that to code and you easly do that
Re: How can I convert exp to percentage? -
Joe Staff - 21.11.2018
Код:
float((PlayerInfo[i][pExp]/exp_max)*100);
And when formatting the string, replace '%d' with '%f.0'
Re: How can I convert exp to percentage? -
zowzow - 21.11.2018
Thanks you guys for help
But I still don't understand how to build the code like you said
This is stupid for me
I used this from joe staff and Its worked fine if my exp was max even over 50-100 value
example : max exp is 250 then I set it to 300 or 350 after that they show me 100% and reset to 0%
The problem is when my exp around 10/50 20/50 and they are not showing the real value Its always 0%
But 50/50 is 100% work fine
My English's really bad too
PHP код:
format(str, sizeof(str), "(%f.0%c)", float((Player[i][Exp]/exp_max)*100), '%');
PlayerTextDrawSetString(i, TDEditor_PTD[i][31], str);
Re: How can I convert exp to percentage? -
Cheryl666 - 21.11.2018
Well....It's very difficult for me)))