Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Km/h functions
- #define FLOAT_INFINITY (Float:0x7F800000)
- stock Float:GetVehicleSpeedFromVelocity(Float:x, Float:y, Float:z)
- {
- return floatmul(VectorSize(x, y, z), 180.0);
- }
- stock Float:GetVehicleSpeed(vehicleid)
- {
- static
- Float:x,
- Float:y,
- Float:z;
- return GetVehicleVelocity(vehicleid, x, y, z)
- ? GetVehicleSpeedFromVelocity(x, y, z)
- : FLOAT_INFINITY;
- }
- stock SetVehicleSpeed(vehicleid, Float:speed)
- {
- new
- Float:x,
- Float:y,
- Float:z;
- if (GetVehicleVelocity(vehicleid, x, y, z))
- {
- new
- Float:angle;
- GetVehicleVelocity(vehicleid, x, y, z);
- GetVehicleZAngle(vehicleid, angle);
- speed = floatdiv(speed, 180.0);
- x = floatmul(speed, floatsin(-angle, degrees));
- y = floatmul(speed, floatcos(-angle, degrees));
- SetVehicleVelocity(vehicleid, x, y, z);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment