I'd want to restrict police cars (id 598.) from all other factions but police. At the moment I've got 2 factions: civilians(pTeam[playerid] == team_civ) and cops (pTeam[playerid] == team_lspd). And I can't figure out how to remove player from a vehicle since the function RemovePlayerFromVehicle doesn't work in the callback OnPlayerEnterVehicle. So is there any way to do this?
|
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
new vehicle = GetPlayerVehicleID(playerid);
if(GetVehicleModel(vehicle) == 598)
{
if(pTeam[playerid] != team_lspd)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, 0xFFFFFFFF, "You're not a cop.");
return 1;
}
}
}
return 1;
}
public OnPlayerEnterVehicle(playerid,vehicleid,ispassenger)
{
if(!ispassenger && pTeam[playerid] != team_lspd && GetVehicleModel(vehicleid) == 598)
{
new Float:pos[3];
GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
SetPlayerPos(playerid,pos[0],pos[1],pos[2]);
SendClientMessage(playerid,-1,"This vehicle is owned by LSPD.");
}
return 1;
}
new lspdcar[3];
lspdcar[0] = CreateVehicle(..);
lspdcar[1] = CreateVehicle(..);
lspdcar[2] = CreateVehicle(..);
public OnPlayerEnterVehicle(playerid,vehicleid,ispassenger)
{
for(new i = 0; i < sizeof(lspdcar); i++)
{
if(vehicleid == lspdcar[i] && pTeam[playerid] != team_lspd)
{
new Float:pos[3];
GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
SetPlayerPos(playerid,pos[0],pos[1],pos[2]);
SendClientMessage(playerid,-1,"This vehicle is owned by LSPD.");
}
}
return 1
}