|= and &
#10

Practical use for this is to store multiple (up to 32) boolean variables (true/false, on/off, yes/no) into one single integer variable. In your case this would probably translate to permissions, so for example:

pawn Код:
enum (<<= 1) // don't forget to add this
{
    CAN_ADD_OBJECT = 1, // set this to 1 otherwise everything will be 0 and the whole thing breaks
    CAN_EDIT_OBJECT,
    CAN_REMOVE_OBJECT,
    // etc
}

new editorPermissions[MAX_PLAYERS];

// somewhere
editorPermissions[playerid] |= CAN_ADD_OBJECT; // player can now add objects

editorPermissions[playerid] &= ~CAN_ADD_OBJECT; // player can no longer add objects
You can write macros or functions for this so you don't have to remember all the | and & things.
Reply


Messages In This Thread
|= and & - by iBots - 08.01.2015, 21:29
Re: |= and & - by DavidSparks - 08.01.2015, 21:30
Re: |= and & - by Schneider - 08.01.2015, 21:32
Re: |= and & - by DavidSparks - 08.01.2015, 21:32
Re: |= and & - by WLSF - 08.01.2015, 21:36
Re: |= and & - by Mauzen - 08.01.2015, 21:43
Re: |= and & - by iBots - 08.01.2015, 21:52
Re: |= and & - by iBots - 08.01.2015, 22:00
Re: |= and & - by WLSF - 08.01.2015, 22:01
Re: |= and & - by Vince - 08.01.2015, 22:02

Forum Jump:


Users browsing this thread: 7 Guest(s)