SA-MP Forums Archive
anyone know how to make a speedo stable - 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: anyone know how to make a speedo stable (/showthread.php?tid=156749)



anyone know how to make a speedo stable - Kar - 24.06.2010

I AM NOT ASKING HOW TO MAKE A SPEEDO


but yet how to make it accurate. it make it go from 1,2,3,4,5,6,7,8,9,10 etc.. maybe if it skips a few numbers but like really accurate D:


Re: anyone know how to make a speedo stable - bigcomfycouch - 24.06.2010

Код:
GetPlayerSpeed(playerid)
{
	new Float:Vx, Float:Vy, Float:Vz;
	if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid), Vx, Vy, Vz);
	else GetPlayerVelocity(playerid, Vx, Vy, Vz);
	return floatround(floatabs((Vx*Vx) + (Vy*Vy) + (Vz*Vz)) * 100);
}

public OnPlayerUpdate(playerid)
{
	if(IsPlayerInAnyVehicle(playerid)) printf("%i", GetPlayerSpeed(playerid));
	return 1;
}
Adjust to a textdraw. However, updating a textdraw ~50 times a second might lag your server.


Re: anyone know how to make a speedo stable - Kar - 24.06.2010

example>?


Re: anyone know how to make a speedo stable - bigcomfycouch - 24.06.2010

Updating a speedometer 1000 times a second isn't very smart seeing as the client doesn't update with the server that quickly. If you insist on a fast timer, use OnPlayerUpdate like I posted before.


Re: anyone know how to make a speedo stable - Kar - 24.06.2010

[quote

[edit]

example>?
[/quote]


Re: anyone know how to make a speedo stable - Hiddos - 24.06.2010

Quote:
Originally Posted by big comfy couch
Код:
GetPlayerSpeed(playerid)
{
	new Float:Vx, Float:Vy, Float:Vz;
	if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid), Vx, Vy, Vz);
	else GetPlayerVelocity(playerid, Vx, Vy, Vz);
	return floatround(floatabs((Vx*Vx) + (Vy*Vy) + (Vz*Vz)) * 100);
}

public OnPlayerUpdate(playerid)
{
	if(IsPlayerInAnyVehicle(playerid)) printf("%i", GetPlayerSpeed(playerid));
	return 1;
}
Adjust to a textdraw. However, updating a textdraw ~50 times a second might lag your server.
22 times a second*, my most accurate test was 2179 times in 100 seconds.


Re: anyone know how to make a speedo stable - Kar - 24.06.2010

thx. so i just attach a textdraw to it. e.g showtextdrawforplayer etc etc.. under the onplayerupdate^