AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get use command. (https://forums.alliedmods.net/showthread.php?t=88362)

One 03-23-2009 16:39

get use command.
 
how to get a user command? for exam :

if user use the command "+left" show a hud.
i just need the code 4 get cmd.

Dores 03-23-2009 17:50

Re: get use command.
 
To catch buttons(+attack, -jump, etc.), you can use the FM_CmdStart forward or check the player's pev_buttons/pev_oldbutton at PreThink.

If something else then just get the first argument of the command at the client_command(id) forward. Just notice that a lot of client-sided commands cannot be hooked.

Dr.G 03-23-2009 17:52

Re: get use command.
 
something like this:

PHP Code:

#include <amxmodx>
#include <fakemeta>
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

public plugin_init() 
{
 
register_plugin(PLUGINVERSIONAUTHOR)
 
 
/* prethink */
 
register_forwardFM_PlayerPreThink"client_prethink" )
}
public 
client_prethink(id)
{
 new 
button pev(id,pev_button)
 
 if(
button IN_MOVERIGHT)
 {
  
//do something
 
}
 
 if(
button IN_MOVELEFT)
 {
  
//do something else
 
}


the buttons you can catch, you can find in hlsdk_const.inc

Arkshine 03-23-2009 17:54

Re: get use command.
 
Better to use FM_CmdStart.

One 03-23-2009 18:02

Re: get use command.
 
:cry::cry::cry: ok... my PC is down.( virus )ill try later to catch +reload. :cry: & ty.

hleV 03-24-2009 12:30

Re: get use command.
 
Code:
#include <amxmodx> #include <fakemeta>   public plugin_init()         register_forward(FM_CmdStart, "HookReload");   public HookReload(ClientID, UC_Handle) {         if (!is_user_alive(ClientID))                 return;           static Button;         Button = get_uc(UC_Handle, Buttons);           if (Button & IN_RELOAD)         {                 // Client used +reload command                   // If you want to block it, use this                 Button &= ~IN_RELOAD;         }           // This will block it         set_uc(UC_Handle, UC_Buttons, Button);           return FMRES_SUPERCEDE; }

One 03-24-2009 12:40

Re: get use command.
 
Quote:

Originally Posted by hleV (Post 788024)
Code:
#include <amxmodx> #include <fakemeta> public plugin_init() register_forward(FM_CmdStart, "HookReload");

public HookReload(ClientID, UC_Handle) { if (!is_user_alive(ClientID)) return;

static Button;
Button = get_uc(UC_Handle, Buttons);

if (Button & IN_RELOAD) { // Client used +reload command // If you want to block it, use this Button &= ~IN_RELOAD; } // This will block it set_uc(UC_Handle, UC_Buttons, Button);

return FMRES_SUPERCEDE;
}


YEa. ty . i have it. but a new problem.ill better ask u in PM. this willbe the last question & i can release ma new plug.

TheRadiance 03-24-2009 12:46

Re: get use command.
 
Quote:

Originally Posted by hleV (Post 788024)
Code:
#include <amxmodx> #include <fakemeta>   public plugin_init()         register_forward(FM_CmdStart, "HookReload");   public HookReload(ClientID, UC_Handle) {         if (!is_user_alive(ClientID))                 return;           static Button;         Button = get_uc(UC_Handle, Buttons);           if (Button & IN_RELOAD)         {                 // Client used +reload command                   // If you want to block it, use this                 Button &= ~IN_RELOAD;         }           // This will block it         set_uc(UC_Handle, UC_Buttons, Button);           return FMRES_SUPERCEDE; }

Sorry for offtop:

What means / does ~ ( tilda )?

Arkshine 03-24-2009 16:19

Re: get use command.
 
Quote:

Originally Posted by Pawn Language Reference
~e : results in the one’s complement of e.


One 03-24-2009 16:42

Re: get use command.
 
Quote:

Originally Posted by Pawn Language Reference
~e : results in the one’s complement of e.
http://www.helpbytes.co.uk/images/smileys/106.gif


All times are GMT -4. The time now is 09:04.

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