Raised This Month: $ Target: $400
 0% 

clcmd, and keypress.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Rolnaaba
Veteran Member
Join Date: May 2006
Old 07-12-2007 , 20:52   clcmd, and keypress.
Reply With Quote #1

how can I register a clcmd and get when it is pressed AND when it is released? I can make people bind the comand, but how will i get when they press AND release that bound key?
Code:
register_clcmd("comand", "handle");   public handle(id) {       //this is when pressed }   //how do i detect release?
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
Deviance
Veteran Member
Join Date: Nov 2004
Location: Sweden
Old 07-12-2007 , 20:58   Re: clcmd, and keypress.
Reply With Quote #2

Code:
register_clcmd("+key", "key_press") register_clcmd("-key", "key_release") public key_press(id) {         // The key is pressed } public key_release(id) {         // The key is released }
Deviance is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 07-12-2007 , 21:01   Re: clcmd, and keypress.
Reply With Quote #3

the engine automatically detects the +/- and acts accordingly?
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
Deviance
Veteran Member
Join Date: Nov 2004
Location: Sweden
Old 07-12-2007 , 21:06   Re: clcmd, and keypress.
Reply With Quote #4

Quote:
Originally Posted by Rolnaaba View Post
the engine automatically detects the +/- and acts accordingly?
Yes.
Deviance is offline
draft
Senior Member
Join Date: Jul 2007
Location: Russia, Saint-Petersburg
Old 07-13-2007 , 12:14   Re: clcmd, and keypress.
Reply With Quote #5

Quote:
register_clcmd("+attack", "check_first_shot")
register_clcmd("status", "check_first_shot")
register_clcmd("-attack", "stop_check")


public check_first_shot(player)
{
client_print(0, print_chat, "Test")
}
I've made simple code but when i make a shot or write in console status there is no message "Test".
draft is offline
toazron1
Senior Member
Join Date: Oct 2006
Old 07-13-2007 , 12:44   Re: clcmd, and keypress.
Reply With Quote #6

You can not catch duck walk or attack using that type of register, you need to do something like this


This is off the top of my head but you get the idea... (not at my house right now)
Code:
 
public client_prethink(id) {
        if (get_user_buttons(id) & IN_ATTACK) {
             server_print("ATTACKED")
        }
}
__________________

Last edited by toazron1; 07-13-2007 at 12:46. Reason: tab + enter = post
toazron1 is offline
Send a message via AIM to toazron1
draft
Senior Member
Join Date: Jul 2007
Location: Russia, Saint-Petersburg
Old 07-13-2007 , 13:25   Re: clcmd, and keypress.
Reply With Quote #7

Quote:
Originally Posted by toazron1 View Post
Code:
 
public client_prethink(id) {
        if (get_user_buttons(id) & IN_ATTACK) {
             server_print("ATTACKED")
        }
}
Thanks, i got it but can u explain two things in your code?
1) What is client prethink? Is it something that is always executing instead of setting task of function? I've found only one explanation that it is "Forward" and nothing else.
2) IN_ATTACK - what is that?
Sorry, if i'm too silly
draft is offline
DotNetJunkie
Senior Member
Join Date: May 2005
Location: In front of my pc
Old 07-16-2007 , 08:13   Re: clcmd, and keypress.
Reply With Quote #8

Quote:
Originally Posted by toazron1 View Post
You can not catch duck walk or attack using that type of register, you need to do something like this


This is off the top of my head but you get the idea... (not at my house right now)
Code:
 
public client_prethink(id) {
        if (get_user_buttons(id) & IN_ATTACK) {
             server_print("ATTACKED")
        }
}

Code:
new g_UseKey[33];

...

new buffer = entity_get_int(id, EV_INT_button);
if( (buffer & IN_USE) && !g_UseKey[id] )
{
	g_UseKey[id] = 1;
	client_print(id, print_chat, "You pressed onto your use key!");
}
if( !(buffer & IN_USE) && g_UseKey[id] )
{
	g_UseKey[id] = 0;
	client_print(id, print_chat, "You let go of your use key!");
}
__________________
DotNetJunkie is offline
Send a message via ICQ to DotNetJunkie Send a message via AIM to DotNetJunkie Send a message via MSN to DotNetJunkie Send a message via Yahoo to DotNetJunkie
Rolnaaba
Veteran Member
Join Date: May 2006
Old 07-13-2007 , 13:46   Re: clcmd, and keypress.
Reply With Quote #9

1) client_prethink is a forward (engine?) that is called before every frame.
2) IN_ATTACk is the ID of the button they are pressing, which is +attack.

fakemeta way:
Code:
#include <amxmodx> #include <fakemeta> //... register_forward(FM_PlayerPreThink, "fwdPlayerPreThink"); //... public fwdPlayerPreThink(ent) {     if(pev(id, pev_button) & IN_ATTACK) {         client_print(id, print_chat, "YOUR ATTACKING!!")     } }
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
draft
Senior Member
Join Date: Jul 2007
Location: Russia, Saint-Petersburg
Old 07-13-2007 , 14:21   Re: clcmd, and keypress.
Reply With Quote #10

Doesn't work. Compiles but i don't see "YOUR ATTACKING!!"

Last edited by draft; 07-13-2007 at 14:52.
draft 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 21:29.


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