SA-MP Forums Archive
How to use GetVehicleVelocity - 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 use GetVehicleVelocity (/showthread.php?tid=598256)



How to use GetVehicleVelocity - NealPeteros - 10.01.2016

I don't want to add speed cameras but I have an alternate solution by getting the vehicle speed, if it goes up to 20kmh, the player's money will be deducted by 200. If possible, please help ASAP


Re: How to use GetVehicleVelocity - adithegman - 10.01.2016

https://sampwiki.blast.hk/wiki/GetVehicleVelocity


Re: How to use GetVehicleVelocity - Karan007 - 10.01.2016

Here is a simple example of it!

PHP код:
//Floats - variables
new FloatxFloat:yFloat:z;
//Get the vehicle speed/velocity
GetVehicleVelocity(GetPlayerVehicleID(playerid), xyz);
//Now checking the speeds
if(>= 200
//Removing $200 from his money & notifying him!
{
    
GivePlayerMoney(playerid, -200);
    
SendClientMessage(playerid, -1"[Speed Limit]: You have crossed the speed limite, therefore, you have been fined $200!");




Re: How to use GetVehicleVelocity - CodeStyle175 - 10.01.2016

//Floats - variables
new Float: x, Float:y, Float:z;
//Get the vehicle speed/velocity
GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z);
//Now checking the speeds
if(x >= 200)
//Removing $200 from his money & notifying him!
{
GivePlayerMoney(playerid, -200);
SendClientMessage(playerid, -1, "[Speed Limit]: You have crossed the speed limite, therefore, you have been fined $200!");
}

wtf that supposed to do?


Re: How to use GetVehicleVelocity - OwlIT - 10.01.2016

Quote:
Originally Posted by Karan007
Посмотреть сообщение
Here is a simple example of it!

PHP код:
//Floats - variables
new FloatxFloat:yFloat:z;
//Get the vehicle speed/velocity
GetVehicleVelocity(GetPlayerVehicleID(playerid), xyz);
//Now checking the speeds
if(>= 200
//Removing $200 from his money & notifying him!
{
    
GivePlayerMoney(playerid, -200);
    
SendClientMessage(playerid, -1"[Speed Limit]: You have crossed the speed limite, therefore, you have been fined $200!");

This is so wrong, listen to me NealPeteros if you want to get the speed of the vehicle you need GetVehicleVelocity function and a formula that converts the results of the previous function in a float number.

This formula is taken from Pottus:
Код:
new Float:vx, Float:vy, Float:vz, Float:vel;
vel = GetVehicleVelocity(GetPlayerVehicleID(playerid), vx, vy, vz);
vel = (floatsqroot(((vx*vx)+(vy*vy))+(vz*vz))* 181.5);



Re: How to use GetVehicleVelocity - NealPeteros - 11.01.2016

Please put the callbacks on where I will put the functions because its confusing me