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 |
Re: Look up a players stats by their AuthID
No.
Use SQL or a better vault format. The way I would do it: Quote:
EDIT: Or, of course, just straight from authid to time ... |
Re: Look up a players stats by their AuthID
Quote:
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. |
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. |
Re: Look up a players stats by their AuthID
Quote:
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 |
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. |
Re: Look up a players stats by their AuthID
Quote:
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 |
Re: Look up a players stats by their AuthID
Yeah, that's looking right.
|
Re: Look up a players stats by their AuthID
You can take a look here :S http://forums.alliedmods.net/showthread.php?p=457071
|
Re: Look up a players stats by their AuthID
Quote:
|
| All times are GMT -4. The time now is 16:04. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.