faction vehicles help
#1

Hi

I am trying to make this function so when a player enters a cop car, and they are not part of the police faction it will remove them from the car and tell them they are not part of that faction. But only if they are in the driver seat.

Here is my code:
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	new vehicleid = GetPlayerVehicleID(playerid);
	if(newstate == 2)
	{
		SetPlayerArmedWeapon(playerid, 0);
		if(IsLAPDVeh(vehicleid) && pInfo[playerid][pFaction] != 1)
		{
			RemovePlayerFromVehicle(playerid);
			SendClientMessage(playerid, COLOR_GREY, "You are not in the LAPD");
		}
		else if(IsLAFMDVeh(vehicleid) && pInfo[playerid][pFaction] != 2)
		{
			RemovePlayerFromVehicle(playerid);
			SendClientMessage(playerid, COLOR_GREY, "You are not in the LAFMD");
		}
        }
        return 1;
}

stock IsLAPDVeh(vehicleid)
{
	for(new i = 0; i < sizeof(LAPDVeh); ++i)
	{
		if(vehicleid == LAPDVeh[i]) return 1;
	}
	return 0;
}
This is under ongamemodeinit:
Код:
LAPDVeh[0] = AddStaticVehicleEx(596, 1602.8655, -1684.0818, 5.5351, 89.8200, -1, -1, 3000);
Reply
#2

Код:
	if(newstate == PLAYER_STATE_DRIVER && oldstate != PLAYER_STATE_DRIVER)
	{
         new vehicleid = GetPlayerVehicleID(playerid);
        else if(IsLAPDVeh(vehicleid) && PlayerInfo[playerid][pFaction] != 1)
	    {
            RemovePlayerFromVehicle(playerid);
		    SendClientMessage(playerid, COLOR_ORANGE, " You are not in LAPD faction.");
	    }
try it!
Reply
#3

Nope still same problem. They can get in and drive off even if they not LAPD
Reply
#4

Ok I got it working Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)