Raised This Month: $ Target: $400
 0% 

getting buttons


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
didoWEE
Senior Member
Join Date: Oct 2012
Location: Bulgaria
Old 05-02-2013 , 05:07   getting buttons
Reply With Quote #1

Hi all.
What will return pev(index, pev_button) if I'm pressing both IN_USE, IN_ATTACK and IN_FORWARD
I mean, will this work:
PHP Code:
new button pev(indexpev_button);
if(
button IN_USE && button IN_ATTACK && button IN_FORWARD)
{
    
// do sth

didoWEE is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-02-2013 , 06:27   Re: getting buttons
Reply With Quote #2

PHP Code:
new button pev(indexpev_button);
if(
button IN_USE && button IN_ATTACK && button IN_FORWARD
can write like this :

PHP Code:
const IN_USE_ATTACK_FORWARD IN_USE IN_ATTACK IN_FORWARD// that one in global scope.
if(pev(indexpev_button) & IN_USE_ATTACK_FORWARD == IN_USE_ATTACK_FORWARD 

And that one :
PHP Code:
new button pev(indexpev_button);
if(
button IN_USE || button IN_ATTACK || button IN_FORWARD
can write like this :

PHP Code:
const IN_USE_ATTACK_FORWARD IN_USE IN_ATTACK IN_FORWARD// that one in global scope.
if(pev(indexpev_button) & IN_USE_ATTACK_FORWARD 
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
didoWEE
Senior Member
Join Date: Oct 2012
Location: Bulgaria
Old 05-02-2013 , 07:05   Re: getting buttons
Reply With Quote #3

Quote:
Originally Posted by ConnorMcLeod View Post
PHP Code:
new button pev(indexpev_button);
if(
button IN_USE && button IN_ATTACK && button IN_FORWARD
can write like this :

PHP Code:
const IN_USE_ATTACK_FORWARD IN_USE IN_ATTACK IN_FORWARD// that one in global scope.
if(pev(indexpev_button) & IN_USE_ATTACK_FORWARD == IN_USE_ATTACK_FORWARD 
Ok, Thanks

But my question is: Will my code work, because I will use code like that
PHP Code:
static buttonbutton pev(indexpev_button);
if(
button IN_USE)
{
   if(
button IN_ATTACK)
   {
      
// do sth
   
}
   else if(
button IN_ATTACK2)
   {
      
// do sth
   
}

Because with your way, I'll check IN_USE many times, instead of one

Last edited by didoWEE; 05-02-2013 at 07:24.
didoWEE is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-02-2013 , 08:32   Re: getting buttons
Reply With Quote #4

You should have asked with that last code from the beginning then.
Yes your code is ok.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 05-02-2013 , 08:33   Re: getting buttons
Reply With Quote #5

By the looks of your code, it doesn't look like it will work as intended. You haven't described what your trying to do. However, your code states that if a player is holding IN_USE and IN_ATTACK it will do something. Keep in mind that the player could also be holding any other button at the same time and it would be same result, even IN_ATTACK2.

Quote:
Because with your way, I'll check IN_USE many times, instead of one
It's not checking for IN_USE, it's checking for the sum of all 3 of those buttons.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.

Last edited by hornet; 05-02-2013 at 08:33.
hornet 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 10:49.


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