SA-MP Forums Archive
Inventory - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Inventory (/showthread.php?tid=126154)



Inventory - Universal - 07.02.2010

I have on problem with inventory...

Код:
dcmd_inv(playerid,params[])
 {
 #pragma unused params
 new Info[6][30];
 new Items[128];
 for(new i=1; i < 6; i++)
 {
 if(pInv[i][playerid][Item]==0) format(Info[i],30,"Empty slot");
 if(pInv[i][playerid][Item]==1) format(Info[i],30,"Ciggarets");
 format(Items,128,"%s\n%s\n%s\n%s\n%s",Info[i],Info[i],Info[i],Info[i],Info[i]);
 }
 ShowPlayerDialog(playerid,5,DIALOG_STYLE_LIST,"Player inventory",Items,"Ok","Close");
 return 1;
 }
And the command, when i buy something:

Код:
...

if(listitem==0){
 if(pInfo[playerid][Cash] < 10)return SendClientMessage(playerid,GREY,"Not enough money !");
 PlayerPlaySound(playerid,1054,0,0,0);
 pInfo[playerid][Cash] = pInfo[playerid][Cash] -10;
 GivePlayerMoney(playerid,-10);
 for(new a=1; a < 6; a++)
 {
 if(pInv[a][playerid][Item]==0) pInv[a][playerid][Item]=1;
 return 0;
 }
 }

...
Now, when i buy ciggaretes, the array pInv[1][playerid][Item] should be equal to 1, and the when i type /inv it formats it to the info of the item, so, if =1 it should be "Ciggarets", and all i get is:

Empty slot
Empty slot
Empty slot
Empty slot
Empty slot

All 5 slots, are empty... Any ideas how to make inventory?



Re: Inventory - Universal - 07.02.2010

Well ?


Re: Inventory - KuHS - 07.02.2010

Try to use this:

Код:
 for(new a=1; a < 6; a++)
 {
 if(pInv[a][playerid][Item]==0) return pInv[a][playerid][Item]=1;
 }