ItsMods

Full Version: PM Manager
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
*Works with .NET 3 versions

Enables private messages between players ingame and supports the player's name or ID shown in 'status.'
Attachment is at the bottom of the post.

Usage:
Code:
!pm <player|ID> <message>
!pm Nukem test message
!pm 0 test message

Image URL

Code:
using System;
using Addon;

namespace pm_manager
{
    public class PMManager : CPlugin
    {
        public ServerClient GetClientByName(string name)
        {
            if (name == null)
                return null;

            ServerClient client = null;

            for(int i = 0; i < 18; i++)
            {
                client = GetClient(i);

                if (client == null)
                    continue;

                if (client.Name.ToLower() == name.ToLower())
                    return client;
            }

            return null;
        }

        public ChatType ManagerError(int ClientNum)
        {
            TellClient(ClientNum, "[^1PM Manager^7]: Invalid player", true);
            TellClient(ClientNum, "[^1PM Manager^7]: Usage: !pm <player|ID> <message>", true);

            return ChatType.ChatNone;
        }

        public override void OnServerLoad()
        {
            ServerPrint("Plugin: PM Manager loaded. Author: Nukem");
        }

        public override ChatType OnSay(string Message, ServerClient Client)
        {
            if (Message.StartsWith("!pm"))
            {
                string[] tokens = Message.Split(' ');

                if (tokens.Length < 3)//Less than three arguments
                    return ManagerError(Client.ClientNum);

                ServerClient ci = null;

                int num = 0;
                if (int.TryParse(tokens[1], out num))
                    ci = GetClient(num);
                else
                    ci = GetClientByName(tokens[1]);

                if (ci == null)
                    return ManagerError(Client.ClientNum);

                string  NewMessage  = null;
                int     iNum        = 0;

                foreach (string part in tokens)
                {
                    if (iNum >= 2)//Quick fix to remove !pm <name> or !pm <ID>
                        NewMessage += part;

                    iNum++;
                }

                TellClient(Client.ClientNum, "[^1PM Manager^7]: Message sent", true);
                TellClient(ci.ClientNum, "[^1" + Client.Name + "^7]: " + NewMessage, true);

                return ChatType.ChatNone;
            }

            return ChatType.ChatContinue;
        }
    }
}
I think you have so much free time these days.

Good job. I'm eager to see more releases from you.
@Lemon this plugin was as example in the old API, he only converted it from C++ to C# Tongue
But it's a epic plugin though
Nukem, please add the ability to use part of the name, insensitive.
hi guys,

got some questions for the PM manager

1. is it legal to use it?
2. where do i have to put the file?
3. is it possible to send massages for example to show my serverrules? i mean the massage repeats all the time!
4. how can i deal with the text i want to send!?
(01-22-2012, 16:01)HdM|Scorpion Wrote: [ -> ]hi guys,

got some questions for the PM manager

1. is it legal to use it?
2. where do i have to put the file?
3. is it possible to send massages for example to show my serverrules? i mean the massage repeats all the time!
4. how can i deal with the text i want to send!?

1. dont know, but if you run the server from another folder than your steamfolder you'll not get banned
2.read up on nukems server addon
3.same, nukems server addon makes that possible
4. use !pm playername/id message
thanks for the answer, but

sorry, i dont really know where to find the instructions...

can i have a link for that pls?
(01-22-2012, 19:54)HdM|Scorpion Wrote: [ -> ]thanks for the answer, but

sorry, i dont really know where to find the instructions...

can i have a link for that pls?

It's in the mw3 server addon forum in the general subforum and has been stickied, i suggest you read the OP there