SA-MP Forums Archive
Help with Y_Bits - 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: Help with Y_Bits (/showthread.php?tid=659140)



Help with Y_Bits - Electrifying - 24.09.2018

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];
?


Re: Help with Y_Bits - VVWVV - 24.09.2018

The first code is correct to use.


Re: Help with Y_Bits - Electrifying - 24.09.2018

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;
}