Team chat
#1

Im trying to make a chat for a team, so they can communicate with eachother(kinda like RP server's /f chat)

Here is the code:
pawn Код:
public OnPlayerText(playerid, text[])
    {
    if(GetPlayerTeam(playerid) = 1)//line 186
        {
        new string[128],
        message[100];
        format(string, sizeof(string), "[Red Team] %s {%s}: %s", GetPlayerName(playerid), playerid, message);
        foreach (new i : Player)
            {
            if(GetPlayerTeam(i) = 1)
                {
                SendClientMessage(i, COLYELLOW, string);
                return 1;
                }
            }
        }
    if(GetPlayerTeam(playerid) = 2)
        {
        new string[128],
        message[100];
        format(string, sizeof(string), "[Blue Team] %s {%s}: %s", GetPlayerName(playerid), playerid, message);
        foreach (new i : Player)
            {
            if(GetPlayerTeam(i) = 2)
                {
                SendClientMessage(i, COLYELLOW, string);
                return 1;
                }
            }
        }
    return 0;
    }
Here are the errors
Код:
(186) : warning 211: possibly unintended assignment
(186) : error 022: must be lvalue (non-constant)
(186) : warning 215: expression has no effect
(186) : error 001: expected token: ";", but found ")"
(186) : error 029: invalid expression, assumed zero
(186) : fatal error 107: too many error messages on one line
Reply
#2

pawn Код:
if(GetPlayerTeam(playerid == 1))//line 186
Reply
#3

that worked, thanks, although I am still getting

(207) : warning 211: possibly unintended assignment
Reply
#4

What's line 207?
Reply
#5

the { below foreach
Reply
#6

You may have one too many brackets somewhere, I can't really look into detail as I'm pretty busy
Reply
#7

Nawh its not that, if it was that, then it would give an error, but thanks anyway
Reply
#8

if(GetPlayerTeam(playerid == 1))//line 186
wtf?

isnt it

if(GetPlayerTeam(playerid) == 1)//line 186
Reply
#9

figured it out, maybe i shouldnt copy paste help answers :S

if(GetPlayerTeam(playerid) == 1)

The way you showed it was if the ID is 1.
Reply
#10

Oh, I didnt see your post! Anyway, yeah, I made a noob mistake, I put = instead of == :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)