SA-MP Forums Archive
How to get - 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: How to get (/showthread.php?tid=367385)



How to get - TaLhA XIV - 09.08.2012

Hello,
I wanted to ask that how can we get vehicle speed?((if is it GetVehicleVelocity,then I am really confuesd between GetVehicleVelocity(vehicleid,x,y,z).becozz I don't know how can I get vehicles speed in kilometers and miles. ))Please help.
ThAnKs!


Re: How to get.................. - Jstylezzz - 09.08.2012

pawn Код:
forward Float:GetVehicleSpeed(vehicleid,UseMPH = 0);
stock Float:GetVehicleSpeed(vehicleid,UseMPH = 0)
{
    new Float:speed_x,Float:speed_y,Float:speed_z,Float:temp_speed;
    GetVehicleVelocity(vehicleid,speed_x,speed_y,speed_z);
    if(UseMPH == 0)
    {
        temp_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*136.666667;
    } else {
        temp_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*85.4166672;
    }
    floatround(temp_speed,floatround_round);return temp_speed;
}
with this