Raised This Month: $ Target: $400
 0% 

Look up a players stats by their AuthID


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-08-2007 , 09:06   Look up a players stats by their AuthID
Reply With Quote #1

I am currently writing a plugin that tracks a users playtime on the server. Based on their playtime, I want to offer adminship to the top 3, granted they have adequate kills\deaths to show they are not sitting in spectator all the time. I am saving the data to vault in this format:

"ENTRIES" "3" //This keeps track of how many there are, incremented each time a new one is added

//When I add a new entry, the entry number is the key for that entry.
//For example:
//key value
"1" "STEAM_0:0:1111111 TIME"
"2" "STEAM_0:0:2222222 TIME"
"3" "STEAM_0:0333333 TIME"

That part is pretty much done and working but now I want to read a particular player's stats. Is it possible to lookup by STEAMID instead of by index?

Thanks in advance
__________________
Bugsy is offline
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 10-08-2007 , 09:16   Re: Look up a players stats by their AuthID
Reply With Quote #2

No.

Use SQL or a better vault format.

The way I would do it:

Quote:
Originally Posted by vault
"ENTRIES" "3"
"ENTRY1" "STEAM_0:0:1111111"
"ENTRY2" "STEAM_0:0:2222222"
"ENTRY3" "STEAM_0:0333333"
"1" "TIME1"
"2" "TIME2"
"3" "TIME3"
So you get their index from authid, and then time from index.

EDIT: Or, of course, just straight from authid to time ...

Last edited by purple_pixie; 10-08-2007 at 09:19.
purple_pixie is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-08-2007 , 09:24   Re: Look up a players stats by their AuthID
Reply With Quote #3

Quote:
Originally Posted by purple_pixie View Post
No.

Use SQL or a better vault format.
Do you mean use a different stats method that uses SQL? Like Psychostats3

As it is, I have no problem extracting the authid and time from the vault entry and putting them into separate strings (authid, time). It's just reading the players stats that I am having a problem with since get_stats uses an index and not a steamID for retrieval.

Edit: I am basically looping through the vault entries and extracting the steamID and time into separate strings. That part is done. I then want to take the steamID and get the users stats and name so I can use that data for the remainder of the plugin.
__________________

Last edited by Bugsy; 10-08-2007 at 09:29.
Bugsy is offline
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 10-08-2007 , 09:31   Re: Look up a players stats by their AuthID
Reply With Quote #4

Exactly ... so you need a way to get the index from their auth-id.


So when you create a new (player) entry in the vault, do this:

add 1 to the "entries" entry.

Create a new entry with the steam id value as its key. Its value should be the new value of "entries".

Create a new entry with this index as its key, and the time as the value.
purple_pixie is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-08-2007 , 09:37   Re: Look up a players stats by their AuthID
Reply With Quote #5

Quote:
Originally Posted by purple_pixie View Post
Exactly ... so you need a way to get the index from their auth-id.


So when you create a new (player) entry in the vault, do this:

add 1 to the "entries" entry.

Create a new entry with the steam id value as its key. Its value should be the new value of "entries".

Create a new entry with this index as its key, and the time as the value.
Sorry but I don't understand how to get the players stats index from their authid. When they connect, do they have a "static" stats index that I can retrieve and record?

Note: My stats file is not being started at the same time as this plugin so there will already be a few thousand entries when I first start this plugin. Would I have to clear stats and start from scratch to do it the way that you are explaining?

Thanks again for the help
__________________
Bugsy is offline
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 10-08-2007 , 09:42   Re: Look up a players stats by their AuthID
Reply With Quote #6

You would have to start over, sadly.

I could write you a .exe to fix it for you, if you like ...

What you want is to make it save as in the quote I posted.

So when you add a new player to the vault, it makes 2 new entries - one is a pointer from Steam ID to Index, and one is from Index to Time.
purple_pixie is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-08-2007 , 09:44   Re: Look up a players stats by their AuthID
Reply With Quote #7

Quote:
Originally Posted by purple_pixie View Post
You would have to start over, sadly.

I could write you a .exe to fix it for you, if you like ...

What you want is to make it save as in the quote I posted.

So when you add a new player to the vault, it makes 2 new entries - one is a pointer from Steam ID to Index, and one is from Index to Time.
Ok, so basically stats are saved in a similar fashion as my plugin? When a new player comes to the server their stats index is total-stats-entries + 1?

Edit:
Just to clarify, I would add entries like this?

"ENTRIES" entries count+1
"STEAM1111" entriesvalue
entriesvalue time

"ENTRIES" entries count+1
"STEAM2222" entriesvalue
entriesvalue time

"ENTRIES" entries count+1
"STEAM3333" entriesvalue
entriesvalue time

Edit2: Now that I'm thinking, there was reasoning behind why I used an index as the key. This way I can cycle through all of the entries without knowing an authid or name. I am currently doing a for loop starting at 1 (first entry) and stopping at ENTRIES value. How would I go about checking all entries with this method?

Here's some samples:
"1" "STEAM_0:0434343 4167"
"2" "STEAM_0:1:43434343 6"
"3" "STEAM_0:1:6767676 158"

Edit3: Ignore edit2, I get it now...I think.

Start at entry1 value and read stats data at entry1 index (which gets me name, authid, etc)
Then take the authid and get that players time index from vault
Take that time index and read the players time value from vault
__________________

Last edited by Bugsy; 10-08-2007 at 10:03.
Bugsy is offline
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 10-08-2007 , 09:55   Re: Look up a players stats by their AuthID
Reply With Quote #8

Yeah, that's looking right.
purple_pixie is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 10-08-2007 , 10:03   Re: Look up a players stats by their AuthID
Reply With Quote #9

You can take a look here :S http://forums.alliedmods.net/showthread.php?p=457071
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-08-2007 , 10:06   Re: Look up a players stats by their AuthID
Reply With Quote #10

Quote:
Originally Posted by Alka View Post
I looked the other day but I think it only shows players currently playing (with top15 command).
__________________
Bugsy 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 16:04.


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