Raised This Month: $32 Target: $400
 8% 

How to Detect Slot number Pressing?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NC.svtrade
Senior Member
Join Date: Nov 2015
Old 07-24-2017 , 10:22   How to Detect Slot number Pressing?
Reply With Quote #1

I want to make a detect plugin to pressing slot.
EX. Press Slot 1 "+slot1" -> Activate Function -> Give a Weapon
NC.svtrade is offline
vortex.
AlliedModders Donor
Join Date: Jan 2017
Location: OnGameFrame()
Old 07-24-2017 , 12:12   Re: How to Detect Slot number Pressing?
Reply With Quote #2

https://forums.alliedmods.net/showthread.php?t=151142
Good luck.

PHP Code:
#define IN_WEAPON1    (1 << 20) // weapon defines these bits 
__________________

Last edited by vortex.; 07-24-2017 at 12:12.
vortex. is offline
0xBatuhan
Member
Join Date: Dec 2016
Location: Turkey
Old 07-24-2017 , 12:47   Re: How to Detect Slot number Pressing?
Reply With Quote #3

Alternative solution example:

PHP Code:
#include <sourcemod>
#include <sdktools>

public void OnPluginStart()
{
       
RegConsoleCmd("slot1"pressedSlot1);
}

public 
void pressedSlot1(int clientint args)
{
       
PrintToChatAll("You pressed to slot1");
       
GivePlayerItem(client"weapon_m4a1"); // Give Weapon Command


Last edited by 0xBatuhan; 07-24-2017 at 12:47.
0xBatuhan is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 07-24-2017 , 13:42   Re: How to Detect Slot number Pressing?
Reply With Quote #4

Pls.... don't register new cmd. Use AddCommandListener
__________________
Do not Private Message @me
Bacardi is offline
inklesspen
Member
Join Date: Nov 2015
Location: Russia, Moscow
Old 07-24-2017 , 16:52   Re: How to Detect Slot number Pressing?
Reply With Quote #5

It's works?
__________________
Mai inglish is veri gud!
inklesspen is offline
Send a message via Skype™ to inklesspen
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 07-24-2017 , 17:25   Re: How to Detect Slot number Pressing?
Reply With Quote #6

I thought the weapon slot keys are client side aliases that cant be directly hooked?
__________________
Neuro Toxin is offline
NC.svtrade
Senior Member
Join Date: Nov 2015
Old 07-24-2017 , 17:42   Re: How to Detect Slot number Pressing?
Reply With Quote #7

Quote:
Originally Posted by inklesspen View Post
I already do that. That doesn't work.
NC.svtrade is offline
NC.svtrade
Senior Member
Join Date: Nov 2015
Old 07-24-2017 , 17:43   Re: How to Detect Slot number Pressing?
Reply With Quote #8

Quote:
Originally Posted by vortex. View Post
https://forums.alliedmods.net/showthread.php?t=151142
Good luck.

PHP Code:
#define IN_WEAPON1    (1 << 20) // weapon defines these bits 
How about pressing slot0 or slot9? There is a bind on a setting, but I can't detect.
NC.svtrade is offline
0xBatuhan
Member
Join Date: Dec 2016
Location: Turkey
Old 07-24-2017 , 17:44   Re: How to Detect Slot number Pressing?
Reply With Quote #9

Quote:
Originally Posted by NC.svtrade View Post
How about pressing slot0 or slot9? There is a bind on a setting, but I can't detect.
what your game?
0xBatuhan is offline
inklesspen
Member
Join Date: Nov 2015
Location: Russia, Moscow
Old 07-25-2017 , 03:25   Re: How to Detect Slot number Pressing?
Reply With Quote #10

On forward of SDKTools, "OnPlayerRunCmd", you ran compare int &weapon with otherweapons. (weapon isn't nextweapon, weapon is weapon of slot that was been pressed... For hook via OnPlayerRunCmd you need non-empty slot.)

For hook button 3
PHP Code:
public Action OnPlayerRunCmd(int clientint &buttonsint &impulsefloat vel[3], float angles[3], int &weaponint &subtypeint &cmdnumint &tickcountint &seedint mouse[2])
{
    if(
weapon != 0)
    {
        if(
GetPlayerWeaponSlot(2) == weapon)
        {
            
//do something
        
}
    }

I think we can hook without OnPlayerRunCmd... How? I don't know
__________________
Mai inglish is veri gud!
inklesspen is offline
Send a message via Skype™ to inklesspen
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:17.


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