AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Look up a players stats by their AuthID (https://forums.alliedmods.net/showthread.php?t=61741)

Bugsy 10-08-2007 09:06

Look up a players stats by their AuthID
 
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:0:3333333 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

purple_pixie 10-08-2007 09:16

Re: Look up a players stats by their AuthID
 
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:0:3333333"
"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 ...

Bugsy 10-08-2007 09:24

Re: Look up a players stats by their AuthID
 
Quote:

Originally Posted by purple_pixie (Post 539988)
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.

purple_pixie 10-08-2007 09:31

Re: Look up a players stats by their AuthID
 
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.

Bugsy 10-08-2007 09:37

Re: Look up a players stats by their AuthID
 
Quote:

Originally Posted by purple_pixie (Post 539994)
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

purple_pixie 10-08-2007 09:42

Re: Look up a players stats by their AuthID
 
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.

Bugsy 10-08-2007 09:44

Re: Look up a players stats by their AuthID
 
Quote:

Originally Posted by purple_pixie (Post 539998)
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:0:3434343 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

purple_pixie 10-08-2007 09:55

Re: Look up a players stats by their AuthID
 
Yeah, that's looking right.

Alka 10-08-2007 10:03

Re: Look up a players stats by their AuthID
 
You can take a look here :S http://forums.alliedmods.net/showthread.php?p=457071

Bugsy 10-08-2007 10:06

Re: Look up a players stats by their AuthID
 
Quote:

Originally Posted by Alka (Post 540011)

I looked the other day but I think it only shows players currently playing (with top15 command).


All times are GMT -4. The time now is 16:04.

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