Making Teams Problem
#1

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?
Reply
#2

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);
}
Reply
#3

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

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.
Reply
#5

how is it not working?
Reply
#6

Quote:

how is it not working?

The teams arn't the correct colour
Reply
#7

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?
Reply
#8

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
Reply
#9

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
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)