TextDrawSetString returns rubbish
#1

I made a simple Speedmeter, but TextDrawSetString returns randomly a number. Only sometimes it writes the current Speed.

Код:
new msg[200];
format(msg,200,"Speed: %dkm/h",GetSpeed(playerid,true));
TextDrawSetString(TextDraws[5], msg);
SendClientMessage(playerid,0xFF0000FF,msg); <-- returns the right Speed every time
Reply
#2

Can you show GetSpeed? If it returns a float, you need to put %0.2f in the format message instead of %d.
Reply
#3

Код:
stock GetSpeed(playerid,bool:kmh) {
    new Float:x,Float:y,Float:z,Float:rtn;
    if(IsPlayerInAnyVehicle(playerid))
 GetVehicleVelocity(GetPlayerVehicleID(playerid),x,y,z); else GetPlayerVelocity(playerid,x,y,z);
    rtn = floatsqroot(x*x+y*y+z*z);
    return kmh?floatround(rtn * 100 * 1.61):floatround(rtn * 100);
}
If I use %f or %0.2f it only returns 0.00(00000)


Solved: I all players used the same variable for the text
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)