Carfixing vehiclespeed -
thimo - 21.12.2010
i made a carfix command and i wanna know how to make it only work if vehicle is stopped but how? i cant find it
Re: Carfixing vehiclespeed -
DJDhan - 21.12.2010
You can use
GetVehicleVelocity function to find the x,y and z components of the velocity and check if they are zero or not.
Re: Carfixing vehiclespeed -
thimo - 21.12.2010
new Float:Velocity[3], output[80];
GetVehicleVelocity(GetPlayerVehicleID(playerid), Velocity[0], Velocity[0], Velocity[0]);
so like this? pls give a example!
Re: Carfixing vehiclespeed -
DJDhan - 21.12.2010
Under your carfix command:
Код:
new Float:Velocity[3];
GetVehicleVelocity(GetPlayerVehicleID(playerid), Velocity[0], Velocity[1], Velocity[2]);
if(Velocity[0] != 0 || Velocity[1] != 0 || Velocity[2] != 0) return SendClientMessage(playerid,0xffffffaa,"Your car needs to be stationary in order to use this command");
Gives you an idea.
Re: Carfixing vehiclespeed -
thimo - 21.12.2010
But now if i do it and it says im not stopped it doesnt checks anymore..
i want something like:
if the car isnt stopped send that message then check again if it's stopped if yes repair the car
Re: Carfixing vehiclespeed -
DJDhan - 21.12.2010
If you have a command like /fix, everytime the player enter the command, it will check if the vehicle is stationary. If you don't and have a checkpoint or are using IsPlayerInRangeOfPoint instead, you can use a timer.
EDIT:
This goes under OnPlayerCommandText callback:
Код:
if(!strcmp(cmdtext,"/repair",true,7))
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xffffffaa,"You need to be in a vehicle");
new Float:Velocity[3];
GetVehicleVelocity(GetPlayerVehicleID(playerid), Velocity[0], Velocity[1], Velocity[2]);
if(Velocity[0] != 0 || Velocity[1] != 0 || Velocity[2] != 0) return SendClientMessage(playerid,0xffffffaa,"Your car needs to be stationary in order to use this command");
RepairVehicle(GetPlayerVehicleID(playerid));
SendClientMessage(playerid,0xffffffaa,"Vehicle Repaired");
return 1;
}
Re: Carfixing vehiclespeed -
thimo - 21.12.2010
Example? i dont understand lol
EDIT!
EDIT!
EDIT!
EDIT!
EDIT!
But what you made doesnt re-check it what about that thing with the timer? :S
Re: Carfixing vehiclespeed -
DJDhan - 21.12.2010
You don't need a timer if you have command. And yes, it does check if the vehicle is static everytime you type in that command.
Re: Carfixing vehiclespeed -
thimo - 21.12.2010
Yes it does but i mean that you typ /carfix then sendclientmessage(playerid, COLOR_KGAG, "Stop vehicle first"); then it gotta check again in like 2 secs if its stopped if yes -> repairvehicle
Re: Carfixing vehiclespeed -
DJDhan - 21.12.2010
You can use
SetTimerEx for that. Just make a new function called Repair Vehicle and call this function using this timer. This timer code goes after the user gets a message "Your car needs to be stationary in order to use this command".