[Tutorial] Making Team Chat[Good for TDM]
#1

Introduction
This is team chat.Symbol"!" The message u type in team chat will be automatically sent to all players with the same team
Requires
Includes: (a_samp & YSI/y_va)
Download YSI from here https://sampforum.blast.hk/showthread.php?tid=321092 )
#include <a_samp>
#include <YSI\y_va>

Codes
So lets add OnPlayerText.
Код:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '!' && strlen(text[1]))//"!" Is the symbol you use to teamchat.e.g: !Hello team
    {
        for (new i = 0; i != MAX_PLAYERS; ++i)
        {
            if(IsPlayerConnected(i) && (gTeam[i] == gTeam[playerid]))
                Msg(playerid, -1, "[Team Chat] %s: %s", PlayerNameEx(playerid), text[1]);//The message to be sent
        }
        return 0;
    }
    return 1;
}
Stocks now
Код:
stock PlayerNameEx(playerid)
{
    new
        playerName[MAX_PLAYER_NAME+1],
        string[MAX_PLAYER_NAME+1+7];

    GetPlayerName(playerid, playerName, sizeof(playerName));
    format(string, sizeof(string), "%s (%d)", playerName, playerid);
    return string;
}

stock Msg(playerid, color, const fmat[], va_args<>)//Like SendClientMessage
{
    return SendClientMessage(playerid, color, va_return(fmat, va_start<3>));
}
Reply
#2

Not explained.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)