Message is send 4 times. - 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)
+--- Thread: Message is send 4 times. (
/showthread.php?tid=315209)
Message is send 4 times. -
milanosie - 02.02.2012
So, /t is to talk on a phone, but it sends the message correct(1 time) to the reciever. but 4 times to the sender.
pawn Code:
CMD:t(playerid, params[])
{
if(isoncall[playerid] == true)
{
if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /t [Text]");
new string[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "[phone]%s: %s", name, params);
foreach(Player, i)
{
if(callnumber[i] == PlayerInfo[playerid][PhoneNumber] && i != playerid) SendClientMessage(i, COLOR_PINK, string);
ProxDetector(10.0, playerid, string, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);
}
}
else return SendClientMessage(playerid, COLOR_GREY, "You are not on a call!");
return 1;
}
Re: Message is send 4 times. -
Snowman12 - 02.02.2012
why are you looping? Just send a message to the player and receiver then do a proxdetector? I'm sorry if this is wrong.
Re: Message is send 4 times. -
milanosie - 02.02.2012
I am looping cause It does not send a message to players based on name, It loops trough all players to see wich player is talking to the sender, so it wont send to all players that are calling at the moment
Re: Message is send 4 times. -
milanosie - 02.02.2012
Quote:
Originally Posted by Y_Less
You have ProxDetector inside the loop, which means the message gets sent to the sender once per connected player.
|
thanks

Silly mistake.
Should I place it after the sendclientmessage?
EDIT:
nvm, place it above the foreach right?