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

+/- Command


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MrPickles
Senior Member
Join Date: Aug 2022
Location: Colombia
Old 10-02-2022 , 17:51   +/- Command
Reply With Quote #1

Is it normal that when I create a command, for example +ultimate/-ultimate, the -ultimate command is being executed constantly? I tried it with a print and it is being executed several times
MrPickles is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-02-2022 , 22:11   Re: +/- Command
Reply With Quote #2

What game are you playing? I just tested in Day of Defeat and it works as expected (the + command executes when I press the button and the - command executes when I release the button).

Did you properly bind your key and properly code your plugin? Write a test plugin like I did and make sure it works there to either rule in our out your primary plugin.
__________________
fysiks is offline
MrPickles
Senior Member
Join Date: Aug 2022
Location: Colombia
Old 10-02-2022 , 22:40   Re: +/- Command
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
What game are you playing? I just tested in Day of Defeat and it works as expected (the + command executes when I press the button and the - command executes when I release the button).

Did you properly bind your key and properly code your plugin? Write a test plugin like I did and make sure it works there to either rule in our out your primary plugin.
PHP Code:

public plugin_init()
{
         
register_clcmd"+ultimate""ChargeUltimate" );
         
register_clcmd"-ultimate""ReleaseUltimate" );
}
public 
ChargeUltimateClient )

         
client_printClientprint_chat"Charging" );
         return 
1;
}
public 
ReleaseUltimateClient )

         
client_printClientprint_chat"Releasing" ); 
         return 
1;

and the mod is Half Life 1, try with a print

edit: is called when you open the menu with escape and close it, i dont know why, it is normal?

Last edited by MrPickles; 10-02-2022 at 22:44.
MrPickles is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-04-2022 , 00:50   Re: +/- Command
Reply With Quote #4

I don't play Half-Life 1 but I did get a server set up and downloaded the game and I was able to reproduce what you're talking about.

You should be able to add a workaround for this. Since you can never see the "-command" without first seeing the "+command", you can simply check in your "-command" if the "+command" was used just prior to the execution. In other words, you simply prevent multiple executions of the "-command" in a row.

To do this, simply keep track of the state for each player. At the end of your "+command", set it to true. In your "-command", only execute the code if the state is true. Then unconditionally set the state back to false at the end of the "-command".
__________________
fysiks is offline
Reply



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 06:29.


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