Question about '&' usage in If statements - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Question about '&' usage in If statements (
/showthread.php?tid=627614)
Question about '&' usage in If statements -
Celson - 30.01.2017
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)
Re: Question about '&' usage in If statements -
jamesbond007 - 30.01.2017
here is some info on bitwise operators
https://sampwiki.blast.hk/wiki/OnPlayerK...ge#Explanation
Re: Question about '&' usage in If statements -
SyS - 30.01.2017
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.