Guest User

Untitled

a guest
Apr 22nd, 2020
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.22 KB | None | 0 0
  1. using RAGE;
  2. using RAGE.Elements;
  3. using RAGE.Game;
  4. using System;
  5. using Vehicle = RAGE.Elements.Vehicle;
  6.  
  7. namespace SouthValleyFive_Client.jobs
  8. {
  9.     class Trucker : Events.Script
  10.     {
  11.         public Checkpoint TruckLoadingCheck = null;
  12.         public Checkpoint TruckDeliverCheck = null;
  13.         public Blip truckingBlip = null;
  14.  
  15.         public Trucker()
  16.         {
  17.             Events.Add("startTrucking", StartTruckingEvent);
  18.             Events.Add("deliverGoods", DeliverGoodsEvent);
  19.             Events.Add("attachTrailer", AttachTrailerEvent);
  20.  
  21.             Events.OnPlayerEnterCheckpoint += OnPlayerEnterCheckpoint;
  22.         }
  23.  
  24.         private void AttachTrailerEvent(object[] args)
  25.         {
  26.             Vehicle vehicle = (Vehicle)args[0];
  27.             Vehicle trailer = (Vehicle)args[1];
  28.  
  29.             RAGE.Game.Vehicle.AttachVehicleToTrailer(vehicle.Id, trailer.Id, 10.0f);
  30.         }
  31.  
  32.         private void DeliverGoodsEvent(object[] args)
  33.         {
  34.             Vector3 pos = (Vector3)args[0];
  35.             uint checkpointType = Convert.ToUInt32(args[1]);
  36.  
  37.             float distance = Pathfind.CalculateTravelDistanceBetweenPoints(TruckLoadingCheck.Position.X, TruckLoadingCheck.Position.Y, TruckLoadingCheck.Position.Z, pos.X, pos.Y, pos.Z);
  38.  
  39.             DeleteCheck(TruckLoadingCheck);
  40.  
  41.             Events.CallRemote("setDistance", distance);
  42.  
  43.             if (truckingBlip == null)
  44.             {
  45.                 truckingBlip = new Blip(1, pos, string.Empty, 1, 1);    
  46.             }
  47.             else
  48.             {
  49.                 truckingBlip.Position = pos;
  50.             }
  51.             truckingBlip.SetRoute(true);
  52.             TruckDeliverCheck = new Checkpoint(checkpointType, pos, 4.0f, new Vector3(), new RGBA(150, 150, 0, 200));
  53.         }
  54.  
  55.         private void StartTruckingEvent(object[] args)
  56.         {
  57.             Vector3 checkpoint = (Vector3)args[0];
  58.             uint checkpointType = Convert.ToUInt32(args[1]);
  59.             truckingBlip = new Blip(1, checkpoint, string.Empty, 1, 5);
  60.             TruckLoadingCheck = new Checkpoint(checkpointType, checkpoint, 4.0f, new Vector3(), new RGBA(150, 150, 0, 200));
  61.             RAGE.Ui.Console.Log(RAGE.Ui.ConsoleVerbosity.Info, $"Checkpoint ID: {TruckLoadingCheck.Id}, {TruckLoadingCheck.IsNull}, {TruckLoadingCheck.Position}");
  62.             truckingBlip.SetRoute(true);    
  63.         }
  64.  
  65.         private void DeleteCheck(Checkpoint check)
  66.         {
  67.             check.Destroy();
  68.             truckingBlip.Destroy();
  69.         }
  70.  
  71.         private void ClearTrucking()
  72.         {
  73.             TruckDeliverCheck = null;
  74.             TruckLoadingCheck = null;
  75.             truckingBlip = null;
  76.         }
  77.  
  78.         private void OnPlayerEnterCheckpoint(Checkpoint checkpoint, Events.CancelEventArgs cancel)
  79.         {
  80.             Chat.Output($"Entered Checkpoint {checkpoint.Handle} {checkpoint.Id}");
  81.            
  82.             if (checkpoint == TruckLoadingCheck)
  83.             {
  84.                 Events.CallRemote("truckingLoad");
  85.             }
  86.             if(checkpoint == TruckDeliverCheck)
  87.             {
  88.                 Events.CallRemote("deliverLoad");
  89.                 DeleteCheck(checkpoint);
  90.                 ClearTrucking();    
  91.             }
  92.         }
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment