![]() |
Sorting through multiple arrays
I've got it sorted through like recommended above for the most part, but am now having issues sorting when showing "all" messages with timevar2. timevar2 is the [2] value in each client array for each message.
My logic is probably flawed on here, and/or I'm missing something really easy. PHP Code:
PHP Code:
It does show some things, and switching back and forth from a category to all makes things pop to the top instead of bottom, but it doesn't show "all" things like it's supposed to and I'm just plain stuck on it. Everything else works fine though... P.S. I moved this because it really should have been in it's own thread. It didn't have much to do with where it was... |
I just skimmed the code, but it sounds like you just want to have different types of messages? Why not just store them all in the same array?
PHP Code:
(I'm still not really sure why you're not just sending triggers and insist on using arrays) |
I am sending triggers. I keep them stored client array because I'm just improving on what was already there, but if I just trigger the message straight through there is no record, and my system shows a record of past messages for the player.
I also have buttons that show a certain category (e.g. masses, or guild messages), which is why I made it like it is as well. Even in the thing you posted above, I'd still have to separately show mass, tell, guild, and system messages, and then show them all at once. Granted sorting them all in one array might be easier to separate than add together, but also I'm figuring the large amount those variables could turn into on some categories, and prefer them separated. I have them all sorted out and show, I just can't seem to loop through and pull them together. |
Quote:
Quote:
I'm not sure what you mean by the "large amount those variables could turn into". There's really no need for an array anywhere here as far as I can tell except possibly in the implementation of the messages display clientside. |
It's just a chatbox like any other MMORPG out there. So I have categories for All, /Tells, /mass, /guild, and system messages.
I'm not trying to be a jerk or unwilling to do it differently. Does storing it in the weapon flag, db npc, or client var change anything? The array is because it adds to all players for things like a mass or players in a guild or a tell to a player, so the array holds all the info like the sender, message, and timevar. Doing those separate would be much more cumbersome I would guess. Again, it could be stored in a txt file, db npc, or as I do it now a client array, but I don't see how it really changes where it is stored because each message contains more than just one value so it would have to be an array at least per my logic, and the location of that array doesn't seem to change too much. Do you see any reason in my code why it would only show up some of them, and then not in timevar order when leaving the category and going back to it? Also I updated the code in first post with comments so it shows what I'm at least trying to do... I'm not great on terminology but I'm pretty sure all I need is a bubble sort, along with a swap holding so it sorts correctly, I just can't seem to wrap my head around it. |
PHP Code:
That little guy : sortbyvalue, solved it. I added all client arrays into a temp, then set to sort by the timevar held in multidem array id 2 of each, then sortbyvalue. Maybe it's not how other people would have done it, but it's not a bad way and it works, and now messages can be separated for my anal organization instead of all in one value holder. |
| All times are GMT +2. The time now is 08:50 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.