adamix

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

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

Share this post


Link to post

I thinked on it very long time ago.But I decided to not go to do. Because It can't include client scripts. But It is great for someone who want to make only server-side scripts.So great job bro.

Share this post


Link to post

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!"); 
                } 
            }; 
  

Share this post


Link to post
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.

Share this post


Link to post
cool im a java developer :D c ++ and java are 90% simillar :D this will help a lot xD

ORLLY? xD SO MUCH FUN!!!!!

Dude, .net isn't java -_-

Share this post


Link to post

lol i mean close to java :3 read before you post :3

if you are programmer you know what im talking about ,similarities beetween c# or c ++ to java language.. calm dude

Share this post


Link to post

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)

Share this post


Link to post

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.