SA-MP Forums Archive
spamming - 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: spamming (/showthread.php?tid=415138)



spamming - pelani - 11.02.2013

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(playeriddamagedidFloatamountweaponid)
{
    if(
GetTeam{playerid} == CLASS_CIV && IsPlayerHoldingAGun(playerid) == 1)
    {
        foreach(
Playeri)
         {
            
shotsfired[playerid] += 2;
            if(
shotsfired[playerid] == && shotsfired[playerid] != 1)
            {
                new 
current_zonestring[150];
                
current_zone Player_Zone[playerid];
                 
SetPlayerWantedLevel(playeridGetPlayerWantedLevel(playerid) + 3);
                
format(stringsizeof(string), "Crime in progress! %s (%d) has assaulted %s (%d) with a deadly weapon - Location:  %s"GetName(playerid), playeridGetName(damagedid), damagedidZoneNames[current_zone][zone_name]);
                
CopRadio(LIGHTBLUEstring);
                
format(fstrsizeof(fstr), "Committed A Crime: Assault With A Deadly Weapon - Wanted Level %d - Ticketable"GetPlayerWantedLevel(playerid));
                
SendClientMessage(playeridYELLOWstring);
                
shotsfired[playerid] = 1;
                
shotsfired{playerid} = SetTimerEx("shotsfired"100000true"d"i);
            }
            else
             {
                new 
current_zonestring[150];
                  
current_zone Player_Zone[playerid];
                
SetPlayerWantedLevel(playeridGetPlayerWantedLevel(playerid) + 6);
                
format(stringsizeof(string), "Crime in progress! %s (%d) has assaulted %s (%d) with a deadly weapon - Location:  %s"GetName(playerid), playeridGetName(damagedid), damagedidZoneNames[current_zone][zone_name]);
                
CopRadio(LIGHTBLUEstring);
                
format(fstrsizeof(fstr), "Committed A Crime: Assault With A Deadly Weapon - Wanted Level %d - Arrestable"GetPlayerWantedLevel(playerid));
                
SendClientMessage(playeridREDfstr);
                
shotsfired[playerid] = 1;
                
shotsfired{playerid} = SetTimerEx("shotsfired"100000true"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


Re: spamming - MP2 - 11.02.2013

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.


Re: spamming - pelani - 12.02.2013

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