Message is send 4 times.
#1

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;
}
Reply
#2

why are you looping? Just send a message to the player and receiver then do a proxdetector? I'm sorry if this is wrong.
Reply
#3

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
Reply
#4

Quote:
Originally Posted by Y_Less
View Post
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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)