Radio system not working.
#1

i'm creating a radio system and want client messages to to be sent to anyone in the channel that the playerid is sending the message through. My channels consist of 1-50 and the variables are "PlayerRadio" and "PlayerRadioChannel". Self explanatory. Radio detects if they have a radio and the channel is what frequency they are in. (From 1-50.)

How would I send a message to players ONLY in the frequency that the playerid is in?

pawn Код:
stock SendClientMessageToRadio(playerid, color, const message[])
{
    foreach(Player, i)
    {
        if(PlayerRadioChannel[i] == PlayerRadioChannel[playerid])
        {
            SendClientMessage(i,  color, message);
        }
   
    }
}

CMD:r(playerid, params[])
{
    if(GameProgress == 0) return SCM(playerid, COLOR_GREY, "Error: A game isn't in progress.");
    if(PlayerRadio[playerid] == 0) return SCM(playerid, COLOR_GREY, "Error: You don't have a radio.");
    new text[128];
    if(sscanf(params, "s", text)) return SCM(playerid,COLOR_WHITE, "USAGE: /r(radio) [text]");
    format(text,sizeof(text), "[Radio] %s: %s", GetName(playerid), text);
    foreach(Player, i)
    {
        SendClientMessageToRadio(i, COLOR_GREEN, text);
    }
    return 1;
}
Reply
#2

EDITED:

pawn Код:
stock SendClientMessageToRadio(playerid, color, const message[])
{
    foreach(Player, i)
    {
        if(PlayerRadioChannel[playerid] == PlayerRadioChannel[i])
        {
            SendClientMessage(i, color, message);
        }
    }
}

CMD:r(playerid, params[])
{
    if(GameProgress == 0) return SCM(playerid, COLOR_GREY, "Error: A game isn't in progress.");
    if(PlayerRadio[playerid] == 0) return SCM(playerid, COLOR_GREY, "Error: You don't have a radio.");
    new text[128];
    if(sscanf(params, "s", text)) return SCM(playerid,COLOR_WHITE, "USAGE: /r(adio) [text]");
    format(text,sizeof(text), "[Radio] <Channel: %i> %s: %s", PlayerRadioChannel[playerid], GetName(playerid), text);
    SendClientMessageToRadio(playerid, COLOR_GREEN, text);
    return 1;
}
Reply
#3

Still doesn't show to players ONLY in the playerid's channel. It shows to everyone.

EDIT:A Fixed, thanks bud.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)