Raised This Month: $ Target: $400
 0% 

Getting the highest value from nVault


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
stanciu
Junior Member
Join Date: Mar 2016
Location: Romania
Old 04-05-2016 , 10:11   Getting the highest value from nVault
Reply With Quote #1

Hello,

I've this nVault that stores every player's stats. Let's say a player stats adds up (+1) every time he gets a kill with a knife.

So, every damn time player X gets a kill with the knife, it adds up to his stat. If he'd kill 5 players with the knife, his stat is now at 5. So every player gets this kind of stat saved every time he disconnects.

How can I query the highest amount from that nVault? To understand better: player X has 50 kills with the knife, Y has 25, and Z has 10. I want to create a command that says,

"Highest kills with the knife: 50 by player X". How can I retrieve the highest value from that vault?

I hope you guys understand, if not, please leave your concern.

Thanks in advance.

Last edited by stanciu; 04-05-2016 at 10:11.
stanciu is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-05-2016 , 10:16   Re: Getting the highest value from nVault
Reply With Quote #2

How are you saving data in nvault?
__________________

Last edited by HamletEagle; 04-05-2016 at 10:16.
HamletEagle is offline
stanciu
Junior Member
Join Date: Mar 2016
Location: Romania
Old 04-05-2016 , 10:22   Re: Getting the highest value from nVault
Reply With Quote #3

Let's say I'd have it saved it like this:

PHP Code:
formatexKNIFEkillscharsmaxKNIFEkills ), "%s's kills with the knife: %d"NAMEg_KNIFEkills )

nvault_set myVaultKNIFEkills 
Not sure if you understood anything, but I used Bugsy's tutorial and example.
stanciu is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 04-06-2016 , 06:40   Re: Getting the highest value from nVault
Reply With Quote #4

The only way I can think of is to loop trough all entries and sort them. If you want to do that, search for "loop nvault". I think Bugsy posted a snippet.

The more efficient and generally suggested (at least when you want to retrieve more complex results) method would be switching to SQL.
__________________
Quote:
#define true ((rand() % 2)? true: false) //Happy debugging suckers
mottzi is offline
Send a message via MSN to mottzi
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 04-06-2016 , 08:39   Re: Getting the highest value from nVault
Reply With Quote #5

get numbers with looping nvault key of kills and save IT to a variabile.

new max = 0;
//your loop (dont know nvault natives)
//inside loop
If(max < curent_nvault_data){
max = curent_nvault_data
//also save player name/steamid to an array
}
siriusmd99 is offline
Reply



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 22:20.


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