Skip to content
Permalink
Browse files

Version 1.3.6.5 change list

- Added stolen flag on vehicle info window
- Added keyboard shortcut to open Computer+ using tablet while player is on foot. (default: LControl + NumPad0)
- Added checkbox to toggle create court case for the citation (Notice to Appear) on the citation form
- Enlarged citation selection list for better UX
- Replace citation ticket 3D model given to the ped with more suitable one
- Fixed bug when driver takes off after being given the citation without waiting player return to the car. (during traffic stop)
  • Loading branch information...
BejoIjo committed Apr 10, 2018
1 parent 9136b19 commit 86ed1166cec87134c77f43a5b5578e83ed617345
@@ -34,6 +34,7 @@ internal static String FontName
private static List<KeyBinder> OpenSimpleNotepadKeys = new List<KeyBinder>();
private static List<KeyBinder> CloseComputerPlusKeys = new List<KeyBinder>();
private static List<KeyBinder> GiveCitationsToPedKeys = new List<KeyBinder>();
private static List<KeyBinder> OpenComputerPlusOnFootKeys = new List<KeyBinder>();

internal static void RunConfigCheck()
{
@@ -87,6 +88,7 @@ private static void ParseKeybindings()
ParseKeybindings(CloseComputerPlusKeys, "CloseComputerPlus");
ParseKeybindings(OpenSimpleNotepadKeys, "OpenSimpleNotepad");
ParseKeybindings(GiveCitationsToPedKeys, "GiveCitationsToPed");
ParseKeybindings(OpenComputerPlusOnFootKeys, "OpenComputerPlusOnFoot");

if (OpenComputerPlusKeys.Count == 0) //Fail safe for opening computer by holding the context secondary (E / DPadRight)
OpenComputerPlusKeys.Add(new KeyBinder(GameControl.Context));
@@ -148,6 +150,11 @@ internal static void CreateINIFile()
ini_file.Write("KEYBINDINGS", "GiveCitationsToPedControllerButton", "None");
ini_file.Write("KEYBINDINGS", "GiveCitationsToPedControllerModifierButton", "None");

ini_file.Write("KEYBINDINGS", "OpenComputerPlusOnFootKey", "None");
ini_file.Write("KEYBINDINGS", "OpenComputerPlusOnFootModifierKey", "None");
ini_file.Write("KEYBINDINGS", "OpenComputerPlusOnFootControllerButton", "None");
ini_file.Write("KEYBINDINGS", "OpenComputerPlusOnFootControllerModifierButton", "None");

}

internal static string Username
@@ -222,6 +229,14 @@ internal static KeyBinder[] GiveTicketsToPed
}
}

internal static KeyBinder[] OpenComputerPlusOnFoot
{
get
{
return OpenComputerPlusOnFootKeys.ToArray();
}
}

