SA-MP Forums Archive
Help - 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: Help (/showthread.php?tid=570237)



Help - Edw - 06.04.2015

I do not look correct health

I did a timer to run every second ..
SetTimer("System", 1000, true);


PHP код:
forward System( );
public 
System( )
{
    for(new 
0MAX_PLAYERSi++) {
        new 
FloathealthFloatarmour;
        
GetPlayerHealthihealth );
        
GetPlayerArmouriarmour );
        new 
hpstr50 ], apstr50 ];
        
formathpstr50"%d"health );
        
formatapstr50"%d"armour );
        
TextDrawSetStringHealth], hpstr );
        
TextDrawSetStringArmour], apstr ); }
    return 
1;




Re: Help - Prostilov - 06.04.2015

May the problem perhaps be that you define health and armour to be explicitly used as floats but you format them as doubles?


Re: Help - SilentSoul - 06.04.2015

Health, and armour are floats not integers.

pawn Код:
forward System( );
public System( )
{
    for(new i = 0; i < MAX_PLAYERS; i++) {
        new Float: health, Float: armour;
        GetPlayerHealth( i, health );
        GetPlayerArmour( i, armour );
        new hpstr[ 50 ], apstr[ 50 ];
        format( hpstr, 50, "%.0f", health );// %.0f is used to get the aprox. percentage like 100 health , %f will get the accurate health like 99.732 health
        format( apstr, 50, "%.0f", armour );// %f
        TextDrawSetString( Health[ i ], hpstr );
        TextDrawSetString( Armour[ i ], apstr ); }
    return 1;
}