[Tutorial] Making Team System ||[Efficient And Easiest Way]||
#1

Making Teams

First of all we need to know a bit about how to make team system.

We need a define first of all to confirm our teams.


Code:
#define YourTeamName // The name of your team in capital.
Now you have successfully defined you team congratulations we have passed the first step of making a team.

Now we need to get a variable through which we can detect our teams so lets get started.


Code:
new gTeam[MAX_PLAYERS];
We are now using the global variable to detect our teams so we can know who is in which team.

Now moving to the next step of the things and now we need to add a player class on.


Code:
{
//==============================Game-Mode=====================================//
      SetGameModeText("Your GM Name");
//================================Teams=======================================//
  
     AddPlayerClass(Skin,x,y,z,weapon,ammo,weapon,ammo,weapon,ammo);
     return 1;
}
Before doing anything here you need to learn from other sa-mp tutorials how to get player's position and add player
class things or you will fall in trouble reading this tutorial.

now moving on to the next step when we're using OnPlayerRequestClass.


Code:
public OnPlayerRequestClass(playerid, classid)
{
	switch(classid)
    {
        case 0:
        {
		   gTeam[playerid] = YourTeamName; // Team name of yours
		   GameTextForPlayer(playerid, "text", time, style); // Game text
           SetPlayerPos(playerid, x,y,z); // Player Position
	       SetPlayerFacingAngle(playerid, cords); //Facing angle for player
	       SetPlayerCameraPos(playerid, x,y,z); // Camera position 
	       SetPlayerCameraLookAt(playerid, x,y,z); //The look at of camera
                  SetPlayerTeam(playerid, YourTeamName); // The anti team kill for setting player's team

        }
       
	}
	{
	SetPlayerToTeamColour(playerid);
	}

	return 1;
}
Remember i told you need to learn how to set a player's position and all those things and camera lookat how to
make them from other sa-mp tutorials now if you have learned then you must have known what those means.

SetPlayerPos is used to set the players position on spawning.

SetPlayerFacingAngle is the code when player will be on class selection it will show the angle in that position.

SetPlayerCameraPos is the camera position when player's will be on class selection the camera look of that.

SetPlayerCameraLookAt is the camera look at when player is spawning.

SetPlayerTeam is used to set a player's team and mainly to prevent the team kill thing.

Then you saw there is SetPlayerToTeamColour i made a stock about that so player can set to its team's color.


Code:
SetPlayerToTeamColour(playerid)
{
    if(gTeam[playerid] == YourTeamName) // The team's name for setting colour.
    {
        SetPlayerColor(playerid,YourColourHere); //The color you have to put in to get a player in that team's colour.
    }    

}
See we again used the gTeam for detecting what the player's team is so you get how we detect teams like this so finally we have completed our team system now you can enjoy the team system.


Hope You Liked The Tutorial

Thanks For Reading
Reply
#2

You don't even assign a value to the definition. So you're assigning nothing and comparing with nothing.
Reply
#3

Like Vince said, and test your script before posting please.
Reply
#4

i tested it and it works perfectly and thanks for your comments .
Reply
#5

That would be impossible since it doesn't even compile.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)