internal static int BaseFormWidth
{
get { return 700; }
@@ -14,10 +14,9 @@
namespace ComputerPlus.Interfaces.ComputerPedDB
{


class ComputerPedController
{
private readonly static List<ComputerPlusEntity> RecentSearches = new List<ComputerPlusEntity>();
private readonly static List<ComputerPlusEntity> RecentSearches = new List<ComputerPlusEntity>();

private static ComputerPlusEntity _LastSelected = null;
public static ComputerPlusEntity LastSelected
@@ -652,40 +652,45 @@ public static void createCourtCaseForCitations(List<TrafficCitation> citations,

foreach (var citation in citations)
{
if (citationStr.Equals(String.Empty)) citationStr = citation.Citation.Name;
else citationStr += ", " + citation.Citation.Name;

int maxFine = (int) citation.Citation.FineAmount;
int fine = 0;
int randumNum = Globals.Random.Next(0, 100);
if (randumNum < 25)
fine = (int)(maxFine * 0.80f);
else if (randumNum < 50)
fine = (int)(maxFine * 0.65f);
else if (randumNum < 75)
fine = (int)(maxFine * 0.5f);
else
fine = maxFine;
if (citation.CreateCourtCase)
{
if (citationStr.Equals(String.Empty)) citationStr = citation.Citation.Name;
else citationStr += ", " + citation.Citation.Name;

int maxFine = (int)citation.Citation.FineAmount;
int fine = 0;
int randumNum = Globals.Random.Next(0, 100);
if (randumNum < 25)
fine = (int)(maxFine * 0.80f);
else if (randumNum < 50)
fine = (int)(maxFine * 0.65f);
else if (randumNum < 75)
fine = (int)(maxFine * 0.5f);
else
fine = maxFine;

totalFine += fine;
totalFine += fine;

if (!citation.Citation.IsPublic)
{
containTrafficCitation = true;
if (citation.Citation.IsArrestable) isRevoked = true;
if (!citation.Citation.IsPublic)
{
containTrafficCitation = true;
if (citation.Citation.IsArrestable) isRevoked = true;
}
}
}

if (containTrafficCitation && !isRevoked && totalFine > 500) isSuspended = true;

courtVerdictStr = "Fined $" + totalFine;
if (!citationStr.Equals(String.Empty))
{
if (containTrafficCitation && !isRevoked && totalFine > 500) isSuspended = true;
courtVerdictStr = "Fined $" + totalFine;

if (isRevoked)
courtVerdictStr += ". License revoked";
else if (isSuspended)
courtVerdictStr += ". License suspended for " + Globals.Random.Next(6, 13) + " months";
if (isRevoked)
courtVerdictStr += ". License revoked";
else if (isSuspended)
courtVerdictStr += ". License suspended for " + Globals.Random.Next(6, 13) + " months";

LSPDFRPlusFunctions.CreateNewCourtCase(pedPersona, citationStr, guiltyChance, courtVerdictStr);
LSPDFRPlusFunctions.CreateNewCourtCase(pedPersona, citationStr, guiltyChance, courtVerdictStr);
}
}
}
}
@@ -74,7 +74,8 @@ public class Storage
public Storage()
{
Function.Log(String.Format("Attempting to load LiteDB database from {0}", DB_FILE_NAME));
db = new LiteDatabase(@String.Format("Filename={0};Cache Size=16;Flush=true", DB_FILE_NAME));
//db = new LiteDatabase(@String.Format("Filename={0};Cache Size=16;Flush=true", DB_FILE_NAME));
db = new LiteDatabase(@String.Format("Filename={0};Cache Size=0;Flush=true", DB_FILE_NAME));
}

public void initDB()
@@ -47,6 +47,7 @@ internal static bool HasBackground
internal GameFiber CheckIfCalloutActiveFiber;
private GameFiber DetectOpenCloseRequestedFiber;
private GameFiber DetectOpenSimpleNotepadFiber;
private GameFiber DetectOpenCPlusOnFootFiber;
private GameFiber RunComputerPlusFiber;

public override void Initialize()
@@ -55,6 +56,7 @@ public override void Initialize()
RunComputerPlusFiber = new GameFiber(RunPoliceComputer);
CheckIfCalloutActiveFiber = new GameFiber(CheckIfCalloutActive);
DetectOpenSimpleNotepadFiber = new GameFiber(CheckOpenSimpleNotepad);
DetectOpenCPlusOnFootFiber = new GameFiber(CheckOpenCPlusOnFoot);
Functions.OnOnDutyStateChanged += DutyStateChangedHandler;
OnVehicleStopped += VehicleStoppedHandler;
OnFacingPedWithPendingTickets += PedFacingPlayerWithPendingTickets;
@@ -75,7 +77,6 @@ public override void Finally()
//Globals.Store.Close();
}


private void DutyStateChangedHandler(bool on_duty)
{
Globals.IsPlayerOnDuty = on_duty;
@@ -87,6 +88,7 @@ private void DutyStateChangedHandler(bool on_duty)
Function.CheckForUpdates();
CheckIfCalloutActiveFiber.Resume();
DetectOpenSimpleNotepadFiber.Resume();
DetectOpenCPlusOnFootFiber.Resume();
DetectOpenCloseRequestedFiber.Resume();
Function.LogDebug("Successfully loaded LSPDFR Computer+.");
InitStorage();
@@ -126,7 +128,7 @@ private void InitStorage()
Function.LogCatch(e.Message);
}
}

private static void ALPRPlusFunctions_OnAlprPlusMessage(object sender, ALPR_Arguments e)
{
ComputerVehicleController.AddAlprScan(e);
@@ -146,7 +148,6 @@ private static void VehicleStoppedHandler(object sender, Vehicle veh)
else sb.AppendFormat(" or {0}", friendlyName);
}


