Posts: 414
Threads: 93
Joined: Dec 2010
I am trying to make my police cars un enterable i have this code
PHP Code:
public OnVehicleStreamIn(vehicleid, forplayerid)
{
if (cop >=1) {
SetVehicleParamsForPlayer(596,forplayerid,0,1);
}
else
{
SetVehicleParamsForPlayer(596,forplayerid,0,0);
}
return 1;
}
Posts: 414
Threads: 93
Joined: Dec 2010
Quote:
Originally Posted by MP2
pawn Code:
public OnVehicleStreamIn(vehicleid, forplayerid) { if(IsVehicleCopCar(vehicleid) && pTeam[forplayerid] != TEAM_COP) // Or whatever team system you are using { SetVehicleParamsForPlayer(vehicleid, forplayerid, 0, 1); // Lock doors } return 1; }
stock IsVehicleCopCar(vehicleid) { switch(GetVehicleModel(vehicleid)) { case 523, 427, 490, 528, 596 .. 599, 601: return 1; } return 0; }
You never have to unlock the vehicles, because when they stream out and in again the doors get unlocked anyway, so if they change class/team/whatever it will likely stream the vehicle out (as they respawn, well I assume).
Not actually tested that, not sure if the IsVehicleCopCar will give errors due to the return.
NOTE: The cop bike doesn't have door locks, obviously, so I'm not sure if locking the doors works, I THINK it does.
|
it doesn't seem to be working its letting me still enter the cars
oh never mind works but i made accidently made it so its 0 instead of 1 thanks.
Posts: 414
Threads: 93
Joined: Dec 2010
Quote:
Originally Posted by xX_Simon_Xx
Try to put this
PHP Code:
if(IsVehicleCopCar(vehicleid) && pTeam[forplayerid] != TEAM_COP) // Or whatever team system you are using
{
SetVehicleParamsForPlayer(vehicleid, forplayerid, 0, 1); // Lock doors
}
under OnPlayerEnterVehicle
or try this code
PHP Code:
if(IsVehicleCopCar(vehicleid) && pTeam[forplayerid] != TEAM_COP) // Or whatever team system you are using
{
new motore,luci,allarme,sicura,cofano,bagagliaio,objective;
GetVehicleParamsEx(vehicleid,motore,luci,allarme,sicura,cofano,bagagliaio,objective);
SetVehicleParamsEx(vehicleid,motore,luci,allarme,VEHICLE_PARAMS_ON,cofano,bagagliaio,objective);
}
|
im using it as a factiontype thing like this
PHP Code:
if(IsVehicleCopCar(vehicleid) && cop < 1) // Or whatever team system you are using
{
SetVehicleParamsForPlayer(vehicleid, forplayerid, 0, 1); // Lock doors
}
if(IsVehicleCopCar(vehicleid) && cop >= 1) // Or whatever team system you are using
{
SetVehicleParamsForPlayer(vehicleid, forplayerid, 0, 0); // Lock doors
}
It locks the car for the cops as well so even a cop can't drive it but ill try what you said. under on player enter vehicle.
Posts: 414
Threads: 93
Joined: Dec 2010
Quote:
Originally Posted by RollTi
Putting the code OnPlayerEnterVehicle will not work as i told you before put it in OnPlayerStateChange
check my last previous post
|
okay ill try that. Its giving me errors saying undefined vehicleid
Posts: 6,236
Threads: 310
Joined: Jan 2011
Reputation:
0
No, don't put it under OnPlayerStateChange, that's a stupid thing to suggest. That's called when they HAVE ENTERED a vehicle. My method will lock the doors, preventing entry.
Posts: 414
Threads: 93
Joined: Dec 2010
Quote:
Originally Posted by MP2
No, don't put it under OnPlayerStateChange, that's a stupid thing to suggest. That's called when they HAVE ENTERED a vehicle. My method will lock the doors, preventing entry.
|
but i want it so that if a player enters the cop car that the cop < 0 it will not allow him to enter but if a players cop is greater than 1 it will let him enter.