Teams problem -
MWF2 - 11.07.2010
I'm trying to make it so teams cannot hurt each other (like in a TDM)
It's not working, im using SetPlayerTeam,
PROBLEM: The problem is, Cops cannot attack each other BUT, Neither can any other team. So if Team_mechanic attacks Team_Cop, The cops are still not taking damage
This is how i setup my team
pawn Код:
#define TEAM_COP 1
SetPlayerToTeamColour(playerid)
{
if(gTeam[playerid] == TEAM_COP) {
}
}
SetPlayerTeamFromClass(playerid, classid)
{
if(classid == 0 || classid == 1 || classid == 2 || classid == 3 || classid == 4 || classid == 5 || classid == 6 || classid == 7 || classid == 10) {
gTeam[playerid] = TEAM_COP;
}
}
SetPlayerToTeamColor(playerid)
{
if (gTeam[playerid] == TEAM_COP) {
SetPlayerColor(playerid, COLOR_BLUE);
}
return 1;
}
if(gTeam[playerid] == TEAM_COP)
{
SetPlayerTeam(playerid, TEAM_COP);
SetPlayerPos( playerid, 1573.7228,-1694.9384,6.2188);
SendClientMessage(playerid,0x1E90FFAA, "Type /commands for your commands");
SendClientMessage(playerid,0x1E90FFAA, "POLICE OFFICER: Your job is to keep criminals off the streets of San Andreas");
SendClientMessage(playerid,0x1E90FFAA, "Remember: This is not a deathmatch server. Please abide by the /rules and enjoy");
TextDrawShowForPlayer(playerid, COPBOX);
TextDrawShowForPlayer(playerid, text11);
TextDrawShowForPlayer(playerid, text12);
TextDrawShowForPlayer(playerid, text13);
TextDrawShowForPlayer(playerid, text14);
hastazer[playerid] =1;
HasLawEnforcementRadio[playerid] =1;
LawEnforcementRadio[playerid] =1;
TextDrawShowForPlayer(playerid,txtTypeSkill1);
CanChooseSkill[playerid] = 0;
}
Re: Teams problem -
cessil - 11.07.2010
are you setting up the other team the same and do you get this line when you choose cop?
"POLICE OFFICER: Your job is to keep criminals off the streets of San Andreas"
Re: Teams problem -
MWF2 - 11.07.2010
I'm only setting my Team_cop with SetPlayerTeam because i only want them not to be able to attack each other. The rest of the teams are set regularly with gTeam
Re: Teams problem -
MWF2 - 11.07.2010
Anyone? Please I'd like to fix this.
Re: Teams problem -
DJDhan - 12.07.2010
Instead of
Код:
SetPlayerTeam(playerid,TEAM_COPS);
You can use
Код:
SetPlayerTeam(playerid,gTeam[playerid]);
which will make it easier.
So this is how/what you should do, to make teams.
At the top of script:
Код:
#define TEAM_COP 0
#define TEAM_MECHANIC 1
Under OnPlayerRequestClass(playerid,classid)
Код:
if(classid == 0)
{
GameTextForPlayer(playerid,"COP",3000,3);
}
if(classid == 1)
{
GameTextForPlayer(playerid,"MECHANIC",3000,3);
}
SetPlayerTeamFromClass(playerid,classid);
return 1;
}
Then comes your SetPlayerTeamFromClass(playerid,classid)
Код:
stock SetPlayerTeamFromClass(playerid, classid)
{
if(classid == 0 || classid == 1 || classid == 2 || classid == 3 || classid == 4 || classid == 5 || classid == 6 || classid == 7 || classid == 10)
{
gTeam[playerid] = TEAM_COP;
}
if(classid == 11)
{
gTeam[playerid] = TEAM_MECHANIC;
}
SetPlayerToTeamColor(playerid);
}
Setting the player's color:
Код:
stock SetPlayerToTeamColor(playerid)
{
if (gTeam[playerid] == TEAM_COP)
{
SetPlayerColor(playerid, COLOR_BLUE);
}
if(gTeam[playerid] == TEAM_MECHANIC)
{
SetPlayerColor(playerid, COLOR_GREEN);
}
return 1;
}
So now you have set-up a team.
Under OnPlayerSpawn(playerid)
Код:
public OnPlayerSpawn(playerid)
{
if(gTeam[playerid] == TEAM_COP)
{
SetPlayerPos( playerid, 1573.7228,-1694.9384,6.2188);
SendClientMessage(playerid,0x1E90FFAA, "Type /commands for your commands");
SendClientMessage(playerid,0x1E90FFAA, "POLICE OFFICER: Your job is to keep criminals off the streets of San Andreas");
SendClientMessage(playerid,0x1E90FFAA, "Remember: This is not a deathmatch server. Please abide by the /rules and enjoy");
TextDrawShowForPlayer(playerid, COPBOX);
TextDrawShowForPlayer(playerid, text11);
TextDrawShowForPlayer(playerid, text12);
TextDrawShowForPlayer(playerid, text13);
TextDrawShowForPlayer(playerid, text14);
hastazer[playerid] =1;
HasLawEnforcementRadio[playerid] =1;
LawEnforcementRadio[playerid] =1;
TextDrawShowForPlayer(playerid,txtTypeSkill1);
CanChooseSkill[playerid] = 0;
}
if(gTeam[playerid] == TEAM_MECHANIC)
{
//All your stuff
}
SetPlayerTeam(playerid, gTeam[playerid]);
return 1;
}
If you still can't figure out your problem with my example, let me know.
Re: Teams problem -
MWF2 - 12.07.2010
Thank you DJ, I will try it ASAP. Please bookmark this topic since you are one of the only people who explain things in full detail.
Thanks man, i appreciate your help.
Re: Teams problem -
FreshKilla - 12.07.2010
Here's a better way.
pawn Код:
#define TEAM_COP 0
#define TEAM_MECHANIC 1
public OnGameModeInit()
{
AddPlayerClass(0,1958.3783,1343.1572,15.3746,270.1425,0,0,24,300,-1,-1); // ClassID 0 Aka Cop
AddPlayerClass(0,1958.3783,1343.1572,15.3746,270.1425,0,0,24,300,-1,-1); // ClassID 1 Aka Mechanic
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
switch(classid)
{
case 0: // ClassID 0 aka Cop
{
GameTextForPlayer(playerid, "~b~Police", 4000, 3);
SetPlayerTeam(playerid,TEAM_COP); // Dosent matter that it goes here, it stops a variable like gTeam and its going to change if you switch classes.
}
case 1: // ClassID 1 aka Mech
{
GameTextForPlayer(playerid, "~r~Mechanic", 4000, 3);
SetPlayerTeam(playerid,TEAM_MECHANIC);
}
}
return 1;
}
public OnPlayerSpawn(playerid)
{
switch(GetPlayerTeam(playerid))
{
case TEAM_COP:
{
// Code here for when cops spawn
}
case TEAM_MECHANIC:
{
// Code here for when Mechanics spawn
}
}
return 1;
}