AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Switch on/off by mouse right click (https://forums.alliedmods.net/showthread.php?t=90047)

johnny40409 04-13-2009 10:13

Switch on/off by mouse right click
 
Hello , I want to do a plugin ,
I want to switch the thing by using mouse right button ,
How can I do? I've seen bazooka's sma, but I still didn't understand how to do that , can somebody teach me ? thanks!

hleV 04-13-2009 11:47

Re: Switch on/off by mouse right click
 
Not tested.
Code:
#include <amxmodx> #include <fakemeta>   new bool:Switch[33];   public plugin_init()         register_forward(FM_CmdStart, "CmdStart");   public CmdStart(Client, Handle) {         static Buttons, OldButtons;         Buttons = get_uc(Handle, UC_Buttons);         //Buttons = pev(Client, pev_button);         OldButtons = pev(Client, pev_oldbuttons);           if ((Buttons & IN_ATTACK2) && !(OldButtons & IN_ATTACK2))                 Switch[Client] = !Switch[Client]; }

YamiKaitou 04-13-2009 12:35

Re: Switch on/off by mouse right click
 
PHP Code:

switch (Switch[Client])
                {
                        
// Switch is on, turn it off
                        
case 1: Switch[Client] = false;
                        
// Switch is off, turn it on
                        
case 0: Switch[Client] = true;
                } 

Better method (IMO) would be Switch[Client] = !Switch[Client]

One 04-14-2009 10:35

Re: Switch on/off by mouse right click
 
Quote:

Originally Posted by hleV (Post 804538)
Not tested.
Code:
#include <amxmodx> #include <fakemeta> new bool:Switch[33];

public plugin_init() register_forward(FM_CmdStart, "CmdStart");

public CmdStart(Client, Handle) { static Buttons, OldButtons;
Buttons = get_uc(Handle, UC_Buttons);
//Buttons = pev(Client, pev_button); OldButtons = pev(Client, pev_oldbuttons);

if ((Buttons & IN_ATTACK) && !(OldButtons & IN_ATTACK)) Switch[Client] = !Switch[Client];
}


isnt right mouse attack2 & not ATTACK??

SnoW 04-15-2009 08:33

Re: Switch on/off by mouse right click
 
Quote:

Originally Posted by One (Post 805261)
isnt right mouse attack2 & not ATTACK??

Right mouse is anything you want. The thread seems to be only detecting when user is attacking, if you count ATTACK2 attacking, lolz.

johnny40409 04-15-2009 11:58

Re: Switch on/off by mouse right click
 
Quote:

Originally Posted by hleV (Post 804538)
Not tested.

Code:
#include <amxmodx></p><p>#include <fakemeta></p><p>&nbsp;</p><p>new bool:Switch[33];</p><p>&nbsp;</p><p>public plugin_init()</p><p> register_forward(FM_CmdStart, "CmdStart");</p><p>&nbsp;</p><p>public CmdStart(Client, Handle)</p><p>{</p><p> static Buttons, OldButtons;</p><p> Buttons = get_uc(Handle, UC_Buttons);</p><p> //Buttons = pev(Client, pev_button);</p><p> OldButtons = pev(Client, pev_oldbuttons);</p><p>&nbsp;</p><p> if ((Buttons & IN_ATTACK2) && !(OldButtons & IN_ATTACK2))</p><p> Switch[Client] = !Switch[Client];</p><p>}

Thanks , it works stablely , ^_^


All times are GMT -4. The time now is 02:27.

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