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

Solved Client index vs user id vs real player index


Post New Thread Reply   
 
Thread Tools Display Modes
CliptonHeist
Senior Member
Join Date: Feb 2016
Old 03-22-2019 , 05:40   Re: Client index vs user id vs real player index
Reply With Quote #11

Why use auto-incremented value when you have a completely unique identifier to use already? Not only does using steamids for primary keys make sure that there is never a duplicated player row inserted into the db but it makes updating records simple since you never have to worry about a client index being invalid.
CliptonHeist is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 03-22-2019 , 14:09   Re: Client index vs user id vs real player index
Reply With Quote #12

Ok, I understand you now.
Look like you have no problems in that case. I hope you store the last ID used for autoincrementation in the separate table, so it will not be duplicated, as CliptonHeist said.

As about UserId - it's just a reference. Using it (with GetClientOfUserId()), you can ensure it is point to valid ClientId (the reference was initially created from). If you would pass ClientId instead (in timer callback) you are risking that while the timer was ticking, that ClientId is disconnected and new player took the same place (same ClientId), so when the timer triggers, it will affect the wrong player.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
McSnaggit
Junior Member
Join Date: Feb 2019
Old 03-24-2019 , 11:54   Re: Client index vs user id vs real player index
Reply With Quote #13

@CliptonHeist I use an AI value because I don't think foreign keys kan be characters, like the steamID2. I do use the steamId to verify if the user exists but I use the id of the table as a foreign key. So I won't ever have duplicate entries.

Thanks all!

PS: How can I solve this post?
McSnaggit is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 03-24-2019 , 11:58   Re: Client index vs user id vs real player index
Reply With Quote #14

Press "edit" button on the first post, go to "Advanced mode" => change value in combobox => save.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
CliptonHeist
Senior Member
Join Date: Feb 2016
Old 03-24-2019 , 14:03   Re: Client index vs user id vs real player index
Reply With Quote #15

Quote:
Originally Posted by McSnaggit View Post
@CliptonHeist I use an AI value because I don't think foreign keys kan be characters, like the steamID2. I do use the steamId to verify if the user exists but I use the id of the table as a foreign key. So I won't ever have duplicate entries.

Thanks all!

PS: How can I solve this post?
Yes they absolutely can, any datatype in mysql can be used as a primary/foreign key lol. I would highly suggest reorganizing your database structure to use them to avoid headaches down the road.
CliptonHeist 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 12:36.


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