Raised This Month: $12 Target: $400
 3% 

[HELP]Adding a command usage limit.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Darkwob
BANNED
Join Date: Oct 2018
Old 07-25-2021 , 04:32   [HELP]Adding a command usage limit.
Reply With Quote #1

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;


Last edited by Darkwob; 07-25-2021 at 04:34.
Darkwob is offline
SpirT
Senior Member
Join Date: Sep 2018
Location: Portugal
Old 07-29-2021 , 10:57   Re: [HELP]Adding a command usage limit.
Reply With Quote #2

Quote:
Originally Posted by Darkwob View Post
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;

__________________
SpirT is offline
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
SpirT
Senior Member
Join Date: Sep 2018
Location: Portugal
Old 08-01-2021 , 12:33   Re: [HELP]Adding a command usage limit.
Reply With Quote #4

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)
__________________
SpirT is offline
Darkwob
BANNED
Join Date: Oct 2018
Old 08-02-2021 , 06:56   Re: [HELP]Adding a command usage limit.
Reply With Quote #5

Quote:
Originally Posted by SpirT View Post
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.
Darkwob is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:46.


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