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

some code question again?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lingzhidiyu
Senior Member
Join Date: Mar 2014
Old 02-04-2015 , 13:34   some code question again?
Reply With Quote #1

1. Should i use GetClientUserId or GetClientSerial in code?
Or just using client index?

2. When i need check (0 < client <= MaxClients)?

3. Where should i put the check?

PHP Code:
public OnClientPutInServer(client) {
    if (!
IsClientInGame(client)) {
        return;
//here?
    
}
    Print(
client)
}

Print(
client) {
    if (!
IsClientInGame(client)) {
        return;
//or here?
    
}
    
PrintToChat(client"hello");

lingzhidiyu is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 02-04-2015 , 14:24   Re: some code question again?
Reply With Quote #2

Depends on your use requirements.

For map changes, doesn't the UserID change? What about ClientSerial?

Write a quick plugin to log the UserID and ClientSerial and see if both change during map changes.

If ClientSerial doesn't change and you need to track a specific person across maps, you could use that (or just SteamID), but it depends on your specific use requirements.
__________________
View my Plugins | Donate
TnTSCS is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 02-04-2015 , 16:11   Re: some code question again?
Reply With Quote #3

Quote:
Originally Posted by TnTSCS View Post
Depends on your use requirements.

For map changes, doesn't the UserID change? What about ClientSerial?

Write a quick plugin to log the UserID and ClientSerial and see if both change during map changes.

If ClientSerial doesn't change and you need to track a specific person across maps, you could use that (or just SteamID), but it depends on your specific use requirements.
Quote:
Originally Posted by Chdata View Post
Note: The UserID definitely changes between maps.
Did you actually test this?

I have and my testing says you're wrong... user IDs do not change on map changes.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 02-04-2015 , 16:30   Re: some code question again?
Reply With Quote #4

Quote:
Originally Posted by Chdata View Post
Note: The UserID definitely changes between maps.
Note: BS.
__________________
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
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 02-04-2015 , 17:00   Re: some code question again?
Reply With Quote #5

Did you update this Wiki:
https://wiki.alliedmods.net/Introduc...Entity_Indexes

-----------
Although SourceMod fires the OnClientConnected and OnClientDisconnected callbacks every map change, the server tracks players across map changes and does not change their userids or client indexes. To see if a client really connected or disconnected, hook the player_connect and player_disconnect events instead
__________________
View my Plugins | Donate

Last edited by TnTSCS; 02-04-2015 at 17:00.
TnTSCS is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 02-04-2015 , 17:36   Re: some code question again?
Reply With Quote #6

Oh yeah I guess I only tested retry before.

Code:
] status
# userid name
#     44 "Chdata ♠"

] sm_remap

] status
# userid name
#     44 "Chdata ♠"

] retry

] status
# userid name
#     84 "Chdata ♠"
__________________

Last edited by Chdata; 02-04-2015 at 17:52.
Chdata is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 02-04-2015 , 19:46   Re: some code question again?
Reply With Quote #7

Quote:
Originally Posted by TnTSCS View Post
Did you update this Wiki:
https://wiki.alliedmods.net/Introduc...Entity_Indexes

-----------
Although SourceMod fires the OnClientConnected and OnClientDisconnected callbacks every map change, the server tracks players across map changes and does not change their userids or client indexes. To see if a client really connected or disconnected, hook the player_connect and player_disconnect events instead
Yes, I updated that wiki last year between my last two posts in the thread I linked.
__________________
Not currently working on SourceMod plugin development.
Powerlord 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 20:08.


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