SA-MP Forums Archive
SendClientMessageToAll bug - 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: SendClientMessageToAll bug (/showthread.php?tid=310048)



SendClientMessageToAll bug - Gooday - 10.01.2012

Please i cant fix this: all can see the message and not just the skins
pawn Код:
CMD:911(playerid,params[])
{
    //911 system
    if(isnull(params)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /911 [Message and Location]");
    new sendername[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, sendername, sizeof(sendername));
    SendClientMessage(playerid, COLOR_GOLD, "[INFO]You have just called 911. Please remain at your location and wait.");
    for(new i=0;i<MAX_PLAYERS;i++) {
        if(GetPlayerSkin(i) == 285 || GetPlayerSkin(i) == 282 || GetPlayerSkin(i) == 281 || GetPlayerSkin(i) == 283 || GetPlayerSkin(i) == 288 ||GetPlayerSkin(i) == 278  || GetPlayerSkin(i) == 275 || GetPlayerSkin(i) == 279 || GetPlayerSkin(i) == 277 || GetPlayerSkin(i) == 274 || GetPlayerSkin(i) == 276) {
            SendClientMessageToAll(COLOR_GREY, "-------------------------------------------------------------------------------------------------");
            SendClientMessageToAll(COLOR_ROYALBLUE, "DISPATCH");
            SendClientMessageToAll(COLOR_GREY, "Be advised, the following is a 911 call.");
            SendClientMessageToAll(COLOR_GREY, "Units aviable please respond.");
            format(string, sizeof(string), "CALLER: %s  ~  INFO & LOCATION: %s", sendername, params);
            SendClientMessageToAll(COLOR_GREY, string);
            SendClientMessageToAll(COLOR_GREY, "-------------------------------------------------------------------------------------------------");
        }

    }
    return 1;
}
+REP! BUT FIX PLEASEEEEEEEEE


Re: SendClientMessageToAll bug - Konstantinos - 10.01.2012

I have already gave you an answer to this. You use SendClientToAll and that sends the message to all the players. Use loop for all players and then if statement. If the skin is correct it SendClientMessage to that player have the correct skin.
pawn Код:
CMD:911(playerid,params[])
{
    //911 system
    if(isnull(params)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /911 [Message and Location]");
    new sendername[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, sendername, sizeof(sendername));
    SendClientMessage(playerid, COLOR_GOLD, "[INFO]You have just called 911. Please remain at your location and wait.");
    for(new i=0;i<MAX_PLAYERS;i++) {
        if(GetPlayerSkin(i) == 285 || GetPlayerSkin(i) == 282 || GetPlayerSkin(i) == 281 || GetPlayerSkin(i) == 283 || GetPlayerSkin(i) == 288 ||GetPlayerSkin(i) == 278  || GetPlayerSkin(i) == 275 || GetPlayerSkin(i) == 279 || GetPlayerSkin(i) == 277 || GetPlayerSkin(i) == 274 || GetPlayerSkin(i) == 276) {
            SendClientMessage(i, COLOR_GREY, "-------------------------------------------------------------------------------------------------");
            SendClientMessage(i, COLOR_ROYALBLUE, "DISPATCH");
            SendClientMessage(i, COLOR_GREY, "Be advised, the following is a 911 call.");
            SendClientMessage(i, COLOR_GREY, "Units aviable please respond.");
            format(string, sizeof(string), "CALLER: %s  ~  INFO & LOCATION: %s", sendername, params);
            SendClientMessage(i, COLOR_GREY, string);
            SendClientMessage(i, COLOR_GREY, "-------------------------------------------------------------------------------------------------");
        }

    }
    return 1;
}



Re: SendClientMessageToAll bug - Mikkel_Pedersen - 10.01.2012

You are doing a loop through all your players and when they got one of the required skins, you send a message to everyone. So if you have 10 players online, 5 with one of the required skins. Then every player on the server will see your client messages 10 times. You would want to change "SendClientMessageToAll(" into "SendClientMessage(i, " (You can use ctrl+h for a fast replacement).


Re: SendClientMessageToAll bug - Gooday - 10.01.2012

Quote:

:\Users\Luca\Desktop\basefixed.pwn(2869) : error 035: argument type mismatch (argument 2)
C:\Users\Luca\Desktop\basefixed.pwn(2870) : error 035: argument type mismatch (argument 2)
C:\Users\Luca\Desktop\basefixed.pwn(2871) : error 035: argument type mismatch (argument 2)
C:\Users\Luca\Desktop\basefixed.pwn(2872) : error 035: argument type mismatch (argument 2)
C:\Users\Luca\Desktop\basefixed.pwn(2874) : error 035: argument type mismatch (argument 2)
C:\Users\Luca\Desktop\basefixed.pwn(2875) : error 035: argument type mismatch (argument 2)

:/ NOT Working


Re: SendClientMessageToAll bug - mitosking - 10.01.2012

After "(" insert "i":

pawn Код:
SendClientMessage(i, ...).



Re: SendClientMessageToAll bug - Konstantinos - 10.01.2012

Quote:
Originally Posted by Gooday
Посмотреть сообщение
:/ NOT Working
yes it does. I have test it and I have no errors, warnings. Just paste the code.


Re: SendClientMessageToAll bug - Gooday - 10.01.2012

Lol i made same as u, post ur code please....


Re: SendClientMessageToAll bug - Konstantinos - 10.01.2012

it works. Something you did wrong.
pawn Код:
#include <a_samp>
#include <zcmd>

#define COLOR_GREY -1
#define COLOR_ROYALBLUE -1
#define COLOR_LIGHTBLUE -1
#define COLOR_GOLD -1

CMD:911(playerid, params[])
{
    //911 system
    if(isnull(params)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /911 [Message and Location]");
    new sendername[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, sendername, sizeof(sendername));
    SendClientMessage(playerid, COLOR_GOLD, "[INFO]You have just called 911. Please remain at your location and wait.");
    for(new i=0;i<MAX_PLAYERS;i++) {
        if(GetPlayerSkin(i) == 285 || GetPlayerSkin(i) == 282 || GetPlayerSkin(i) == 281 || GetPlayerSkin(i) == 283 || GetPlayerSkin(i) == 288 ||GetPlayerSkin(i) == 278  || GetPlayerSkin(i) == 275 || GetPlayerSkin(i) == 279 || GetPlayerSkin(i) == 277 || GetPlayerSkin(i) == 274 || GetPlayerSkin(i) == 276) {
            SendClientMessage(i, COLOR_GREY, "-------------------------------------------------------------------------------------------------");
            SendClientMessage(i, COLOR_ROYALBLUE, "DISPATCH");
            SendClientMessage(i, COLOR_GREY, "Be advised, the following is a 911 call.");
            SendClientMessage(i, COLOR_GREY, "Units aviable please respond.");
            format(string, sizeof(string), "CALLER: %s  ~  INFO & LOCATION: %s", sendername, params);
            SendClientMessage(i, COLOR_GREY, string);
            SendClientMessage(i, COLOR_GREY, "-------------------------------------------------------------------------------------------------");
        }

    }
    return 1;
}
pawn Код:
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase



Re: SendClientMessageToAll bug - mitosking - 10.01.2012

New code:

Quote:

CMD:911(playerid,params[])
{
//911 system
if(isnull(params)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /911 [Message and Location]");
new sendername[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, sendername, sizeof(sendername));
SendClientMessage(playerid, COLOR_GOLD, "[INFO]You have just called 911. Please remain at your location and wait.");
for(new i=0;i<MAX_PLAYERS;i++) {
if(GetPlayerSkin(i) == 285 || GetPlayerSkin(i) == 282 || GetPlayerSkin(i) == 281 || GetPlayerSkin(i) == 283 || GetPlayerSkin(i) == 288 ||GetPlayerSkin(i) == 278 || GetPlayerSkin(i) == 275 || GetPlayerSkin(i) == 279 || GetPlayerSkin(i) == 277 || GetPlayerSkin(i) == 274 || GetPlayerSkin(i) == 276) {
SendClientMessage(i, COLOR_GREY, "-------------------------------------------------------------------------------------------------");
SendClientMessage(i, COLOR_ROYALBLUE, "DISPATCH");
SendClientMessage(i, COLOR_GREY, "Be advised, the following is a 911 call.");
SendClientMessage(i, COLOR_GREY, "Units aviable please respond.");
format(string, sizeof(string), "CALLER: %s ~ INFO & LOCATION: %s", sendername, params);
SendClientMessage(i, COLOR_GREY, string);
SendClientMessage(i, COLOR_GREY, "-------------------------------------------------------------------------------------------------");
}

}
return 1;
}

Try it.