SA-MP Forums Archive
Its letting anyone drive the cars - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Its letting anyone drive the cars (/showthread.php?tid=115403)



Its letting anyone drive the cars - JoeDaDude - 23.12.2009

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;
}



Re: Its letting anyone drive the cars - Jefff - 23.12.2009

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;
}



Re: Its letting anyone drive the cars - LarzI - 23.12.2009

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


Re: Its letting anyone drive the cars - JoeDaDude - 23.12.2009

Nope still lets me drive


Re: Its letting anyone drive the cars - Joe Staff - 23.12.2009

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;