How to make this shorter?
#8

Quote:
Originally Posted by K0P
Посмотреть сообщение
Код:
stock ShowInventory(playerid,targetid)
{
    if(IsPlayerConnected(playerid)&&IsPlayerConnected(targetid))
	{
		// format stats and send to playerPlayerInfo[targetid][pLottoNr]
		new string[1200];
		new string2[1200];
		
		new check[18];
		new count;
		
		new phonebook[20],lottonumber[20],screwdriver[20],fish[20],briefcase[20],seeds[20],blindfold[20],crack[30],pot[30],adrenaline[30],a[30],b[30],c[30],d[30],products[30],dice[30],cards[30];

		if(PlayerInfo[targetid][pPhoneBook] == 0) check[0] = 0; phonebook = ""; else format(phonebook, sizeof(phonebook), "a phone book, ");
		if(PlayerInfo[targetid][pLottoNr] == 0) check[1] = 0; lottonumber = ""; else format(lottonumber, sizeof(lottonumber), "a Lotto Cupon %d, ", PlayerInfo[targetid][pLottoNr]);
		if(PlayerInfo[targetid][pScrew] == 0) check[2] = 0; screwdriver = ""; else format(screwdriver, sizeof(screwdriver), "a screwdriver, ", PlayerInfo[targetid][pLottoNr]);
		if(PlayerInfo[targetid][pFishes] == 0) check[3] = 0; fish = ""; else format(fish, sizeof(fish), "a %s, ", PlayerInfo[targetid][pFishes]);
		if(PlayerInfo[targetid][pBriefCase] == 0) check[4] = 0; briefcase = ""; else format(briefcase, sizeof(briefcase), "a briefcase, ");
		if(PlayerInfo[targetid][pWSeeds] == 0) check[5] = 0; seeds = ""; else format(seeds, sizeof(seeds), "%d seeds, ", PlayerInfo[targetid][pWSeeds]);
		if(PlayerInfo[targetid][pBlindfolds] == 0) check[6] = 0; blindfold = ""; else format(blindfold, sizeof(blindfold), "a blindfold, ");
		if(PlayerInfo[targetid][pCrack] == 0) check[7] = 0; crack = ""; else format(crack, sizeof(crack), "%d grams of crack, ", PlayerInfo[targetid][pCrack]);
		if(PlayerInfo[targetid][pPot] == 0) check[8] = 0; pot = ""; else format(pot, sizeof(pot), "%d grams of pot, ", PlayerInfo[targetid][pPot]);
		if(PlayerInfo[targetid][pAdrenaline] == 0) check[9] = 0; adrenaline = ""; else format(adrenaline, sizeof(adrenaline), "%d adrenaline syringes, ", PlayerInfo[targetid][pAdrenaline]);
		if(PlayerInfo[targetid][pMats] == 0) check[10] = 0; a = ""; else format(a, sizeof(a), "%d A materials, ", PlayerInfo[targetid][pMats]);
		if(PlayerInfo[targetid][pMats] == 0) check[11] = 0; b = ""; else format(b, sizeof(b), "%d B materials, ", PlayerInfo[targetid][pMatsb]);
		if(PlayerInfo[targetid][pMatsc] == 0) check[12] = 0; c = ""; else format(c, sizeof©, "%d C materials, ", PlayerInfo[targetid][pMatsc]);
		if(PlayerInfo[targetid][pMatsd] == 0) check[13] = 0; d = ""; else format(d, sizeof(d), "%d D materials, ", PlayerInfo[targetid][pMatsd]);
		if(PlayerInfo[targetid][pProducts] == 0) check[14] = 0; products = ""; else format(products, sizeof(products), "%d products, ", PlayerInfo[targetid][pProducts]);
		if(PlayerInfo[targetid][pDice] == 0) check[15] = 0; dice = ""; else format(dice, sizeof(dice), "a dice, ");
		if(PlayerInfo[targetid][pDeck] == 0) check[16] = 0; cards = ""; else format(cards, sizeof(cards), "a deck of cards, ");

        for(new i = 0; i < sizeof(check); i++)
        {
			if(check[i] == 0)
			{
				count++;
			}
        }
        
        if(count >= 17) return SendClientMessage(playerid, 0xFFFFFFFF, "* Your inventory is empty");

		format(string, sizeof(string), ""COL_GREEN"Mats & Drugs - "COL_WHITE"%s%s%s%s%s%s%s%s%s%s\n",crack,pot,adrenaline,a,b,c,d,products,dice,cards);
		strcat(string2,string);
		format(string, sizeof(string), ""COL_GREEN"Odds & Ends - "COL_WHITE"%s%s%s%s%s%s%s\n",blindfold,seeds,briefcase,screwdriver,fish,lottonumber,phonebook);
		strcat(string2,string);
        format(string, sizeof string, ""COL_WHITE"Your Inventory:");
		ShowPlayerDialog(playerid,DIALOG_INVENTORY,DIALOG_STYLE_MSGBOX, string, string2,"Done","Print");
	}
}
You have copied the whole code from a gamemode, don't be so over smart.

Quote:

This forum requires that you wait 120 seconds between posts. Please try again in 43 seconds.

Dayum... SA-MP forum's anti spam.
Reply


Messages In This Thread
How to make this shorter? - by MayaEU - 19.07.2016, 18:03
Re: How to make this shorter? - by d1git - 19.07.2016, 18:16
Re: How to make this shorter? - by MayaEU - 19.07.2016, 18:20
Re: How to make this shorter? - by Logic_ - 19.07.2016, 18:21
Re: How to make this shorter? - by d1git - 19.07.2016, 18:24
Re: How to make this shorter? - by Logic_ - 19.07.2016, 18:28
Re: How to make this shorter? - by K0P - 19.07.2016, 18:37
Re: How to make this shorter? - by Logic_ - 19.07.2016, 18:42
Re: How to make this shorter? - by K0P - 19.07.2016, 18:46
Re: How to make this shorter? - by d1git - 19.07.2016, 20:09

Forum Jump:


Users browsing this thread: 1 Guest(s)