Getting bit from a binary -
iBots - 30.08.2016
i have one question, for example i wanna give a player an object,and they can have unlimited objects,So what i do is:
pawn Код:
Example[playerid] |= objectid;
Lets say i have gave him 100 objects for example, and i want to check the id of his second object,what can i do to get like the second bit (second object) that he has, i dont wanna loop all over the objects....
Re: Getting bit from a binary -
DeeadPool - 30.08.2016
You can use this. add few parameters and the you are done

and for getting the object id in the slot you even have to create slots for it to do so.
https://sampwiki.blast.hk/wiki/GetPlayerObjectModel
Re: Getting bit from a binary -
iBots - 30.08.2016
He has the option to use it or not...what if he didnt use it?and also i cant make unlimited slots,because as i have said for example he can have unlimited amount of objects.
Re: Getting bit from a binary -
AndySedeyn - 30.08.2016
You can't extract an objectid from a single bit unless the id is 0 or 1.
Re: Getting bit from a binary -
PrO.GameR - 30.08.2016
Thats not the way binary works, basically if you are using binary 3 means both 1 and 2, you need an array for the way you do it.
You can do it binary way too, but you'd need to know what the max objectid is, and split them into groups of 32, saving over an array of objectid/32, but thats one hell lot of a hassle.
Re: Getting bit from a binary -
iBots - 30.08.2016
Can you give me an example of how to do it?
Re: Getting bit from a binary -
PrO.GameR - 30.08.2016
https://sampforum.blast.hk/showthread.php?tid=177523
There are multiple topics regarding bits and binary operators, take a good read and try your own version with what I explained in my last post then get back at us here for more help.
Re: Getting bit from a binary -
iBots - 31.08.2016
I have read it and i still need an example....you didnt reply with a clear answer,can you tell me if it's possible to get a specific bit from a binary like i said?if yes how?and if not then what can i do?i mean something that is like it.
Re: Getting bit from a binary -
Kaliber - 31.08.2016
Quote:
Originally Posted by iBots
and they can have unlimited
|
That is impossible...cause they can only have 32.
Cause Pawn VM is 32-Bit so max var is just 2^32
(If you work with only one Variable)
Re: Getting bit from a binary -
AbyssMorgan - 31.08.2016
To modify bits, use:
PHP код:
GetValueBit(value,bit);
SetValueBit(&value,bit,power);
https://sampforum.blast.hk/showthread.php?tid=591223