mta-mono/Test/Program.cs

66 lines
1.8 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using MultiTheftAuto;
using MultiTheftAuto.EventArgs;
namespace Test
{
public class Program
{
static void MonoCommandHandler( Player player, string command, string[] args )
{
Debug.Info( player.GetName() + " executed command '" + command + "' with args: " + string.Join( " ", args ) );
}
static void Main( string[] args )
{
Server.AddCommandHandler( "mono", new CommandHandler( MonoCommandHandler ) );
2015-12-12 10:10:23 +00:00
Element.Root.OnPlayerJoin += Root_OnPlayerJoin;
2015-12-12 10:10:23 +00:00
//Element.Root.OnElementDestroy += ( Element sender, ElementEventArgs e ) =>
//{
// Debug.Info( "lambda " + sender.GetType() + " " + e.This.GetType() );
//};
Element vehicle = new Vehicle( VehicleModel.ADMIRAL, Vector3.Zero, Vector3.Zero );
Debug.Info( vehicle.GetType().ToString() );
vehicle.OnElementDestroy += Root_ElementDestroy;
2015-12-12 10:10:23 +00:00
//Event.Add( "onTest", true );
//Event.AddHandler( "onTest", vehicle, new Action<Element, string, bool, bool>( testEvent_OnTrigger ) );
//Event.Trigger( "onTest", vehicle, "test", true, false, 123, 456.7f, 1337.01d, null, vehicle );
vehicle.Destroy();
}
2015-12-12 10:10:23 +00:00
static void Root_OnPlayerJoin( Element sender, ElementEventArgs e )
{
Player player = sender as Player;
2015-12-12 10:10:23 +00:00
Debug.Info( "Player '" + player.GetName() + "' joined" );
}
static void Root_OnPlayerConnect( Element sender, PlayerConnectEventArgs e )
{
//Player player = sender as Player;
2015-12-12 10:10:23 +00:00
Debug.Info( "Player '" + sender.GetType() + "' connected" );
}
2015-12-12 10:10:23 +00:00
static void testEvent_OnTrigger( Element sender, string a, bool b, bool c )
{
Debug.Info( "testEvent_OnTrigger " + sender.GetType() + " " + a + " " + b + " " + c );
}
static void Root_ElementDestroy( Element sender, ElementEventArgs e )
{
Debug.Info( "Root_ElementDestroy " + sender.GetType() + " " + e.This.GetType() );
}
}
}