team chat help [+rep]
#1

Well I am trying to make a team chat and I have some code tho, but how I actually make the command out of it...

Код:
stock SendTeamMessage( playerid, t_MSG[ ] )
{
    for( new i = 0; i < MAX_PLAYERS; i ++ )
    {
        if( GetPlayerTeam( i ) == GetPlayerTeam( playerid ) )
        {
            new c_msg[ 128 ], c_name[ MAX_PLAYER_NAME ];
            GetPlayerName( playerid, c_name, sizeof c_name );
            format( c_msg, ( 128 ), "[Team Chat] %s: {FFFFFF}%s", c_name, t_MSG );
            SendClientMessage( i, GetPlayerColor( playerid ), c_msg );
        }
        else continue;
    }
    return ( 1 );
}
I want to make like

[Team Chat] Name: Text

Edit: I don't want to loose global chat.

And I tried with

Код:
	if (strcmp("/teamchat", cmdtext, true) == 0 || (strcmp("/tc", cmdtext, true) == 0))
	{
	    SendTeamMessage( playerid, t_MSG[ ] );
		return 1;
	}
But I think I did that wrong?
Reply
#2

Bump
Reply
#3

pawn Код:
cmd:teamchat(playerid, params[])
{
    SendTeamMessage(playerid, params);
    return 1;
}
Reply
#4

Mate, I ain't using ZCMD
Reply
#5

sorry, here, try this.
pawn Код:
if(strcmp(cmd, "/teamchat", false) == 0)
    {
        new length = strlen(cmdtext);
       
        new PlayerName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
        new str[128];
        format(str,sizeof(str),"[Team] %s: %s", PlayerName, cmdtext[3]);
        SendTeamMessage( playerid, str);
        return 1;
    }
Reply
#6

Quote:

C:\Users\Maki\Desktop\server 0.3d\gamemodes\TankDM.pwn(484) : error 017: undefined symbol "strrest"
C:\Users\Maki\Desktop\server 0.3d\gamemodes\TankDM.pwn(484) : error 033: array must be indexed (variable "tmp")
C:\Users\Maki\Desktop\server 0.3d\gamemodes\TankDM.pwn(48 : error 017: undefined symbol "SendClientUsage"
C:\Users\Maki\Desktop\server 0.3d\gamemodes\TankDM.pwn(492) : error 017: undefined symbol "PlayerName"

Oh Mate I don't get it why it's not working
Reply
#7

try it now, i edited (im not good with strcmp tho, i went straight to zcmd/sscanf)
Reply
#8

Since I was receiving that CMD is undefined symbol I used cmdtext so I've cut some of the errors, but still getting some about the TMP and the other stuff.

Quote:

C:\Users\Maki\Desktop\server 0.3d\gamemodes\TankDM.pwn(442) : error 017: undefined symbol "tmp"
C:\Users\Maki\Desktop\server 0.3d\gamemodes\TankDM.pwn(444) : error 035: argument type mismatch (argument 2)
C:\Users\Maki\Desktop\server 0.3d\gamemodes\TankDM.pwn(450) : error 012: invalid function call, not a valid address
C:\Users\Maki\Desktop\server 0.3d\gamemodes\TankDM.pwn(450) : warning 215: expression has no effect
C:\Users\Maki\Desktop\server 0.3d\gamemodes\TankDM.pwn(450) : error 001: expected token: ";", but found ")"
C:\Users\Maki\Desktop\server 0.3d\gamemodes\TankDM.pwn(450) : error 029: invalid expression, assumed zero
C:\Users\Maki\Desktop\server 0.3d\gamemodes\TankDM.pwn(450) : fatal error 107: too many error messages on one line

So errors on these:
Код:
if(!strlen(tmp)) //<- 442
SendClientMessage(playerid, cmdtext, " /teamchat [text]"); //<-444
format(str, sizeof(str), "Teamchat %s: %s", PlayerName(playerid), cmdtext[3]); //<-450
BUMP: I've added new
Код:
tmp[128];
and got rid of the 442 error


Edit: Since you don't know about the STR maybe this should help you.
Код:
format(string,sizeof string,"PM Send to %s: %s",gName,inputtext)
;
This is how we format in the str.
Reply
#9

Maybe you should wait for someone with more experience with strcmp Sorry i couldnt help you more
Reply
#10

Oh okay mate Thanks for trying btw Really appreciated.


Edit:
So errors:
Код:
C:\Users\Maki\Desktop\server 0.3d\gamemodes\TankDM.pwn(451) : error 012: invalid function call, not a valid address
C:\Users\Maki\Desktop\server 0.3d\gamemodes\TankDM.pwn(451) : warning 215: expression has no effect
C:\Users\Maki\Desktop\server 0.3d\gamemodes\TankDM.pwn(451) : error 001: expected token: ";", but found ")"
C:\Users\Maki\Desktop\server 0.3d\gamemodes\TankDM.pwn(451) : error 029: invalid expression, assumed zero
C:\Users\Maki\Desktop\server 0.3d\gamemodes\TankDM.pwn(451) : fatal error 107: too many error messages on one line
Line:
Код:
format(str, sizeof(str), "Teamchat %s: %s", PlayerName(playerid), cmdtext[3]);
Only that left, I got rid of the others
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)