Raised This Month: $51 Target: $400
 12% 

Solved Check if number was pressed


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
abdelwahab
Member
Join Date: Aug 2019
Old 04-12-2024 , 03:46   Check if number was pressed
Reply With Quote #1

Hello, is it possible to check if player pressed numbers ? such as slot1...slot10

Last edited by abdelwahab; 04-13-2024 at 00:50.
abdelwahab is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 04-12-2024 , 06:22   Re: Check if number was pressed
Reply With Quote #2

IIRC, it's not possible, but there should be workarounds for this.

You could for example check the player's current weapon and save it weither it's a primary, secondary, knife or grenades. On weapon change, you could detect what the new weapon is and that way you could possibly check which button was pressed (Keep in mind keybindings are client-sided, so this is not 100% how you would want to check it.)

https://www.amxmodx.org/api/hlsdk_const
https://forums.alliedmods.net/showpo...4&postcount=10
__________________

Last edited by Napoleon_be; 04-12-2024 at 06:24.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
abdelwahab
Member
Join Date: Aug 2019
Old 04-12-2024 , 06:29   Re: Check if number was pressed
Reply With Quote #3

Aight, Thanks
abdelwahab is offline
Tote
Senior Member
Join Date: Jul 2023
Old 04-12-2024 , 08:05   Re: Check if number was pressed
Reply With Quote #4

register_clcmd("slot1", "pressedslot1")

public pressedslot1(id) {
client_print(id, print_chat, "* You've just pressed slot 1!")
}
Tote is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 04-12-2024 , 08:38   Re: Check if number was pressed
Reply With Quote #5

you've tried

PHP Code:
new const g_key[] = "slot1"

public client_command(id)
{
    if(
id || id 32)
        return 
PLUGIN_CONTINUE
    
    
new getCmd[32]; read_argv(0getCmdcharsmax(getCmd))
    
    if(
equal(getCmdg_key))
    {
        
client_print(id3"pressed key %s"g_key)
    }
    
    return 
PLUGIN_CONTINUE

__________________
mlibre is offline
abdelwahab
Member
Join Date: Aug 2019
Old 04-13-2024 , 00:49   Re: Check if number was pressed
Reply With Quote #6

well the last 2 didn't work, but nvm
i found what i wanted!
abdelwahab is offline
Reply



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:01.


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