[HELP] How to create team chat
#1

can tell me how to make the team chat using gTeam please help me
Reply
#2

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(text[0] == ';')
    {
    new string[128];
    GetPlayerName(playerid, string, sizeof(string));
    format(string, sizeof(string), "[Team Chat] %s(%d): %s", string, playerid, text[1]);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
    if(IsPlayerConnected(i) && gTeam[i] == gTeam[playerid]) SendClientMessage(i, GetPlayerColor(playerid), string);
    }
    return 0;
    }

    return 1;
}
Reply
#3

i got some error

Quote:

C:\Documents and Settings\xp\Desktop\LZGS Mission\filterscripts\ladmin.pwn(565 : error 017: undefined symbol "text"
C:\Documents and Settings\xp\Desktop\LZGS Mission\filterscripts\ladmin.pwn(565 : warning 215: expression has no effect
C:\Documents and Settings\xp\Desktop\LZGS Mission\filterscripts\ladmin.pwn(565 : error 001: expected token: ";", but found "]"
C:\Documents and Settings\xp\Desktop\LZGS Mission\filterscripts\ladmin.pwn(565 : error 029: invalid expression, assumed zero
C:\Documents and Settings\xp\Desktop\LZGS Mission\filterscripts\ladmin.pwn(565 : fatal error 107: too many error messages on one line

how to fix this?
Reply
#4

Which line?
Reply
#5

in here:
if(text[0] == ';')
Reply
#6

Try replacing the
pawn Код:
if(text[0] == ';')
part with this:
pawn Код:
if(strfind(text, ';') == 0)
Reply
#7

i got some error again

Quote:

C:\Documents and Settings\xp\Desktop\LZGS Mission\filterscripts\ladmin.pwn(565 : error 017: undefined symbol "text"
C:\Documents and Settings\xp\Desktop\LZGS Mission\filterscripts\ladmin.pwn(5660) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Documents and Settings\xp\Desktop\LZGS Mission\filterscripts\ladmin.pwn(5662) : error 017: undefined symbol "text"
C:\Documents and Settings\xp\Desktop\LZGS Mission\filterscripts\ladmin.pwn(5662) : warning 215: expression has no effect
C:\Documents and Settings\xp\Desktop\LZGS Mission\filterscripts\ladmin.pwn(5662) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\xp\Desktop\LZGS Mission\filterscripts\ladmin.pwn(5662) : error 029: invalid expression, assumed zero
C:\Documents and Settings\xp\Desktop\LZGS Mission\filterscripts\ladmin.pwn(5662) : fatal error 107: too many error messages on one line

Reply
#8

Are you placing this under the OnPlayerText callback?
Reply
#9

whether this

Quote:

public OnPlayerText(playerid, text[])
{
//------------------------------------------------------------------------------
if(strfind(text, ';') == 0)
{
new string[128];
GetPlayerName(playerid, string, sizeof(string));
format(string, sizeof(string), "[Team Chat] %s(%d): %s", string, playerid, text[1]);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && gTeam[i] == gTeam[playerid]) SendClientMessage(i, GetPlayerColor(playerid), string);
}
return 0;
}
//------------------------------------------------------------------------------

if true I keep getting this error

Quote:

C:\Documents and Settings\xp\Desktop\LZGS Mission\filterscripts\ladmin.pwn(1322) : error 035: argument type mismatch (argument 2)
C:\Documents and Settings\xp\Desktop\LZGS Mission\filterscripts\ladmin.pwn(1329) : error 017: undefined symbol "gTeam"
C:\Documents and Settings\xp\Desktop\LZGS Mission\filterscripts\ladmin.pwn(1329) : warning 215: expression has no effect
C:\Documents and Settings\xp\Desktop\LZGS Mission\filterscripts\ladmin.pwn(1329) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\xp\Desktop\LZGS Mission\filterscripts\ladmin.pwn(1329) : error 029: invalid expression, assumed zero
C:\Documents and Settings\xp\Desktop\LZGS Mission\filterscripts\ladmin.pwn(1329) : fatal error 107: too many error messages on one line

Reply
#10

pawn Код:
public OnPlayerText(playerid, text[])
{
new gTeam[5];

if(strfind(text, ";") != -1)
{
new pName[MAX_PLAYER_NAME], pString[128];

for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && gTeam[i] == gTeam[playerid])
{
GetPlayerName(playerid, pName, sizeof(pName));
format(pString, sizeof(pString), "[Team Chat][%s]: %s", pName, text);
SendClientMessage(i, GetPlayerColor(playerid), pString);
}
}
}
return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)