Hello I am trying to get the category names to display horizontally instead of vertically so instead of this:
Cat 1
Cat 2
Cat 3
Cat 4
Cat 5
etc.
To get them to display like this cat1, cat2, cat3, cat4, cat,5 etc,
I was told to change this code
So I would be replacing this line of codeCode:[ChatCommand("shop")] private void ChatCmd_Shop(PlayerSession player, string command, string[] args) { double tmpPer; double.TryParse(Config["sellpercentage"].ToString(), out tmpPer); saleModifier = (1d - ((double)tmpPer / 100d)); switch (args.Length == 0) { case true: var DistinctCats = StoreStock.Select(x => x.category).Distinct(); //TEST var catsCount = (DistinctCats.ToArray().Length > 0 && DistinctCats.ToArray().Length <= 7) ? 9 - DistinctCats.ToArray().Length : 0; int i = 0; while (i < catsCount) { hurt.SendChatMessage(player, ""); i++; } //TEST hurt.SendChatMessage(player, GetMsg("header_catlisiting", player.SteamId) .Replace("{Color:Header}", "<color=#00ffffff>") .Replace("{/Color:Header}", "</color>") .Replace("{Color:Good}", "<color=#00ff00ff>") .Replace("{/Color:Good}", "</color>")); foreach (var cats in DistinctCats) { if (cats != null) hurt.SendChatMessage(player, cats); } //inline cats = hurt.SendChatMessage(player, string.Join(", ", DistinctCats)); break;
With thisCode:foreach (var cats in DistinctCats) { if (cats != null) hurt.SendChatMessage(player, cats); }
But each time I try it breaks the plugin and /shop command cannot be used. Could anyone help me out?Code:hurt.SendChatMessage(player, string.Join(", ", DistinctCats));
Help with modifications to HurtStore.cs
Discussion in 'Hurtworld Development' started by Enclave, Feb 12, 2016.
-
Well, I don't know C# at all, but if Join doesn't work
Code:string CatsStr = ''; string p = ''; foreach(var cats in DistinctCats) { if(cats != null) { CatsStr += p+cats; p = ', '; } } hurt.SendChatMessage(player, CatsStr);break;
And if your plugin is throwing error then you should check logs. -
I'll try it out thanks!
[DOUBLEPOST=1455342938][/DOUBLEPOST]Just tried it but still not displaying the categories horizontally after using /reload HurtStore
[DOUBLEPOST=1455353033,1455342610][/DOUBLEPOST]This ended up breaking the entire plugin -
You were close
All you need to do is add each one to a string, then send a message with that string.
Change this:
Code:foreach (var cats in DistinctCats) { if (cats != null) hurt.SendChatMessage(player, cats); } //inline cats = hurt.SendChatMessage(player, string.Join(", ", DistinctCats));
Code:string catstring = ""; foreach (var cats in DistinctCats) { if (cats != null) catstring += cats+", "; } hurt.SendChatMessage(player, catstring);
-
-
mark as solved please