02.10.2016, 11:21
The issue here is that you're using GetPlayerVehicleID instead of the vehicleid parameter provided in the callback header.
It helps to clear the player's animations as they attempt entry. With the code you provided it's still possible for anyone to enter the vehicle. If you're looking to lock the vehicle when a player in the wrong team approaches it, use OnVehicleStreamIn:
Also what is Car[TEAM_COP] being assigned to? You may be attempting to assign multiple vehicle IDs to it, e.g:
In this instance only the last created vehicle ID is assigned to that variable. Therefore this means only one vehicle is designated for TEAM_COP. Two dimensional arrays exist for this purpose:
It helps to clear the player's animations as they attempt entry. With the code you provided it's still possible for anyone to enter the vehicle. If you're looking to lock the vehicle when a player in the wrong team approaches it, use OnVehicleStreamIn:
pawn Код:
public OnVehicleStreamIn(vehicleid, forplayerid)
{
if(vehicleid == Car[TEAM_COP] && gTeam[playerid] != TEAM_COP)
{
SetVehicleParamsForPlayer(vehicleid, forplayerid, 0, 1);
}
}
pawn Код:
Car[TEAM_COP] = CreateVehicle(...);
Car[TEAM_COP] = CreateVehicle(...);
Car[TEAM_COP] = CreateVehicle(...);
pawn Код:
Car[TEAM_COP][0] = CreateVehicle(...);
Car[TEAM_COP][1] = CreateVehicle(...);
Car[TEAM_COP][2] = CreateVehicle(...);