diff --git a/Callouts/Test.cs b/Callouts/Test.cs new file mode 100644 index 0000000..3ae1907 --- /dev/null +++ b/Callouts/Test.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Rage; +using LSPD_First_Response.Mod.API; +using LSPD_First_Response.Mod.Callouts; +using System.Drawing; + +namespace Code_Blue_Calls.Callouts +{ + [CalloutInfo("Test", CalloutProbability.High)] + public class Test : Callout + { + private Ped suspect; + private Vehicle vehicle; + private Blip blip; + private LHandle Pursuit; + private Vector3 spawn; + private bool created; + public override bool OnBeforeCalloutDisplayed() + { + spawn = World.GetRandomPositionOnStreet(); + ShowCalloutAreaBlipBeforeAccepting(spawn, 30f); + //AddMaximumDistanceCheck(40, spawn); + CalloutMessage = "Test"; + CalloutPosition = spawn; + Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_RESISTING_ARREST_02 IN_OR_ON_POSITION", spawn); + return base.OnBeforeCalloutDisplayed(); + } + + public override bool OnCalloutAccepted() + { + vehicle = new Vehicle("BLISTA", spawn); + vehicle.IsPersistent = true; + suspect = new Ped(vehicle.GetOffsetPositionFront(5f)); + suspect.IsPersistent = true; + suspect.BlockPermanentEvents = true; + suspect.WarpIntoVehicle(vehicle, -1); + + blip = suspect.AttachBlip(); + blip.Color = System.Drawing.Color.Yellow; + blip.IsRouteEnabled = true; + + created = false; + + return base.OnCalloutAccepted(); + } + + public override void Process() + { + base.Process(); + + if (!created && Game.LocalPlayer.Character.DistanceTo(vehicle) <= 20f) + { + Pursuit = Functions.CreatePursuit(); + Functions.AddPedToPursuit(Pursuit, suspect); + Functions.SetPursuitIsActiveForPlayer(Pursuit, true); + + created = true; + } + if (created && !Functions.IsPursuitStillRunning(Pursuit)) + { + End(); + } + + } + public override void End() + { + base.End(); + + if (suspect.Exists()) + { + suspect.Dismiss(); + } + } + } +} diff --git a/Code Blue Calls.csproj b/Code Blue Calls.csproj new file mode 100644 index 0000000..7e2a1fd --- /dev/null +++ b/Code Blue Calls.csproj @@ -0,0 +1,58 @@ + + + + + Debug + AnyCPU + {3CD9D818-ECAE-497B-A7AD-5B64C2345A84} + Library + Properties + Code_Blue_Calls + Code Blue Calls + v4.7.2 + 512 + true + + + true + full + false + ..\..\..\Games\GTAV\plugins\LSPDFR\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\References\LSPD First Response.dll + + + ..\References\RagePluginHookSDK.dll + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code Blue Calls.sln b/Code Blue Calls.sln new file mode 100644 index 0000000..32ec6a4 --- /dev/null +++ b/Code Blue Calls.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33516.290 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Code Blue Calls", "Code Blue Calls.csproj", "{3CD9D818-ECAE-497B-A7AD-5B64C2345A84}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3CD9D818-ECAE-497B-A7AD-5B64C2345A84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3CD9D818-ECAE-497B-A7AD-5B64C2345A84}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3CD9D818-ECAE-497B-A7AD-5B64C2345A84}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3CD9D818-ECAE-497B-A7AD-5B64C2345A84}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {29F89CB0-BC42-4243-9068-9A57520D3379} + EndGlobalSection +EndGlobal diff --git a/IniFile.cs b/IniFile.cs new file mode 100644 index 0000000..f64f9c1 --- /dev/null +++ b/IniFile.cs @@ -0,0 +1,59 @@ +using System; +using System.Runtime.InteropServices; +using System.Text; + +namespace Code_Blue_Calls +{ + /// + /// Create a New INI file to store or load data + /// + public class IniFile + { + public string path; + + [DllImport("kernel32")] + private static extern long WritePrivateProfileString(string section, + string key, string val, string filePath); + [DllImport("kernel32")] + private static extern int GetPrivateProfileString(string section, + string key, string def, StringBuilder retVal, + int size, string filePath); + + /// + /// INIFile Constructor. + /// + /// + public IniFile(string INIPath) + { + path = INIPath; + } + /// + /// Write Data to the INI File + /// + /// + /// Section name + /// + /// Key Name + /// + /// Value Name + public void IniWriteValue(string Section, string Key, string Value) + { + WritePrivateProfileString(Section, Key, Value, this.path); + } + + /// + /// Read Data Value From the Ini File + /// + /// + /// + /// + /// + public string IniReadValue(string Section, string Key) + { + StringBuilder temp = new StringBuilder(255); + int i = GetPrivateProfileString(Section, Key, "", temp, 255, this.path); + return temp.ToString(); + + } + } +} \ No newline at end of file diff --git a/Main.cs b/Main.cs new file mode 100644 index 0000000..fde5247 --- /dev/null +++ b/Main.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Rage; +using LSPD_First_Response.Mod.API; +using System.Reflection; +//using LSPD_First_Response.Mod.Callouts; + +namespace Code_Blue_Calls +{ + public class Main : Plugin + { + public override void Initialize() + { + Functions.OnOnDutyStateChanged += OnOnDutyStateChangedHandler; + Game.LogTrivial("Code Blue callouts initialized."); + AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(LSPDFRResolveEventHandler); + } + + public override void Finally() + { + throw new NotImplementedException(); + } + + public static void OnOnDutyStateChangedHandler(bool OnDuty) + { + if (OnDuty) + { + RegisterCallouts(); + Game.DisplayNotification("Code Blue Callouts loaded."); + } + } + + private static void RegisterCallouts() + { + Functions.RegisterCallout(typeof(Callouts.Test)); + } + + 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 an = assembly.GetName(); + if (an.Name.ToLower() == Plugin.ToLower()) + { + if (minversion == null || an.Version.CompareTo(minversion) >= 0) + { + return true; + } + } + } + return false; + } + } +} diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..eb586cc --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Code Blue Calls")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Code Blue Calls")] +[assembly: AssemblyCopyright("Copyright © 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("3cd9d818-ecae-497b-a7ad-5b64c2345a84")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")]