Raised This Month: $51 Target: $400
 12% 

Pro's vs. Con's of storing player data in variables?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
aexi0n
AlliedModders Donor
Join Date: Nov 2014
Location: bhop_deluxe
Old 12-27-2015 , 19:25   Pro's vs. Con's of storing player data in variables?
Reply With Quote #1

So recently I made the change to switch from clearing all variables on disconnect, and reloading data on connect, thus refreshing all player data every map change. This was great in terms of never mixing up/losing data, but the queries held up the server constantly. So now I've made it so player data is only loaded on their first connect, and not cleared unless they disconnect, (not from map change).

However after making this dhange I was wondering if there were some possible ways that the data could get mixed around or lost? I've had a few players since the change explain their level was switched to someone else's data. I've reviewed the code where levels are saved, and it checks the steamid right before the update query, so I don't believe it could be an error in there. I'm thinking it might be switched with another client on mapchange somehow. Is this possible?
aexi0n is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 12-27-2015 , 19:26   Re: Pro's vs. Con's of storing player data in variables?
Reply With Quote #2

Client indexes can change on map change - which is why you see them reconnect from a plugin point-of-view.
__________________
asherkin is offline
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 12-27-2015 , 23:44   Re: Pro's vs. Con's of storing player data in variables?
Reply With Quote #3

Quote:
Originally Posted by asherkin View Post
Client indexes can change on map change - which is why you see them reconnect from a plugin point-of-view.
Correct me if I'm wrong, but as far as I know they only change if the server forces the client to reconnect (you can see a special output in the console in that case)?
__________________
Santa or Satan?

Watch out when you're paying people for private requests! Most stuff already exists and you can hardly assess the quality of what you'll get, and if it's worth the money.
Dr. Greg House is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 12-28-2015 , 10:41   Re: Pro's vs. Con's of storing player data in variables?
Reply With Quote #4

Quote:
Originally Posted by Dr. Greg House View Post
Correct me if I'm wrong, but as far as I know they only change if the server forces the client to reconnect (you can see a special output in the console in that case)?
It's been a while, but I think some of my past tests agree with this.

I don't remember if I checked this with bots and the "bots join after players" setting disabled, though.

Still, if the server forces a client to reconnect it probably fires the player_disconnect event for that player as well as assigns them a new userid.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
aexi0n
AlliedModders Donor
Join Date: Nov 2014
Location: bhop_deluxe
Old 12-27-2015 , 20:03   Re: Pro's vs. Con's of storing player data in variables?
Reply With Quote #5

Alright well that was my concern, however, if this is true why does the wiki say that they do not?

https://wiki.alliedmods.net/Introduc...Entity_Indexes
aexi0n is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 12-27-2015 , 20:11   Re: Pro's vs. Con's of storing player data in variables?
Reply With Quote #6

Quote:
Originally Posted by aexi0n View Post
Alright well that was my concern, however, if this is true why does the wiki say that they do not?

https://wiki.alliedmods.net/Introduc...Entity_Indexes
It doesn't any more. That entire section was very wrong.
__________________
asherkin is offline
Disowned
Member
Join Date: Oct 2015
Old 12-29-2015 , 16:51   Re: Pro's vs. Con's of storing player data in variables?
Reply With Quote #7

Quote:
Originally Posted by asherkin View Post
It doesn't any more. That entire section was very wrong.
Any possibility we could get accurate information on this then? I thought that a userid will stay consistent across maps, as you will find servers well into the hundreds of userid numbers. Or is this only accurate per map?
Disowned is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 12-29-2015 , 17:02   Re: Pro's vs. Con's of storing player data in variables?
Reply With Quote #8

Quote:
Originally Posted by Disowned View Post
Any possibility we could get accurate information on this then? I thought that a userid will stay consistent across maps, as you will find servers well into the hundreds of userid numbers. Or is this only accurate per map?
userids don't change until a client disconnects.

userids can repeat if your server is up long enough without rebooting. This is because they are stored as a 16-bit number, meaning they go from 0 (never used) to 65535... and then repeat.

I do vaguely remember hearing that they only went up to 32767 rather than 65535, but I've never tested that to check.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
aexi0n
AlliedModders Donor
Join Date: Nov 2014
Location: bhop_deluxe
Old 12-27-2015 , 20:31   Re: Pro's vs. Con's of storing player data in variables?
Reply With Quote #9

Alright, well that's good to know then. Out of curiosity, did you have any suggestions on what I would use instead of the client index that doesn't have a chance of getting changed on mapchange?
aexi0n is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 12-27-2015 , 20:36   Re: Pro's vs. Con's of storing player data in variables?
Reply With Quote #10

Userid, but you can't sanely use it as an array index since SourcePawn doesn't have sparse arrays.
You'll need to move over to using a StringMap.
__________________
asherkin 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 03:00.


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