24.03.2010, 15:30
Try this:
Untested.
pawn Code:
//at top of script
#define TEAM_COPS 1
#define TEAM_CRIMINALS 2
new Team[MAX_PLAYERS];
forward SetPlayerTeamFromClass(playerid, classid);
public SetPlayerTeamFromClass(playerid, classid) //called from OnPlayerRequestClass
{
// Set their team number based on the class they selected.
if (classid == 4 || classid == 5 || classid == 6 || classid == 7 || classid == 8 || classid == 9 || classid == 10 || classid == 11 || classid == 12)
{
SetPVarInt(playerid, Team[playerid], TEAM_COPS);
SetPVarInt(playerid, HasPlayerChangedTeams, 1);
SetPVarInt(playerid, HasBeenSentObjectives, 0);
}
else if (classid == 0 || classid == 1 || classid == 2 || classid == 3)
{
SetPVarInt(playerid, Team[playerid], TEAM_CRIMINALS);
SetPVarInt(playerid, HasPlayerChangedTeams, 1);
SetPVarInt(playerid, HasBeenSentObjectives, 0);
}
return 1;
}
public SetPlayerToTeamColor(playerid) //called from OnPlayerSpawn, which also checks for team
{
if (GetPVarInt(playerid, Team[playerid]) == TEAM_COPS) SetPlayerColor(playerid,COPS_COLOR); // blue
else if (GetPVarInt(playerid, Team[playerid]) == TEAM_CRIMINALS) SetPlayerColor(playerid,CRIMINALS_COLOR); // red
return 1;
}