SA-MP Forums Archive
radio chat - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: radio chat (/showthread.php?tid=125775)



radio chat - bartje01 - 05.02.2010

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


Re: radio chat - hvampire - 05.02.2010

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


Re: radio chat - bartje01 - 05.02.2010

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


Re: radio chat - VonLeeuwen - 05.02.2010

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.


Re: radio chat - Mike Garber - 05.02.2010

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



Re: radio chat - bartje01 - 05.02.2010

Код:
	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.



Re: radio chat - MadeMan - 05.02.2010

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

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


Re: radio chat - bartje01 - 05.02.2010

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


Re: radio chat - MadeMan - 05.02.2010

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

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



Re: radio chat - bartje01 - 05.02.2010

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