SetPlayerTeam question
#1

Hi!

What does the 4 (ID 4) means in SetPlayerTeam.. Is that how many class selections u have??..
Or what does it means?
pawn Код:
public OnPlayerSpawn(playerid)
{
    // Set a player's team to 4 when they spawn
    SetPlayerTeam(playerid, 4);
    return 1;
}
https://sampwiki.blast.hk/wiki/SetPlayerTeam
Reply
#2

nah, the id is just like a playerid. once i scripted a "no friendly fire" for groups, so joining a players' group automatically set the joining players team to the same team as the groupleader (his playerid).
if you are playerid4, and i join your group (team), then its clever to set my according to your playerid (since i had to ask you /grj). you will always know which group your sheep ae belonging to: YOUR(playerid)s'
Reply
#3

Ok.. Thanks but are there another script that set team in class selection?? .. An easy to make.. (I'm a pretty beginner).


Btw: It sound like SetPlayerTeam, That u can invite someone to your team, But that I didn't
want.. I want like said above.. I whasn't 100 sure just 99 Hahaha.... ^^.....
Reply
#4

AddPlayerClassEx.
Reply
#5

So I should write AddPlayerClassEx? And more how to make them in same team??.
Reply
#6

Like the function name say SetPlayerTeam means to set player team (or change it)
If you use AddPlayerClass than when player select class his team id is set to NO_TEAM
But if you use AddPlayerClassEx than you have defined team id for that class (skin)

Here are some useful documentation for these functions
https://sampwiki.blast.hk/wiki/SetPlayerTeam
https://sampwiki.blast.hk/wiki/AddPlayerClass
https://sampwiki.blast.hk/wiki/AddPlayerClassEx

By the way players on same team can not kill each other ( No team kill )
Reply
#7

Add gTeam[MAX_PLAYERS] in top of your script, this will store the player's team.

Now define your teams:

Example:

pawn Код:
#define RED_TEAM 0
#define GREEN_TEAM 1
Now OnPlayerRequestClass:

pawn Код:
switch(classid) // Switch to know which team the player is gonna choose
{
    case 0: // case 0: = The player is gonna choose the first AddPlayerClass AKA RED_TEAM
    {
        gTeam[playerid] = RED_TEAM; // Will set the player's team to RED_TEAM
        SetPlayerTeam(playerid, 1); // A player of the team 1 can't kill a player of the team 1
    }
    case 1: // case 1: = The player is gonna choose the second AddPlayerClass AKA GREEN_TEAM
    {
        gTeam[playerid] = GREEN_TEAM; // Will set the player's team to GREEN_TEAM
        SetPlayerTeam(playerid, 2); // A player of the team 2 can't kill a player of the team 2
    }
}
Don't forget to add your player classes.

Note: Personaly, I set the player's team (SetPlayerTeam) in the callback OnPlayerSpawn, using the condition:

pawn Код:
if(gTeam[playerid] == RED_TEAM)
{
    SetPlayerTeam(playerid, 1);
    SetPlayerColor(playerid, COLOR_RED);
}

// And so on...
Reply
#8

Okay, thanks alot! .
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)