Full bag warning is flooding - 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: Full bag warning is flooding (
/showthread.php?tid=660941)
Full bag warning is flooding -
Corin - 17.11.2018
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.");
}
Re: Full bag warning is flooding -
ReD_HunTeR - 17.11.2018
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.");
Re: Full bag warning is flooding -
kingmk - 17.11.2018
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.");
Re: Full bag warning is flooding -
kingmk - 17.11.2018
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.
Re: Full bag warning is flooding -
CantBeJohn - 18.11.2018
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.");
|
Re: Full bag warning is flooding -
kingmk - 18.11.2018
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.