SA-MP Forums Archive
Making Teams Problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Making Teams Problem (/showthread.php?tid=188428)



Making Teams Problem - Tessar - 07.11.2010

I used some coding for coloured teams. The problem is when i want to have the colors:
Robbers = White
Police = Blue
Swat = Purple
Army = Green
Here is the code:
Код:
#define TEAM_ROBBERS 0
#define TEAM_POLICE 1
#define TEAM_SWAT 2
#define TEAM_ARMY 3
#define TEAM_ROBBERS_COLOUR 0xFFFFFFAA // White
#define TEAM_POLICE_COLOUR 0x0000FFAA // Blue
#define TEAM_SWAT_COLOUR 0x800080AA // Purple
#define TEAM_ARMY_COLOUR 0x33AA33AA // Green
new gTeam[MAX_PLAYERS];
Код:
public OnPlayerRequestClass(playerid, classid)
{
	SetPlayerTeamFromClass(playerid, classid);
	return 1;
}
Код:
public OnPlayerSpawn(playerid)
{
    SetPlayerToTeamColour(playerid);
    return 1;
}

SetPlayerTeamFromClass(playerid, classid)
{
    if(classid == 0)
    {
        gTeam[playerid] = TEAM_ROBBERS;
    }
    if(classid == 1)
    {
        gTeam[playerid] = TEAM_POLICE;
    }
    if(classid == 2)
    {
		gTeam[playerid] = TEAM_SWAT;
    }
    else if(classid == 3)
	{
		gTeam[playerid] = TEAM_ARMY;
	}

}

SetPlayerToTeamColour(playerid)
{
    if(gTeam[playerid] == TEAM_ROBBERS)
    {
        SetPlayerColor(playerid,TEAM_ROBBERS_COLOUR);
    }
    if(gTeam[playerid] == TEAM_POLICE)
    {
        SetPlayerColor(playerid,TEAM_POLICE_COLOUR);
    }
	if(gTeam[playerid] == TEAM_SWAT)
	{
		SetPlayerColor(playerid,TEAM_SWAT_COLOUR);
	}
	if(gTeam[playerid] == TEAM_ARMY)
	{
		SetPlayerColor(playerid,TEAM_ARMY_COLOUR);
    }
}
What do i need to do/change to make sure that when you choose a skin that you end up with the color of that team?


Re: Making Teams Problem - (SF)Noobanatior - 08.11.2010

this should work fine can be simplified to
pawn Код:
#define TEAM_ROBBERS 0
#define TEAM_POLICE 1
#define TEAM_SWAT 2
#define TEAM_ARMY 3
#define TEAM_ROBBERS_COLOUR 0xFFFFFFAA // White
#define TEAM_POLICE_COLOUR 0x0000FFAA // Blue
#define TEAM_SWAT_COLOUR 0x800080AA // Purple
#define TEAM_ARMY_COLOUR 0x33AA33AA // Green
new gTeam[MAX_PLAYERS];

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerTeamFromClass(playerid, classid);
    return 1;
}

public OnPlayerSpawn(playerid)
{
      return 1;
}

stock SetPlayerTeamFromClass(playerid, classid){
    if(classid == 0)gTeam[playerid] = TEAM_ROBBERS;
    else if(classid == 1)gTeam[playerid] = TEAM_POLICE;
    else if(classid == 2)gTeam[playerid] = TEAM_SWAT;
    else if(classid == 3)gTeam[playerid] = TEAM_ARMY;
    SetPlayerToTeamColour(playerid);
}

stock SetPlayerToTeamColour(playerid){
    if(gTeam[playerid] == TEAM_ROBBERS)SetPlayerColor(playerid,TEAM_ROBBERS_COLOUR);
    else if(gTeam[playerid] == TEAM_POLICE)SetPlayerColor(playerid,TEAM_POLICE_COLOUR);
    else if(gTeam[playerid] == TEAM_SWAT)SetPlayerColor(playerid,TEAM_SWAT_COLOUR);
    else if(gTeam[playerid] == TEAM_ARMY)SetPlayerColor(playerid,TEAM_ARMY_COLOUR);
}



Re: Making Teams Problem - Tessar - 09.11.2010

Doesn't work I was looking for:
Robbers = White
Police = Blue
Swat = Purple
Army = Green


Re: Making Teams Problem - jonnyboy - 09.11.2010

Quote:
Originally Posted by Tessar
Посмотреть сообщение
Doesn't work I was looking for:
Robbers = White
Police = Blue
Swat = Purple
Army = Green
i think it should work... you made the code right i think.


Re: Making Teams Problem - (SF)Noobanatior - 09.11.2010

how is it not working?


Re: Making Teams Problem - Tessar - 09.11.2010

Quote:

how is it not working?

The teams arn't the correct colour


Re: Making Teams Problem - (SF)Noobanatior - 10.11.2010

more info are they the wrong colours all together or the right colours but for the wrong team?
do you only have 4 player classes?


Re: Making Teams Problem - Tessar - 10.11.2010

Quote:

more info are they the wrong colours all together or the right colours but for the wrong team?
do you only have 4 player classes?

