How to make Team Chat?
#1

I have a TDM script but I cant find a tutorial to make a team chat,for instance when player picks a team from a dialog it sets his chat to the team channel chat,so when they talk only team members see it. If someone can help me out with this I would be very thankful
Reply
#2

This is pretty simple really, hopefully this should work!
pawn Код:
enum pInfo
{
    pTeam
}

stock SendTeamMessage(teamid, message[]) // This is a stock function, it pretty much allows you to use "SendTeamMessage(teamid, message[])"
{
    for(new i = 0; i < MAX_PLAYERS; i++) // This is a loop it loops through the total players that your server would allow.
    {
        if(IsPlayerConnected(i) && PlayerInfo[i][pTeam] == teamid) // This checks if the player is connected and if there team matches the teamid.
        {
            SendClientMessage(i, 0xFFFFFFFF, message); // This will send the message to the team.
        }
    }
    return 1;
}
Reply
#3

But you didnt explain what it does I dont understand coding like that either,with the brackets in the same line,may you explain what all of this does please? and change code,I do not care about space in script at the moment,I am still learning.

EDIT: I dont want the team defined for what you are,I made it so you can change what team you are when you relog. So team selection is not permanent. so pTeam would be useless for me wouldn't it?
Reply
#4

Right, i've edited my code. Hopefully it'll explain.
Reply
#5

I use class selection like this.

pawn Код:
SetPlayerTeamFromClass(playerid,classid)
{
    switch(classid)
    {
        case 0: // classid 0
        {
            gTeam[playerid] = 0; // it sets the data of the player who selected the first team (in the gTeam array) to TEAM_BLUE
            {
                SetSpawnInfo(playerid,0,176,2156.3208,-1708.1588,15.0859,89.9102,34,80,0,0,0,0);
                SetPlayerColor(playerid, COLOR_BLUE);
                SetPlayerInterior(playerid,0);
                SetCameraBehindPlayer(playerid);
            }
        }
        case 1: // classid 1
        {
            gTeam[playerid] = 1; // it sets the data of the player who selected the second team (in the gTeam array) to TEAM_RED
            {
                SetSpawnInfo(playerid,1,19,2528.0120,-1650.0964,14.4368,89.9102,34,80,0,0,0,0);
                SetPlayerColor(playerid, COLOR_RED);
                SetPlayerInterior(playerid,0);
                SetCameraBehindPlayer(playerid);
            }
        }
    }
}
Couldnt I use
if gTeam[playerid] = 0; >>make team chat code
if gTeam[playerid] = 1; >>make team chat code
Reply
#6

pawn Код:
stock SendTeamMessage(teamid, message[]) // SendTeamMessage(1, string);
{
    for(new i = 0; i < MAX_PLAYERS; i++) // Loops through all the players.
    {
        if(IsPlayerConnected(i) && PlayerInfo[i][pTeam] == teamid)// If the player is connected and their 'pTeam' equals teamid then..
        {
            SendClientMessage(i, 0xFFFFFFFF, message); // Send the message
        }
    }
    return 1;
}
Reply
#7

Here you go.
pawn Код:
stock SendTeamMessage(teamid, message[]) // This is a stock function, it pretty much allows you to use "SendTeamMessage(teamid, message[])"
{
    for(new i = 0; i < MAX_PLAYERS; i++) // This is a loop it loops through the total players that your server would allow.
    {
        if(IsPlayerConnected(i) && gTeam[i] == teamid) // This checks if the player is connected and if there team matches the teamid.
        {
            SendClientMessage(i, 0xFFFFFFFF, message); // This will send the message to the team.
        }
    }
    return 1;
}
Reply
#8

Quote:
Originally Posted by Luis-
Посмотреть сообщение
Here you go.
pawn Код:
stock SendTeamMessage(teamid, message[]) // This is a stock function, it pretty much allows you to use "SendTeamMessage(teamid, message[])"
{
    for(new i = 0; i < MAX_PLAYERS; i++) // This is a loop it loops through the total players that your server would allow.
    {
        if(IsPlayerConnected(i) && gTeam[i] == teamid) // This checks if the player is connected and if there team matches the teamid.
        {
            SendClientMessage(i, 0xFFFFFFFF, message); // This will send the message to the team.
        }
    }
    return 1;
}

Thank you Luis and everyone else +rep for your time and effort to help me out
Reply
#9

It's alright, glad to help. If you have anymore trouble feel free to PM me!
Reply
#10

Would this work?
pawn Код:
stock SendTeamMessage(teamid, message[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && gTeam[i] == TEAM_BLUE)
        {
            SendClientMessage(i, TEAM_BLUE_COLOR, "Blue Team Chat"message);
        }
        else if(IsPlayerConnected(i) && gTeam[i] == TEAM_RED)
        {
            SendClientMessage(i, TEAM_RED_COLOR,"Red Team Chat"message);
        }
    }
    return 1;
}
the "Blue Team Chat" is intended for when the player talks it says that :P does that work?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)