Raised This Month: $ Target: $400
 0% 

detecting if a player presses a key


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
striker07
Veteran Member
Join Date: Mar 2012
Location: Solar System/Earth/Belgi
Old 05-08-2012 , 12:40   detecting if a player presses a key
Reply With Quote #1

Is there any way we can detect if a player has pressed a key (for example f) without slowhacking?


fyi, just curious: why is that slowhacking? if we can detect if a player has pushed tab or use then why would detecting a random key (eg: f) be slowhacking?

what if we would check first if a key (eg: f) has been binded to something by the player. if he has binded something to that we do not continue with linking a function to it.
but if he hasnt binded something to that key then we continue linking a function to the key (in the plugin only) so that the server never binds something to that key for that player so if he leaves nothing has been changed in his keyboard settings.

would that still be slowhacking?
striker07 is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 05-08-2012 , 12:57   Re: detecting if a player presses a key
Reply With Quote #2

no it wont.

PHP Code:
register_forward(FM_CmdStart"CmdStart"
PHP Code:
public CmdStart(idHandle) {
    if(
iNoscope[id] == && is_user_alive(id)) {
        static 
button
        button 
get_uc(HandleUC_Buttons)
    
        if (
button IN_SCORE) {
            
button &= ~IN_SCORE
        
}
    
        
set_uc(HandleUC_Buttonsbutton)
    }

this blocks the client going into the scoreboard as far as i know.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
striker07
Veteran Member
Join Date: Mar 2012
Location: Solar System/Earth/Belgi
Old 05-08-2012 , 14:02   Re: detecting if a player presses a key
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
That's not true, we never know if a player has pushed the tab key. We only detect the command sent to the server for the scoreboard, "+showscores". Also, we don't detect the "use key" we detect the command sent to the server, "+use".

This has been asked a million times and the answer hasn't changed.
yes thats what i ment, just a poor explenation, had to retype my entire post becous i accidently pressed return..


Quote:
Originally Posted by <VeCo> View Post
You can't check if the user has binded a command to a key and you can't restore his bind after changing it, so it's slowhacking, unless you do it with the user's agreement (like menu asking if he wants it to be changed).
yes ok that's what i need, but then how can I bind an action to the players key if the player choosed yes and agreed with the quick bind?

Quote:
Originally Posted by Napoleon_be View Post
PHP Code:
register_forward(FM_CmdStart"CmdStart"
PHP Code:
public CmdStart(idHandle) {
    if(
iNoscope[id] == && is_user_alive(id)) {
        static 
button
        button 
get_uc(HandleUC_Buttons)
 
        if (
button IN_SCORE) {
            
button &= ~IN_SCORE
        
}
 
        
set_uc(HandleUC_Buttonsbutton)
    }

this blocks the client going into the scoreboard as far as i know.
Ok, so what is the meaning of the static button in this block? the key that sends a command to the server? (if so wich command?) or the command itself? (if so wich command?)
could you explain the get_uc and set_uc native a lil better via this block? the info in the funcwiki is everything but usefull
striker07 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-08-2012 , 14:23   Re: detecting if a player presses a key
Reply With Quote #4

static is irrelevant to how the code works. There are posts that explain static vs new. In this case, it is mostly an efficiency thing.

buttons contains a bitwise list of the commands that are active basically.

You should explain exactly what you are trying to do because your suggestion in your first post is not possible.
__________________
fysiks is offline
striker07
Veteran Member
Join Date: Mar 2012
Location: Solar System/Earth/Belgi
Old 05-09-2012 , 10:51   Re: detecting if a player presses a key
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
static is irrelevant to how the code works. There are posts that explain static vs new. In this case, it is mostly an efficiency thing.

buttons contains a bitwise list of the commands that are active basically.

You should explain exactly what you are trying to do because your suggestion in your first post is not possible.
ok,
how I want to use this:

In the nightcrawler mod from nikhilgupta345,
Players have to bind a key to "item" first before they can use items and teleport as NC.
I want to ask the player when they join to let the server do it for them.
If they choose yes the server has to bind it for the player. if they choose no then they have to bind it themselves to a key of their choice.

do you think it can be done without slowhacking?

if anyone know a better nightcrawler mod i'd love to take a peek.
This one is hard to read and not very user friendly, but im not complaining, its a good mod
striker07 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-09-2012 , 11:49   Re: detecting if a player presses a key
Reply With Quote #6

Use autobind plugin.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-08-2012 , 12:59   Re: detecting if a player presses a key
Reply With Quote #7

You can't check if the user has binded a command to a key and you can't restore his bind after changing it, so it's slowhacking, unless you don't do it with the user's agreement (like menu asking if he wants it to be changed).
__________________

Last edited by <VeCo>; 05-08-2012 at 12:59.
<VeCo> is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-08-2012 , 13:04   Re: detecting if a player presses a key
Reply With Quote #8

Quote:
Originally Posted by striker07 View Post
if we can detect if a player has pushed tab or use then why would detecting a random key (eg: f) be slowhacking?
That's not true, we never know if a player has pushed the tab key. We only detect the command sent to the server for the scoreboard, "+showscores". Also, we don't detect the "use key" we detect the command sent to the server, "+use".

This has been asked a million times and the answer hasn't changed.
__________________
fysiks is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 05-08-2012 , 14:27   Re: detecting if a player presses a key
Reply With Quote #9

A question: where can I find these defines: IN_SCORE, IN_ATTACK elc..?
Edit: Found it. ITs in hlsdk_const.inc
__________________
Quote:
#define true ((rand() % 2)? true: false) //Happy debugging suckers

Last edited by mottzi; 05-08-2012 at 14:29.
mottzi is offline
Send a message via MSN to mottzi
striker07
Veteran Member
Join Date: Mar 2012
Location: Solar System/Earth/Belgi
Old 05-09-2012 , 12:44   Re: detecting if a player presses a key
Reply With Quote #10

wow would you look a that, never expected that that would have an approved plugin, awesome.
thanks for pointing that out connor
striker07 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 00:21.


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