17.01.2010, 17:42
How i make cars for only a gang like my gang? [IR]
new [IR]; // The name of your gang
[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; }
#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;
}