Posts: 716
	Threads: 92
	Joined: May 2018
	
	
 
	
	
		Ok so, i made a simple 24/7 shop where players can buy anything they want.
Currently shop dialog is this:
pawn Code:
ShowPlayerDialog(playerid, DIALOG_SHOP, DIALOG_STYLE_LIST, "24/7 Shop", "Lighter - ("GREEN"$"#LIGHTER_COST") "WHITE"\nGps - ("GREEN"$"#GPS_COST") "WHITE"\nMarijuana Seeds - ("GREEN"$"#MARIJUANA_5_SEEDS_COST") "WHITE"\nCocaine Seeds - ("GREEN"$"#COCAINE_5_SEEDS_COST") "WHITE"\nHeroin Seeds - ("GREEN"$"#HEROIN_5_SEEDS_COST")\nPhone - ("GREEN"$"#PHONE_COST")\nTop Up Phone Credit\nFishing Rod - ("GREEN"$"#FISHING_ROD_COST") "WHITE"", "Buy", "Cancel");
 
As you can see, the dialog text is so damn long, my question now is...it's possible to store this items maybe in an enum and show them in the dialog? And how i should work with dialog response if i do in this way?
Thanks.
	
		
	
 
 
	
	
	
		
	Posts: 716
	Threads: 92
	Joined: May 2018
	
	
 
 
	
	
	
		
	Posts: 716
	Threads: 92
	Joined: May 2018
	
	
 
	
	
		I don't know if you two are trolling me, if no, please read again my first post.
My question was if it's possible to store in an enum this shop items and calling them with ShowPlayerDialog.
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 357
	Threads: 6
	Joined: Feb 2018
	
	
 
	
	
		He meant like this
pawn Code:
new gStr[900];
    strcat(gStr, "Lighter - ("GREEN"$"#LIGHTER_COST") "WHITE"\nGps - ("GREEN"$"#GPS_COST") "WHITE"\n");
    strcat(gStr, "Marijuana Seeds - ("GREEN"$"#MARIJUANA_5_SEEDS_COST") "WHITE"\n");
    strcat(gStr, "Cocaine Seeds - ("GREEN"$"#COCAINE_5_SEEDS_COST") "WHITE"\nHeroin Seeds - ("GREEN"$"#HEROIN_5_SEEDS_COST")\n");
    strcat(gStr, "Phone - ("GREEN"$"#PHONE_COST")\n");
    strcat(gStr, "Top Up Phone Credit\nFishing Rod - ("GREEN"$"#FISHING_ROD_COST") "WHITE"\n");
    ShowPlayerDialog(playerid, DIALOG_SHOP, DIALOG_STYLE_LIST, "24/7 Shop", gStr, "Buy", "Cancel");
 
	
		
	
 
 
	
	
	
		
	Posts: 1,773
	Threads: 47
	Joined: Jan 2015
	
Reputation: 
0
	 
	
	
		Update ypur compiler to zeex's compiler.
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 716
	Threads: 92
	Joined: May 2018
	
	
 
	
	
		
Quote:
| 
					Originally Posted by TheToretto  Do you mean:  
pawn Code: #include <a_samp>
 enum ENUM_SHOP
 {
 ITEM_NAME[28],
 ITEM_PRICE
 };
 
 static const ShopItems[][ENUM_SHOP] =    {
 {"Marijuana Seeds",                    {5000}},
 {"GPS",            {4000}},
 {"Condom",                   {3000}}
 };
 
 public OnFilterScriptInit()
 {
 printf("Item name: %s - Item price : $%d", ShopItems[1], ShopItems[1][ITEM_PRICE]);
 return 1;
 }
 | 
 Finally someone that understand! How do i work with OnDialogResponse?
	
 
	
	
	
		
	
 
 
	
	
	
		
	Posts: 716
	Threads: 92
	Joined: May 2018
	
	
 
	
	
		
Quote:
| 
					Originally Posted by TheToretto  //code | 
 Any way to show items in enum in ShowPlayerDialog without writing one per one?
	
 
	
	
	
		
	
 
 
	
	
	
		
	Posts: 15,941
	Threads: 0
	Joined: Jun 2008
	
	
 
	
	
		What's wrong with having a long string? You are just getting the server to do more work to replicate something you already have.
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 716
	Threads: 92
	Joined: May 2018
	
	
 
	
	
		
Quote:
| 
					Originally Posted by Y_Less  What's wrong with having a long string? You are just getting the server to do more work to replicate something you already have. | 
 Then i don't see the reason of using an enum if i have to rewrite everything in ShowPlayerDialog!
	
 
	
	
	
		
	
 
 
	
	
	
		
	Posts: 15,941
	Threads: 0
	Joined: Jun 2008
	
	
 
	
	
		Yes, that was my point.  I don't see the point in using an enum either.
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 543
	Threads: 4
	Joined: Jul 2015
	
Reputation: 
0
	 
	
	
		Using an enumerator for this kind of script is useful, for example to modify easily the names of articles, or their prices, or even replace/remove them without having to #define them every time, plus it's neater for anyone reading the script.
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 716
	Threads: 92
	Joined: May 2018
	
	
 
	
	
		@TheToretto it's possible to loop through that enum and add items with just one line at ShowPlayerDialog? I mean without writing ShopItems[0][ITEM_PRICE]/ShopItems[1][ITEM_PRICE] and so on for every item?
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 716
	Threads: 92
	Joined: May 2018
	
	
 
	
	
		Thank you very much, how i should edit the dialog response now that you added the loop?
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 716
	Threads: 92
	Joined: May 2018
	
	
 
	
	
		Finally, thank you very much.
This topic can be closed.