Post Reply 
 
Thread Rating:
  • 2 Votes - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Release Ping viewer
01-02-2012, 20:01 (This post was last modified: 01-12-2012 18:00 by Pozzuh.)
Post: #1
Ping viewer
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;
        }
    }
}

Related links


Attached File(s)
.zip  pingPlugin.zip (Size: 2.59 KB / Downloads: 278)

[Image: MaEIQ.png]
Find all posts by this user
Add Thank You Quote this message in a reply
[-] The following 12 users say Thank You to Pozzuh for this post:
d0h! (01-02-2012), gato (01-20-2012), Gorre (04-05-2012), Ikono (01-13-2012), JariZ (01-02-2012), krzy (01-02-2012), Mauser (01-12-2012), surtek (01-03-2012), Tylerd86 (01-02-2012), Yamato (01-05-2012), Yurio (01-09-2012), zxz0O0 (01-03-2012)
01-02-2012, 20:04
Post: #2
RE: Ping viewer
awesome, finally someone else who develops plugins Awesome

[Image: k5sVYyb.gif]
Visit this user's website Find all posts by this user
Add Thank You Quote this message in a reply
01-02-2012, 20:44
Post: #3
RE: Ping viewer
thx pozzuh and jariz
Find all posts by this user
Add Thank You Quote this message in a reply
01-03-2012, 16:18
Post: #4
RE: Ping viewer
Pozzuh, please add the ability to use part of the name, insensitive.
Now !ping <name> don't work.
Related links

Visit this user's website Find all posts by this user
Add Thank You Quote this message in a reply
01-03-2012, 17:40
Post: #5
RE: Ping viewer
It already doesn't care about uppercase and lowercase. And I'll see what I can do for using part of the name..

[Image: MaEIQ.png]
Find all posts by this user
Add Thank You Quote this message in a reply
01-03-2012, 17:46
Post: #6
RE: Ping viewer
(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).
Find all posts by this user
Add Thank You Quote this message in a reply
01-03-2012, 18:08 (This post was last modified: 01-05-2012 16:03 by Pozzuh.)
Post: #7
RE: Ping viewer
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 'læring' 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).

[Image: MaEIQ.png]
Find all posts by this user
Add Thank You Quote this message in a reply
01-03-2012, 18:11
Post: #8
RE: Ping viewer
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).
Related links

Visit this user's website Find all posts by this user
Add Thank You Quote this message in a reply
01-03-2012, 18:32 (This post was last modified: 01-03-2012 21:30 by Pozzuh.)
Post: #9
RE: Ping viewer
(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 'læring' you can do !ping lae to get the ping, because of 'StringComparison.InvariantCultureIgnoreCase'

[Image: MaEIQ.png]
Find all posts by this user
Add Thank You Quote this message in a reply
01-05-2012, 16:00 (This post was last modified: 01-05-2012 16:03 by Pozzuh.)
Post: #10
RE: Ping viewer
Updated, changelog, new download & new source code in original post.

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

[Image: MaEIQ.png]
Find all posts by this user
Add Thank You Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  [Release] [BigBrotherBot] External Rcon 0.5/Chat viewer 0.2 beta archit 46 6,562 Yesterday 06:54
Last Post: archit
  [Release] Ping block 1.3 archit 17 1,601 10-07-2012 02:48
Last Post: archit
  [Release] Max Ping Plugin [Updated, v1.7] SirGravzy 13 3,397 09-21-2012 22:50
Last Post: mobious39
  [Release] Ping Warn Plugin v1.1 master131 30 7,289 06-22-2012 03:33
Last Post: FootballMatches
Lightbulb [Release] Core Ping plugin [updated to v1.0.2] Nerus 11 1,882 04-18-2012 11:29
Last Post: Nerus

Forum Jump:


User(s) browsing this thread: 1 Guest(s)
Media Embeding by Simple Audio Video Embeder