Getting bit from a binary
#1

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....
Reply
#2

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
Reply
#3

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.
Reply
#4

You can't extract an objectid from a single bit unless the id is 0 or 1.
Reply
#5

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.
Reply
#6

Can you give me an example of how to do it?
Reply
#7

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.
Reply
#8

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.
Reply
#9

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)
Reply
#10

To modify bits, use:
PHP код:
GetValueBit(value,bit);
SetValueBit(&value,bit,power); 
https://sampforum.blast.hk/showthread.php?tid=591223
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)