SA-MP Forums Archive
TextDrawSetString returns rubbish - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: TextDrawSetString returns rubbish (/showthread.php?tid=273900)



TextDrawSetString returns rubbish - red13 - 03.08.2011

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



Re: TextDrawSetString returns rubbish - MP2 - 03.08.2011

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


AW: TextDrawSetString returns rubbish - red13 - 03.08.2011

Код:
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