02.04.2014, 22:32
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?
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;
}