Game.DisplayHelp(String.Format("Hold {0} to open ~b~LSPDFR Computer+~w~.", sb.ToString()));
_prompted = true;
}
@@ -156,7 +157,10 @@ private static void VehicleStoppedHandler(object sender, Vehicle veh)
private static List<List<TrafficCitation>> mPromptedCitations = new List<List<TrafficCitation>>();
private static void PedFacingPlayerWithPendingTickets(object sender, Ped ped, List<TrafficCitation> citations)
{
if (mPromptedCitations.Contains(citations)) return;
lock (mPromptedCitations)
{
if (mPromptedCitations.Contains(citations)) return;
}
mPromptedCitations.Add(citations);
StringBuilder sb = new StringBuilder();
foreach (var friendlyName in Configs.GiveTicketsToPed.Select(x => x.FriendlyName))
@@ -261,19 +265,16 @@ private void CheckForDeliverTicketTrigger()
if (Game.LocalPlayer.Character.LastVehicle && !Game.LocalPlayer.Character.LastVehicle.HasDriver)
Game.DisplayNotification("The driver will wait until you are back in your vehicle before taking off");

int count = 0;
while (Game.LocalPlayer.LastVehicle && !Game.LocalPlayer.LastVehicle.HasDriver && count < 5)
while (Game.LocalPlayer.LastVehicle && !Game.LocalPlayer.LastVehicle.HasDriver)
{
GameFiber.Sleep(1000); //Wait for the player to enter their vehicle
count++;
}

Function.Log("Starting Ending pull over wait timer for ped to leave");
var stopAt = DateTime.Now.AddMilliseconds(4000); //have the sadPed drive off in 4 seconds if the traffic stop isnt over
while (DateTime.Now < stopAt) GameFiber.Sleep(500);
try
{

lock (mPromptedCitations) mPromptedCitations.Clear();
var handle = Functions.GetCurrentPullover();
if (handle != null)
@@ -306,8 +307,9 @@ private void CheckForDeliverTicketTrigger()
List<TrafficCitation> citations = Globals.GetTrafficCitationsInHandForPed(sadPed);
Globals.RemoveTrafficCitationsInHandForPed(sadPed);

var item = new Rage.Object(new Model("prop_cs_documents_01"), Game.LocalPlayer.Character.Position);
item.AttachTo(Game.LocalPlayer.Character, Game.LocalPlayer.Character.GetBoneIndex(PedBoneId.RightThumb1), new Vector3(item.Model.Dimensions.Length() * 0.4f, 0, 0), Rotator.Zero);
//var item = new Rage.Object(new Model("prop_cs_documents_01"), Game.LocalPlayer.Character.Position);
var item = new Rage.Object(new Model("prop_cs_pamphlet_01"), Game.LocalPlayer.Character.GetOffsetPositionUp(3f));
item.AttachTo(Game.LocalPlayer.Character, Game.LocalPlayer.Character.GetBoneIndex(PedBoneId.RightThumb1), new Vector3(0.11f, -0.015f, 0f), new Rotator(-195f, 90f, 0f));
GameFiber.StartNew(delegate
{
GameFiber.Sleep(1300);
@@ -365,7 +367,6 @@ private void ComputerPlusMain()
}



internal static void OpenMain()
{
if (Configs.SkipLogin) Globals.Navigation.Push(new ComputerMain());
@@ -414,13 +415,19 @@ private void RunPoliceComputer()
GameFiber.Yield();
}
while (Globals.Navigation.Head != null);
GameFiber.Sleep(100);
EntryPoint.OnRecentTextAdded = null;
FreePersistedEntities();
ClosePoliceComputer();
GameFiber.Yield();
ShowBackground(false, true);
GameFiber.Yield();
PauseGame(false, true);
GameFiber.Yield();
Globals.Navigation.Clear();
IsMainComputerOpen = false;
PauseGame(false, true);
ShowBackground(false, true);
FreePersistedEntities();
endStandingWithTabletAnim();

GameFiber.Yield(); //Yield to allow form fibers to close out
GameFiber.Hibernate();

@@ -478,12 +485,13 @@ private void NavOnFormRemoved(object sender, NavigationController.NavigationEntr
try
{
if (entry.form.Window == null || !entry.form.IsOpen()) return;
GameFiber.StartNew(() =>
{
entry.form.Window.Close();
// I know close() supposed to dispose the form. but just in case to make sure the memory is freed
entry.form.Window.Dispose();
});
entry.form.Window.Close();
//GameFiber.StartNew(() =>
//{
//entry.form.Window.Close();
// I know close() supposed to dispose the form. but just in case to make sure the memory is freed
//entry.form.Window.Dispose();
//});
}
catch (Exception e)
{
@@ -625,6 +633,77 @@ private void CheckOpenSimpleNotepad()
}
}

private void CheckOpenCPlusOnFoot()
{
while (Globals.IsPlayerOnDuty)
{
try
{
GameFiber.Yield();
if (!IsMainComputerOpen && Configs.OpenComputerPlusOnFoot.Any(x => x.IsPressed))
{
startStandingWithTabletAnim();
ShowPoliceComputer();
}
}
catch (Exception e)
{
//Function.Log(e.ToString());
}
}
}

private static void startStandingWithTabletAnim()
{
if (Globals.tablet != null)
{
Globals.tablet.Delete();
Globals.tablet = null;
}

holsterWeapon(Game.LocalPlayer.Character);
Game.LocalPlayer.Character.Tasks.PlayAnimation(new AnimationDictionary("amb@world_human_clipboard@male@idle_a"), "idle_c", 1f, AnimationFlags.Loop);
GameFiber.Sleep(500);

Globals.tablet = new Rage.Object("prop_cs_tablet", Game.LocalPlayer.Character.GetOffsetPositionUp(3f));
int boneIndex = Game.LocalPlayer.Character.GetBoneIndex(PedBoneId.LeftPhHand);
Globals.tablet.AttachTo(Game.LocalPlayer.Character, boneIndex, new Vector3(0f, 0f, 0f), new Rotator(0f, -90f, 0f));
GameFiber.Sleep(1500);
}

private static void endStandingWithTabletAnim()
{
if (Game.LocalPlayer.Character.IsOnFoot)
{
Game.LocalPlayer.Character.Tasks.Clear();
}
if (Globals.tablet != null)
{
Globals.tablet.Detach();
Globals.tablet.Delete();
Globals.tablet = null;
}
}

private static void holsterWeapon(Ped ped)
{
ped.Tasks.Clear();
ped.Tasks.ClearSecondary();

if (ped.Inventory.EquippedWeaponObject != null)
{
WeaponDescriptor weapon = ped.Inventory.EquippedWeapon;
if (weapon.Hash != WeaponHash.Pistol && weapon.Hash != WeaponHash.CombatPistol
&& weapon.Hash != WeaponHash.APPistol && weapon.Hash != WeaponHash.Pistol50)
{
ped.Tasks.PlayAnimation("weapons@unarmed", "holster", 4f, AnimationFlags.None);
GameFiber.Sleep(350);
}
ped.Inventory.GiveNewWeapon("WEAPON_UNARMED", 0, true);
GameFiber.Sleep(500);
}
}

public static void AddRecentText(String text)
{
recent_text.Add(text);
@@ -305,7 +305,10 @@ private static string GetBackgroundFileNameForVehicle(Vehicle veh)
string file;
try
{
file = Configs.bgs[veh.Model.Hash];
if (veh != null && veh.IsValid())
file = Configs.bgs[veh.Model.Hash];
else
file = Globals.DefaultBackgroundImage;
}
catch (KeyNotFoundException)
{
@@ -719,7 +722,6 @@ internal static String DateFormatForPart(DateOutputPart part)
}
}


internal static String ToLocalDateString(DateTime date, DateOutputPart output, bool convertToLocal = true)
{
var local = date;
@@ -733,7 +735,7 @@ internal static String ToLocalDateString(DateTime date, DateOutputPart output, b
}
}

/*
/*
internal static String ToLocalDateString(String date, DateOutputPart input = DateOutputPart.ALL, DateOutputPart output = DateOutputPart.ALL, bool convertToLocal = true)
{
DateTime parsed;
Oops, something went wrong.

0 comments on commit 86ed116

Please sign in to comment.
You can’t perform that action at this time.