Help with Y_Bits
#1

Can anyone help me with Y_Bits? I'm new using YSI and I didn't find good explanations about it. What is slot? what is <>? How can I check a value of a bitarray? is it correct to use
Код:
new BitArray:array<MAX_PLAYERS>;
or
Код:
new BitArray:array[MAX_PLAYERS];
?
Reply
#2

The first code is correct to use.
Reply
#3

Quote:
Originally Posted by ******
Посмотреть сообщение
A “slot” is the same in any array. It is just one piece of the array. Saying new arr[20]; declares an array with 20 slots. Saying new arr<20>; is similar, it declares an array with 20 slots too, but a special array. A special array is one that isn’t really an array. They are usually defined by libraries as here.
I've made this code for tests, but don't work for others players, just for ID 0

Код:
new BitArray:Escondertxt<MAX_PLAYERS>;

public OnPlayerConnect(playerid)
{
Bit_Set(BitArray:Escondertxt<playerid>, playerid, bool:false);
return 1;
}

public OnPlayerSpawn(playerid)
{
	if(Bit_Get(BitArray:Escondertxt, playerid) == false)
	{
		MostrarAllTXTS(playerid);
	}
	else
	{
		EsconderAllTXTS(playerid);
	}

return 1;
}

YCMD:texts(playerid, params[], help)
{
	if(Bit_Get(BitArray:Escondertxt, playerid) == false)
	{
		Bit_Set(BitArray:Escondertxt<playerid>, playerid, bool:true);
		EsconderAllTXTS(playerid);
		SendMessageAVS(playerid, "Vocк escondeu todas as textdraws.");
	}
	else
	{
		Bit_Set(BitArray:Escondertxt<playerid>, playerid, bool:false);
		MostrarAllTXTS(playerid);
		SendMessageAVS(playerid, "Vocк ativou todas as textdraws.");
	}
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)