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

GetClientConnectionStatus


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
noxuu
Member
Join Date: Dec 2015
Old 03-22-2017 , 17:15   GetClientConnectionStatus
Reply With Quote #1

Hello, I try to get client connection status to check whether his connections are stable, but I don't have idea how to do this .. Anyone can help me, please ?
noxuu is offline
xines
Veteran Member
Join Date: Aug 2013
Location: Denmark
Old 03-22-2017 , 17:43   Re: GetClientConnectionStatus
Reply With Quote #2

https://sm.alliedmods.net/new-api/cl...ientAvgLatency
https://sm.alliedmods.net/new-api/cl...tClientLatency

To check for ongoing connections between players the above is probably what you are looking for?

If you meant to check successfully connected clients, then i would use this stock function below, in whatever check you need. stock returns true if client is valid.
PHP Code:
stock bool IsValidClient(int client)
{
    return (
<= client <= MaxClients && IsClientInGame(client));

__________________
xines is offline
psychonic

BAFFLED
Join Date: May 2008
Old 03-23-2017 , 09:31   Re: GetClientConnectionStatus
Reply With Quote #3

Quote:
Originally Posted by xines View Post
https://sm.alliedmods.net/new-api/cl...ientAvgLatency
https://sm.alliedmods.net/new-api/cl...tClientLatency

To check for ongoing connections between players the above is probably what you are looking for?

If you meant to check successfully connected clients, then i would use this stock function below, in whatever check you need. stock returns true if client is valid.
PHP Code:
stock bool IsValidClient(int client)
{
    return (
<= client <= MaxClients && IsClientInGame(client));

(I'm not trying to pick on you personally. This is a general pet peeve.)

You've perfectly demonstrated some of the many issues with these "IsValidClient" stocks that people keep pasting around.

Many are different and all leave the client of "valid for what purpose?". There is no global marker making a client "valid" which is why separate functions exist. In this case, that stock above would potentially be skipping some connected clients, since they would only need to pass IsClientConnected for those linked natives, and not necessarily be fully in-game.

There are other cases where people stick and an "IsValidClient" stock and maybe it skips bots for example, but bots are valid and desired for the purpose. Or only alive, or non-spectator players are wanted, but aren't filtered out.

At most, you could condense to just having an IsClientIndex to return the first checks and then do what you actually want from there.
psychonic is offline
xines
Veteran Member
Join Date: Aug 2013
Location: Denmark
Old 03-23-2017 , 10:24   Re: GetClientConnectionStatus
Reply With Quote #4

Quote:
Originally Posted by psychonic View Post
(I'm not trying to pick on you personally. This is a general pet peeve.)

You've perfectly demonstrated some of the many issues with these "IsValidClient" stocks that people keep pasting around.
Hello, Yes i agree that "customizing" the Isvalid stock is a thing for OP to decide the usage of.

Tho in this case i'm unsure of OP's problem, as it is not clear enough.

Op states in his question that the client must be a "stable" client, and do you think checking for only the index or IsClientConnected, is stable enough? Only way i could possible be thinking of "stable" is checking against higest ingame time, but that would have the negative effect of the same index being chosen almost everytime untill he leaves.
__________________
xines 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 13:35.


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