AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   +command wont work (https://forums.alliedmods.net/showthread.php?t=153154)

urban_ninja 03-19-2011 13:26

+command wont work
 
Im trying to get a feature in my plugin to be triggered when the user is firing his weapon but +attack don't work. In fact nothing with "+" in front of a command works. What causes +commands to fail?

Here's what I have.
PHP Code:

public plugin_init()
{
    
register_clcmd("+attack""fire_restrict")
    
register_clcmd("-attack""restore")


I even added a hud message to see if what I added in the code block was at fault but no hud message appeared so the code block isn't being triggered at all.

Emp` 03-19-2011 13:44

Re: +command wont work
 
You cannot hook all commands that way. You have to either hook command start or prethink and check if a user's button field contains IN_ATTACK.

urban_ninja 03-19-2011 14:42

Re: +command wont work
 
Im not sure how to do that. Would get_clcmd make it work? client_PreThink, get_user_button, get_usercmd only has one parameter. Idk where to start.

wrecked_ 03-19-2011 16:10

Re: +command wont work
 
Code:
register_forward( FM_CmdStart, "MetaCmdStart" ) public MetaCmdStart( id, handle, seed ) {     if( get_uc( handle, UC_Buttons ) & IN_ATTACK ) // holding IN_ATTACK     {         if( !( pev( id, pev_oldbuttons ) & IN_ATTACK ) ) // just pushed it, as it was not being held before this function call but it is now         {             // ...         }     } }

urban_ninja 03-19-2011 19:25

Re: +command wont work
 
Ok, I tried that but wont up causing the feature no to work at all.

I have
register_forward( FM_CmdStart, "speed_task");
register_event("Spectator", "speed", "abcde");

The way I have it is when the HW looses health below 40 he gets a speed rush untill his heath is back above 40. But set_user_maxspeed over rides the slow down speed when firing his minigun so the speed never differs. So this needs to be fixed so when minigun is firing the HWguy slows down like he should. I also have set_task to keep the code responding down to the milliseconds in a way where caping the flag dont glitch amxx and forget the players index. Register_event is to start running the tasks because it only seems to index players (individually to be specific) by the player him self triggers the code block.

Im having a heck of a time applying a fix for this minor game play issue along with the pre existing code.


All times are GMT -4. The time now is 14:33.

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