Find empty slot in a two dimensional array
#4

In that case you don't need cID, because its value is the same as ClanInfo array index. Also, cName should be an array, because only arrays can hold text. I suggest doing in this way:
Код:
enum ClanDaten
{
	bool:cAvailable=true,
	cName[20]
}
new ClanInfo[MAX_CLANS][ClanDaten];

stock CreateClan(playerid, clanname[])
{
    if(IsPlayerConnected(playerid) && !IsPlayerNPC(playerid))
    {
	new EmptySlot = FindEmptySlot();
        ClanInfo[EmptySlot][cAvailable] = false;
        format(ClanInfo[EmptySlot][cName], sizeof ClanInfo[EmptySlot][cName], clanname);
    }
}

stock FindEmptySlot()
{
	new
		i = 0;
	while (i <= MAX_CLANS)
	{
                if(!ClanInfo[i][cAvailable])
		    i++;
                else break;
	}
	if (i == MAX_CLANS) return -1;
	return i;
}
Reply


Messages In This Thread
Find empty slot in a two dimensional array - by Leenert - 29.06.2013, 20:38
Re: Find empty slot in a two dimensional array - by Scottas - 29.06.2013, 20:53
AW: Find empty slot in a two dimensional array - by Leenert - 29.06.2013, 21:02
Re: Find empty slot in a two dimensional array - by Scottas - 29.06.2013, 21:20
AW: Find empty slot in a two dimensional array - by Leenert - 29.06.2013, 21:54
Re: Find empty slot in a two dimensional array - by Scottas - 29.06.2013, 22:00
AW: Find empty slot in a two dimensional array - by Leenert - 29.06.2013, 22:03

Forum Jump:


Users browsing this thread: 1 Guest(s)