Converting a float into an integer
#1

pawn Код:
forward UpdateSpeedo( );
public UpdateSpeedo ( )
{
    for( new u; u < MAX_PLAYERS; u ++ )
    {
        if( InCar [ u ] == true )
        {
            new
                Float:speed,
                str [ 64 ];
               
            speed = GetPlayerSpeed( u, false );
           
            format( str, 64, "~b~MPH: ~w~%02f", speed );
            PlayerTextDrawSetString( u, Speedo [ u ], str );
        }
    }
    return true;
}
pawn Код:
stock Float:GetPlayerSpeed(playerid, bool:KMH)
{
    new Float:Speed, Float:vX, Float:vY, Float:vZ;
    if(!IsPlayerInAnyVehicle(playerid)) GetPlayerVelocity(playerid, vX, vY, vZ);
    else GetVehicleVelocity(GetPlayerVehicleID(playerid), vX, vY, vZ);
    Speed = floatsqroot(((vX*vX)+(vY*vY))+(vZ*vZ));
    return KMH ? (Speed*100.0) : (Speed*62.1371);
}
But right now, it reads "MPH: 59.398217387218"

I would like it to just be 59. I tried %0.2f and it didn't work, so what do I do?
Reply


Messages In This Thread
Converting a float into an integer - by 2KY - 18.09.2012, 17:28
Re: Converting a float into an integer - by AtItsMax - 18.09.2012, 17:32
Re: Converting a float into an integer - by 2KY - 18.09.2012, 17:39
Re: Converting a float into an integer - by AtItsMax - 18.09.2012, 17:41
Re: Converting a float into an integer - by 2KY - 18.09.2012, 18:01
Re: Converting a float into an integer - by ViniBorn - 18.09.2012, 18:18
Re: Converting a float into an integer - by ReVo_ - 18.09.2012, 18:24

Forum Jump:


Users browsing this thread: 2 Guest(s)