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

block key


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
samir_dz
Junior Member
Join Date: Oct 2022
Old 12-05-2022 , 11:24   block key
Reply With Quote #1

Hello, can anyone make a plugin when a player presses f9 or f8, a hud message appears for all players on the server, name player use the f9 button

To check if he was using cheats
samir_dz is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 12-05-2022 , 19:10   Re: block key
Reply With Quote #2

What is f9 supposedly? Mine used to be a bind to buy a scout.
__________________
DJEarthQuake is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-05-2022 , 23:08   Re: block key
Reply With Quote #3

It is not possible to know what actual button is being pressed. You can only know what commands are sent to the server. Some keys are unlikely to be changed (like ASDW) so you can hook hose sort of reliably (I know people who use the actual arrow keys instead of ASDW.
__________________
fysiks is offline
administratora
Member
Join Date: Mar 2015
Old 12-18-2022 , 11:43   Re: block key
Reply With Quote #4

Try that:

PHP Code:
#include <amxmodx>
#include <hud>

public plugin_init()
{
    
register_event("KeyEvent""event_key""be""1=0""2!=0")
}

public 
event_key(const id, const id_type, const id_state, const key, const unk)
{
    if(
key == KEY_F9)
    {
        new 
player_name[32]
        
get_user_name(idplayer_name31)
        new 
hud_msg[64]
        
format(hud_msg63"%s used the F9 key!"player_name)
        
show_hudmessage(0hud_msg)
    }
    else if(
key == KEY_F8)
    {
        new 
player_name[32]
        
get_user_name(idplayer_name31)
        new 
hud_msg[64]
        
format(hud_msg63"%s used the F8 key!"player_name)
        
show_hudmessage(0hud_msg)
    }


Last edited by administratora; 12-18-2022 at 11:46.
administratora is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-18-2022 , 17:50   Re: block key
Reply With Quote #5

Quote:
Originally Posted by administratora View Post
Try that:
  1. You can't know what keys are pressed
  2. KeyEvent doesn't exist
  3. hud.inc doesn't exist unless you have it somewhere (in which case you should provide a link or attachment).
__________________
fysiks is offline
Old 12-19-2022, 13:19
administratora
This message has been deleted by administratora.
administratora
Member
Join Date: Mar 2015
Old 12-19-2022 , 13:51   Re: block key
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
  1. You can't know what keys are pressed
  2. KeyEvent doesn't exist
  3. hud.inc doesn't exist unless you have it somewhere (in which case you should provide a link or attachment).
What about that?

PHP Code:
#include <amxmodx>

#define KEY_F9 119
#define KEY_F8 118

public plugin_init()
{
    
register_event("KeyValue""event_key""be""1=0""2!=0")
}

public 
event_key(const id, const id_type, const id_state, const key)
{
    if(
key == KEY_F9)
    {
        new 
player_name[32]
        
get_user_name(idplayer_name31)
        
client_print(0print_chat"[F9] %s used the F9 key!"player_name)
    }
    else if(
key == KEY_F8)
    {
        new 
player_name[32]
        
get_user_name(idplayer_name31)
        
client_print(0print_chat"[F8] %s used the F8 key!"player_name)
    }

administratora is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 12-19-2022 , 14:23   Re: block key
Reply With Quote #7

Quote:
Originally Posted by administratora View Post
What about that?

PHP Code:
#include <amxmodx>

#define KEY_F9 119
#define KEY_F8 118

public plugin_init()
{
    
register_event("KeyValue""event_key""be""1=0""2!=0")
}

public 
event_key(const id, const id_type, const id_state, const key)
{
    if(
key == KEY_F9)
    {
        new 
player_name[32]
        
get_user_name(idplayer_name31)
        
client_print(0print_chat"[F9] %s used the F9 key!"player_name)
    }
    else if(
key == KEY_F8)
    {
        new 
player_name[32]
        
get_user_name(idplayer_name31)
        
client_print(0print_chat"[F8] %s used the F8 key!"player_name)
    }

Can you test it?
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
administratora
Member
Join Date: Mar 2015
Old 12-19-2022 , 15:44   Re: block key
Reply With Quote #8

Quote:
Originally Posted by JocAnis View Post
Can you test it?
No, I am writing this on my phone, sorry. I'm on a holiday without my laptop, if someone can test it would be great

Last edited by administratora; 12-19-2022 at 15:46.
administratora is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-19-2022 , 22:34   Re: block key
Reply With Quote #9

Quote:
Originally Posted by administratora View Post
No, I am writing this on my phone, sorry. I'm on a holiday without my laptop, if someone can test it would be great
Are you also just randomly guessing with random things that have "key" in their name? "KeyValue" is not an event that can be hooked like this and has nothing to do with your keyboard. As I already said, it's been understood for nearly ever that you cannot know what keys are pressed.

You might want to test it yourself before posting since you're clearly not confident what you're posting will actually work.
__________________
fysiks is offline
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 20:53.


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