22.07.2015, 19:52
pawn Код:
new CurrentVehicle[MAX_PLAYERS] = { -1, ... };
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
CurrentVehicle[playerid] = GetPlayerVehicleID(playerid);
}
return 1;
}
//When you want to lock the car use CurrentVehicle[playerid] as the vehicle id, make sure it isn't -1 though
CMD:lock(playerid, params[])
{
if(CurrentVehicle[playerid] != -1)
{
for(new i, j = GetPlayerPoolSize(); i <= j; i++) // note that we assign the return value to a new variable (j) to avoid calling the function with each iteration
{
if(i != playerid) SetVehicleParamsForPlayer(CurrentVehicle[playerid],i,0,1);
}
}
return 1;
}