-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.cs
83 lines (73 loc) · 2.75 KB
/
Main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using LSPD_First_Response;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Rage;
using Rage.Native;
using LSPD_First_Response.Mod.API;
using LSPD_First_Response.Mod.Callouts;
using LSPD_First_Response.Engine.Scripting.Entities;
using SSStuartCallouts;
using SSStuartCallouts.Callouts;
using System.Reflection;
namespace SSStuartCallouts
{
public class Main : Plugin
{
readonly string pluginName = "SSStuart Callouts";
//Initialization of the plugin.
public override void Initialize()
{
Functions.OnOnDutyStateChanged += OnOnDutyStateChangedHandler;
Game.LogTrivial(pluginName + " Plugin " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " has been initialised.");
Game.LogTrivial("Go on duty to fully load " + pluginName + ".");
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(LSPDFRResolveEventHandler);
}
public override void Finally()
{
Game.LogTrivial(pluginName + " has been cleaned up.");
}
private static void OnOnDutyStateChangedHandler(bool OnDuty)
{
if (OnDuty)
{
RegisterCallouts();
Game.DisplayNotification("commonmenu", "mp_hostcrown", "SSStuart Callout", "V 0.1.1", "~g~Loaded successfully !");
}
}
private static void RegisterCallouts()
{
// Functions.RegisterCallout(typeof(Callouts.TestCallout));
Functions.RegisterCallout(typeof(Callouts.CarCrash));
Functions.RegisterCallout(typeof(Callouts.TrainDerailment));
Functions.RegisterCallout(typeof(Callouts.AbandonedVehicle));
}
public static Assembly LSPDFRResolveEventHandler(object sender, ResolveEventArgs args)
{
foreach (Assembly assembly in Functions.GetAllUserPlugins())
{
if (args.Name.ToLower().Contains(assembly.GetName().Name.ToLower()))
{
return assembly;
}
}
return null;
}
public static bool IsLSPDFRPluginRunning(string Plugin, Version minversion = null)
{
foreach (Assembly assembly in Functions.GetAllUserPlugins())
{
AssemblyName assemblyName = assembly.GetName();
if (assemblyName.Name.ToLower() == Plugin.ToLower())
{
if (minversion == null || assemblyName.Version.CompareTo(minversion) >= 0)
{
return true;
}
}
}
return false;
}
}
}