Lock cars for certain players?
#1

Alright, I already have the faction system in the server, it goes like Faction[playerid] [Whatever] So, I was wondering how do I make it so only certain factions can enter a vehicle? And if they are not in the faction for the vehicle it kicks them out
Reply
#2

pawn Код:
OnPlayerSpawn ( playerid )
{
  if ( Variable == 1 )
  {
    SetVehicleParamsForPlayer ( vehicleid , playerid , false , false );
  }
  else
  {
    SetVehicleParamsForPlayer ( vehicleid , playerid , false , true );
  }

  return 1;
}
Reply
#3

i think he want to kick the player from the vehicle if he is not in the desired faction
for example the car faction id is 4
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
      if(GetPlayerVehicleID(playerid) == 458) // this is to check if the player enter the desired vehicle IDyou can change the "458" by the real vehicle ID
      {
        if(PlayerInfo[playerid][pMember] == 4) // this is to check if the player is in the faction 4(you can change "4" by your desired faction id)
        {
          SendClientMessage(playerid, COLOR_YELLOW, "Welcome to your gang vehicle");
          return 1;
        }
        else
        {
          SendClientMessage(playerid, COLOR_LIGHTRED, "This vehicle is only for the faction id 4 memebers !");
          RemovePlayerFromVehicle(playerid);
        }
        return 1;
      }
    }
}
Reply
#4

For some reason, it is still not working... I want it to kick players out of vehicle 599, and I changed it to 599 but it still doesnt work, it lets the player go in....
Reply
#5

You are using the vehicle type id am I right? U want to kick players out of vehicle 599 (Police Ranger)?

There is your problem, you need another id...

To get this:
OnPlayerEnterVehicle
Код:
new string[128];
format(string,128,"vehicle id: %d",GetPlayerVehicleID(playerid));
SendClientMessage(playerid,yourcolor,string);
When you enter (or try to enter) a vehicle you will get the id (when it is 12, means that this is the 12th vehicle created in your server).
Delete the code when you no longer need it ofcourse.

Hope it helps

Grts Riz
Reply
#6

Now, its showing all the vehicle IDs as 0?
Reply
#7

K my bad, put the code in 'public OnPlayerStateChange()'

this would become
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate==PLAYER_STATE_DRIVER)
{
new string[128];
format(string,128,"vehicle id: %d",GetPlayerVehicleID(playerid));
SendClientMessage(playerid,yourcolor,string);
}
should be giving you the vehicle id('s) you need

Grts Riz
Reply
#8

Ok, I got the IDs and set the IDs, but for some reason it kicks the player out no matter what car he is in, or what faction... this is how it looks:



Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if(newstate == PLAYER_STATE_DRIVER)
	{
		if(GetPlayerVehicleID(playerid) == 65 || 66 || 67 || 68 || 69 || 70 || 71 || 72 || 73 || 74 || 75 || 76 || 77 || 78 || 79 || 80 || 81 || 82 || 83 || 84 || 85 || 86 && Faction[playerid] != 3)
		{
		SCM(playerid, COLOR_RED, "You are not a police officer!");
		new string[128];
		format(string,128,"vehicle id: %d",GetPlayerVehicleID(playerid));
		SendClientMessage(playerid,COLOR_RED,string);
		RemovePlayerFromVehicle(playerid);
		}
	}
	else if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER && GetPlayerVehicleID(playerid) == 65 || 66 || 67 || 68 || 69 || 70 || 71 || 72 || 73 || 74 || 75 || 76 || 77 || 78 || 79 || 80 || 81 || 82 || 83 || 84 || 85 || 86 && Faction[playerid] == 3)
	{
	  SCM(playerid, COLOR_WHITE, "Police Vehicle");
	}
	return 1;
}
Reply
#9

I think you have the wrong id's. 0-300 are like skins..
Reply
#10

Ummm no, those are the vehicle IDs I got in game....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)