AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   getting buttons (https://forums.alliedmods.net/showthread.php?t=214980)

didoWEE 05-02-2013 05:07

getting buttons
 
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



ConnorMcLeod 05-02-2013 06:27

Re: getting buttons
 
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 


didoWEE 05-02-2013 07:05

Re: getting buttons
 
Quote:

Originally Posted by ConnorMcLeod (Post 1944287)
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

ConnorMcLeod 05-02-2013 08:32

Re: getting buttons
 
You should have asked with that last code from the beginning then.
Yes your code is ok.

hornet 05-02-2013 08:33

Re: getting buttons
 
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.


All times are GMT -4. The time now is 10:49.

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