SendClientMessage Spam
#1

My Warning system is spamming the chat, but i don't know why,

PHP код:
stock ServerBan(playeridReason[])
{
    new 
string[128];
    
format(stringsizeof(string), "[%s] %s Might be hacking, Reason: %s"date(gettime()+36009), RPName(playerid), Reason);
    
SendToAdmins(YELLOWstring);
    return 
1;

Reply
#2

Show the body of
pawn Код:
SendToAdmins(x,y)
Reply
#3

PHP код:
public SendToAdmins(colourstring[])
{
    for(new 
0MAX_PLAYERSi++)
    {
          if(
IsPlayerConnectedEx(i))
          {
              if(
AdminLoggedIn[i] == && Player[i][Adminlevel] >= 1)
              {
                  
SendClientMessage(icolourstring);
               }
        }
    }
    return 
1;

Reply
#4

where in your script are you using ServerBan(playerid,reason)?
Reply
#5

Quote:
Originally Posted by lulo356
Посмотреть сообщение
PHP код:
public SendToAdmins(colourstring[])
{
    for(new 
0MAX_PLAYERSi++)
    {
          if(
IsPlayerConnectedEx(i))
          {
              if(
AdminLoggedIn[i] == && Player[i][Adminlevel] >= 1)
              {
                  
SendClientMessage(icolourstring);
               }
        }
    }
    return 
1;

Well, this function is not spaming itself.
When ServerBan is called? If it is called in frequently called callback (however that sounds like) consider something like this.

Let lastWarningSent[MAX_PLAYERS] be the variable to hold timestamp of last warning sent.

Let's assume your ServerBan command is called this way:
pawn Код:
public OnPlayerUpdate(playerid){
  if(isPlayerCheating(playerid)) ServerBan(0, "cheating");
}
As you can see, isPlayerCheating would eventually return 1 every time it is called. That's why it might call ServerBan function so often. Therefore, try something like this:
pawn Код:
public OnPlayerUpdate(playerid) {
  if(isPlayerCheating(playerid)) {
    if(lastWarningSent[playerid] < gettime()) {
      ServerBan(playerid, "cheater");
      lastWarningSent[playerid] = gettime() + howmanyseconds;
    }
  }
}
Now, even if isPlayerCheating returns 1, it will not call ServerBan() until some time lapses.
Of course, if you would like to handle more cases that ServerBan is called, then you'll have to reconsider entire strategy with lastWarningSent thing. I just wanted to give you an idea. Maybe it will appear helpfull.

Reply
#6

Quote:
Originally Posted by lulo356
Посмотреть сообщение
PHP код:
public SendToAdmins(colourstring[])
{
    for(new 
0MAX_PLAYERSi++)
    {
          if(
IsPlayerConnectedEx(i))
          {
              if(
AdminLoggedIn[i] == && Player[i][Adminlevel] >= 1)
              {
                  
SendClientMessage(icolourstring);
               }
        }
    }
    return 
1;

Can't tell if you're being serious or not..
You're wondering why it's spamming?

your "SendToAdmins"
Counts Every player that's in the server..
Then If there's an admin on it sends the message for max players.

PHP код:
public SendToAdmins(color, const string[]) {
    foreach(
Playeri) {
        if(
IsPlayerConnectedEx(i)) {
            if(
AdminLoggedIn[i] == && Player[i][Adminlevel] >= 1) {
                
SendClientMessage(icolormsg);
            }
        }
    }

Fixed above..
Reply
#7

Quote:
Originally Posted by Prokill911
Посмотреть сообщение
Can't tell if you're being serious or not..
You're wondering why it's spamming?

your "SendToAdmins"
Counts Every player that's in the server..
Then If there's an admin on it sends the message for max players.

PHP код:
public SendToAdmins(color, const string[]) {
    foreach(
Playeri) {
        if(
IsPlayerConnectedEx(i)) {
            if(
AdminLoggedIn[i] == && Player[i][Adminlevel] >= 1) {
                
SendClientMessage(icolormsg);
            }
        }
    }

Fixed above..
Now I'm not sure if YOU are serious or just doesn't know anything about scripting..
His code is perfectly fine, it doesn't count shit and just sends the msg to admins.
He just sends too many ServerBan calls in his anti-cheat script instead of one, as people mentioned above, best way to prevent it is to flag player after sending first msg so next ones won't be send.
Reply
#8

I don't know shit?
Yet I have a degree in computer science with a major in programming languages..
Okay for sure.
Reply
#9

Oh, boasting with degrees. Yet PrO.GameR is actually right.
Reply
#10

I'll tell you the problem, the problem is this donkey just downloads gamemodes and has absolutely no idea what the hell he is doing with them at all.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)