[Tutorial] How to make teams
#1

Introduction
Hello! I am stuun i am kinda new at samp forums i wanted to teach you how to make teams for newbies hope you enjoy it. It's simple if not explained tell me i will edit.

EDITED.

1.

First of all make sure you have teams under GameModeInit like that

PHP Code:
public OnGameModeInit()
{
  
SetGameModeText("Blank text");
  
AddPlayerClass(Here you put skin id ,Put here your coordinates,weapon 1,weapon_ammo,weapon 2,weapon_ammo,weapon 3,weapon_ammo);//That 
2.

Make how much teams you want but here ima make only 1. if you wanna make more do the same.

3.

Define your team at the top like that

PHP Code:
#define TEAM_TEST//You don't put test, Put your team name 
4.

Go in: public OnPlayerSpawn(playerid)

Put
PHP Code:
switch(GetPlayerTeam(playerid)){ 
5.

Now we will use cases this will be in OnPlayerSpawn

PHP Code:
case .. 5://1 .. 5 is the ids and ".." is the numbers inside it like 2,3,4 and under it add bracket "{" 
Like that:

PHP Code:
case: .. 5:
{
// That is a bracket. 
6.

Now we will use SetPlayerTeam.

PHP Code:
SetPlayerTeam(playeridTEAM_TEST);//SetPlayerTeam is sets the team so the friendly fire will be off. Then put the team name of course so the server will understand that they are team. 
Now close bracket like that "}"

FULL CODE:

PHP Code:
case .. 5:
{
  
SetPlayerTeam(playeridTEAM_TEST);

If you need to add color just put this under SetPlayerTeam

PHP Code:
SetPlayerColor(playeridCOLOR_YOURCOLOUR);//SetPlayerColor sets his color after that choose the color and make sure it's defined at the top 
Like that

PHP Code:
#define COLOR_YOURCOLOR 
FULL CODE
PHP Code:
case: .. 5:
{
  
SetPlayerTeam(playeridTEAM_TEST);
  
SetPlayerColor(playeridCOLOR_YOURCOLOUR);

Hope you enjoyed my simple tutorial it's for newbies that are new at scripting.

Didn't explain good? Tell me i will edit it.
Reply
#2

if u can make one team for me u would be very thankful from myside plz reply
Reply
#3

Well use the tutorial.

If you did not understand tell me. I'm sure i explained very well.
Reply
#4

Ah and could you please tell me

Why you asking me to make 1 for you? the tutorial wasn't explained enough? Cause if not please tell me.

Btw i didn't edit my last post cause when i press on it it loads 1 hour ffs. @Admins/Moderators
Reply
#5

it becuz when i make myself team isnt coming in-game
help me in making tht team bro plz
Reply
#6

You mean when u are in class selection you see only sky? or something no people on class selection?
Reply
#7

EDIT: nvm
Reply
#8

no i already have 5 teams in jarnu script but i wanna add 2 more when i added one team in team selection, its not apearring the team but the gang zones is thier
Reply
#9

I did not understand you anyways..Pm me insted
Reply
#10

man talk me here!!
u know jarnu?
he made a cod Script world at war
i upgrading it and added many features but when i add teams!! when i go to team selection those teams textdraws and selection doesnt appears!!
Reply
#11

Well i don't know how to fix it.

Sorry.
Reply
#12

Quote:
Originally Posted by xMx4LiFe
View Post
man talk me here!!
u know jarnu?
he made a cod Script world at war
i upgrading it and added many features but when i add teams!! when i go to team selection those teams textdraws and selection doesnt appears!!
Ofcourse not, this has nothing to do with textdraws.
Reply
#13

Quote:
Originally Posted by Stuun
View Post
First of all make sure you have teams under GameModeInit like that

PHP Code:
public OnGameModeInit()
{
  
SetGameModeText("Blank text");
  
AddPlayerClass(Here you put skin id ,Put here your coordinates,weapon 1,weapon_ammo,weapon 2,weapon_ammo,weapon 3,weapon_ammo);//That 
So AddPlayerClass is used to add a team?

Quote:
Originally Posted by Stuun
View Post
2.

Make how much teams you want but here ima make only 5.
Where and how then?

Quote:
Originally Posted by Stuun
View Post
3.

Define your team at the top like that

PHP Code:
#define TEAM_TEST//You don't put test, Put your team name 
How to add more teams?

Quote:
Originally Posted by Stuun
View Post
5.

Now we will use cases this will be in OnPlayerSpawn

PHP Code:
case .. 5://1 .. 5 is the ids and ".." is the numbers inside it like 2,3,4 and under it add bracket "{" 
Like that:

PHP Code:
case: .. 5:
{
// That is a bracket. 
1- What does those IDs stand for?
2- sooo like this?
pawn Code:
public OnPlayerSpawn(playerid)
{
    case 1 .. 5:
    {
        //
    }
    return 1;
}
Quote:
Originally Posted by Stuun
View Post
6.

Now we will use SetPlayerTeam.

PHP Code:
SetPlayerTeam(playeridTEAM_TEST);//SetPlayerTeam is sets the team so the friendly fire will be off. Then put the team name of course so the server will understand that they are team. 
Now close bracket like that "}"
But 'TEAM_TEST' didn't get a value at the #define. Will that also work?
Reply
#14

It's like gang stuff right?
Reply
#15

Quote:
Originally Posted by Arastair
View Post
It's like gang stuff right?
It could be.


And kwarde i will edit asap.

And how to add more teams? i think i explained it well -.-

Just define it under it i mean #define TEAM_yourteamname.
Reply
#16

Quote:
Originally Posted by Stuun
View Post
It could be.
That makes it way better +Rep
Reply
#17

Lol this system will not work at all. There is no switch statement to fetch which team the player is in?

pawn Code:
switch(GetPlayerTeam(playerid)){
     case 1..5: {
             // code
     } // sorry for bad indentation i didnt use pawno or anything
}
Reply
#18

Quote:
Originally Posted by sammp
View Post
Lol this system will not work at all. There is no switch statement to fetch which team the player is in?

pawn Code:
switch(GetPlayerTeam(playerid)){
     case 1..5: {
             // code
     } // sorry for bad indentation i didnt use pawno or anything
}
Omg i forgot that part :O

But i remember once i used without it and it still worked..
Reply
#19

Quote:
Originally Posted by Stuun
View Post
Omg i forgot that part :O

But i remember once i used without it and it still worked..
Impossible! You might've confused it with something else, but the script will not even compile if you didn't add the switch() statement.
Also, you should add IDs after the TEAM_{teamname} defines. When you compile the script, the pre-compiler (that happens before the script actually gets compiled), will replace all the defines (it was called placeholders I think? Not sure!) with the #define data. For example:
pawn Code:
//Actual script;
#include <a_samp>

#define HELLO_WORLD "Hello world!"

main()
{
    print(HELLO_WORLD);
    return 1;
}

//Pre-compiled script:
#include <a_samp> //Actually, all the data of a_samp will be in one script.. but I'm not copying that all -atleast, I think it does, I read it once I think. Not sure!! -- It would make sense though-

main()
{
    print("Hello world!"); //This got replaced with the HELLO_WORLD define data.
    return 1;
}
So, if you don't use IDs, this will happen;
pawn Code:
//Actual script:
#include <a_samp>

#define TEAM_ALFA
#define TEAM_BRAVO
#define TEAM_CHARLIE
#define TEAM_DELTA
#define TEAM_ECHO
#define TEAM_FOXTROT

main()
{
    printf("TEAM_ALFA is %d", TEAM_ALFA);
    printf("TEAM_BRAVO is %d", TEAM_BRAVO);
    printf("TEAM_CHARLIE is %d", TEAM_CHARLIE);
    printf("TEAM_DELTA is %d", TEAM_DELTA);
    printf("TEAM_ECHO is %d", TEAM_ECHO);
    printf("TEAM_FOXTROT is %d", TEAM_FOXTROT);
    return 1;
}

//Pre-compiled script:
#include <a_samp>

main()
{
    printf("TEAM_ALFA is %d", );
    printf("TEAM_BRAVO is %d", );
    printf("TEAM_CHARLIE is %d", );
    printf("TEAM_DELTA is %d", );
    printf("TEAM_ECHO is %d", );
    printf("TEAM_FOXTROT is %d", );
    return 1;
}
That won't even compile, it'd just give 12 errors (6x error 29, and 6x error 21). This would be a proper way:
pawn Code:
#include <a_samp>

#define TEAM_ALFA       0
#define TEAM_BRAVO      1
#define TEAM_CHARLIE    2
#define TEAM_DELTA      3
#define TEAM_ECHO       4
#define TEAM_FOXTROT    5

main()
{
    printf("TEAM_ALFA is %d", TEAM_ALFA);
    printf("TEAM_BRAVO is %d", TEAM_BRAVO);
    printf("TEAM_CHARLIE is %d", TEAM_CHARLIE);
    printf("TEAM_DELTA is %d", TEAM_DELTA);
    printf("TEAM_ECHO is %d", TEAM_ECHO);
    printf("TEAM_FOXTROT is %d", TEAM_FOXTROT);
    return 1;
}
You should also consider using SetTeamCount();.


This post is not meant to be mean, but it's only fully intended so your PAWN knowledge gets extended, so you have a better understanding of what you're doing, and so that you can improve (or please, re-write!) your tutorial.

p.s.
AddPlayerClass doesn't add teams. It only adds an option in the class selection with spawn data, weapon data and skin data. You can, however, used AddPlayerClassEx and also add data on what team they should be.
*
Reply
#20

Right on Kwarde,

He shouldn't be writing tutorials if he is unsure as to what he is doing.....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)