radio chat
#1

Hey guys. I am looking for a radio chat system for each color.

I want it like this: /r [text]

But I want that you only can see it if someone of your own color says it.

0xFFFF00AA
0x33CCFFAA
0xC2A2DAAA
0x10F441AA
0x2641FEAA
0xAA3333AA
0x33AA33AA


I hope someone can help me a littlebit?

Kind regards
Reply
#2

i don't think that's possible but u can make on teams : team 1 : color orange , team 2 : color red etc.. then u just gonna need team chat
Reply
#3

Then, can I make when you spawn with this color:
0x2641FEAA
You are automaticly in a cop team? Because I don't know how to work with teams. I am working with name colors
Reply
#4

Untested!

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  new cmd[128], idx;
    cmd = strtok(cmdtext, idx);
    if(strcmp(cmd,"/r",true) == 0)
    {
        new str[128], pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid,pName,sizeof(pName));
        format(str,sizeof(str) , "[Radio] (%s): %s",pName, cmdtext [ 3 ] );
        for(new loopplayers = 0; loopplayers<MAX_PLAYERS; loopplayers ++)
        {
            if(IsPlayerConnected(loopplayers))
            {
                if (GetPlayerColor(playerid) == GetPlayerColor(loopplayers))
                {
                    SendClientMessage(loopplayers,0xFF0000AA,str); // red
                }
            }
        }
        return 1;
    }
    return 1;
}
Be sure you use SetPlayerColor, else this wont work!
Also, be sure to define Strtok.
Reply
#5

pawn Код:
if(GetPlayerColor(playerid)==0x33AA33AA){ // Change the 0x33AA33AA to the color you want.
// Do whatever you want It to.
}
Reply
#6

Код:
	new cmd[128], idx;

	cmd = strtok(cmdtext, idx);
	if (strcmp("/r", cmdtext, true, 10) == 0)
	{
	new str[128], pName[MAX_PLAYER_NAME];
	GetPlayerName(playerid,pName,sizeof(pName));
	format(str,sizeof(str) , "[Radio] (%s): %s",pName, cmdtext [ 3 ] );
	for(new loopplayers = 0; loopplayers<MAX_PLAYERS; loopplayers ++)
		{
			if(IsPlayerConnected(loopplayers))
			{
				if (GetPlayerColor(playerid) == GetPlayerColor(loopplayers))
				{
					SendClientMessage(loopplayers,0xFF0000AA,str); // red
				}
			}
		}
	return 1;
}
Errors

Код:
C:\Users\Bart\Desktop\samp server\gamemodes\bartmarc.pwn(1457) : warning 219: local variable "cmd" shadows a variable at a preceding level
C:\Users\Bart\Desktop\samp server\gamemodes\bartmarc.pwn(1457) : warning 219: local variable "idx" shadows a variable at a preceding level
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Warnings.
Reply
#7

pawn Код:
new cmd[128], idx;

cmd = strtok(cmdtext, idx);
Remove them if you already have them in OnPlayerCommandText.
Reply
#8

the errors are removed but when I do /r test nothing shows up
Reply
#9

pawn Код:
if (strcmp("/r", cmdtext, true, 10) == 0)
change it to

pawn Код:
if (strcmp("/r", cmdtext, true, 2) == 0)
Reply
#10

Quote:
Originally Posted by MadeMan
pawn Код:
if (strcmp("/r", cmdtext, true, 10) == 0)
change it to

pawn Код:
if (strcmp("/r", cmdtext, true, 2) == 0)
this is what I have now
Код:
	if (strcmp("/r", cmdtext, true, 2) == 0)
	{
	new str[128], pName[MAX_PLAYER_NAME];
	GetPlayerName(playerid,pName,sizeof(pName));
	format(str,sizeof(str) , "[Radio] (%s): %s",pName, cmdtext [ 3 ] );
	for(new loopplayers = 0; loopplayers<MAX_PLAYERS; loopplayers ++)
		{
			if(IsPlayerConnected(loopplayers))
			{
				if (GetPlayerColor(playerid) == GetPlayerColor(loopplayers))
				{
					SendClientMessage(loopplayers,0xFF0000AA,str); // red
				}
			}
		}
	return 1;
}
Still nothing happends when I do /r test
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)