faction 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: faction vehicles (
/showthread.php?tid=477492)
faction vehicles -
fonetic - 24.11.2013
I have this script that allows only faction 1 members enter faction 1 vehicles.
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
for(new i = 0; i < 12; i++) //Loop. It counts to 11
{ //Open Bracket
if(vehicleid == LSPDVehicles[i]) //If the vehicleid is an LSPD vehicle
{ //Open Bracket
if(pData[playerid][Faction] != 1) //If the player is not in faction 1 (LSPD, in this case)
{ //Open Bracket
ClearAnimations(playerid); //Clears their animation, preventing them from entering the vehicle.
SendClientMessage(playerid, -1, "You don`t have the keys for this car."); //Sends a message to the player that he cannot enter it.
} //Closed Bracket
} //Closed Bracket
} //Closed Bracket
return 1; //Return a value
}
how to make that faction 2 memebers, can only enter faction 2 vehicles?
Re: faction vehicles -
Krakuski - 24.11.2013
Try this.
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
for(new i = 0; i < 12; i++) //Loop. It counts to 11
{ //Open Bracket
if(vehicleid == LSPDVehicles[i]) //If the vehicleid is an LSPD vehicle
{ //Open Bracket
if(pData[playerid][Faction] != 1) //If the player is not in faction 1 (LSPD, in this case)
{ //Open Bracket
ClearAnimations(playerid); //Clears their animation, preventing them from entering the vehicle.
SendClientMessage(playerid, -1, "You don`t have the keys for this car."); //Sends a message to the player that he cannot enter it.
}
else if(pData[playerid][Faction] != 2) // Faction 2
{ //Open Bracket
ClearAnimations(playerid); //Clears their animation, preventing them from entering the vehicle.
SendClientMessage(playerid, -1, "You don`t have the keys for this car."); //Sends a message to the player that he cannot enter it.
} //Closed Bracket
} //Closed Bracket
} //Closed Bracket
return 1; //Return a value
}
Re: faction vehicles -
fonetic - 24.11.2013
nop, that doesn't work,
i think it needs to be something like this
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
for(new i = 0; i < 27; i++) //Loop. It counts to 11
{ //Open Bracket
if(vehicleid == LSPDVehicles[i]) //If the vehicleid is an LSPD vehicle
{ //Open Bracket
if(PlayerInfo[playerid][pFaction] != 1) //If the player is not in faction 1 (LSPD, in this case)
{ //Open Bracket
ClearAnimations(playerid); //Clears their animation, preventing them from entering the vehicle.
SendClientMessage(playerid, -1, "You don`t have the keys for this car."); //Sends a message to the player that he cannot enter it.
{
{
for(new i = 0; i < 2; i++) //Loop. It counts to 11
{ //Open Bracket
if(vehicleid == MedVehicles[i]) //If the vehicleid is an LSPD vehicle
{ //Open Bracket
else if(PlayerInfo[playerid][pFaction] != 2) // Faction 2
{ //Open Bracket
ClearAnimations(playerid); //Clears their animation, preventing them from entering the vehicle.
SendClientMessage(playerid, -1, "You don`t have the keys for this car."); //Sends a message to the player that he cannot enter it.
} //Closed Bracket
} //Closed Bracket
} //Closed Bracket
return 1; //Return a value
}
but i cant get it work, because i'm newbie to pawno.
Re: faction vehicles -
Zues - 24.11.2013
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
for(new i = 0; i < 12; i++) //Loop. It counts to 11
{ //Open Bracket
if(vehicleid == LSPDVehicles[i]) //If the vehicleid is an LSPD vehicle
{ //Open Bracket
if(pData[playerid][Faction] != 1) //If the player is not in faction 1 (LSPD, in this case)
{ //Open Bracket
ClearAnimations(playerid); //Clears their animation, preventing them from entering the vehicle.
SendClientMessage(playerid, -1, "You don`t have the keys for this car."); //Sends a message to the player that he cannot enter it.
} //Closed Bracket
} //Closed Bracket
else if(vehicleid == MedVehicles[i]) //If the vehicleid is an LSPD vehicle
{ //Open Bracket
if(pData[playerid][Faction] != 2) //If the player is not in faction 1 (LSPD, in this case)
{ //Open Bracket
ClearAnimations(playerid); //Clears their animation, preventing them from entering the vehicle.
SendClientMessage(playerid, -1, "You don`t have the keys for this car."); //Sends a message to the player that he cannot enter it.
} //Closed Bracket
} //Closed Bracket
} //Closed Bracket
return 1; //Return a value
}
How about this?
Re: faction vehicles -
fonetic - 24.11.2013
It's better now, now faction 1 members can only enter faction 1 cars and they can't enter faction 2 cars, but faction 2 members can enter faction 1 and faction 2 cars!