Posts: 108
Threads: 21
Joined: Aug 2016
Could someone tell me why this specific vehicle door isn't locking? it's my first time locking vehicle doors though.
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
new veh = GetPlayerVehicleID(playerid);
if(veh == Car[TEAM_COP] && gTeam[playerid] != TEAM_COP)
{
SetVehicleParamsForPlayer(veh, playerid, 0, 1);
SendClientMessage(playerid, -1, "Cops Only!.");
}
return 1;
}
Posts: 11,827
Threads: 33
Joined: Dec 2011
Reputation:
0
OnPlayerEnterVehicle is called when a player starts to enter the vehicle but the player is not in the vehicle yet. GetPlayerVehicleID will return 0 by the way and the whole statement will fail, use vehicleid parameter.
Posts: 108
Threads: 21
Joined: Aug 2016
Quote:
Originally Posted by Konstantinos
OnPlayerEnterVehicle is called when a player starts to enter the vehicle but the player is not in the vehicle yet. GetPlayerVehicleID will return 0 by the way and the whole statement will fail, use vehicleid parameter.
|
Ik,i read the wiki,i've tried the vehicleid it still doesn't work.
Posts: 108
Threads: 21
Joined: Aug 2016
Quote:
Originally Posted by Chump
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:
pawn Код:
public OnVehicleStreamIn(vehicleid, forplayerid) { if(vehicleid == Car[TEAM_COP] && gTeam[playerid] != TEAM_COP) { SetVehicleParamsForPlayer(vehicleid, forplayerid, 0, 1); } }
Also what is Car[TEAM_COP] being assigned to? You may be attempting to assign multiple vehicle IDs to it, e.g:
pawn Код:
Car[TEAM_COP] = CreateVehicle(...); Car[TEAM_COP] = CreateVehicle(...); Car[TEAM_COP] = CreateVehicle(...);
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:
pawn Код:
Car[TEAM_COP][0] = CreateVehicle(...); Car[TEAM_COP][1] = CreateVehicle(...); Car[TEAM_COP][2] = CreateVehicle(...);
|
My teams are now defined in an enum. so i've
to make the team cars,should i change it to the second time you said?