Sending one message instead of 2
#1

I know the topic name is lame heh..
i have a problem when people are talking in /radio it sends the radio message twice, it sends the message to all people on the radio channel, and everybody around him..
Thats what i want but the player who types the message gets the message twice(the radio and the proxdetector), could i make so he only sees the (radio) chat, and others around him see's the other part, just to avoid being spammed when talking in radio

Code:
  	if(strcmp(cmd, "/radio", true) == 0 || strcmp(cmd, "/r", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
			new wstring[128];
			new faction = PlayerInfo[playerid][pFaction];
			new rank = PlayerInfo[playerid][pRank];
			new length = strlen(cmdtext);
			while ((idx < length) && (cmdtext[idx] <= ' '))
			{
				idx++;
			}
			new offset = idx;
			new result[128];
			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] (/r)adio");
				return 1;
			}
			if(Muted[playerid])
			{
				SendClientMessage(playerid, COLOR_GREY, "[Error] You can not use the radio, You are muted");
				return 1;
			}
			if(PlayerInfo[playerid][pFaction] == 5 || PlayerInfo[playerid][pFaction] == 0)
			{
				 		if(rank == 1)
						{
						  format(wstring, sizeof(wstring), "[Radio] %s %s: %s, over",DynamicFactions[faction][fRank1],GetPlayerNameEx(playerid),result);
						  ProxDetector(20.0, playerid, wstring,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
							SendFactionTypeMessage(1, COLOR_LSPD, wstring);
						  FactionChatLog(wstring);
						}
			}
			else
			{
				SendClientMessage(playerid, COLOR_GREY, "[Error] Invalid faction");
			}
		}
		return 1;
	}
One more thing! I'm tired of other players spectating me when i am testing, so can i disable people to spectate me, example:
/spec perker
returns and sends a message; Fool.

since the code is based on ID, could it then check the ID's name with some extra stuff ?

Code:
	if(strcmp(cmd, "/spec", true) == 0)
	{
	  new playerid2;
	  tmp = strtok(cmdtext, idx);
		if(!strlen(tmp))
		{
			SendClientMessage(playerid, COLOR_GREY, "[Usage] /spec [ID] to spectate a player.");
			return 1;
		}
		playerid2 = strval(tmp);
		if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdmin] >= 1)
		{
		TogglePlayerSpectating(playerid, 1);
		PlayerSpectatePlayer(playerid, playerid2);
		SetPlayerInterior(playerid,GetPlayerInterior(playerid2));
		}
		return 1;
	}
That is my code, please help me
Reply
#2

pawn Code:
for(new i; i<MAX_PLAYERS; i++)
{
  if(IsPlayerConnected(i))
  {
    if(i != playerid)
    {
      ProxDetector(20.0, i, wstring,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
    }
  }
}
Sends the proxdetector to everyone except the player that typed the command.

pawn Code:
if(strcmp(cmd, "/spec", true) == 0)
    {
      new playerid2;
      tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_GREY, "[Usage] /spec [ID] to spectate a player.");
            return 1;
        }
        playerid2 = strval(tmp);
        new Pname[24];
        GetPlayerName(playerid2, Pname, 24)
        if(!strcmp(Pname, "perker", true)) return SendClientMessage(playerid, COLOR_RED, "FOOL!");
        if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdmin] >= 1)
        {
        TogglePlayerSpectating(playerid, 1);
        PlayerSpectatePlayer(playerid, playerid2);
        SetPlayerInterior(playerid,GetPlayerInterior(playerid2));
        }
        return 1;
    }
Reply
#3

Wow, thanks!
But i'm very lost at these errors


Code:
//top
forward ProxDie(Float:radi, playerid, string[],col1,col2,col3,col4,col5);

//bottom
public ProxDie()
{
	for(new i; i<MAX_PLAYERS; i++)
	{
	  if(IsPlayerConnected(i))
	  {
	    if(i != playerid) //Line 30019
	    {
	      ProxDetector(20.0, playerid, wstring,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5); // Line 30021
	    }
    }
  }
  return 1;
}
I get these errors on the public proxdie
C:\Users\Perker\Desktop\IBP.pwn(30019) : error 017: undefined symbol "playerid"
C:\Users\Perker\Desktop\IBP.pwn(30021) : error 017: undefined symbol "playerid"

