public TrailScript() { if (GetCurrentResourceName() != "light-trail") { Debug.WriteLine("Invalid resource name, be sure the resource name is light-trail"); return; } DecorRegister(DecorName, 3); RegisterCommand("trail_mode", new Action <int, dynamic>(async(source, args) => { if (args.Count < 1) { Debug.WriteLine($"Missing argument off|on|brake"); return; } if (!Enum.TryParse <TrailMode>(args[0], true, out TrailMode trailMode)) { Debug.WriteLine($"Invalid parameter {args[0]}, accepted values are: [off|on|brake]"); return; } if (localVehicle == null) { Debug.WriteLine($"No local vehicle found"); return; } await localVehicle.SetTrailModeAsync(trailMode); Debug.WriteLine($"Switched light trail mode to {trailMode}"); if (DoesEntityExist(localVehicle.PlayerVehicle)) { DecorSetInt(localVehicle.PlayerVehicle, DecorName, (int)trailMode); } }), false); RegisterCommand("trail_print", new Action <int, dynamic>((source, args) => { if (localVehicle != null) { Debug.WriteLine(localVehicle.ToString()); } foreach (var vehicle in remoteVehicles) { Debug.WriteLine(vehicle.Value.ToString()); } }), false); Tick += Update; }
public TrailScript() { if (GetCurrentResourceName() != "light-trail") { Debug.WriteLine("Invalid resource name, be sure the resource name is light-trail"); return; } DecorRegister(DecorName, 3); RegisterCommand("trail_mode", new Action <int, dynamic>(async(source, args) => { if (args.Count < 1) { Debug.WriteLine($"LightTrail: Missing argument off|on|brake"); return; } if (!Enum.TryParse <TrailMode>(args[0], true, out TrailMode trailMode)) { Debug.WriteLine($"LightTrail: Error parsing {args[0]}"); return; } Debug.WriteLine($"LightTrail: Switched trail mode to {trailMode}"); await localVehicle.SetTrailModeAsync(trailMode); DecorSetInt(localVehicle.PlayerVehicle, DecorName, (int)trailMode); }), false); RegisterCommand("trail_print", new Action <int, dynamic>(async(source, args) => { if (localVehicle != null) { Debug.WriteLine(localVehicle.ToString()); } foreach (var vehicle in remoteVehicles) { Debug.WriteLine(vehicle.ToString()); } }), false); Tick += Update; }