MTAMono is a module that does bridge between Lua and .Net worlds!
It uses Mono framework(http://mono-project.com), .Net-based wrapper, C module and small lua script!
It is in a beta stage, but many server features already working good.
Example of a small script:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using MTAAPI;
namespace MTAAPI_Sample
{
public class Events : IIEvents
{
public static void onConsole(Element source, string text)
{
string[] args = text.Split('|');
Console.WriteLine("OnConsole: " + text);
}
public static void onPlayerJoin(Element player)
{
Player p = player.GetAsPlayer();
Simple.SpawnPlayer(p);
Chat.OutputChatBox("Player " + p.GetName() + " joined!", Element.Root, 255, 0, 0, false);
}
public static bool onPlayerChat(Element player, string message, int messageType)
{
Console.WriteLine("CHAT: " + player.GetAsPlayer().GetName() + " : msg: " + message);
Chat.OutputChatBox(player.GetAsPlayer().GetName() + ": " + message, Element.Root, 0, 255, 0);
return false;
}
}
public class Binds : IIBinds
{
public static void keyBind(Element player, string key, string keyState)
{
Console.WriteLine("keyBIND! + " + key + " " + player.GetAsPlayer().GetName());
}
};
public class Simple : IPlugin
{
public string GetPluginName() { return "Simple"; }
public void Startup()
{
Console.WriteLine("Simple startup");
MTAAPI.Events.HandleEvent("onPlayerJoin");
MTAAPI.Events.HandleEvent("onConsole");
MTAAPI.Events.HandleEvent("onPlayerChat");
}
public static void SpawnPlayer(Player p)
{
p.Spawn(10.0f, 10.0f, 15.0f);
Camera.Fade(p, true);
Camera.SetCameraTarget(p, p);
Vehicle v = new Vehicle(411, 15.0f, 15.0f, 10.0f);
p.WarpIntoVehicle(v);
v.SetDamageProof(true);
Blip b = new Blip(v);
p.GiveMoney(5000);
p.SetDoingGangDriveby(true);
}
}
}
You can download it from:
Module and wrapper:
http://unix-net.ru/MTAMono_win32.zip (Win32 binary)
http://unix-net... (Linux 32bit - coming soon!)
Mono class libraries:
http://office.web-hunter.ru/MTAMono_classlibs.rar
Okay, installation
Extract MTAMono_win32.zip to your server folder
Add MTAMono.dll module to "modules" section of your mtaserver.conf
Extract MTAMono_classlibs.zip to mods\deathmatch\modules\
Add mtamono resource to your mtaserver.conf
Start the server! You will see the Simple script working.
For writing your own scripts theres an "src" folder, just open MTAAPI_Simple.csproj, add mods\deathmatch\modules\MTAMonoNet.dll to references and start coding!
Documentation with linux version and source code will come soon.