/staff command repeats itself. -
OMonger - 24.10.2015
Hi
I have madfe a /staff command and for some reason it only shows your name (on everything that is) and repeats itself over and over. This is teh code:
PHP код:
command(staff, playerid, params[])
{
#pragma unused params
new string[128];
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(playerid))
{
SendClientMessage(playerid, COLOR_ORANGE, ". : : Administrators : : .");
if(PlayerInfo[playerid][pAdmin] >= 1)
{
format(string, sizeof(string), "Name: %s{A9C4E4}: (Level %d) {%s}", RPName(playerid), PlayerInfo[playerid][pAdmin], GetAwayStatus(playerid));
SendClientMessage(playerid, GREY, string);
}
SendClientMessage(playerid, COLOR_ORANGE, ". : : Moderators : : .");
if(PlayerInfo[playerid][pModerator] >= 1)
{
format(string, sizeof(string), "Name: %s{A9C4E4} {%s}", RPName(playerid), GetAwayStatus(i));
SendClientMessage(playerid, GREY, string);
}
SendClientMessage(playerid, COLOR_ORANGE, ". : : Helpers : : .");
if(PlayerInfo[playerid][pHelper] >= 1)
{
format(string, sizeof(string), "Name: %s{A9C4E4} {%s}", RPName(playerid), GetAwayStatus(playerid));
SendClientMessage(playerid, GREY, string);
}
}
}
}
Re: /staff command repeats itself. -
JaKe Elite - 24.10.2015
You do not need that code "#pragma unused params".
Also you are using loops but you never used the loop, you instead used playerid (I replaced them with i).
Another note, The message you put inside the loop excluding the part of listing the admins, will spam the screen. (": : Admins : :, etc..")
PHP код:
command(staff, playerid, params[])
{
new string[128];
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
SendClientMessage(playerid, COLOR_ORANGE, ". : : Administrators : : .");
if(PlayerInfo[i][pAdmin] >= 1)
{
format(string, sizeof(string), "Name: %s{A9C4E4}: (Level %d) {%s}", RPName(i), PlayerInfo[i][pAdmin], GetAwayStatus(i));
SendClientMessage(playerid, GREY, string);
}
SendClientMessage(playerid, COLOR_ORANGE, ". : : Moderators : : .");
if(PlayerInfo[i][pModerator] >= 1)
{
format(string, sizeof(string), "Name: %s{A9C4E4} {%s}", RPName(i), GetAwayStatus(i));
SendClientMessage(i, GREY, string);
}
SendClientMessage(playerid, COLOR_ORANGE, ". : : Helpers : : .");
if(PlayerInfo[i][pHelper] >= 1)
{
format(string, sizeof(string), "Name: %s{A9C4E4} {%s}", RPName(i), GetAwayStatus(i));
SendClientMessage(playerid, GREY, string);
}
}
}
}
Re: /staff command repeats itself. -
jlalt - 24.10.2015
try this: i have made the format of strings at the loop but sending the message out from the loop
,
also you define the loop with i [ check all players stats ] and on player check admin,moderator,and helper you used [playerid] here is the wrong, you have to use it as [i]
PHP код:
command(staff, playerid, params[])
{
new string[128],string2[128],string3[128];
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pAdmin] >= 1)
{
format(string, sizeof(string), "Name: %s{A9C4E4}: (Level %d) {%s}", RPName(i), PlayerInfo[i][pAdmin], GetAwayStatus(i));
}
if(PlayerInfo[i][pModerator] >= 1)
{
format(string2, sizeof(string2), "Name: %s{A9C4E4} {%s}", RPName(i), GetAwayStatus(i));
}
if(PlayerInfo[i][pHelper] >= 1)
{
format(string3, sizeof(string3), "Name: %s{A9C4E4} {%s}", RPName(i), GetAwayStatus(i));
}
}
}
SendClientMessage(playerid, COLOR_ORANGE, ". : : Administrators : : .");
SendClientMessage(playerid, GREY, string);
SendClientMessage(playerid, COLOR_ORANGE, ". : : Moderators : : .");
SendClientMessage(playerid, GREY, string2);
SendClientMessage(playerid, COLOR_ORANGE, ". : : Helpers : : .");
SendClientMessage(playerid, GREY, string3);
}
Re: /staff command repeats itself. -
OMonger - 24.10.2015
Thanks guys, rep+'d u both.