SA-MP Forums Archive
I have setvehiclespeed function, how can I make getvehiclespeed using similiar setup? - 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: I have setvehiclespeed function, how can I make getvehiclespeed using similiar setup? (/showthread.php?tid=634862)



I have setvehiclespeed function, how can I make getvehiclespeed using similiar setup? - Saddin - 27.05.2017

Here is my SetVehicleSpeed function:

Код:
stock SetVehicleSpeed(vehicleid, Float:speed)
{
	new Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2, Float:a;
	GetVehicleVelocity(vehicleid, x1, y1, z1);
	GetVehiclePos(vehicleid, x2, y2, z2);
	GetVehicleZAngle(vehicleid, a); a = 360 - a;
	x1 = (floatsin(a, degrees) * (speed/100) + floatcos(a, degrees) * 0 + x2) - x2;
	y1 = (floatcos(a, degrees) * (speed/100) + floatsin(a, degrees) * 0 + y2) - y2;
	SetVehicleVelocity(vehicleid, x1, y1, z1);
}
Could someone help me and make GetVehicleSpeed function with similiar setup and close values?


Re: I have setvehiclespeed function, how can I make getvehiclespeed using similiar setup? - FaLLenGirL - 29.05.2017

PHP код:
GetVehicleSpeed(vehicleid)
{
    new 
Float:VxFloat:VyFloat:Vz;
    
GetVehicleVelocity(vehicleidVxVyVz);
    new 
Float:rtn;
    
rtn floatsqroot(floatpower(Vx*100,2) + floatpower(Vy*100,2));
    
rtn floatsqroot(floatpower(rtn,2) + floatpower(Vz*100,2));
    return 
floatround(rtn);

Maybe this will help you.