*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:
Image URL
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;
}
}
}