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



speed calc help - THE_KNOWN - 27.03.2011

Код:
	SetTimer("scalc",500,true);

forward scalc();
public scalc()
{
	for(new i;i<MAX_PLAYERS;i++)
	{
	    if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
	    {
	        new Float:p[3],Float:Speed;
	        GetVehicleVelocity(GetPlayerVehicleID(i), p[0], p[1], p[2]);
	        Speed = floatmul(floatsqroot(floatadd(floatadd(floatpower(p[0], 2), floatpower(p[1], 2)),  floatpower(p[2], 2))), 100.0);
			new Float:tmp = Speed / 1.6;
			new mph=floatround(tmp,floatround_round);
			new s[128];
			format(s,128,"Speed: %d MPH",mph);
			TextDrawSetString(speedtd[i],s);
		}
	}
	return 1;
}
the problem is it gets stuck after some time, after about 10 secs. any idea why?