AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [HELP]Adding a command usage limit. (https://forums.alliedmods.net/showthread.php?t=333616)

Darkwob 07-25-2021 04:32

[HELP]Adding a command usage limit.
 
I wanted to ask you here as I couldn't figure out how to do it. I want to add a usage limit to this Command. I wanted to enable a player to use it maximum 3 times, but when he used this command, I could not write the code to increase it and when it reached the limit, I could not disable it from using it. I'm giving you the source version without the garbage code I made. I would be very happy if you can help.

PHP Code:

public Action ResetBHP(int clientint args)
{
    
    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;
    }
    
    
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;



SpirT 07-29-2021 10:57

Re: [HELP]Adding a command usage limit.
 
Quote:

Originally Posted by Darkwob (Post 2753611)
I wanted to ask you here as I couldn't figure out how to do it. I want to add a usage limit to this Command. I wanted to enable a player to use it maximum 3 times, but when he used this command, I could not write the code to increase it and when it reached the limit, I could not disable it from using it. I'm giving you the source version without the garbage code I made. I would be very happy if you can help.

PHP Code:

public Action ResetBHP(int clientint args)
{
    
    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;
    }
    
    
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;



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;



Darkwob 07-31-2021 10:26

Re: [HELP]Adding a command usage limit.
 
Quote:

Originally Posted by SpirT (Post 2753991)
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;



SpirT 08-01-2021 12:33

Re: [HELP]Adding a command usage limit.
 
Well, on the code that you sent there isn't any hint to countdown whatsoever. Is there any change that you can provide it? (otherwise, I can do a little timer to reset it anyways as an example)

Darkwob 08-02-2021 06:56

Re: [HELP]Adding a command usage limit.
 
Quote:

Originally Posted by SpirT (Post 2754314)
Well, on the code that you sent there isn't any hint to countdown whatsoever. Is there any change that you can provide it? (otherwise, I can do a little timer to reset it anyways as an example)

I sent you a friend request.


All times are GMT -4. The time now is 07:16.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.