public OnPlayerText(playerid, text[])
{
if(text[0] == '&')
{
new string[128],name[30];
GetPlayerName(playerid, name, 30);
format(string, sizeof(string), "CHAT: %s [ID: %d]: %s", name, playerid, text[1]);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(PlayerInfo[playerid][Team] == PlayerInfo[i][Team])
{
SendClientMessage(i,agua,string);
return 0;
}
}
return 0;
}
return 0;
}
public OnPlayerText(playerid, text[])
{
if(text[0] == ';')
{
// player has typed a message starting with ;
}
return 1;
}
public OnPlayerText(playerid, text[])
{
if(text[0] == ';')
{
// player has typed a message starting with ;
new msg[128], pname[MAX_PLAYER_NAME], teamname[MAX_TEAM_NAME];
}
return 1;
}
#define MAX_TEAM_NAME 32 // defines the max length of a team name as 32 characters
stock GetTeamName(playerid, tname[], len) // Returns a player's team name depending on their team id (gTeam[playerid])
{
switch(gTeam[playerid]) // Checks the player's team id
{
case 0: format(tname, len, "RedGang"); // teamid 0 has the teamname RedGang
case 1: format(tname, len, "BlueGang"); // teamid 1 has the teamname BlueGang
case 2: format(tname, len, "GreenGang"); // teamid 2 has the teamname GreenGang
case 3: format(tname, len, "YellowGang"); // teamid 3 has the teamname YellowGang
default: printf("Invalid team name"); // this will only print if there is an error
}
return 1;
}
public OnPlayerText(playerid, text[])
{
if(text[0] == ';')
{
// player has typed a message starting with ;
new msg[128], pname[MAX_PLAYER_NAME], teamname[MAX_TEAM_NAME];
GetPlayerName(playerid, pname, sizeof(pname)); // gets the player's name
GetTeamName(playerid, teamname, sizeof(teamname)); // gets the player's teamname
strmid(msg, text, 1, strlen(text), sizeof(msg)); // saves what the player has typed without the ; at the start
format(msg, sizeof(msg), "[%s]%s: %s", teamname, pname, msg); // puts all the info together to create the message to send to players on the same team
}
return 1;
}
#define MAX_TEAM_NAME 32
stock GetTeamName(playerid, tname[], len)
{
switch(gTeam[playerid])
{
case 0: format(tname, len, "RedGang");
case 1: format(tname, len, "BlueGang");
case 2: format(tname, len, "GreenGang");
case 3: format(tname, len, "YellowGang");
default: printf("Invalid team name");
}
return 1;
}
public OnPlayerText(playerid, text[])
{
if(text[0] == ';')
{
// player has typed a message starting with ;
new msg[128], pname[MAX_PLAYER_NAME], teamname[MAX_TEAM_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
GetTeamName(playerid, teamname, sizeof(teamname));
strmid(msg, text, 1, strlen(text), sizeof(msg));
format(msg, sizeof(msg), "[%s]%s: %s", teamname, pname, msg);
for(new i=0; i<MAX_PLAYERS; i++) // loops through all players
{
if(gTeam[i] == gTeam[playerid]) // checks to see if the current player is on the same team as the player who typed the message
{
SendClientMessage(i, -1, msg); // prints the message for the player on the same team
}
}
return 0; // return 0 so that the original message with ; in front of it isn't shown to everybody
}
return 1;
}
stock GetTeamName(playerid, tname[], len) { switch(gTeam[playerid]) { case 0: format(tname, len, "TEAM_SWAT"); case 1: format(tname, len, "TEAM_CHICKENS"); case 2: format(tname, len, "TEAM_KAMIKAZERS"); case 3: format(tname, len, "TEAM_IMMIGRANTS"); case 4; format(tname, len, "TEAM_MEDICS"); case 5; format(tname, len, "TEAM_FARMERS"); case 6; format(tname, len, "TEAM_RICHS") case 7; format(tname, len, "TEAM_PILOTS"); default: printf("Invalid team name"); } return 1; }
public OnPlayerText(playerid, text[])
{
if(text[0] == '&')
{
new string[128],name[30];
GetPlayerName(playerid, name, 30);
format(string, sizeof(string), "CHAT: %s [ID: %d]: %s", name, playerid, text[1]);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(GetPlayerTeam(playerid) == GetPlayerTeam(i)) // Send message to all players of the player which typed: & + text
{
SendClientMessage(i,0x00FFFFFF,string);
return 0;
}
}
return 0;
}
return 0;
}
if(text[0] == '&')
{
new string[128],name[30];
GetPlayerName(playerid, name, 30);
format(string, sizeof(string), "CHAT: %s [ID: %d]: %s", name, playerid, text[1]);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(GetPlayerTeam(playerid) == GetPlayerTeam(i)) // Send message to all players of the player which typed: & + text
{
SendClientMessage(i,0x00FFFFFF,string);
return 0;
}
}
return 0;
}
Thanks at both.
Benjo,i've a problem. I definied the teams name as TEAM_TEAMNAME: Код:
stock GetTeamName(playerid, tname[], len) { switch(gTeam[playerid]) { case 0: format(tname, len, "TEAM_SWAT"); case 1: format(tname, len, "TEAM_CHICKENS"); case 2: format(tname, len, "TEAM_KAMIKAZERS"); case 3: format(tname, len, "TEAM_IMMIGRANTS"); case 4; format(tname, len, "TEAM_MEDICS"); case 5; format(tname, len, "TEAM_FARMERS"); case 6; format(tname, len, "TEAM_RICHS") case 7; format(tname, len, "TEAM_PILOTS"); default: printf("Invalid team name"); } return 1; } |