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

[Solved][Q] Unique Client ID


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Arrow768
Veteran Member
Join Date: Nov 2011
Location: Austria
Old 05-19-2013 , 06:12   [Solved][Q] Unique Client ID
Reply With Quote #1

Hi Guys,
atm I am working on a Betting Plugin for the Store Plugin by alongub.

The user should be able to place a bet on what team is going to win.

I have though of the following way to do it:

Create a global array (indexed with the client id), where the team (they have placed the bet on) and the amount of their bet is stored.

If the client disconnects before the round is over, and another client connects, is it possible that the connected client gets the same client ID as the previous client ?

Is there a better way to have a unique index per client ?
__________________

Last edited by Arrow768; 05-19-2013 at 20:54.
Arrow768 is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 05-19-2013 , 06:42   Re: [Q] Unique Client ID
Reply With Quote #2

Quote:
Originally Posted by Arrow768 View Post

If the client disconnects before the round is over, and another client connects, is it possible that the connected client gets the same client ID as the previous client ?

Is there a better way to have a unique index per client ?
Yes, there's a good chance the next person who connects will take up that ClientID. Instead, use their UserID which for all intents and purposes should be unique for that server instance until it wraps around at 65535.
__________________
11530 is offline
RedSword
SourceMod Plugin Approver
Join Date: Mar 2006
Location: Quebec, Canada
Old 05-19-2013 , 19:32   Re: [Q] Unique Client ID
Reply With Quote #3

If you want to make it so if a client disconnect and reconnect i.e. 5 minutes later while keeping the same id; you can do an array of last connected (i.e. 100 last connected); or use cookies.
__________________
My plugins :
Red Maze
Afk Bomb
RAWR (per player/rounds Awp Restrict.)
Kill Assist
Be Medic

You can also Donate if you appreciate my work
RedSword is offline
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 05-19-2013 , 19:40   Re: [Q] Unique Client ID
Reply With Quote #4

Cookies?
What are steamids for?

If you want the credits to be stored after the player leaves anyway you will need a database to store the credit in. Therefore use the steamid for identification. For the on-going bets use a table as well to store them.
Problem solved?

Last edited by Dr. Greg House; 05-19-2013 at 19:42.
Dr. Greg House is offline
Arrow768
Veteran Member
Join Date: Nov 2011
Location: Austria
Old 05-19-2013 , 20:53   Re: [Q] Unique Client ID
Reply With Quote #5

The SQL Table is a good idea, I think I am going to do it that way.
__________________
Arrow768 is offline
rhelgeby
Veteran Member
Join Date: Oct 2008
Location: 0x4E6F72776179
Old 05-21-2013 , 18:19   Re: [Solved][Q] Unique Client ID
Reply With Quote #6

It's fine to use client indexes if you do cleanup when a player disconnects. Just remove/reset stuff for that client. A good habit is to reset when a client is connected.
__________________
Richard Helgeby

Zombie:Reloaded | PawnUnit | Object Library
(Please don't send private messages for support, they will be ignored. Use the forum.)

Last edited by rhelgeby; 05-21-2013 at 18:20.
rhelgeby is offline
Send a message via MSN to rhelgeby
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 08:53.


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