Private vehicles - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Private vehicles (
/showthread.php?tid=610453)
Private vehicles - Godly - 24.06.2016
This code should prevent non-military players to not be able to enter the vehicles, but looks like they can't eneter any vehicle in-game, how so?I struggled with the code for quite a while and I am out of ideas.Help would be appreciated.Thanks in advance
Code
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if (newstate == PLAYER_STATE_DRIVER)
{
new CarID = GetPlayerVehicleID(playerid);
if(pInfo[playerid][Class] != CLASS_MILITARY && aDuty[playerid] == 0 && GetVehicleModel(CarID) == 520, 447, 579, 432, 470, 433)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, -1, "{FFFF00}[SERVER] {FFFFFF}This is an army vehicle. You can't enter it.");
}
}
return 1;
}
Re: Private vehicles -
F1N4L - 24.06.2016
OnPlayerEnterVehicle
Re: Private vehicles - Godly - 24.06.2016
Same thing happens when I put it in OnPlayerEnterVehicle
Re: Private vehicles -
Vince - 24.06.2016
Quote:
Код:
GetVehicleModel(CarID) == 520, 447, 579, 432, 470, 433
|
This is completely invalid. You can't list them like that. They must each be checked individually. I suggest using a switch.
PHP код:
switch(GetVehicleModel(CarID))
{
case 520, 447, 579, 432, 470, 433:
{
// rest of statements
}
}