Jump to content

[WIP] MTAMono - bringing .Net scripting to the MTA!


adamix

Recommended Posts

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.

Edited by Guest
Link to comment

Of course it can! With some limitations, but still it can!

Im working on these right now, some small results:

  
            string guid = ClientRPC.Call(player.GetAsPlayer(), "isMTAWindowActive"); 
            ClientRPC.Answer += (g, a) => 
            { 
                if (g == guid) 
                { 
                    if((bool)a.var == false) 
                        Chat.OutputChatBox("Your window is inactive!"); 
                } 
            }; 
  

Link to comment
Of course it can! With some limitations, but still it can!

Im working on these right now, some small results:

  
            string guid = ClientRPC.Call(player.GetAsPlayer(), "isMTAWindowActive"); 
            ClientRPC.Answer += (g, a) => 
            { 
                if (g == guid) 
                { 
                    if((bool)a.var == false) 
                        Chat.OutputChatBox("Your window is inactive!"); 
                } 
            }; 
  

It's good idea but not very useful I think.

Link to comment

what are stats like? is it any faster using mono than lua? this is only server side, right? looks cool but sophisticated servers would only use this, and they would only use something fast. good job! just stats/benchmarks are needed :)

A better description would be bringing C#* to MTA (not .net :P)

Link to comment
  • 6 months later...
  • 2 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...