Team Chat help[rep]
#1

hi so i got these teams:
Код:
#define TEAM_TERROR	   0
#define TEAM_SWAT	   1
#define TEAM_ARMY      2
#define TEAM_CIA       4
#define TEAM_FBI       5
I want the symbol ! to be team chat.
When a player types ! a
this sentence will be sent only to player's team.
Reply
#2

You can make a command like /t [message]
/t means Teamchat
Reply
#3

I need help with the system.
Reply
#4

It's very easy.

pawn Код:
#include <a_samp>
#include <YSI\y_va>

public OnPlayerText(playerid, text[])
{
    if(msg[0] = '!')
    {
        for (new i = 0; i != MAX_PLAYERS; ++i)
        {
            if(IsPlayerConnected(i) && (gTeam[i] == gTeam[playerid])
                Msg(playerid, 0xC8C8C8FF, "[Team Msg] %s: %s", PlayerNameEx(playerid), msg[1]);
        }
        return 0;
    }
    return 1;
}

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<>)
{
    return SendClientMessage(playerid, color, va_return(fmat, va_start<3>));
}
Hope i helped.
If a player types "!hello" it will be sent to their team in this format: "[Team Chat] Name (ID): hello"
Reply
#5

C:\Users\John\Desktop\BlueZ Community Servers Scripts(RP,STUNT & TRUCKING\dm\gamemodes\TDM.pwn(172) : error 025: function heading differs from prototype
C:\Users\John\Desktop\BlueZ Community Servers Scripts(RP,STUNT & TRUCKING\dm\gamemodes\TDM.pwn(174) : warning 211: possibly unintended assignment
C:\Users\John\Desktop\BlueZ Community Servers Scripts(RP,STUNT & TRUCKING\dm\gamemodes\TDM.pwn(179) : error 001: expected token: ")", but found "-identifier-"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Reply
#6

Oh, my bad.

change
pawn Код:
public OnPlayerText(playerid, msg[])
to
pawn Код:
public OnPlayerText(playerid, text[])
Reply
#7

now i got more errors:
C:\Users\John\Desktop\BlueZ Community Servers Scripts(RP,STUNT & TRUCKING\dm\gamemodes\TDM.pwn(174) : error 017: undefined symbol "msg"
C:\Users\John\Desktop\BlueZ Community Servers Scripts(RP,STUNT & TRUCKING\dm\gamemodes\TDM.pwn(174) : warning 215: expression has no effect
C:\Users\John\Desktop\BlueZ Community Servers Scripts(RP,STUNT & TRUCKING\dm\gamemodes\TDM.pwn(174) : error 001: expected token: ";", but found "]"
C:\Users\John\Desktop\BlueZ Community Servers Scripts(RP,STUNT & TRUCKING\dm\gamemodes\TDM.pwn(174) : error 029: invalid expression, assumed zero
C:\Users\John\Desktop\BlueZ Community Servers Scripts(RP,STUNT & TRUCKING\dm\gamemodes\TDM.pwn(174) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#8

Try this one:

pawn Код:
#include <a_samp>
#include <YSI\y_va>

public OnPlayerText(playerid, text[])
{
    if(text[0] = '!' && strlen(text[1]))
    {
        for (new i = 0; i != MAX_PLAYERS; ++i)
        {
            if(IsPlayerConnected(i) && (gTeam[i] == gTeam[playerid])
                Msg(playerid, 0xC8C8C8FF, "[Team Msg] %s: %s", PlayerNameEx(playerid), text[1]);
        }
        return 0;
    }
    return 1;
}

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<>)
{
    return SendClientMessage(playerid, color, va_return(fmat, va_start<3>));
}
Reply
#9

C:\Users\John\Desktop\BlueZ Community Servers Scripts(RP,STUNT & TRUCKING\dm\gamemodes\TDM.pwn(174) : warning 211: possibly unintended assignment
C:\Users\John\Desktop\BlueZ Community Servers Scripts(RP,STUNT & TRUCKING\dm\gamemodes\TDM.pwn(179) : error 001: expected token: ")", but found "-identifier-"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#10

Sorry for that, i wrote this in the SA-MP Editor.

pawn Код:
#include <a_samp>
#include <YSI\y_va>

public OnPlayerText(playerid, text[])
{
    if(text[0] == '!' && strlen(text[1]))
    {
        for (new i = 0; i != MAX_PLAYERS; ++i)
        {
            if(IsPlayerConnected(i) && (gTeam[i] == gTeam[playerid]))
                Msg(playerid, 0xC8C8C8FF, "[Team Msg] %s: %s", PlayerNameEx(playerid), text[1]);
        }
        return 0;
    }
    return 1;
}

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<>)
{
    return SendClientMessage(playerid, color, va_return(fmat, va_start<3>));
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)