AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   +use triggering action. (HOW?) (https://forums.alliedmods.net/showthread.php?t=87265)

TiToTal 03-09-2009 00:12

+use triggering action. (HOW?)
 
I just want to know how to do a simple code...
I want to, when someone press de "+use" buttom (E default), I get something doing...

For example, when someone press E, and if he is near some entity, then he is going to die...

Thank you ;)


EDIT: It's for The Specialists mod!

TheRadiance 03-09-2009 00:31

Re: A simple question...
 
PHP Code:

register_clcmd"+use""CommandUse" )

public 
CommandUseid )
{
    
// Your actions



zwfgdlc 03-09-2009 11:36

Re: A simple question...
 
look this.
http://forums.alliedmods.net/showthread.php?t=86213

ConnorMcLeod 03-09-2009 12:52

Re: A simple question...
 
You would have to hook FM_CmdStart and then check for with button the player press.
I suggest you to edit your title to be more explicit about your request.

TiToTal 03-09-2009 21:12

Re: +use triggering action. (HOW?)
 
wait wait... ( I changed the topic title... sorry for not being explicit )

Wait... I didn't got it yet... What code do I have actually to do?

I tried:

Code:

register_clcmd( "+use", "CommandUse" )

public CommandUse( id )
{
    // Your actions
}

but it didn't work...

BOYSplayCS 03-09-2009 22:17

Re: +use triggering action. (HOW?)
 
For example, this thing I whipped up in literally like ten seconds will kill someone when they are if the water. It probably doesn't work, but it is just an example.

PHP Code:

public CommandUseid 
{
    if(
pev(idpev_flags) & FL_INWATER)
    {
        
user_killid )
        
    } 
    else
    {
        
// do nothing
    
}
    return 
PLUGIN_HANDLED



TiToTal 03-10-2009 13:18

Re: +use triggering action. (HOW?)
 
but is this code activated by +use button?


I got my function working already, all I want to know is how to get it triggered by +use button (E default)

padilha007 03-10-2009 13:52

Re: +use triggering action. (HOW?)
 
PHP Code:

public client_prethink(id)
{
    if (
pev(id,pev_button) & IN_USE)
    {
          
// Your actions
    
}



Exolent[jNr] 03-10-2009 15:50

Re: +use triggering action. (HOW?)
 
This is the best way to detect button usage:
Code:
#include <amxmodx> #include <fakemeta> public plugin_init() {     register_forward(FM_CmdStart, "FwdCmdStart"); } public FwdCmdStart(client, uc_handle, seed) {     new button = get_uc(uc_handle, UC_Buttons);         // how to block a button:     if( button & IN_USE )     {         button &= ~IN_USE;         set_uc(uc_handle, UC_Buttons, button);                 return FMRES_SUPERCEDE;     }         return FMRES_IGNORED; }

TiToTal 03-10-2009 19:10

Re: +use triggering action. (HOW?)
 
THANK YOOOOOOOOUUUU

I am gonna test it 'till tomorrow... I appreciate your help.. ;)
Thanks for helping a newbie... lol =)

I am considering to study "programming" ( I don't know how I should say this in english.)
Anyway.

Thanks for your help guys... I am gonna +karma you ;)


All times are GMT -4. The time now is 08:54.

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