for(new i = 0; i < 10; i++)
{
if(i != 10)
{
if(PlayerInfo[playerid][pSlot][i] == 0)
{
PlayerInfo[playerid][pSlot][i] = item;
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "ERROR:{FFFFFF} Your inventory is full.");
}
}
new items;
for(new i = 0; i < 10; i++)
{
if(items < 10)
{
if(PlayerInfo[playerid][pSlot][i] == 0)
{
PlayerInfo[playerid][pSlot][i] = item;
items++;
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "ERROR:{FFFFFF} Your inventory is full.");
break;
}
}
stock GetNextSlot(playerid)
{
for(new i = 0; i < 10; i++)
{
if(i == 10) break;
if(!PlayerInfo[playerid][pSlot][i]) // is slot empty
{
return i; // return empty slot
}
}
return -1; // couldn't find an empty slot
}
// usage -> couldn't find
if(GetNextSlot(playerid) == -1) return SendClientMessage(playerid, COLOR_RED, "ERROR:{FFFFFF} Your inventory is full.");
// usage -> found an empty slot
if(GetNextSlot(playerid))
{
// do something here, ...
}
|
I do not promise anything, and this might not work at all but try:
pawn Код:
|
for(new i = 0; i < 10; i++)
{
if(PlayerInfo[playerid][pSlot][i] == 0)
{
PlayerInfo[playerid][pSlot][i] = item;
return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED, "ERROR:{FFFFFF} Your inventory is full.");
}
}
new
bool: isfull
;
for(new i = 0; i < 10; i++)
{
if(!PlayerInfo[playerid][pSlot][i])
{
PlayerInfo[playerid][pSlot][i] = item;
isfull = true;
break;
}
}
if(!isfull) SendClientMessage(playerid, COLOR_RED, "ERROR:{FFFFFF} Your inventory is full.");
// You may return the message, that depends on what you want.