Creating a vehicle group - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Creating a vehicle group (
/showthread.php?tid=273859)
Creating a vehicle group -
McCarthy - 03.08.2011
So I need some advice, I have FBI and SWAT factions on my server, and both of them use FBI Ranchers.
I need to make it so the script can detect whether it is a SWAT Rancher or FBI Rancher, although the vehicle id is the same. Just so FBI cant use SWAT vehicles and vice versa
AW: Creating a vehicle group -
Drebin - 03.08.2011
Edit your AddStaticVehicle(); to
pawn Код:
new swatcar[2]; //On top of script
new fbicar[2]; //
swatcar[0]=AddStaticVehicle(...); //OnGameModeInit
swatcar[1]=AddStaticVehicle(...); //
fbicar[0]=AddStaticVehicle(...); //
fbicar[1]=AddStaticVehicle(...); //
And then use this or similar method to check the driver
This is an example to check if a player can drive the swat cars (you have to do the same for FBI cars)
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate==PLAYER_STATE_DRIVER)
{
for(new i=0; i<sizeof(swatcar); i++)
{
if(GetPlayerVehicleID(playerid)==swatcar[i])
{
if(GetPVarInt(playerid,"Fraction")!=2) //In my example the ID of the faction a player is in is stored in his scriptfile txt
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid,RED,"You are not allowed to drive this vehicle.");
}
}
}
}
return 1;
}
Re: Creating a vehicle group -
McCarthy - 03.08.2011
Alright thanks
Re: Creating a vehicle group -
McCarthy - 05.08.2011
Quick question..how can I use all 3 of these in one public?
pawn Код:
for(new i=7; i<sizeof(fbicar); i++)
for(new i=2; i<sizeof(swatcar); i++)
for(new i = 0; i < MAX_PLAYERS; i++)
Re: Creating a vehicle group -
Toreno - 05.08.2011
You can create stocks, which are easy to use.
pawn Код:
stock IsSWATVehicles(playerid) {
for(new 1; i < sizeof(swatcar)l ++i) {
if(GetPlayerVehicleID(playerid) == swatcar[i]) return 1;
}
return 0;
}