Weird issue - 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: Weird issue (
/showthread.php?tid=494542)
Weird issue -
EmilLykke - 13.02.2014
Hello there..
I am currently having a weird issue with my little command here..
It says: "There are currently '%d' administrators online, type (/ra) for any administrative assistance!"
It says it probably 23812740923748912347234 times. Do you know what the error is? Thankyou for reading.
Here is the command:
pawn Код:
COMMAND:admins(playerid, params[])
{
new string[128];
if (GetPVarInt(playerid, "PlayerLogged") == 0) return SendClientMessage(playerid, COLOR_WHITE, "You must be logged in to use this.");
new found = GetAdminCount(2);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(found == 0) return SendClientMessage(playerid, 0x8080FF96, "(( There are currently none administrators online. ))");
if(found == 1) return SendClientMessage(playerid, 0x8080ff96, "(( There are currently '1' administrator online, type (/ra) for any administrative assistance! ))");
if(found >= 2)
{
format(string, sizeof(string), "(( There are currently '%d' administrators online, type (/ra) for any administrative assistance! ))", found);
SendClientMessage(playerid, 0x8080FF96, string);
SendClientMessage(playerid, -1, " ");
if(GetPVarInt(i, "Admin") >= 1)
{
if(GetPVarInt(i, "AdminDuty") == 1)
{
format(string, sizeof(string), "(Level: %d) %s (ID: %d) Adminduty: Yes", GetPVarInt(i, "Admin"), RemoveUnderScore(i));
SendClientMessage(playerid, 0x006200FF, string);
}
else if(GetPVarInt(i, "AdminDuty") == 0)
{
format(string, sizeof(string), "(Level: %d) %s (ID: %d) Adminduty: No", GetPVarInt(i, "Admin"), RemoveUnderScore(i));
SendClientMessage(playerid, 0xAE002CFF, string);
}
}
}
}
return 1;
}
Re: Weird issue -
jtemple042996 - 13.02.2014
pawn Код:
COMMAND:admins(playerid, params[])
{
new string[128];
if (GetPVarInt(playerid, "PlayerLogged") == 0) return SendClientMessage(playerid, COLOR_WHITE, "You must be logged in to use this.");
new found = GetAdminCount(2);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(found == 0) return SendClientMessage(playerid, 0x8080FF96, "(( There are currently none administrators online. ))");
if(found == 1) return SendClientMessage(playerid, 0x8080ff96, "(( There are currently '1' administrator online, type (/ra) for any administrative assistance! ))");
if(found >= 2)
{
format(string, sizeof(string), "(( There are currently '%d' administrators online, type (/ra) for any administrative assistance! ))", found);
}
}
SendClientMessage(playerid, 0x8080FF96, string);
SendClientMessage(playerid, -1, " ");
for(new i = 0; i < MAX_PLAYERS; i++){
if(found == 2){
if(GetPVarInt(i, "Admin") >= 1)
{
if(GetPVarInt(i, "AdminDuty") == 1)
{
format(string, sizeof(string), "(Level: %d) %s (ID: %d) Adminduty: Yes", GetPVarInt(i, "Admin"), RemoveUnderScore(i));
SendClientMessage(playerid, 0x006200FF, string);
}
else if(GetPVarInt(i, "AdminDuty") == 0)
{
format(string, sizeof(string), "(Level: %d) %s (ID: %d) Adminduty: No", GetPVarInt(i, "Admin"), RemoveUnderScore(i));
SendClientMessage(playerid, 0xAE002CFF, string);
}
}
}
}
return 1;
}
You had the "There are currently '%d' administrators online, type (/ra) for any administrative assistance!" message inside of your loop, which caused it to send the message to you so many times.