The colours are correct but they sometimes come up on the wrong teams.
Here are my player classes:
Код:
AddPlayerClass(105,2502.9766,-1682.0063,13.5469,23.6501,0,0,0,0,0,0); // TEAM_ROBBERS 0
AddPlayerClass(104,2502.9766,-1682.0063,13.5469,23.6501,0,0,0,0,0,0); // TEAM_ROBBERS 0
AddPlayerClass(115,2502.9766,-1682.0063,13.5469,23.6501,0,0,0,0,0,0); // TEAM_ROBBERS 0
AddPlayerClass(116,2502.9766,-1682.0063,13.5469,23.6501,0,0,0,0,0,0); // TEAM_ROBBERS 0
AddPlayerClass(265,1587.1246,-1685.5427,6.2252,227.7512,0,0,0,0,0,0); // TEAM_POLICE 1
AddPlayerClass(266,1587.1246,-1685.5427,6.2252,227.7512,0,0,0,0,0,0); // TEAM_POLICE 1
AddPlayerClass(267,1587.1246,-1685.5427,6.2252,227.7512,0,0,0,0,0,0); // TEAM_POLICE 1
AddPlayerClass(280,1587.1246,-1685.5427,6.2252,227.7512,0,0,0,0,0,0); // TEAM_POLICE 1
AddPlayerClass(285,1587.1246,-1685.5427,6.2252,227.7512,0,0,0,0,0,0); // TEAM_SWAT 2
AddPlayerClass(287,1587.1246,-1685.5427,6.2252,227.7512,0,0,0,0,0,0); // TEAM_ARMY 3



Re: Making Teams Problem - (SF)Noobanatior - 11.11.2010

i see each line is a class id so will have to be like this
pawn Код:
#define TEAM_ROBBERS 0
#define TEAM_POLICE 1
#define TEAM_SWAT 2
#define TEAM_ARMY 3
#define TEAM_ROBBERS_COLOUR 0xFFFFFFAA // White
#define TEAM_POLICE_COLOUR 0x0000FFAA // Blue
#define TEAM_SWAT_COLOUR 0x800080AA // Purple
#define TEAM_ARMY_COLOUR 0x33AA33AA // Green
new gTeam[MAX_PLAYERS];

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerTeamFromClass(playerid, classid);
    return 1;
}

public OnPlayerSpawn(playerid)
{
      return 1;
}

stock SetPlayerTeamFromClass(playerid, classid){
    if(classid == 0 || classid == 1 || classid == 2 || classid == 3)gTeam[playerid] = TEAM_ROBBERS;
    else if(classid == 4 || classid == 5 || classid == 6 || classid == 7)gTeam[playerid] = TEAM_POLICE;
    else if(classid == 8)gTeam[playerid] = TEAM_SWAT;
    else if(classid == 9)gTeam[playerid] = TEAM_ARMY;
    SetPlayerToTeamColour(playerid);
}

stock SetPlayerToTeamColour(playerid){
    if(gTeam[playerid] == TEAM_ROBBERS)SetPlayerColor(playerid,TEAM_ROBBERS_COLOUR);
    else if(gTeam[playerid] == TEAM_POLICE)SetPlayerColor(playerid,TEAM_POLICE_COLOUR);
    else if(gTeam[playerid] == TEAM_SWAT)SetPlayerColor(playerid,TEAM_SWAT_COLOUR);
    else if(gTeam[playerid] == TEAM_ARMY)SetPlayerColor(playerid,TEAM_ARMY_COLOUR);
}
have fun


Re: Making Teams Problem - Tessar - 11.11.2010

Quote:

i see each line is a class id so will have to be like this
pawn Code:
#define TEAM_ROBBERS 0
#define TEAM_POLICE 1
#define TEAM_SWAT 2
#define TEAM_ARMY 3
#define TEAM_ROBBERS_COLOUR 0xFFFFFFAA // White
#define TEAM_POLICE_COLOUR 0x0000FFAA // Blue
#define TEAM_SWAT_COLOUR 0x800080AA // Purple
#define TEAM_ARMY_COLOUR 0x33AA33AA // Green
new gTeam[MAX_PLAYERS];

public OnPlayerRequestClass(playerid, classid)
{
SetPlayerTeamFromClass(playerid, classid);
return 1;
}

public OnPlayerSpawn(playerid)
{
return 1;
}

stock SetPlayerTeamFromClass(playerid, classid){
if(classid == 0 || classid == 1 || classid == 2 || classid == 3)gTeam[playerid] = TEAM_ROBBERS;
else if(classid == 4 || classid == 5 || classid == 6 || classid == 7)gTeam[playerid] = TEAM_POLICE;
else if(classid == gTeam[playerid] = TEAM_SWAT;
else if(classid == 9)gTeam[playerid] = TEAM_ARMY;
SetPlayerToTeamColour(playerid);
}

stock SetPlayerToTeamColour(playerid){
if(gTeam[playerid] == TEAM_ROBBERS)SetPlayerColor(playerid,TEAM_ROBBERS_ COLOUR);
else if(gTeam[playerid] == TEAM_POLICE)SetPlayerColor(playerid,TEAM_POLICE_CO LOUR);
else if(gTeam[playerid] == TEAM_SWAT)SetPlayerColor(playerid,TEAM_SWAT_COLOUR );
else if(gTeam[playerid] == TEAM_ARMY)SetPlayerColor(playerid,TEAM_ARMY_COLOUR );
}
have fun

Thanks mate!! This worked and am now really happy, i thought i did something wrong in the script