SA-MP Forums Archive
Teamchat - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Teamchat (/showthread.php?tid=533866)



Teamchat - YanLanger - 26.08.2014

Does anyone got idea how do i make teamchat?

Teams: Grove ballas homlesses chinese aztecas vagos police


Re: Teamchat - YanLanger - 26.08.2014

anyone?


Re: Teamchat - Stinged - 26.08.2014

As a command (zcmd):
pawn Код:
CMD:t(playerid, params[])
{
    if (insull(params)) return SendClientMessage(playerid, -1, "Usage: /t [message]");
   
    new string[145], pName[24];
    GetPlayerName(playerid, pName, sizeof (pName));
    format(string, sizeof (string), "[TEAM CHAT] %s (%i): %s", pName, playerid, params);
    foreach (new i : Player) // Change to for(new i; i != MAX_PLAYERS; i++) if you don't have foreach
    {
        if (GetPlayerTeam(i) == GetPlayerTeam(playerid))
        {
            SendClientMessage(i, GetTeamColor(GetPlayerTeam(playerid)), string);
        }
    }
    return 1;
}
Using a symbol:
pawn Код:
public OnPlayerText(playerid, text[])
{
    if (text[0] == '#') // Change # to your symbol
    {
        new string[145], pName[24];
        GetPlayerName(playerid, pName, sizeof (pName));
        format(string, sizeof (string), "[TEAM CHAT] %s (%i): %s", pName, playerid, text[1]);
        foreach (new i : Player) // Change to for(new i; i != MAX_PLAYERS; i++) if you don't have foreach
        {  
            if (GetPlayerTeam(i) == GetPlayerTeam(playerid))
            {
                SendClientMessage(i, GetTeamColor(GetPlayerTeam(playerid)), string);
            }
        }
                return 0;
    }
    return 1;
}
Note: You need GetTeamColor:
pawn Код:
GetTeamColor(teamid)
{
    switch(teamid)
    {
        case TEAM1: return TEAM1_COLOR;
        case TEAM2: return TEAM2_COLOR;
        case TEAM3: return TEAM3_COLOR;
        // ...
    }
    return 0;
}
Should work.


Re: Teamchat - YanLanger - 26.08.2014

didn't work


Re: Teamchat - MikeEd - 26.08.2014

Do you use SetPlayerTeam or do you have custom variables?


Re: Teamchat - YanLanger - 26.08.2014

I think setplayerteam not sure...


Re: Teamchat - MikeEd - 26.08.2014

Team Chat depends on how your player is assigned a Team. So for that you probably need to provide us with some code to work with.


Re: Teamchat - IceCube! - 26.08.2014

Don't work. Isn't descriptive... if you don't put in the effort we won't either!

Why didn't it work!