Teams Color Problem?
#1

Hello.
I have made this script , and when a player spawns, he doesnt spawn with the right color.
Here is the code I'm havign trouble with:

Код:
//====[TEAMS]====//
new gTeam[MAX_PLAYERS];

//===============//
#define TEAM_CIVILIANS 	1
#define TEAM_GYPSIES 	2
#define TEAM_FIREMAN	3
#define TEAM_MEDIC      4
#define TEAM_POLICE     5
#define TEAM_SWAT	    6
#define TEAM_FBI   		7

//==[TEAMCOLOR]==//
#define TEAM_CIVILIANS_COLOR    0xFFFFFFFF
#define TEAM_GYPSIES_COLOR      0xD9C555FF
#define TEAM_FIREMAN_COLOR      0xBA5A5AFF
#define TEAM_MEDIC_COLOR        0x4078D5FF
#define TEAM_POLICE_COLOR       0x2CD162FF
#define TEAM_SWAT_COLOR         0xB13A94FF
#define TEAM_FBI_COLOR          0x509C85FF

//=========[SETPLAYERTEAMFROMCLASS]=========//
SetPlayerTeamFromClass(playerid, classid)
{
	if (classid == 7 || classid == 12 || classid == 18 || classid == 19 || classid == 20
	  || classid == 21 || classid == 22 || classid == 23 || classid == 29 || classid == 30
 	  || classid == 40 || classid == 41 || classid == 47 || classid == 90 || classid == 169
      || classid == 170 || classid == 188 || classid == 193 || classid == 223)
	{
		gTeam[playerid] = TEAM_CIVILIANS;
	}
	
	if (classid == 35 || classid == 78 || classid == 79 || classid == 131 || classid == 132
	  || classid == 133 || classid == 134 || classid == 135 || classid == 136 || classid == 137
	  || classid == 158 || classid == 159 || classid == 160 || classid == 161 || classid == 162)
	{
		gTeam[playerid] = TEAM_GYPSIES;
	}
	
	if (classid == 277 || classid == 278 || classid == 279)
	{
	    gTeam[playerid] = TEAM_FIREMAN;
	}
	
	if (classid == 280 || classid == 281  || classid == 282  || classid == 283  || classid == 288)
	{
		gTeam[playerid] = TEAM_POLICE;
	}

	if (classid == 274 || classid == 275 || classid == 276)
	{
	    gTeam[playerid] = TEAM_MEDIC;
	}
	
	if (classid == 284 || classid == 285)
	{
		gTeam[playerid] = TEAM_SWAT;
	}
	
	if (classid == 286)
	{
		gTeam[playerid] = TEAM_FBI;
	}
}

//=========[SETPLAYERTOTEAMCOLOR]=========//
SetPlayerToTeamColor(playerid)
{
	if (gTeam[playerid] == TEAM_CIVILIANS)
	{
		SetPlayerColor(playerid, TEAM_CIVILIANS_COLOR);
	}

	if (gTeam[playerid] == TEAM_GYPSIES)
	{
		SetPlayerColor(playerid, TEAM_GYPSIES_COLOR);
	}

	if (gTeam[playerid] == TEAM_FIREMAN)
	{
		SetPlayerColor(playerid, TEAM_FIREMAN_COLOR);
	}

	if (gTeam[playerid] == TEAM_POLICE)
	{
		SetPlayerColor(playerid, TEAM_POLICE_COLOR);
	}

	if (gTeam[playerid] == TEAM_MEDIC)
	{
		SetPlayerColor(playerid, TEAM_MEDIC_COLOR);
	}

	if (gTeam[playerid] == TEAM_SWAT)
	{
		SetPlayerColor(playerid, TEAM_SWAT_COLOR);
	}
	
	if (gTeam[playerid] == TEAM_FBI)
	{
		SetPlayerColor(playerid, TEAM_FBI_COLOR);
	}

}
Код:
public OnPlayerRequestClass(playerid, classid)
{

	SetPlayerPos(playerid, -1825.3901, 540.6253, 150.8125);
	SetPlayerCameraPos(playerid, -1828.2405, 538.8458, 153.3919);
	SetPlayerCameraLookAt(playerid, -1825.3901, 540.6253, 150.8125);
	SetPlayerFacingAngle(playerid, 117.5598);
	SetPlayerTeamFromClass(playerid, classid);
	return 1;
}
Код:
public OnPlayerSpawn(playerid)
{
	//================[TEAMS]================//
    SetPlayerToTeamColor(playerid);
}
Reply
#2

Nevermind, solved. The solution if you have the same problem:

Don't put classid as the skin id. Just the order in where you used AddPlayerClass:

Код:
	if (classid == 1 || classid == 2 || classid == 3 || classid == 4 || classid == 55
	  || classid == 6 || classid == 7 || classid == 8 || classid == 9 || classid == 10
 	  || classid == 11 || classid == 12 || classid == 13 || classid == 14 || classid == 15
      || classid == 16 || classid == 17 || classid == 18 || classid == 19)
	{
		gTeam[playerid] = TEAM_CIVILIANS;
	}
This means that :

Код:
public OnGameModeInit()
{
	//===============================[CLASSES]================================//
	AddPlayerClass(7, -1825.3901, 540.6253, 150.8125, 126.0199, 0, 0, 0, 0, 0, 0); //1
	AddPlayerClass(12, -1825.3901, 540.6253, 150.8125, 126.0199, 0, 0, 0, 0, 0, 0); //2
	AddPlayerClass(18, -1825.3901, 540.6253, 150.8125, 126.0199, 0, 0, 0, 0, 0, 0); //3
	AddPlayerClass(19, -1825.3901, 540.6253, 150.8125, 126.0199, 0, 0, 0, 0, 0, 0); //4
	AddPlayerClass(20, -1825.3901, 540.6253, 150.8125, 126.0199, 0, 0, 0, 0, 0, 0); //5
	AddPlayerClass(21, -1825.3901, 540.6253, 150.8125, 126.0199, 0, 0, 0, 0, 0, 0); // and so on
	AddPlayerClass(22, -1825.3901, 540.6253, 150.8125, 126.0199, 0, 0, 0, 0, 0, 0);
	AddPlayerClass(23, -1825.3901, 540.6253, 150.8125, 126.0199, 0, 0, 0, 0, 0, 0);
	AddPlayerClass(29, -1825.3901, 540.6253, 150.8125, 126.0199, 0, 0, 0, 0, 0, 0);
	AddPlayerClass(30, -1825.3901, 540.6253, 150.8125, 126.0199, 0, 0, 0, 0, 0, 0);
	AddPlayerClass(40, -1825.3901, 540.6253, 150.8125, 126.0199, 0, 0, 0, 0, 0, 0);
	AddPlayerClass(41, -1825.3901, 540.6253, 150.8125, 126.0199, 0, 0, 0, 0, 0, 0);
	AddPlayerClass(47, -1825.3901, 540.6253, 150.8125, 126.0199, 0, 0, 0, 0, 0, 0);
	AddPlayerClass(90, -1825.3901, 540.6253, 150.8125, 126.0199, 0, 0, 0, 0, 0, 0);
	AddPlayerClass(169, -1825.3901, 540.6253, 150.8125, 126.0199, 0, 0, 0, 0, 0, 0);
	AddPlayerClass(170, -1825.3901, 540.6253, 150.8125, 126.0199, 0, 0, 0, 0, 0, 0);
I was using the skin id instead of the actual order
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)