AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   +/- Command (https://forums.alliedmods.net/showthread.php?t=339808)

MrPickles 10-02-2022 17:51

+/- Command
 
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

fysiks 10-02-2022 22:11

Re: +/- Command
 
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.

MrPickles 10-02-2022 22:40

Re: +/- Command
 
Quote:

Originally Posted by fysiks (Post 2790244)
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?

fysiks 10-04-2022 00:50

Re: +/- Command
 
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".


All times are GMT -4. The time now is 15:42.

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