Question about '&' usage in If statements
#1

I was going through an old script and I've used '&' within an If statement. I don't remember what this actually represents. I understand that '&&' is used to check if multiple statements are true, but I don't get what '&' does.

The line of code in particular is this:

Код:
if(newkeys & KEY_SECONDARY_ATTACK)
Also how does this differ from:

Код:
if(newkeys == KEY_SECONDARY_ATTACK)
Reply
#2

here is some info on bitwise operators

https://sampwiki.blast.hk/wiki/OnPlayerK...ge#Explanation
Reply
#3

That is Bitwise AND (consider it as multiplication of binary number) if one of the input is 0 the output is 0 otherwise 1. It mainly used for combination of hardware events and computing combination of two inputs.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)