[Tutorial] Speedometer - 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: [Tutorial] Speedometer (
/showthread.php?tid=171898)
[Tutorial] Speedometer -
lukica - 28.08.2010
Before a year I`ve looking whole day to find some speedometer for my server... So i decided to give you one cool
URL: https://sampforum.blast.hk/showthread.php?tid=161275
Thanks to mckennie but there are guys that dont know how to use it so I make it easyer...
Lets start...
On top of the screen add this:
Code:
forward GetVehicleSpeed(vehicleid);
Put this in end of a script:
Code:
public GetVehicleSpeed(vehicleid) {
new Float:speed_x,Float:speed_y,Float:speed_z,Float:final_speed,final_speed_int;
if(vehicleid != 0) {
GetVehicleVelocity(vehicleid,speed_x,speed_y,speed_z);
final_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*136;
final_speed_int = floatround(final_speed,floatround_round);
return 1; }
return final_speed_int; }
So this is some kind of speedometer...you can use it simply like:
Code:
new Text:speedtext[MAX_PLAYERS];
public OnPlayerConnect(playerid) {
speedtext[playerid] = TextDrawCreate(510, 105, "~g~Speed~w~: 0 Km/h");
TextDrawFont(speedtext[playerid], 3);
TextDrawLetterSize(speedtext[playerid], 0.4, 1.4);
TextDrawSetOutline(speedtext[playerid], 1);
return 1; }
public OnPlayerStateChange(playerid, oldstate, newstate) {
new vid = GetPlayerVehicleID(playerid);
if(newstate == PLAYER_STATE_DRIVER) {
new string[256];
format(string,sizeof(string),"~g~Speed~w~: %d Km/h", GetVehicleSpeed(vid));
TextDrawSetString(speedtext[playerid], string);
TextDrawShowForPlayer(playerid, speedtext[playerid]);
}else if(newstate == PLAYER_STATE_ONFOOT) {
TextDrawHideForPlayer(playerid, speedtext[playerid]);
return 1; }
return 1; }
public OnPlayerDisconnect(playerid) {
TextDrawDestroy(speedtext[playerid]);
return 1; }
So this is it

...I hope this will help you

...
Sorry for bad english :S...
Re: [Tutorial] Speedometer -
[HiC]TheKiller - 28.08.2010
1. It should be in here
http://forum.sa-mp.com/forumdisplay.php?f=70
2. It looks the same as the other guys topic
3. You need to explain it to be a tut.