Faction Radio problem once again - 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: Faction Radio problem once again (
/showthread.php?tid=312876)
Faction Radio problem once again -
milanosie - 23.01.2012
Hello, I am trying to make a /r (radio) for every faction. Every faction radio will send a message to all online members of the faction the sender is in..
Now my problem is: Only player id 0 sees the messages...
My code:
pawn Код:
CMD:r(playerid, params[])
{
if(PlayerInfo[playerid][Fmember] >= 1)
{
if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /r [Text]");
foreach(Player, i) {
if(PlayerInfo[i][Fmember] == PlayerInfo[playerid][Fmember]) {
new
string[ 128 ], name[ MAX_PLAYER_NAME ];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s (radio): %s , Over.", name, params);
SendClientMessage(i, TEAM_RADIO_COLOR, string);
return 1;
}
}
return 1;
}
else return SendClientMessage(playerid, COLOR_GREY, "You are not in a faction!");
}
someone know how to fix it?
Re: Faction Radio problem once again -
viper_viper - 23.01.2012
Try
pawn Код:
for (new i = 0; i < MAX_PLAYERS; i++)
instead of foreach
Re: Faction Radio problem once again -
[ABK]Antonio - 23.01.2012
Quote:
Originally Posted by milanosie
Hello, I am trying to make a /r (radio) for every faction. Every faction radio will send a message to all online members of the faction the sender is in..
Now my problem is: Only player id 0 sees the messages...
My code:
pawn Код:
CMD:r(playerid, params[]) { if(PlayerInfo[playerid][Fmember] >= 1) { if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /r [Text]"); foreach(Player, i) { if(PlayerInfo[i][Fmember] == PlayerInfo[playerid][Fmember]) { new string[ 128 ], name[ MAX_PLAYER_NAME ]; GetPlayerName(playerid, name, sizeof(name)); format(string, sizeof(string), "%s (radio): %s , Over.", name, params); SendClientMessage(i, TEAM_RADIO_COLOR, string); return 1; } } return 1; } else return SendClientMessage(playerid, COLOR_GREY, "You are not in a faction!"); }
someone know how to fix it?
|
Hmm, try this out
pawn Код:
CMD:r(playerid, params[])
{
if(PlayerInfo[playerid][Fmember] >= 1)
{
if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /r [Text]");
new string[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s (radio): %s , Over.", name, params);
foreach(Player, i)
{
if(PlayerInfo[i][Fmember] == PlayerInfo[playerid][Fmember]) SendClientMessage(i, TEAM_RADIO_COLOR, string);
}
}
else return SendClientMessage(playerid, COLOR_GREY, "You are not in a faction!");
return 1;
}