Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Release Ping viewer
#1
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;
        }
    }
}


Attached Files
.zip   pingPlugin.zip (Size: 2.59 KB / Downloads: 320)
[Image: MaEIQ.png]
Reply

#2
awesome, finally someone else who develops plugins Awesome
Reply

#3
thx pozzuh and jariz
Reply

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

#5
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]
Reply

#6
(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).
Reply

#7
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).
[Image: MaEIQ.png]
Reply

#8
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).
Reply

#9
(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'
[Image: MaEIQ.png]
Reply

#10
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]
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  [Release] Ping Warn Plugin v1.1 master131 28 23,724 07-10-2013, 09:34
Last Post: spike17
  [Release] IWI Viewer TwoPumpChump 22 26,853 12-18-2012, 19:13
Last Post: meredith
  ping warn 1.1, I passed from the server kpoviv 1 2,383 12-13-2012, 09:47
Last Post: XxBRxX
  [Release] [C++]ObjectFile Viewer/Compiler[OpenGL][v 0.1] Tomsen1410 8 6,323 10-07-2012, 10:47
Last Post: aosma8
  [Release] Ping block 1.3 archit 17 10,613 10-07-2012, 02:48
Last Post: archit
  High Ping block still badly needed here choobie 6 4,276 10-01-2012, 12:22
Last Post: archit
  High ping blocker choobie 5 4,169 08-21-2012, 15:16
Last Post: choobie
  DLL PING WARN1.1 kpoviv 5 4,901 07-17-2012, 20:28
Last Post: narkos
  DLL PING WARN1.1 kpoviv 2 2,223 07-07-2012, 23:39
Last Post: JariZ
  [Request] Ping Text visible plugin b00mmolo 2 2,888 05-14-2012, 16:23
Last Post: b00mmolo

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.