How to use GetVehicleVelocity
#1

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
Reply
#2

https://sampwiki.blast.hk/wiki/GetVehicleVelocity
Reply
#3

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!");

Reply
#4

//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?
Reply
#5

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);
Reply
#6

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


Forum Jump:


Users browsing this thread: 1 Guest(s)