Command spams
#6

Quote:
Originally Posted by C0oL3r
Посмотреть сообщение
it will send me the message and Unknown Command if i spam, i use ZCMD and the function is not OnPlayerCommandText, is OnPlayerCommandPerformed
Doesn't matter buddy, it's the same,
PHP код:
new TextTickOne[MAX_PLAYERS]; 
new 
TextTickTwo[MAX_PLAYERS];  
#define MAX_WAIT_TIME 500 //max waiting time in MS (half a second here)  
public OnPlayerCommandPerformed(playeridcmdtext[], success)
{  
    if(
TextTickTwo[playerid] == && TextTickOne[playerid] ==TextTickOne[playerid] = GetTickCount();//if he hasn't used a cmd for a while 
    
else if(TextTickOne[playerid] != && TextTickTwo[playerid] == 0TextTickTwo[playerid] = GetTickCount();//if he used a cmd once 
    
else if(TextTickOne[playerid] != && TextTickTwo[playerid] != && TextTickTwo[playerid] - TextTickOne[playerid] < MAX_WAIT_TIME//if he messaged for the 2nd time check if last time was lower than the max time (500 ms) 
    
{  
        
SendClientMessage(playerid, -1" Hi, stop spamming you asshole");  
        
TextTickOne[playerid] = 0///reset 
        
TextTickTwo[playerid] = 0//Same ^^ 
        
return 1;  
    }  
    else if(
TextTickOne[playerid] != && TextTickTwo[playerid] != && TextTickTwo[playerid] - TextTickOne[playerid] >= MAX_WAIT_TIME//if it took him long enough to use a cmd again 
    
{  
        
TextTickOne[playerid] =0//reset 
        
TextTickTwo[playerid] =0//Same ^^ 
    
}  
    if(!
success)  return 0;
    else return 
1;
}  
public 
OnPlayerDisconnect(playeridreason)  
{  
    
TextTickOne[playerid] =0//reset in case of disconnection 
    
TextTickTwo[playerid] =0//Same ^^ 
    
return 1;  

You can also change the MAX_WAIT_TIME to the amount of time you want.
Reply


Messages In This Thread
Command spams - by C0oL3r - 24.02.2018, 23:15
Re: Command spams - by RogueDrifter - 24.02.2018, 23:18
Re: Command spams - by C0oL3r - 24.02.2018, 23:20
Re: Command spams - by RogueDrifter - 24.02.2018, 23:23
Re: Command spams - by C0oL3r - 24.02.2018, 23:30
Re: Command spams - by RogueDrifter - 24.02.2018, 23:32
Re: Command spams - by RogueDrifter - 24.02.2018, 23:39
Re: Command spams - by C0oL3r - 24.02.2018, 23:40
Re: Command spams - by C0oL3r - 24.02.2018, 23:59
Re: Command spams - by Lucases - 25.02.2018, 06:57

Forum Jump:


Users browsing this thread: 1 Guest(s)