SA-MP Forums Archive
vehicle speed not showing - 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)
+--- Thread: vehicle speed not showing (/showthread.php?tid=581987)



vehicle speed not showing - alexanderjb918 - 17.07.2015

Alright so I have made a vradar but it does not display the speed of the vehicle in front and the model that it is, it does show the textdraws tho.

Код:
     new string[128], vehicleid;
     vehicleid = GetClosestVehicle(playerid, 20);
     TextDrawShowForPlayer(playerid, RadarHud);
     TextDrawShowForPlayer(playerid, RadarHud1);
     // Vehicle Speed
     new speed = GetVehicleSpeed(vehicleid, 20);
     format(string, sizeof(string), "Speed: %d KM/H", speed);
     TextDrawSetString(RadarHud2, string);
     TextDrawShowForPlayer(playerid, RadarHud2);
     // Vehicle Model
     new vehmd = GetVehicleModel(vehicleid);
     format(string, sizeof(string), "Vehicle: %s", RVN(vehmd));
     TextDrawSetString(RadarHud3, string);
     TextDrawShowForPlayer(playerid, RadarHud3);



Re: vehicle speed not showing - Trucido - 17.07.2015

Код:
stock GetVehicleSpeed(vehicle) {
	if(IsVehicleSpawned(vehicle)) {
		new Float:X,
		    Float:Y,
		    Float:Z;

	    GetVehicleVelocity(vehicle, X, Y, Z);
		return floatround((floatsqroot(((X * X) + (Y * Y)) + (Z * Z)) * 100) * 1.6);
	}
	
	return 0;
}



Re: vehicle speed not showing - [KHK]Khalid - 17.07.2015

Where is that code placed?


Re: vehicle speed not showing - alexanderjb918 - 17.07.2015

in a CMD:vradar


Re: vehicle speed not showing - [KHK]Khalid - 17.07.2015

Well, I think you have to place it in a repeatedly called timer to show correct speed because speed changes very frequently. Search for speedometer scripts and see how they're done internally, understand the basics and then fix your mistakes!