Its letting anyone drive the cars
#1

Hi,

I have a privatecars code, And its letting any team drive the sfpd cars,
It dosent say the message or kick them out the vehicle,

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
  new vehicleid = GetPlayerVehicleID(playerid);
  if(newstate == PLAYER_STATE_DRIVER && oldstate == PLAYER_STATE_ONFOOT)
  {
    if(vehicleid == cruiser1 || vehicleid == cruiser2 || vehicleid == cruiser3 || vehicleid == cruiser4 || vehicleid == cruiser5 || vehicleid == cruiser6 || vehicleid == cruiser7 || vehicleid == cruiser8)
    {
      if(gTeam[playerid] != TEAM_COP)
      {
        RemovePlayerFromVehicle(playerid);
        SendClientMessage(playerid, COLOR_RED, "This vehicle belongs to the San Fierro Police Department.");
      }
    }
   }
  return 1;
}
Reply
#2

I think it should be
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if(newstate == PLAYER_STATE_DRIVER && oldstate == PLAYER_STATE_ONFOOT)
	{
		new vehicleid = GetPlayerVehicleID(playerid);
		if(vehicleid == cruiser1 || vehicleid == cruiser2 || vehicleid == cruiser3 || vehicleid == cruiser4 || vehicleid == cruiser5 || vehicleid == cruiser6 || vehicleid == cruiser7 || vehicleid == cruiser8)
		{
			if(gTeam[playerid] != TEAM_COP)
			{
				RemovePlayerFromVehicle(playerid);
				SendClientMessage(playerid, COLOR_RED, "This vehicle belongs to the San Fierro Police Department.");
			}
		}
	}
	return 1;
}
Reply
#3

What's the difference?
You moved the vehicleid definition, so what?
Just do
pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
instead of
pawn Код:
if(newstate == PLAYER_STATE_DRIVER && oldstate == PLAYER_STATE_ONFOOT)
Oldstate could be something else :P
Reply
#4

Nope still lets me drive
Reply
#5

is TEAM_COP the same as 0? inwhich case everyone is that until you set it to something else.

#define TEAM_COP 0
#define TEAM_CIVI 1
public OnPlayerConnect(playerid)gTeam[playerid]=TEAM_CIVI;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)