spamming
#1

look at script when civil can shoot a plaayer or cop so they spam i want make it they don't spam

PHP код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
{
    if(
GetTeam{playerid} == CLASS_CIV && IsPlayerHoldingAGun(playerid) == 1)
    {
        foreach(
Player, i)
         {
            
shotsfired[playerid] += 2;
            if(
shotsfired[playerid] == 1 && shotsfired[playerid] != 1)
            {
                new 
current_zone, string[150];
                
current_zone = Player_Zone[playerid];
                 
SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 3);
                
format(string, sizeof(string), "Crime in progress! %s (%d) has assaulted %s (%d) with a deadly weapon - Location:  %s", GetName(playerid), playerid, GetName(damagedid), damagedid, ZoneNames[current_zone][zone_name]);
                
CopRadio(LIGHTBLUE, string);
                
format(fstr, sizeof(fstr), "Committed A Crime: Assault With A Deadly Weapon - Wanted Level %d - Ticketable", GetPlayerWantedLevel(playerid));
                
SendClientMessage(playerid, YELLOW, string);
                
shotsfired[playerid] = 1;
                
shotsfired{playerid} = SetTimerEx("shotsfired", 100000, true, "d", i);
            }
            else
             {
                new 
current_zone, string[150];
                  
current_zone = Player_Zone[playerid];
                
SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 6);
                
format(string, sizeof(string), "Crime in progress! %s (%d) has assaulted %s (%d) with a deadly weapon - Location:  %s", GetName(playerid), playerid, GetName(damagedid), damagedid, ZoneNames[current_zone][zone_name]);
                
CopRadio(LIGHTBLUE, string);
                
format(fstr, sizeof(fstr), "Committed A Crime: Assault With A Deadly Weapon - Wanted Level %d - Arrestable", GetPlayerWantedLevel(playerid));
                
SendClientMessage(playerid, RED, fstr);
                
shotsfired[playerid] = 1;
                
shotsfired{playerid} = SetTimerEx("shotsfired", 100000, true, "d", i);
            }
        }
    }
    return 
1;
} 
i added timer system but didn;t worked. "shotsfired{playerid} = SetTimerEx("shotsfired", 100000, true, "d", i);"

and pls make it they dnt spamming after 3 shoot and then see that msg to player
Reply
#2

Why do you have a foreach loop when you don't do anything with it..?

The best way to make an anti-spam (IMO) is this (without ANY timers):

pawn Код:
new pAntiSpam[MAX_PLAYERS]; // Don't call it this..
public SomeEvent(playerid)
{
    if(gettime()-pAntiSpam[playerid] > 10) // It's been at least 10 seconds since we sent the last message
    {
        SendClientMessage(..);
        pAntiSpam[playerid] = gettime();
    }
    return 1;
}
You should use GetTickCount (instead of gettime) if you want an anti-spam that is accurate to the milisecond. gettime() may be up to 0.999999.. seconds off. Not a problem when it's something like 10 seconds.
Reply
#3

Quote:
Originally Posted by MP2
Посмотреть сообщение
Why do you have a foreach loop when you don't do anything with it..?

The best way to make an anti-spam (IMO) is this (without ANY timers):

pawn Код:
new pAntiSpam[MAX_PLAYERS]; // Don't call it this..
public SomeEvent(playerid)
{
    if(gettime()-pAntiSpam[playerid] > 10) // It's been at least 10 seconds since we sent the last message
    {
        SendClientMessage(..);
        pAntiSpam[playerid] = gettime();
    }
    return 1;
}
You should use GetTickCount (instead of gettime) if you want an anti-spam that is accurate to the milisecond. gettime() may be up to 0.999999.. seconds off. Not a problem when it's something like 10 seconds.
i rly dont understand, it's work on crime? or this is game msg anti spam
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)