View Single Post
Darkwob
BANNED
Join Date: Oct 2018
Old 07-31-2021 , 10:26   Re: [HELP]Adding a command usage limit.
Reply With Quote #3

Quote:
Originally Posted by SpirT View Post
This might help you out ;)

PHP Code:
int resetBhpTimesUsed[MAXPLAYERS+1]; //our variable to store how many times he used the command

public void OnClientPostAdminCheck(int client) {
    
//If u want, let's set back to 0 once he's inside our server
    
resetBhpTimesUsed[client] = 0;
}

public 
void OnClientDisconnect(int client) {
    
//If u want, let's set back to 0 once he left our server
    
resetBhpTimesUsed[client] = 0;
}

public 
Action ResetBHP(int clientint args)
{
    if (
client == || !IsClientInGame(client))
    {
        return 
Plugin_Handled;
    }

    if(
resetBhpTimesUsed[client] >= 3) {
        
PrintToChat(client"You have already used this command 3 times");
        return 
Plugin_Handled;
    }

    
//he has used less than 3, so let's do our stuff
    
resetBhpTimesUsed[client]++;
    
    
AdminId clientId GetUserAdmin(client);
    if (
clientId == INVALID_ADMIN_ID || iPounces[client] == 0)
    {
        
CPrintToChat(client"\x03Invalid!\x01");
        return 
Plugin_Handled;
    }
    
    
CPrintToChat(client"\x04Fatal Jump\x01 \x03Counts Reset!\x01");
    

        
/* 
       I left these out because it sums up what I want to do.
      if(int i, i =< limited i++ ){
    CPrintToChat(client, "\x04You Used Reset. (%i/%i)",resetnum,limited );
    
}*/
    
if (hPenaltyTime[client] != null)
    {
        
hPenaltyTime[client] = null;
    }
    
    
//iPounces[client] = 0;
    
iPenalty[client] = 0;
    
    return 
Plugin_Handled;

Thank you for your answer, finally I found a way and I solved it, but the worst part is, if he wants to reset it again when the limit is reached, this time the countdown hint goes and does not come back while the countdown continues. but at the same time you can't do it in brutal. how can i solve this.

PHP Code:
public Action ResetBHP(int clientint args) {

    if(
GetUserFlagBits(client) && ADMFLAG_CUSTOM3){
    if (
client == || !IsClientInGame(client))
    {
        return 
Plugin_Handled;
    }
    
    
AdminId clientId GetUserAdmin(client);
    if (
clientId == INVALID_ADMIN_ID || iPounces[client] == 0)
    {
        
CPrintToChat(client"\x03Invalid!\x01");
        return 
Plugin_Handled;
    }
     if (
iPenaltyCounter[client] < 3) {
        
iPenalty[client] = 0;
        
//iPounces[client] = 0;
        
iPenaltyCounter[client]++;
        
CPrintToChat(client"\x05You Can Used \x03Counts Reset \x04(\x03%i\x05/\x033\x04)"iPenaltyCounter[client]);
    }
    else { 
        
CPrintToChat(client"\x05You Cannot Use Count Reset \x04Limit Reached.");
    }
    
CPrintToChat(client"\x04Fatal Jump\x01 \x03Counts Reset!\x01");
    if (
hPenaltyTime[client] != null)
    {
        
hPenaltyTime[client] = null;
    }
    
    
     }
   else { 

}
return 
Plugin_Handled;

Darkwob is offline