Skip to content

Commit

Permalink
add a remove last and a clear command
Browse files Browse the repository at this point in the history
  • Loading branch information
Alsekwolf committed Apr 3, 2019
1 parent 5e77349 commit ad5f140
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions DebugLocations/DebugLocations.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using CitizenFX.Core;
using CitizenFX.Core.Native;
using static CitizenFX.Core.Native.API;
Expand All @@ -14,6 +15,23 @@ public Locations()
{
API.RegisterCommand("loc", new Action<int, List<object>, string>((source, arguments, raw) => { GetLocation(); }), false);
API.RegisterCommand("WriteLocations", new Action<int, List<object>, string>((source, arguments, raw) => { WriteLocations(); }), false);
API.RegisterCommand("ClearLocations", new Action<int, List<object>, string>((source, arguments, raw) => { CLearLocations(); }), false);
API.RegisterCommand("RemoveLastLoc", new Action<int, List<object>, string>((source, arguments, raw) => { Removelast(); }), false);
}

private async void CLearLocations()
{
await Delay(0);
LocationsNew.Clear();
}

private async void Removelast()
{
await Delay(0);
if(LocationsNew.Any()) //prevent IndexOutOfRangeException for empty list
{
LocationsNew.RemoveAt(LocationsNew.Count - 1);
}
}

private async void GetLocation()
Expand Down

0 comments on commit ad5f140

Please sign in to comment.