Gang Cars - 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: Gang Cars (
/showthread.php?tid=121659)
Gang Cars -
icorne - 17.01.2010
How i make cars for only a gang like my gang? [IR]
Re: Gang Cars -
akis_tze - 17.01.2010
add this below #include <samp>
Код:
new [IR]; // The name of your gang
add this OnGameModeInit or OnFilterScriptInit
Код:
[IR] = AddStaticVehicle(451,1890.1632,1989.1708,13.4920,179.9223,6,6); // This will spawn a turismo in the parking lot in LV
Код:
public OnPlayerStateChange(playerid, newstate, oldstate) // The OnPlayerStateChange function
{
new GangName[24]; // We create a variable which will contain the gang name.
GetPlayerName(playerid, GangName, sizeof(GangName)); // We use GetPlayerName to store the name in 'GangName'.
if(newstate == PLAYER_STATE_DRIVER) // Check the new state, since he's the driver in this case, we continue.
{
new Vehicle = GetPlayerVehicleID(playerid); // This saves the player's vehicle id into the variable 'vehicle'
if(Vehicle == [IR]) // We check if the vehicle is the one we don't want everyone to enter
{ // It is, so we continue.
if(strcmp(GangName,"[IR]",true)) // We use strcmp to check if the player who entered the car is the same as '[IR]'
{
RemovePlayerFromVehicle(playerid); // It's not, so we remove the player from the car.
SendClientMessage(playerid, 0x33AA33AA, "This car been belongs to [IR] "); // And we inform him about why he got removed from the car.
}
}
}
return 1;
}
Re: Gang Cars -
akis_tze - 17.01.2010
the above code maybe works maybe not works i dont have tested
Re: Gang Cars -
akis_tze - 17.01.2010
i see this code from
http://forum.sa-mp.com/index.php?topic=116016.0
i dont know if it work
Re: Gang Cars -
Rzzr - 17.01.2010
I think that only works if your name is [IR]?
If your name is [IR]Noname will it still work?
Re: Gang Cars -
Joe Staff - 17.01.2010
Here ye go
pawn Код:
#define MAX_GANGS 2
#define GANG_IR 0
#define GANG_GS 1
#define MAX_GANG_VEHICLES 10
new GangCars[MAX_GANGS][MAX_GANG_VEHICLES];
public OnGameModeInit()
{
GangCars[GANG_IR][0]=AddStaticVehicle(522,0,0,0,0,-1,-1);//IR, gang vehicles can go up 9 (because MAX_GANG_VEHICLES is 10)
GangCars[GANG_IR][1]=AddStaticVehicle(522,0,0,0,0,-1,-1);
GangCars[GANG_IR][2]=AddStaticVehicle(522,0,0,0,0,-1,-1);
GangCars[GANG_GS][0]=AddStaticVehicle(522,0,0,0,0,-1,-1);
GangCars[GANG_GS][1]=AddStaticVehicle(522,0,0,0,0,-1,-1);
GangCars[GANG_GS][2]=AddStaticVehicle(522,0,0,0,0,-1,-1);
return 1;
}
public OnPlayerStateChange(playerid,newstate,oldstate)
{
if(newstate==PLAYER_STATE_DRIVER)
{
new pname[24];
GetPlayerName(playerid,pname,sizeof(pname));
for(new gangcar;gangcar<MAX_GANG_VEHICLES;gangcar++)
{
if(GetPlayerVehicleID(playerid)==GangCars[GANG_IR][gangcar])
{
if(strfind(pname,"[IR]")==-1)RemovePlayerFromVehicle(playerid);
}
}
for(new gangcar;gangcar<MAX_GANG_VEHICLES;gangcar++)
{
if(GetPlayerVehicleID(playerid)==GangCars[GANG_GS][gangcar])
{
if(strfind(pname,"[GS]")==-1)RemovePlayerFromVehicle(playerid);
}
}
}
return 1;
}
For some reason I REALLY don't like that...