First you gotta make them
Код:
new CAdmin[7]; //Top of the script. Make sure you define the number of the cars. Dont forget 0 counts as number too.
//PLACE THIS UNDER ONGAMEMODEINIT
CAdmin[0] = AddStaticVehicleEx(405,-2036.5665,-123.5742,34.9100,180.4638,1,1,1800); //Change into your positions
CAdmin[1] = AddStaticVehicleEx(405,-2033.5212,-122.9200,34.9033,178.2843,1,1,1800);
CAdmin[2] = AddStaticVehicleEx(405,-2030.0134,-123.4365,34.9096,179.7268,1,1,1800);
CAdmin[3] = AddStaticVehicleEx(405,-2026.8402,-123.3068,34.9058,179.8116,1,1,1800);
CAdmin[4] = AddStaticVehicleEx(405,-2022.3026,-124.1238,34.9183,177.6386,1,1,1800);
CAdmin[5] = AddStaticVehicleEx(405,-2018.6248,-123.9074,34.9285,179.4833,1,1,1800);
CAdmin[6] = AddStaticVehicleEx(405,-2021.2585,-130.0021,34.9722,88.3122,1,1,1800);
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
new CarCheck = GetPlayerVehicleID(playerid);
for(new i = 0; i < sizeof(CAdmin); i++) /*loop for all CAdmin*/
{
if(CarCheck == CAdmin[i])
{
if(IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, COLOR_YELLOW, "Welcome into the administrator vehicle!");
return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED, "<!>You are not an admin!");
RemovePlayerFromVehicle(playerid);
return 1;
}
}
}
}
return 1;
}
OnPlayerStateChange will detect when they are actualy sitting inside the vehicle. If you use OnPlayerEnterVehicle it wont be so effective.