Raised This Month: $ Target: $400
 0% 

clcmd, and keypress.


Post New Thread Reply   
 
Thread Tools Display Modes
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 07-13-2007 , 16:34   Re: clcmd, and keypress.
Reply With Quote #11

Quote:
Originally Posted by Rolnaaba View Post
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!!")     } }
You used...
public fwdPlayerPreThink(ent)

Should it not be...
public fwdPlayerPreThink(id)

Since you used id in the function ;D?
hlstriker is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 07-13-2007 , 17:16   Re: clcmd, and keypress.
Reply With Quote #12

bah! I am a retard, but with that error it shouldnt have compiled....maybe he changed it before compiling and trying it.
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
draft
Senior Member
Join Date: Jul 2007
Location: Russia, Saint-Petersburg
Old 07-15-2007 , 04:39   Re: clcmd, and keypress.
Reply With Quote #13

Thanks to all, that works correct. +Karma everyone. Results:
One knife shot - 5 times of "Your Shooting"
One pistol shot - about 12 times
But I have another problem. Can u help what returns func "get_user_aiming" when checked player aims to another one? In help is said that it returns distance but i need to return hitbox (head, neck, and so on) at which player aims on another player. Can u help plz?)
draft is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 07-16-2007 , 01:19   Re: clcmd, and keypress.
Reply With Quote #14

@Rolnaaba

I like to do it like this:

PHP Code:
register_clcmd("+command""cmd_whatever")
register_clcmd("-command""cmd_whatever")

public 
cmd_whatever(id)
{
    new 
cmd[2]
    
read_argv(0cmd1)
    
    switch(
cmd[0])
    {
        case 
'+':
        {
            
//pressed
        
}
        case 
'-':
        {
            
//released
        
}
    }

stupok is offline
draft
Senior Member
Join Date: Jul 2007
Location: Russia, Saint-Petersburg
Old 07-16-2007 , 06:03   Re: clcmd, and keypress.
Reply With Quote #15

Quote:
Originally Posted by stupok69 View Post
@Rolnaaba

I like to do it like this:

PHP Code:
register_clcmd("+command""cmd_whatever")
register_clcmd("-command""cmd_whatever")
 
public 
cmd_whatever(id)
{
    new 
cmd[2]
    
read_argv(0cmd1)
 
    switch(
cmd[0])
    {
        case 
'+':
        {
            
//pressed
        
}
        case 
'-':
        {
            
//released
        
}
    }

Does it work with cmd = attack ? I've tried and no result.

Last edited by draft; 07-16-2007 at 06:50.
draft is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 07-16-2007 , 06:11   Re: clcmd, and keypress.
Reply With Quote #16

No! You must use Rolnaaba way! With button constants ;)
http://forums.alliedmods.net/showpos...50&postcount=8

But anyway!

Code:
public fwdPlayerPreThink(id)
{
 static button
 button = pev(id,pev_button)
 
 if(button & IN_ATTACK)
 {
  client_print(id, print_chat, "YOUR ATTACKING!!")
 }
}
__________________
Still...lovin' . Connor noob! Hello

Last edited by Alka; 07-16-2007 at 06:14.
Alka 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 #17

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
Old 07-16-2007, 11:37
Rolnaaba
This message has been deleted by Rolnaaba. Reason: repeat
Rolnaaba
Veteran Member
Join Date: May 2006
Old 07-16-2007 , 11:46   Re: clcmd, and keypress.
Reply With Quote #18

*barf* engine! besides he is catching +attack, which is different than use...
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
DotNetJunkie
Senior Member
Join Date: May 2005
Location: In front of my pc
Old 07-17-2007 , 05:28   Re: clcmd, and keypress.
Reply With Quote #19

Quote:
Originally Posted by Rolnaaba View Post
*barf* engine! besides he is catching +attack, which is different than use...
Code:
new g_AttackKey[33][2];

...

public client_PreThink(id)
{

new buffer = entity_get_int(id, EV_INT_button);

for( new i = 0; i < 2; i++ )
{
if( (buffer & ( i ? IN_ATTACK2 : IN_ATTACK)) && !g_AttackKey[id][i] )
{
	g_AttackKey[id][i] = 1;
	if( i ) { client_AttackSecondaryDown(id); } else { client_AttackPrimaryDown(id); }
}
if( !(buffer & ( i ? IN_ATTACK2 : IN_ATTACK )) && g_AttackKey[id][i] )
{
	g_AttackKey[id][i] = 0;
	if( i ) { client_AttackSecondaryUp(id); } else { client_AttackPrimaryUp(id); }
}
}

return PLUGIN_CONTINUE;

}

...

public client_AttackKeyPrimaryDown(id)
{
client_print(id, print_chat, "You pressed your primary attack key down!");
return 1;
}
public client_AttackKeySecondaryDown(id)
{
client_print(id, print_chat, "You pressed your secondary attack key down!");
return 1;
}

public client_AttackKeyPrimaryUp(id)
{
client_print(id, print_chat, "You let go of your primary attack key!");
return 1;
}
public client_AttackKeySecondaryUp(id)
{
client_print(id, print_chat, "You let go of your secondary attack key!");
return 1;
}
Besides, what is wrong with engine? It's so useful for so many things!
__________________
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-17-2007 , 13:00   Re: clcmd, and keypress.
Reply With Quote #20

it is *barf* because fakemeta can do anything it does, more, and faster...

[EDIT] Even though you give me negative karma, doesnt make it any less true. Fakemeta has all of the functionalities engine has (albeit a different implimentation to accomplish the same thing) + more. It is also faster, because its interception and execution is earlier. I am not sure exactly when it is, I remember reading it somewhere....but it is faster, and more efficient, making it faster. Did i mention fakemeta is faster than engine?
__________________
DO NOT PM me about avp mod.

Last edited by Rolnaaba; 07-18-2007 at 15:46.
Rolnaaba 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 06:57.


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