ItsMods
[Release] Ping viewer - Printable Version

+- ItsMods (https://www.itsmods.com)
+-- Forum: Archive (https://www.itsmods.com/Forum-Archive.html)
+--- Forum: Archive (https://www.itsmods.com/Forum-Archive--64.html)
+--- Thread: [Release] Ping viewer (/Thread-Release-Ping-viewer.html)

Pages: 1 2


Ping viewer - Pozzuh - 01-02-2012

Features:
This plugin enables you to see the ping of you and every other player.

Requirements:
@Nukem's dedicated server addon 1.190+

Changelog:
v1.2 Added linux support, now needs 1.190+
v1.1 made it easier to use !ping <name>. You can now do !ping <Part of name>. For Pozzuh you can do !ping p, but !ping zuh will also work.
v1 initial release

Usage:
Code:
!ping // Shows your ping !ping <name> // shows the ping of another player !highestping // shows player with highest ping !lowestping // shows player with lowest ping

Screenshots:
[Image: 633E44B18B342EB8031AF2A0C231773B3B2AF36F]
[Image: BE2AA9180520E427F7B5EDB59205AB69AB0FF2ED]

Credits:
@Pozzuh - Made the plugin
@Nukem - Helped me with random derp & made the server addon Heart

Source:
Code:
using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using Addon; namespace myCSplugin { public class main : CPlugin { public override void OnServerLoad() { ServerPrint("Ping plugin loaded. Author: Pozzuh. Version: 1.1"); } public override ChatType OnSay(string Message, ServerClient Client) { string lowMsg = Message.ToLower(); if (lowMsg.StartsWith("!ping")) { string[] splitMsg = lowMsg.Split(' '); if (splitMsg.Length == 1) TellClient(Client.ClientNum, "^2Ping plugin:^7 Your current ping is: " + Client.Ping, true); else { ServerClient c = GetClientByName(splitMsg[1]); if(c != null) TellClient(Client.ClientNum, "^2Ping plugin:^7 " + c.Name + "'s ping is: " + c.Ping, true); else TellClient(Client.ClientNum, "^2Ping plugin: ^1Unknown player name!", true); } return ChatType.ChatNone; } else if (lowMsg.StartsWith("!highestping")) { ServerClient HPclient = getHighestPingPlayer(); if(HPclient == null) TellClient(Client.ClientNum, "^2Ping plugin: ^1Highest ping search failed! ", true); else TellClient(Client.ClientNum, "^2Ping plugin:^7 Player \'" + HPclient.Name + "\' has the highest ping with " + HPclient.Ping, true); return ChatType.ChatNone; } else if (lowMsg.StartsWith("!lowestping")) { ServerClient LPclient = getLowestPingPlayer(); if(LPclient ==null) TellClient(Client.ClientNum, "^2Ping plugin: ^1Lowest ping search failed! ", true); else TellClient(Client.ClientNum, "^2Ping plugin:^7 Player \'" + LPclient.Name + "\' has the lowest ping with " + LPclient.Ping, true); return ChatType.ChatNone; } return ChatType.ChatContinue; } ////////////////////////////////////////////////////////////////////////////////////// ServerClient GetClientByName(string name) { if (name == null) return null; ServerClient C = null; int maxclients = Convert.ToInt32(GetDvar("sv_maxclients")); for (int i = 0; i < maxclients; i++) { C = GetClient(i); if (C != null) { if (C.Name.StartsWith(name, StringComparison.InvariantCultureIgnoreCase)) return C; else if (C.Name.ToLower().Contains(name.ToLower())) return C; } } return null; } ////////////////////////////////////////////////////////////////////////////////////// public ServerClient getHighestPingPlayer() { int Lowest = 0; ServerClient client = null; ServerClient last = null; for (int i = 0; i < 18; i++) { client = GetClient(i); if (client == null) continue; if (client.Ping > Lowest && client.Ping != 999) { last = client; Lowest = client.Ping; } } return last; } ////////////////////////////////////////////////////////////////////////////////////// public ServerClient getLowestPingPlayer() { int highest = 999; ServerClient client = null; ServerClient last = null; for (int i = 0; i < 18; i++) { client = GetClient(i); if (client == null) continue; if (client.Ping < highest && client.Ping != 0) { last = client; highest = client.Ping; } } return last; } } }



RE: Ping viewer - JariZ - 01-02-2012

awesome, finally someone else who develops plugins Awesome


RE: Ping viewer - krzy - 01-02-2012

thx pozzuh and jariz


RE: Ping viewer - Yurio - 01-03-2012

Pozzuh, please add the ability to use part of the name, insensitive.
Now !ping <name> don't work.


RE: Ping viewer - Pozzuh - 01-03-2012

It already doesn't care about uppercase and lowercase. And I'll see what I can do for using part of the name..


RE: Ping viewer - surtek - 01-03-2012

(01-03-2012, 17:40)Pozzuh Wrote: It already doesn't care about uppercase and lowercase. And I'll see what I can do for using part of the name..

Like if someone's name is Pozzuh you only need to write Poz and it will automaticly choose Pozzuh. (because some names are long).


RE: Ping viewer - Pozzuh - 01-03-2012

I made something that allows you to !ping p for Pozzuh. You just have to enter the first few characters. Also if someone's name is like 'lring' you can do !ping lae to get the name. I just need some people to help me test it because I dunno if it works alright with multiple people (I think so though).


RE: Ping viewer - SuperNovaAO - 01-03-2012

Problem are people that put some random unicode in front of their name.
You will be unable to enter those first characters then (most likely).


RE: Ping viewer - Pozzuh - 01-03-2012

(01-03-2012, 18:11)SuperNovaAO Wrote: Problem are people that put some random unicode in front of their name.
You will be unable to enter those first characters then (most likely).

I tried a view random unicode characters from here. And they all show up ingame as '_'. And as I already posted: if someone's name is like 'lring' you can do !ping lae to get the ping, because of 'StringComparison.InvariantCultureIgnoreCase'


RE: Ping viewer - Pozzuh - 01-05-2012

Updated, changelog, new download & new source code in original post.

/facepalm, I updated the tool a few days ago but forgot to upload.