You don't have to check if the player is in a vehicle. It probably does work when you make a COMMAND such as /gate? I suppose it works when inside a vehicle else you are doing something wrong.
I have something like this:
pawn Код:
CMD:gate(playerid, params[])
{
new aName[MAX_PLAYER_NAME]; // Getting names to use in a /me command
GetPlayerName(playerid, aName, MAX_PLAYER_NAME);
if(IsPlayerInRangeOfPoint(playerid, 10, 1879.6033,-2510.2000,13.5547)) // Is he in range of the point
{
if(PlayerInfo[playerid][pTeam] == 7 || PlayerInfo[playerid][pTeam] == 8) // Can be whatever you want I use it to check if someone is in a specific team.
{
if(trainingOpen == false) //Defined if my gate is open or closed
{
MoveObject(traininggate, 1870.6999500,-2510.6001000,14.2000000, 1.5);
new string[128];
format(string, sizeof(string), "%s uses their remote to open the gate", aName);
SendClientMessage(playerid, COLOR_PURPLE, string);
trainingOpen = true;
}
else if(trainingOpen == true)
{
MoveObject(traininggate, 1879.4000200,-2510.6001000,14.2000000, 1.5);
new string[128];
format(string, sizeof(string), "%s uses their remote to close the gate", aName);
SendClientMessage(playerid, COLOR_PURPLE, string);
trainingOpen = false;
}
}
else
{
new string[128];
format(string, sizeof(string), ""COL_RED"ERROR: "COL_WHITE"You need to be in the Fire or Medical Department to use this gate!");
SendClientMessage(playerid, -1, string);
}
}
else
{
new string[128];
format(string, sizeof(string), ""COL_RED"ERROR: "COL_WHITE"You are not near any gate.");
SendClientMessage(playerid, -1, string);
}
return 1;
}
hope this helps for a bit.