17.07.2010, 20:30
So like always, make sure you define the a_samp include file.
That just defines, that you are going to be scripting a San Andreas Multiplayer server. Next you will have to add the new files. We want to make Team Players, so put this under the #include, add this:
That defines, that there are teams in you server, with a maximum of 250 players in your server(MAX_PLAYERS does not equal, infinity. In SA-MP it equals 250 players). Next we have define our teams. So above the new file, and below the include file, add this:
This right here, defines that GROVE_STREET 1, and POLICE 2 will do something (in this case, they will be two separate teams). In order for your nametag to show up as the Team Color you are in, you must define these two, right underneath the #define POLICE 2:
This defines that GROVE_STREET_COLOUR is Green (0x00820FAA), and that POLICE_COLOUR is Blue (0x003DF5AA). So far our script should look like this:
The Next thing you want to do is make sure that you have skins for you Team. So we are gonna add a Grove Street Gang member skin and a Police Officer skin under OnGameModeInit. So under the new file, add this:
Next all we have to do is make sure the Class gets changed into a Team. So under OnPlayerRequestClass, add this:
What we did there was, when you get to request a skin, and you select it, it will set the team from the class you chose. Now we have to make sure that the class you chose, gives you the appropriate nametag color. So under OnPlayerSpawn, add this:
This basically added a player who spawns, to the appropriate team Color. But nothing will work unless you have this next few lines scripted. To be able to determine whether you're a cop or a gang member, you must make sure you Set the Player Team from the Class. So underneath everything script this:
Next you will tell gTeam, that this is a Grove Street Gang Member, and his nametag should be green. So next add this under everything:
This basically sets the Grove Street Gang Member to the Grove Street Color, we had defined earlier which was green, so, now this nametag is green. Now Lets add the Police the exact same way. It should look something like this:
REMEMBER: the skin id goes up by number as you go down the player class. (for example: if grove street gang member is 0, so will be the classid.
Next we must add Team Cars (If you are a Grove Street Gang Member, and you attempt to get into a Police Car, it will say, You do not have the keys to this car). So now add this in between, #define files and new files:
This made it where these two title ids, are TeamCars. So to make them TeamCars, make sure you define this, on top of the new file:
This Defines Cars as [any team in here]. Next we create the vehicle. (you can either do AddStaticVehicle, or CreateVehicle, but make sure at the beggining, you put Cars[Team name here]). Now Add the Police Car, and the Greenwood into Los Santos, so it will look like this under OnGameModeInit:
Next we make sure that the Script Gets the vehicle and know that you are not part of that team. Under everything add this:
This here makes sure that if you try to get into one of the cars, it will not let you. For example, if gTeam(playerid) is not equal to 1, then removeplayerfromvehicle and send him a message in red saying You Don't have the keys for this car! So now, lets define the Color Red. On top of the script under the last #define, add this:
That just defined the Color Red. So here we are! WE ARE DONE! You have made your own player teams, and car teams! Enjoy them, and practice making more, as more more make is more progress for you!
pawn Код:
#include <a_samp>
pawn Код:
new gTeam[MAX_PLAYERS];
pawn Код:
#define GROVE_STREET 1
#define POLICE 2
pawn Код:
#define GROVE_STREET_COLOUR 0x00820FAA
#define POLICE_COLOUR 0x003DF5AA
pawn Код:
#include <a_samp>
#define GROVE_STREET 1
#define POLICE 2
#define GROVE_STREET_COLOUR 0x00820FAA
#define POLICE_COLOUR 0x003DF5AA
new gTeam[MAX_PLAYERS];
pawn Код:
public OnGameModeInit()
{
AddPlayerClass(105,2497.2693,-1676.9578,13.3398,23.6501,0,0,0,0,0,0); //Grove Street Gang Member (0)
AddPlayerClass(280,1544.0514,-1675.7766,13.5577,98.0974,0,0,0,0,0,0); //Police Officer (1)
return 1;
}
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerTeamFromClass(playerid, classid);
return 1;
}
pawn Код:
public OnPlayerSpawn(playerid)
{
SetPlayerToTeamColour(playerid);
return 1;
}
pawn Код:
SetPlayerTeamFromClass(playerid, classid)
{
if(classid == 0)
{
gTeam[playerid] = GROVE_STREET;
}
}
pawn Код:
SetPlayerToTeamColour(playerid)
{
if(gTeam[playerid] == GROVE_STREET)
{
SetPlayerColor(playerid,GROVE_STREET_COLOUR); //Green
}
}
pawn Код:
SetPlayerTeamFromClass(playerid, classid)
{
if(classid == 0)
{
gTeam[playerid] = GROVE_STREET;
}
if(classid == 1)
{
gTeam[playerid] = POLICE;
}
}
SetPlayerToTeamColour(playerid)
{
if(gTeam[playerid] == GROVE_STREET)
{
SetPlayerColor(playerid,GROVE_STREET_COLOUR); //Green
}
if(gTeam[playerid] == POLICE)
{
SetPlayerColor(playerid,POLICE_COLOUR); // Blue
}
}
Next we must add Team Cars (If you are a Grove Street Gang Member, and you attempt to get into a Police Car, it will say, You do not have the keys to this car). So now add this in between, #define files and new files:
pawn Код:
enum TeamCars
{
GroveStreet,
Police
}
pawn Код:
new Cars[TeamCars];
pawn Код:
public OnGameModeInit()
{
AddPlayerClass(105,2497.2693,-1676.9578,13.3398,23.6501,0,0,0,0,0,0); //Grove Street Gang Member (0)
AddPlayerClass(280,1544.0514,-1675.7766,13.5577,98.0974,0,0,0,0,0,0); //Police Officer (1)
Cars[GroveStreet] = CreateVehicle(492,2484.3054,-1655.0886,13.1036,90.8565,44,16,900); //Greenwood
Cars[Police] = CreateVehicle(596,1536.0603,-1676.5302,13.1054,0.6847,-1,-1,900); //LSPD Cruiser
return 1;
}
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == 2)
{
new CarCheck = GetPlayerVehicleID(playerid);
if(CarCheck == Cars[GroveStreet] )
{
if(gTeam[playerid] != 1)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "You Don't have the keys for this car!");
return 1;
}
}
if(CarCheck == Cars[Police] )
{
if(gTeam[playerid] != 2)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "You Don't have the keys for this car!");
return 1;
}
}
return 1;
}
return 1;
}
pawn Код:
#define COLOR_RED 0xFF0000AA