Raised This Month: $91 Target: $400
 22% 

Best way to get client ping?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SM9
AlliedModders Donor
Join Date: Sep 2013
Location: United Kingdom
Old 05-20-2015 , 08:07   Best way to get client ping?
Reply With Quote #1

Hello, I am wondering what the best way to get a clients ping is ie: As close as possible to pinging the server from cmd prompt.

Im currently using:

PHP Code:
stock int GetLatency(int iClient)
{
    
float fLatency GetClientLatency(iClientNetFlow_Both);
    return 
RoundToNearest(fLatency 500);

Thanks.
SM9 is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 05-20-2015 , 08:33   Re: Best way to get client ping?
Reply With Quote #2

PHP Code:
GetEntProp(GetPlayerResourceEntity(), Prop_Send"m_iPing"_client
Will get you what is displayed on the scoreboard.
__________________
asherkin is offline
Benoist3012
Veteran Member
Join Date: Mar 2014
Location: CWave::ForceFinish()
Old 05-27-2015 , 07:16   Re: Best way to get client ping?
Reply With Quote #3

This code work too for get the score?
__________________
Benoist3012 is offline
cam0
Senior Member
Join Date: Feb 2015
Old 05-27-2015 , 08:41   Re: Best way to get client ping?
Reply With Quote #4

Quote:
Originally Posted by asherkin View Post
PHP Code:
GetEntProp(GetPlayerResourceEntity(), Prop_Send"m_iPing"_client
Will get you what is displayed on the scoreboard.
What about what is displayed when you type 'ping' in console? (You can notice they can be very different, or even yours on the scoreboard compared to yours in net graph)

Quote:
Originally Posted by Benoist3012 View Post
This code work too for get the score?
I think you want GetClientFrags, or with the same code, instead of m_iPing:
m_iFrags -> frags
m_iDeaths -> deaths
m_iMPVs -> most valuable player count
m_iAssists -> assists

Also CS_SetClientContributionScore & CS_GetClientContributionScore for CS:GO.

Last edited by cam0; 05-27-2015 at 08:47.
cam0 is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 05-27-2015 , 18:47   Re: Best way to get client ping?
Reply With Quote #5

Quote:
Originally Posted by cam0 View Post
What about what is displayed when you type 'ping' in console? (You can notice they can be very different, or even yours on the scoreboard compared to yours in net graph)



I think you want GetClientFrags, or with the same code, instead of m_iPing:
m_iFrags -> frags
m_iDeaths -> deaths
m_iMPVs -> most valuable player count
m_iAssists -> assists

Also CS_SetClientContributionScore & CS_GetClientContributionScore for CS:GO.
I will beleive it just the scoreboard that get refresh more rarely but the value itself should be accurate (I might be wrong)

Last edited by Mathias.; 05-27-2015 at 18:47.
Mathias. is offline
Benoist3012
Veteran Member
Join Date: Mar 2014
Location: CWave::ForceFinish()
Old 05-29-2015 , 06:49   Re: Best way to get client ping?
Reply With Quote #6

Quote:
Originally Posted by cam0 View Post
What about what is displayed when you type 'ping' in console? (You can notice they can be very different, or even yours on the scoreboard compared to yours in net graph)



I think you want GetClientFrags, or with the same code, instead of m_iPing:
m_iFrags -> frags
m_iDeaths -> deaths
m_iMPVs -> most valuable player count
m_iAssists -> assists

Also CS_SetClientContributionScore & CS_GetClientContributionScore for CS:GO.
So m_iScore work too?
__________________
Benoist3012 is offline
RedSword
SourceMod Plugin Approver
Join Date: Mar 2006
Location: Quebec, Canada
Old 05-29-2015 , 08:24   Re: Best way to get client ping?
Reply With Quote #7

Quote:
Originally Posted by Benoist3012 View Post
So m_iScore work too?
m_iScore is a netprops in the resource manager in CSS/GO, but its datamaps equivalent is m_iFrags for the player, in CS. So if your game is CS, using Asherkin method with "m_iScore" should work.

If you were to get m_iFrags on the resource manager it would not work as it doesn't have that netprop (in CSS/GO at least). However, in CSS at least, they (m_iFrags @ the player entity and m_iScore @ resmanager) represent the same value by default (while CSGO has m_iKills as netprops which I didn't test, which could be replacing CSS m_iScore; while m_iScore would now really represent the player score).

Red

edit :
Quote:
Originally Posted by Black-Rabbit View Post
I will beleive it just the scoreboard that get refresh more rarely but the value itself should be accurate (I might be wrong)
AFAIK the "Think" of the scoreboard (being the resource manager) is about ~1 to 4 times a second in CSS; so you better change the datamap if you want to set/get non-ping values.
__________________
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

Last edited by RedSword; 05-30-2015 at 01:18. Reason: clarified
RedSword is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-29-2015 , 14:17   Re: Best way to get client ping?
Reply With Quote #8

Quote:
Originally Posted by RedSword View Post
m_iScore is a netprops in the resource manager in CSS/GO; not a datamap in the player entity (but its equivalent is m_iFrags in the player, for CS). Therefore unless I'm wrong, it should not work.

If your game isn't CS, it might work.

Red

edit :


AFAIK the think of the scoreboard (being the resource manager) is about ~1 to 4 times a second in CSS; so you better change the datamap (unless you want to change the ping).
Did you look at asherkin's source code right above his question?

It's calling GetPlayerResourceEntity(), which returns the entity index of the game-specific child of CPlayerResource... which controls the scoreboard.
__________________
Am I back? Well, we'll see.
Powerlord is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 05-29-2015 , 18:28   Re: Best way to get client ping?
Reply With Quote #9

You can also use this function I transformed once from the HL2SDK:

https://github.com/bcserv/smlib/blob...ients.inc#L647

True gives you the scoreboard latency, false the latency as show in net_graph. Haven't tested it with current games like CS:GO tho.
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
RedSword
SourceMod Plugin Approver
Join Date: Mar 2006
Location: Quebec, Canada
Old 05-30-2015 , 01:12   Re: Best way to get client ping?
Reply With Quote #10

Quote:
Originally Posted by Powerlord View Post
Did you look at asherkin's source code right above his question?

It's calling GetPlayerResourceEntity(), which returns the entity index of the game-specific child of CPlayerResource... which controls the scoreboard.
I saw his code, but cam0 talks about m_iFrags as if he could be getting that value from the resource manager, which he can't (it must be m_iScore). Thanks for pointing that out. I did change/correct/clarify my post.

Red
__________________
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

Last edited by RedSword; 05-30-2015 at 01:18.
RedSword 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 23:28.


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