Raised This Month: $ Target: $400
 0% 

Detect +USE key


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 11-11-2007 , 05:21   Re: Detect +USE key
Reply With Quote #1

Quote:
Originally Posted by styles View Post
wow so my shove mod uses bad practices.. I should update this to FM_CmdStart

Thanks
Historically, it's been good practice back when people first used the buttons entvar because a FM_CmdStart forward didn't even exist then.
__________________
hello, i am pm
PM is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 11-11-2007 , 05:27   Re: Detect +USE key
Reply With Quote #2

Quote:
Originally Posted by PM View Post
Historically, it's been good practice back when people first used the buttons entvar because a FM_CmdStart forward didn't even exist then.
o.O, prehistoric era! hi PM :-)
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
Orangutanz
Veteran Member
Join Date: Apr 2006
Old 11-11-2007 , 09:15   Re: Detect +USE key
Reply With Quote #3

Quote:
Originally Posted by PM View Post
Historically, it's been good practice back when people first used the buttons entvar because a FM_CmdStart forward didn't even exist then.
True just a good job a few of us AMX guys joined AMXX. I took a particular liking to FakeMeta so suggested improvements and bug fixes, CmdStart being one of them (I believe) quite a few anyhow
__________________
|<-- Retired from everything Small/Pawn related -->|
You know when you've been Rango'd

Last edited by Orangutanz; 11-11-2007 at 09:18.
Orangutanz is offline
alien
Senior Member
Join Date: Aug 2005
Location: London || Slovakia
Old 11-12-2007 , 20:57   Re: Detect +USE key
Reply With Quote #4

May I use it for every single IN_ command? What an optimization this came down to be!
__________________
alien is offline
Send a message via ICQ to alien
Orangutanz
Veteran Member
Join Date: Apr 2006
Old 11-12-2007 , 21:38   Re: Detect +USE key
Reply With Quote #5

Quote:
Originally Posted by alien View Post
May I use it for every single IN_ command? What an optimization this came down to be!
Yes
__________________
|<-- Retired from everything Small/Pawn related -->|
You know when you've been Rango'd
Orangutanz is offline
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 11-12-2007 , 22:07   Re: Detect +USE key
Reply With Quote #6

Nice!!!!!
When you hold the use key, it spams the function though, is there a way to make it so the function is called only once when the use key is held down instead of just tapped?
__________________

mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
travo
Senior Member
Join Date: Aug 2006
Old 11-12-2007 , 22:40   Re: Detect +USE key
Reply With Quote #7

Quote:
Originally Posted by mysticssjgoku4 View Post
Nice!!!!!
When you hold the use key, it spams the function though, is there a way to make it so the function is called only once when the use key is held down instead of just tapped?
i wondered this same thing but it did this

Code:
new CTimer;

public fw_start(const id,const uc_handle,random_seed)
{
    if (!is_user_alive(id))
        return FMRES_IGNORED
    
    static buttons
    buttons = get_uc(uc_handle,UC_Buttons);
    if (buttons & IN_USE)
    {
        if (!CTimer)
        {
            // do something
            CTimer = 1;
            set_task(2.0,"reset_CTimer");
        }
    }
    return FMRES_SUPERCEDE
}

public reset_CTimer()
{
    CTimer = 0;
}

Last edited by travo; 11-12-2007 at 22:40. Reason: oops
travo is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 11-14-2007 , 08:17   Re: Detect +USE key
Reply With Quote #8

Quote:
Originally Posted by travo View Post
i wondered this same thing but it did this

Code:
new CTimer;

public fw_start(const id,const uc_handle,random_seed)
{
    if (!is_user_alive(id))
        return FMRES_IGNORED
    
    static buttons
    buttons = get_uc(uc_handle,UC_Buttons);
    if (buttons & IN_USE)
    {
        if (!CTimer)
        {
            // do something
            CTimer = 1;
            set_task(2.0,"reset_CTimer");
        }
    }
    return FMRES_SUPERCEDE
}

public reset_CTimer()
{
    CTimer = 0;
}
This really isn't an optimal (or accurate for that matter) way to do this:
Code:
if ((buttons & IN_USE) && !(pev(id, pev_oldbuttons) & IN_USE))) { // user has now intially pressed the use key, was not pressed before // This is the intial tap, and won't execute if they're holding it down. } if (!(buttons & IN_USE) && (pev(id, pevoldbuttons) & IN_USE))) { // User was pressing the use key, but no longer is }

Hrm, could another coder verify that this code works in FM_CMDStart (or works it all for that matter), it may only work in prethink (I'm a bit rusty in this field).

note
Post not finished, school bell rung.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred

Last edited by Zenith77; 11-14-2007 at 08:20.
Zenith77 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 01:13.


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