And another one in the spec command, sorry for not fixing them myself, but i cant find the problems
Code:
C:\Users\Perker\Desktop\IBP.pwn(7296) : error 001: expected token: ";", but found "if"
Code:
	if(strcmp(cmd, "/spec", true) == 0)
	{
	new playerid2;
	tmp = strtok(cmdtext, idx);
	if(!strlen(tmp))
	{
	SendClientMessage(playerid, COLOR_GREY, "[Usage] /spec [ID] to spectate a player.");
	return 1;
	}
	playerid2 = strval(tmp);
	new Pname[24];
	GetPlayerName(playerid2, Pname, 24)
	if(!strcmp(Pname, "Chris", true)) return SendClientMessage(playerid, COLOR_RED, "FOOL!"); // Line 7296
	if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdmin] >= 1)
	{
	TogglePlayerSpectating(playerid, 1);
	PlayerSpectatePlayer(playerid, playerid2);
	SetPlayerInterior(playerid,GetPlayerInterior(playerid2));
	}
	return 1;
	}
Thank you so much Hic Killer
Reply
#4

pawn Code:
GetPlayerName(playerid2, Pname, 24)
To
pawn Code:
GetPlayerName(playerid2, Pname, 24)
And

pawn Code:
for(new i; i<MAX_PLAYERS; i++)
    {
      if(IsPlayerConnected(i))
      {
        if(i != playerid) //Line 30019
        {
          ProxDetector(20.0, playerid, wstring,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5); // Line 30021
        }
    }
  }
Is meant to be in with the command.
Reply
#5

Oops, i guess i must have made a mistake in the radio, it still sends the message twice
i'll paste the it again, could anybody help me with it?
Code:
  	if(strcmp(cmd, "/radio", true) == 0 || strcmp(cmd, "/r", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
			new wstring[128];
			new faction = PlayerInfo[playerid][pFaction];
			new rank = PlayerInfo[playerid][pRank];
			new length = strlen(cmdtext);
			while ((idx < length) && (cmdtext[idx] <= ' '))
			{
				idx++;
			}
			new offset = idx;
			new result[128];
			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] (/r)adio");
				return 1;
			}
			if(Muted[playerid])
			{
				SendClientMessage(playerid, COLOR_GREY, "[Error] You can not use the radio, You are muted");
				return 1;
			}
			if(PlayerInfo[playerid][pFaction] == 5 || PlayerInfo[playerid][pFaction] == 0)
			{
				 		if(rank == 1)
						{
						  format(wstring, sizeof(wstring), "[Radio] %s %s: %s, over",DynamicFactions[faction][fRank1],GetPlayerNameEx(playerid),result);
						  for(new i; i<MAX_PLAYERS; i++)
							{
							  if(IsPlayerConnected(i))
							  {
							    if(i != playerid) //Line 30019
							    {
							      ProxDetector(20.0, playerid, wstring,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5); // Line 30021
							    }
							  }
							}
							SendFactionTypeMessage(1, COLOR_LSPD, wstring);
						  FactionChatLog(wstring);
						}
				 		else if(rank == 2)
						{
						  format(wstring, sizeof(wstring), "[Radio] %s %s: %s, over",DynamicFactions[faction][fRank2],GetPlayerNameEx(playerid),result);
						  for(new i; i<MAX_PLAYERS; i++)
							{
							  if(IsPlayerConnected(i))
							  {
							    if(i != playerid) //Line 30019
							    {
							      ProxDetector(20.0, playerid, wstring,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5); // Line 30021
							    }
							  }
							}
							SendFactionTypeMessage(1, COLOR_LSPD, wstring);
						  FactionChatLog(wstring);
						}
			}
			else
			{
				SendClientMessage(playerid, COLOR_GREY, "[Error] Invalid faction");
			}
		}
		return 1;
	}
It shows up like this for the player who types in radio
Paul(radio): Text
and then it shows one more time for the faction message
Commander Paul: Text
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)