Raised This Month: $47 Target: $400
 11% 

Building a Top10 List


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DabuDos
Junior Member
Join Date: Feb 2015
Location: Germany
Old 10-06-2015 , 16:21   Building a Top10 List
Reply With Quote #1

Hi all,
I'm currently trying stuff out with KVs and such (only single-server ranking). I couldn't find a proper working Snippet for SQLite or such, so I used KV.

And now I come to the point where I have no clue: How do I make a Top list (Top10)?

I tried it with going through every Entry getting the points and look if the points are higher or not but then I would only get the current leader.

Anyone an idea how I could this?
DabuDos is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 10-06-2015 , 16:44   Re: Building a Top10 List
Reply With Quote #2

Could probably use more info here.

Few ideas off the small amount of info:

Code:
SELECT * FROM table ORDER BY column ASCENDING LIMIT 0,10;
...or make a menu with 10 menu items?

...or use strcat/format and add to a string and print?

...or make a site and just have an MOTD open?
__________________
Discord: Drixevel#9016 - Steam Profile - Github (Taking paid work currently, add me on Discord)
Drixevel is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 10-06-2015 , 18:45   Re: Building a Top10 List
Reply With Quote #3

Avoid KV for your purpose.

1. It's slow with large datasets
2. It's not threaded and your server will hang during iteration
3. As above you don't get power of sql's order by instruction
__________________
Neuro Toxin is offline
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 10-07-2015 , 00:37   Re: Building a Top10 List
Reply With Quote #4

as mentioned, SQL is the way to go. Use the query mentioned above, or one similar. If you MUST use KV, you could push it all to an array and use the appropriate SM array sorting functions. There are different functions depending on if it is an ADT array or not, and if you want ascending, descending, or you can make your own custom sort. But again, you really should be using SQL for that.

You mentioned there not being SQLite examples...I've seen them all over in here. Alternately, look at another plugin that uses sqlite, and just base your code off that. If you still dont get it, one of us can whip you up an example, but use the search key, cuz how to use sqlite has been asked several times before.
__________________
ThatOneGuy is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 10-07-2015 , 13:18   Re: Building a Top10 List
Reply With Quote #5

Keyvalue is total shit, avoid it like cancer if you can. (Neuro Toxin stole my reasons.)

One acceptable case of keyvalues are for config files for plugins, and that's all I can think of.

You ideally want to haul as much of the work to SQL as possible since that is ran on a separate worker thread; that way the main game thread can do less work.

Last edited by Potato Uno; 10-07-2015 at 13:18.
Potato Uno is offline
DabuDos
Junior Member
Join Date: Feb 2015
Location: Germany
Old 10-07-2015 , 14:18   Re: Building a Top10 List
Reply With Quote #6

Thanks for all the reasons why KVs are shit, that's ok how it is.
I'm gonna try to use the Array sorting function for that.
SQLite comes later.
DabuDos is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 10-07-2015 , 14:22   Re: Building a Top10 List
Reply With Quote #7

KeyValues are not shit... They are just not meant to be used that way...
KissLick is offline
SoulSharD
Member
Join Date: Oct 2013
Location: United Kingdom
Old 10-07-2015 , 14:45   Re: Building a Top10 List
Reply With Quote #8

Use KeyValues for storing key values.
__________________

SoulSharD is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 10-07-2015 , 16:23   Re: Building a Top10 List
Reply With Quote #9

If keyvalues are not shit, then other than config files, I would like someone to give TWO cases where keyvalues > SQL.

I avoid keyvalues like cancer if I can help it, especially since I managed to always find a satisfactory alternative to keyvalues with sqlite.

The API is also somewhat painful to use compared to sqlite.

Last edited by Potato Uno; 10-07-2015 at 16:25.
Potato Uno is offline
DabuDos
Junior Member
Join Date: Feb 2015
Location: Germany
Old 10-07-2015 , 16:55   Re: Building a Top10 List
Reply With Quote #10

Quote:
Originally Posted by Potato Uno View Post
If keyvalues are not shit, then other than config files, I would like someone to give TWO cases where keyvalues > SQL.

I avoid keyvalues like cancer if I can help it, especially since I managed to always find a satisfactory alternative to keyvalues with sqlite.

The API is also somewhat painful to use compared to sqlite.
My problem is I never used SQLite or SQL before in general and KVs are simple to read and store.
And (at the moment) KVs are easier to understand for me. Gonna search for good SQLite snippets/Tutorials/Plugins to learn from, maybe I can understand it better then, since someone said that the tutorial in the wiki wouldn't work properly.
DabuDos is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:18.


Powered by vBulletin®
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Theme made by Freecode