SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 11/01/2010, 10:42 AM   #1
Perker12345
Big Clucker
 
Join Date: Jan 2010
Posts: 97
Reputation: 0
Default Sending one message instead of 2

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
Perker12345 is offline  
Old 11/01/2010, 11:08 AM   #2
[HiC]TheKiller
High-roller
 
Join Date: Mar 2008
Location: New Zealand
Posts: 3,095
Reputation: 406
Default Re: Sending one message instead of 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;
    }
__________________
People seem to enjoy negitive repping me for topics that I made in 2009.
Therefore, if you want to view my releases, you can go here.

Skype: TheKiller@dr.com
I do NOT script for cash. Add me on MSN if you need help with small issues.
[HiC]TheKiller is offline  
Old 11/01/2010, 11:53 AM   #3
Perker12345
Big Clucker
 
Join Date: Jan 2010
Posts: 97
Reputation: 0
Default Re: Sending one message instead of 2

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
Perker12345 is offline  
Old 11/01/2010, 11:59 AM   #4
[HiC]TheKiller
High-roller
 
Join Date: Mar 2008
Location: New Zealand
Posts: 3,095
Reputation: 406
Default Re: Sending one message instead of 2

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.
__________________
People seem to enjoy negitive repping me for topics that I made in 2009.
Therefore, if you want to view my releases, you can go here.

Skype: TheKiller@dr.com
I do NOT script for cash. Add me on MSN if you need help with small issues.
[HiC]TheKiller is offline  
Old 11/01/2010, 01:00 PM   #5
Perker12345
Big Clucker
 
Join Date: Jan 2010
Posts: 97
Reputation: 0
Default Re: Sending one message instead of 2

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
Perker12345 is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
kill streak sending message sending wrong Andy_McKinley Help Archive 0 08/07/2010 12:40 PM
Its sending message and everyone can see my text Torran Help Archive 1 05/05/2010 12:10 PM
dcmd_givecash < sending wrong message Andy_McKinley Help Archive 7 27/03/2010 09:07 AM
Okay, could use some help in sending a global message Zomane_Rooot Help Archive 1 13/12/2009 09:12 PM
Have problem with sending message NickName3 Help Archive 1 14/10/2009 01:54 PM


All times are GMT. The time now is 06:04 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.