Inventory Help
#1

So what happens, is that it compiles, but this does not show up in game.

Код:
new coordsstring[900];
	new title[900];
	switch(AccountInfo[playerid][pChips])
	{
	    case 0: return 0;
	    default: format(coordsstring, sizeof coordsstring, "%s%d\tChips\n",coordsstring,chips);
	}
	switch(AccountInfo[playerid][pToolKit])
	{
     	case 0: return 0;
	    default: format(coordsstring, sizeof coordsstring, "%s%d\tTool Kits\n",coordsstring,kit);
	}
	switch(AccountInfo[playerid][pWaterBottle])
	{
     	case 0: return 0;
	    default: format(coordsstring, sizeof coordsstring, "%s%d\tWater Bottles\n",coordsstring,waterbottle);
	}
	switch(AccountInfo[playerid][pBeef])
	{
     	case 0: return 0;
	    default: format(coordsstring, sizeof coordsstring, "%s%d\tBeef\n",coordsstring,Beef);
	}
	switch(AccountInfo[playerid][pWater])
	{
     	case 0: return 0;
	    default: format(coordsstring, sizeof coordsstring, "%s%d\tWater\n",coordsstring,water);
	}
	switch(AccountInfo[playerid][pSoda])
	{
     	case 0: return 0;
	    default: format(coordsstring, sizeof coordsstring, "%s%d\tSoda\n",coordsstring,Soda);
	}
	switch(AccountInfo[playerid][pMatches])
	{
     	case 0: return 0;
	    default: format(coordsstring, sizeof coordsstring, "%s%d\tMatches\n",coordsstring,matches);
	}
	switch(AccountInfo[playerid][pWood])
	{
     	case 0: return 0;
	    default: format(coordsstring, sizeof coordsstring, "%s%d\tWood\n",coordsstring,wood);
	}
	switch(AccountInfo[playerid][pMetal])
	{
     	case 0: return 0;
	    default: format(coordsstring, sizeof coordsstring, "%s%d\tMetal\n",coordsstring,metal);
	}
	switch(AccountInfo[playerid][pBeefDone])
	{
     	case 0: return 0;
	    default: format(coordsstring, sizeof coordsstring, "%s%d\tBeef Cooked\n",coordsstring,cookedBeef);
	}
	switch(AccountInfo[playerid][pChips] + AccountInfo[playerid][pToolKit] + AccountInfo[playerid][pWaterBottle])
	{
	    case 0: format(coordsstring,sizeof(coordsstring),"Empty Backpack");
	}
	format(title, sizeof title, "{9ACD32}Current Backpack{FFFFFF} [%d/%d]",slotsfree,slots);
    ShowPlayerDialog(playerid, BACKPACK, DIALOG_STYLE_LIST, title, coordsstring, "Select", "Close");
Reply
#2

This is some really weird coding..... Of course it will fail because of the return 0; on all the switch() statements as soon as one of those is not 0 then it will do the format but they would all have to be something other than 0 and in that case it will work. To be honest this coding is completely out to lunch. Avoid using multiple return; statements only use them when needed which should almost never be more than two per function. The use of switch() here is a bad choice as well use if statements.

pawn Код:
if(AccountInfo[playerid][pChips]) format(coordsstring, sizeof coordsstring, "%s%d\tChips\n",coordsstring,chips);
if(AccountInfo[playerid][pToolKit]) format(coordsstring, sizeof coordsstring, "%s%d\tTool Kits\n",coordsstring,kit);
if(AccountInfo[playerid][pWaterBottle]) format(coordsstring, sizeof coordsstring, "%s%d\tWater Bottles\n",coordsstring,waterbottle);
Reply
#3

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
This is some really weird coding..... Of course it will fail because of the return 0; on all the switch() statements as soon as one of those is not 0 then it will do the format but they would all have to be something other than 0 and in that case it will work. To be honest this coding is completely out to lunch. Avoid using multiple return; statements only use them when needed which should almost never be more than two per function. The use of switch() here is a bad choice as well use if statements.

pawn Код:
if(AccountInfo[playerid][pChips]) format(coordsstring, sizeof coordsstring, "%s%d\tChips\n",coordsstring,chips);
if(AccountInfo[playerid][pToolKit]) format(coordsstring, sizeof coordsstring, "%s%d\tTool Kits\n",coordsstring,kit);
if(AccountInfo[playerid][pWaterBottle]) format(coordsstring, sizeof coordsstring, "%s%d\tWater Bottles\n",coordsstring,waterbottle);
Im sorry, is this supposed to be a fix? or a comment on my coding. If it was supposed to be a fix, didnt work out bud
Reply
#4

How hard is to remove all the switch() and make them if's ?
Reply
#5

Well from what you have just showen, is really a fix, but just given lines not saying where to place them
Reply
#6

anyone help please
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)