Loop ends up with Spamming.
#1

Allright, so i'm trying to do a decent /report command using DCMD + sscanf... apparently it is working, however it doesnt stop looping, and if it doesnt stop looping, it spams the IRC channel we are using to ECHO in, can someone try to explain to me, why it is bugging...

pawn Код:
dcmd_report(playerid, params[])
{
    new id, pName[MAX_PLAYER_NAME], iName[MAX_PLAYER_NAME], string[128], reason[128];
    if (sscanf(params, "us", id,reason)) SendClientMessage(playerid, COLOR_RED, "Usage: \"/report <playerid> <reason>\"");
    else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_RED, "Player not found");
    else
    {
      GetPlayerName(playerid, pName,sizeof(pName));
      GetPlayerName(id, iName,sizeof(iName));
        format(string,sizeof(string),"%s[%d] Reported %s[%d] For: '%s'",pName,playerid,iName,id,reason);
        for(new i; i <MAX_PLAYERS; i++)
        if(AdminLevel[i] >= 0)
        {
            SendClientMessage(i,COLOR_PURPLE,string);
            ircSay(EchoConnection, EchoChan,string);
        }
        return 1;
    }
    return 1;
}
Reply
#2

You could just break; after ircSay
Reply
#3

pawn Код:
for(new i; i <MAX_PLAYERS; i++) //repeat two hundred times
        if(AdminLevel[i] >= 0) //if 'i' has a level which is equal or greater than zero
        {
            SendClientMessage(i,COLOR_PURPLE,string); //send a message to the 'i'
            ircSay(EchoConnection, EchoChan,string); //send a message to the IRC
        }
Anyone without a negative admin level will be sent a message.
Reply
#4

replace this code:

pawn Код:
for(new i; i <MAX_PLAYERS; i++)
        if(AdminLevel[i] >= 0)
        {
            SendClientMessage(i,COLOR_PURPLE,string);
            ircSay(EchoConnection, EchoChan,string);
        }
with this and try again:

pawn Код:
for(new i; i <MAX_PLAYERS; i++) {
        if(AdminLevel[i] > 0) // itll check if your adminlevel is higher than 0 i guess 0 isn't admin.
        {
            SendClientMessage(i,COLOR_PURPLE,string);
        }
        }
        ircSay(EchoConnection, EchoChan,string);
Reply
#5

If you only want it said once in the IRC chat keep that out of the loop, and then change your >= to a > as someone already said.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)