Raised This Month: $32 Target: $400
 8% 

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
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 #3

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 #4

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
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 #5

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 #6

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
aexi0n
AlliedModders Donor
Join Date: Nov 2014
Location: bhop_deluxe
Old 12-27-2015 , 20:48   Re: Pro's vs. Con's of storing player data in variables?
Reply With Quote #7

Welp. Guessing that means I need to start converting all my plugins to use the new syntax? (Yes, I'm so lazy that I've been using the old one up until now.) Or is there any sort of StringMap in the old syntax?
aexi0n is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 12-27-2015 , 20:50   Re: Pro's vs. Con's of storing player data in variables?
Reply With Quote #8

Quote:
Originally Posted by aexi0n View Post
Welp. Guessing that means I need to start converting all my plugins to use the new syntax? (Yes, I'm so lazy that I've been using the old one up until now.) Or is there any sort of StringMap in the old syntax?
StringMap = ADTTrie
WildCard65 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 #9

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 #10

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
Reply


Thread Tools
Display Modes

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 00:47.


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