How can I convert exp to percentage?
#1

PHP код:
forward PlayerCheck();
public 
PlayerCheck()
{
    static
        
str[128];
        
    foreach (new 
Player)
    {
        new 
exp_max 50 + (Player[playerid][Level] - 2) * 50 50;
        
        
format(strsizeof(str), "%d"PlayerInfo[i][pLevel]);
        
PlayerTextDrawSetString(ipTextDraws[i][4], str);
        
format(strsizeof(str), "(%d%c)"PlayerInfo[i][pExp], '%');
        
PlayerTextDrawSetString(ipTextDraws[i][3], str);
        
PlayerTextDrawTextSize(ipTextDraws[i][1], PlayerInfo[i][pExp]*1.0915.749994);  // max progress = 109.559906
        
        
PlayerTextDrawShow(ipTextDraws[i][1]);
        if(
PlayerInfo[i][pExp] >= exp_max)
        {
            
PlayerTextDrawTextSize(ipTextDraws[i][1], 0.015.749994);
            
PlayerTextDrawShow(ipTextDraws[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
Reply
#2

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
Reply
#3

Код:
float((PlayerInfo[i][pExp]/exp_max)*100);
And when formatting the string, replace '%d' with '%f.0'
Reply
#4

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(strsizeof(str), "(%f.0%c)"float((Player[i][Exp]/exp_max)*100), '%'); 
        
PlayerTextDrawSetString(iTDEditor_PTD[i][31], str); 
Reply
#5

Well....It's very difficult for me)))
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)