[Help] Problem with team chat
#1

I was trying to make a team chat for my TDM GM, I copied a code from another server changed it to my variables.
But I get those errors. Help me fix this please.

Код:
	if(strcmp(cmdtext, "/team", true) == 0 || strcmp(cmdtext, "/t", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
            if(gTeam[playerid]) return 1;
			new length = strlen(cmdtext);
			while ((idx < length) && (cmdtext[idx] <= ' '))
			{
				idx++;
			}
			new offset = idx;
			new result[256];
			while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
			{
				result[idx - offset] = cmdtext[idx];
				idx++;
			}
			result[idx - offset] = EOS;
			if(!strlen(result))
			{
				SendClientMessage(playerid, COLOR_WHITE, "USAGE: (/t)eam [team chat]");
				return 1;
			}
		   	if(gTeam[playerid] == TEAM_CT)
		   	{
		   	    format(string, sizeof(string), "** %s: %s **",PlayerName(playerid), result);
                SendClientMessage(playerid, COLOR_BLUE, string);
   			}
   			else if(gTeam[playerid] == TEAM_TT)
		   	{
		   	    format(string, sizeof(string), "** %s: %s **",PlayerName(playerid), result);
                SendClientMessage(playerid, COLOR_RED, string);
   			}
		}
		return 1;
	}
Код:
C:\Users\Chaccour\Desktop\CS\gamemodes\csa.pwn(419) : error 017: undefined symbol "idx"
C:\Users\Chaccour\Desktop\CS\gamemodes\csa.pwn(421) : error 017: undefined symbol "idx"
C:\Users\Chaccour\Desktop\CS\gamemodes\csa.pwn(421) : warning 215: expression has no effect
C:\Users\Chaccour\Desktop\CS\gamemodes\csa.pwn(423) : error 017: undefined symbol "idx"
C:\Users\Chaccour\Desktop\CS\gamemodes\csa.pwn(425) : error 017: undefined symbol "idx"
C:\Users\Chaccour\Desktop\CS\gamemodes\csa.pwn(427) : error 017: undefined symbol "idx"
C:\Users\Chaccour\Desktop\CS\gamemodes\csa.pwn(428) : error 017: undefined symbol "idx"
C:\Users\Chaccour\Desktop\CS\gamemodes\csa.pwn(428) : warning 215: expression has no effect
C:\Users\Chaccour\Desktop\CS\gamemodes\csa.pwn(430) : error 017: undefined symbol "idx"
C:\Users\Chaccour\Desktop\CS\gamemodes\csa.pwn(438) : error 017: undefined symbol "string"
C:\Users\Chaccour\Desktop\CS\gamemodes\csa.pwn(438) : error 017: undefined symbol "string"
C:\Users\Chaccour\Desktop\CS\gamemodes\csa.pwn(438) : error 029: invalid expression, assumed zero
C:\Users\Chaccour\Desktop\CS\gamemodes\csa.pwn(438) : fatal error 107: too many error messages on one line
Reply
#2

Okay I had it fix to that point

Код:
    if(strcmp(cmdtext, "/team", true) == 0 || strcmp(cmdtext, "/t", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
            if(gTeam[playerid]) return 1;
			new length = strlen(cmdtext);
		    new idx;
		    new string[128], playername[30];
		    GetPlayerName(playerid, playername, sizeof(playername));
			while ((idx < length) && (cmdtext[idx] <= ' '))
			{
				idx++;
			}
			new offset = idx;
			new result[256];
			while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
			{
				result[idx - offset] = cmdtext[idx];
				idx++;
			}
			result[idx - offset] = EOS;
			if(!strlen(result))
			{
				SendClientMessage(playerid, COLOR_WHITE, "USAGE: (/t)eam [team chat]");
				return 1;
			}
		   	if(gTeam[playerid] == TEAM_CT)
		   	{
		   	    format(string, sizeof(string), "** %s: %s **",playername(playerid), result);
                SendClientMessage(playerid, CT_COLOR, string);
   			}
   			else if(gTeam[playerid] == TEAM_TT)
		   	{
		   	    format(string, sizeof(string), "** %s: %s **",playername(playerid), result);
                SendClientMessage(playerid, TT_COLOR, string);
   			}
		}
		return 1;
	}
Still need to fix those errors.

Код:
C:\Users\Chaccour\Desktop\CS\gamemodes\csa.pwn(445) : error 012: invalid function call, not a valid address
C:\Users\Chaccour\Desktop\CS\gamemodes\csa.pwn(445) : warning 215: expression has no effect
C:\Users\Chaccour\Desktop\CS\gamemodes\csa.pwn(445) : error 001: expected token: ";", but found ")"
C:\Users\Chaccour\Desktop\CS\gamemodes\csa.pwn(445) : error 029: invalid expression, assumed zero
C:\Users\Chaccour\Desktop\CS\gamemodes\csa.pwn(445) : fatal error 107: too many error messages on one line
Line 445 is this one:
Код:
 format(string, sizeof(string), "** %s: %s **",playername(playerid), result);
                SendClientMessage(playerid, CT_COLOR, string);
Reply
#3

Make the code like this
pawn Код:
format(string, sizeof(string), "** %s: %s **",playername(playerid), result);
 SendClientMessage(playerid, CT_COLOR, string);
make sure that yoy are using space correctly.
Reply
#4

I got it fix by remove the (playerid). Compliles with no errors.

But problem is that its not working good. When i type /t it sends a team message just sayin /t, i cant /t [blabla]
and for the TT team, nothing happens.

Dunno, anyone got a better team chat system or script, please tell me.
Reply
#5

problem solved
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)