Full bag warning is flooding
#1

Hi guys, I would like to tell the player when his purse is full, but it is flooding and is not working properly.

Код:
for(new i = 0; i < 10; j++)
{
	if(Bag[playerid][i][Slot] == 0)
	{
		Bag[playerid][i][Slot] = 1279;
		Bag[playerid][i][Unity] = 100;
		return 1;
	}
	else SendClientMessage(playerid, -1, "Your bag is full.");
}
Reply
#2

use variable to count, if count is 0 then send bag is full msg
pawn Код:
new iCount = 0;
for(new i = 0; i < 10; i++)
{
    if(Bag[playerid][i][Slot] == 0)
    {
        Bag[playerid][i][Slot] = 1279;
        Bag[playerid][i][Unity] = 100;
        iCount = 1;
        break; //i think you need this else it will set all slots which are empty to new item...
    }
}
if (iCount == 0) return SendClientMessage(playerid, -1, "Your bag is full.");
Reply
#3

I guess u get a spam of msg, and u want to show it just when all slots are unavaible (when bag it's full)

Код:
new i;
for(i = 0; i < 10; i++)
{
	if(Bag[playerid][i][Slot] == 0)
	{
		Bag[playerid][i][Slot] = 1279;
		Bag[playerid][i][Unity] = 100;
		return 1;
	}
}
if(i==10) SendClientMessage(playerid, -1, "Your bag is full.");
Reply
#4

Quote:
Originally Posted by ReD_HunTeR
Посмотреть сообщение
use variable to count, if count is 0 then send bag is full msg
pawn Код:
new iCount = 0;
for(new i = 0; i < 10; i++)
{
    if(Bag[playerid][i][Slot] == 0)
    {
        Bag[playerid][i][Slot] = 1279;
        Bag[playerid][i][Unity] = 100;
        iCount = 1;
        break; //i think you need this else it will set all slots which are empty to new item...
    }
}
if (iCount == 0) return SendClientMessage(playerid, -1, "Your bag is full.");
You can look my code above, it's more effcicient.
Reply
#5

Quote:
Originally Posted by kingmk
Посмотреть сообщение
You can look my code above, it's more effcicient.
No, it's not. Your code and the OP's is an infinite loop.

Quote:
Originally Posted by kingmk
Посмотреть сообщение
Код:
new i;
for(i = 0; i < 10; j++)
{
	if(Bag[playerid][i][Slot] == 0)
	{
		Bag[playerid][i][Slot] = 1279;
		Bag[playerid][i][Unity] = 100;
		return 1;
	}
}
if(i==10) SendClientMessage(playerid, -1, "Your bag is full.");
Reply
#6

Quote:
Originally Posted by CantBeJohn
Посмотреть сообщение
No, it's not. Your code and the OP's is an infinite loop.
Damm, i just make a little mistake, pressed the key on my keyboard a bit down, instead of i typed j by wrong. I guess u understood, was tired dull.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)