ItsMods
Help for writing a plugin - 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: Help for writing a plugin (/Thread-Help-for-writing-a-plugin.html)



for writing a plugin - mac1981 - 01-09-2012

hi there,
i git some questions i want to create my own plugin for the awsome mw3 server addon i startet with coding but i dont know how i can create a dll with this code with visual studio.. what must i do pls help a little noob..

My idea is a working war plugin like short chat text elements to control the server like: !fr -> fast_restart, !mr -> map_restart, !mr10 ->roundlimit 10, !map alpha -> map mp_alpha and so on...

Pls take a look i just copied the code from iAegle and changed the way it might be working for me:

using System;
using System.Collections.Generic;
using Addon;

namespace plugin_test
{

public class plugin_test : CPlugin
{
List<string> admins = new List<string>();
bool disable = false;
public override ChatType OnSay(string Message, ServerClient Client)
{
if (disable)
return ChatType.ChatAll;

if (Message.StartsWith("!fr") && admins.Contains(Client.XUID))
{
if (Message.Length <= 6)
TellClient(Client.ClientNum, "^2Admin: ^3Usage: [COMMAND]", true);
else
{
string cmd = Message.Substring(6);
ServerPrint(Client.Name + " used Admin command: \"" + cmd + "\"");
ServerCommand(fast_restart);
}

return ChatType.ChatNone;
}
return ChatType.ChatAll;
}

public override void OnServerLoad()
{
string l = GetServerCFG("RCON", "Admin_xuids", "");
if (l == "")
foreach (string xuid in l.Split(','))
admins.Add(xuid);

if (admins.Count == 0)
disable = true;

ServerPrint("Ingame RCON loaded. Author: M@C. Version: 1.0");
}
}
}

this i entered in visual studio but i cant create a working dll with this...
Pls Help a Noob
Greetz M@C


RE: for writing a plugin - Nekochan - 01-09-2012


there is no thing to restart server, setdvar(fast_restart dont work...



RE: for writing a plugin - mac1981 - 01-10-2012

(01-09-2012, 21:59)Se7en Wrote: there is no thing to restart server, setdvar(fast_restart dont work...

so i got somethings running but got some problems...

if (Message.StartsWith("!mr") && admins.Contains(Client.XUID))
if (Message.Length <= 6)
TellClient(Client.ClientNum, "^2Admin: ^3Map Restart", true);
System.Threading.Thread.Sleep(5000);
ServerCommand("map_restart");
if (Message.StartsWith("!fr") && admins.Contains(Client.XUID))
if (Message.Length <= 6)
TellClient(Client.ClientNum, "^2Admin: ^3Fast Restart", true);
System.Threading.Thread.Sleep(5000);
ServerCommand("fast_restart");
if (Message.StartsWith("!paris") && admins.Contains(Client.XUID))
if (Message.Length <= 6)
TellClient(Client.ClientNum, "^2Admin: ^3Map changed to Revolution", true);
System.Threading.Thread.Sleep(5000);
ServerCommand("map mp_paris");

this works half its way i want that the server prints in Map restart and after 5 seconds he will do this but this dont work he just jumps to server command map mp_paris.. whtas wrong?? if dont enter sleep and messages everything works fine..



RE: for writing a plugin - zxz0O0 - 01-10-2012

(01-09-2012, 21:59)Se7en Wrote: there is no thing to restart server, setdvar(fast_restart dont work...

Code:
ServerCommand("fast_restart");