Raised This Month: $ Target: $400
 0% 

[Solved] Player Duck


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 07-05-2013 , 09:22   [Solved] Player Duck
Reply With Quote #1

Hi
What is the best way to know if player is ducking?
__________________
Jhob94 is online now
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 07-05-2013 , 09:23   Re: Player Duck
Reply With Quote #2

By seeing if their buttons contain IN_DUCK
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 07-05-2013 , 09:46   Re: Player Duck
Reply With Quote #3

Something like this?
PHP Code:
public plugin_init()
{  
    
register_forward(FM_CmdStart"fw_CmdStart")
}

public 
fw_CmdStart(iduc_handleseed)
{
    static 
CurrentButton
    CurrentButton 
get_uc(uc_handleUC_Buttons)
    
    if(
is_user_alive(id) && CurrentButton IN_DUCK)
    {
           
// Code
    
}

It seems good but on code i display one message and xD it display lot of messages
__________________

Last edited by Jhob94; 07-05-2013 at 10:43.
Jhob94 is online now
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-05-2013 , 10:59   Re: Player Duck
Reply With Quote #4

If you print a message in that conditional statement it will print any time that it is true. It will be true the entire time that you are holding the button down (remember that it will execute really fast so what you may think is a single press is actually a long time relative to the computer).

If you only want the message to show when you first press the button then you need to save the previous value and compare it to the current value to detect the change of state.

If you search you can find all the information you need. Amazing how that works.
__________________

Last edited by fysiks; 07-05-2013 at 11:00.
fysiks is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 07-05-2013 , 11:11   Re: Player Duck
Reply With Quote #5

Hum i used bool and now works fine
__________________
Jhob94 is online now
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-05-2013 , 11:19   Re: Player Duck
Reply With Quote #6

Quote:
Originally Posted by Jhob94 View Post
Hum i used bool and now works fine
How so? How do you reset the boolean?
__________________
fysiks is offline
Bos93
Veteran Member
Join Date: Jul 2010
Old 07-05-2013 , 11:25   Re: Player Duck
Reply With Quote #7

Quote:
If you only want the message to show when you first press the button then you need to save the previous value and compare it to the current value to detect the change of state.
#define m_afButtonPressed 246
#define m_afButtonReleased 247
__________________
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-05-2013 , 11:39   Re: Player Duck
Reply With Quote #8

Player is ducking when size if lower than standup size, if you want to detect that, you can check flags & FL_DUCKING
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 07-05-2013 , 13:10   Re: Player Duck
Reply With Quote #9

Well its good how it is.
About bool i set Can_Duck false after ducks ;)
__________________
Jhob94 is online now
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-05-2013 , 13:13   Re: Player Duck
Reply With Quote #10

Quote:
Originally Posted by Jhob94 View Post
Well its good how it is.
About bool i set Can_Duck false after ducks ;)
So it only shows the message once per map?
__________________
fysiks 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:26.


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