Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using RAGE;
- using RAGE.Elements;
- using RAGE.Game;
- using System;
- using Vehicle = RAGE.Elements.Vehicle;
- namespace SouthValleyFive_Client.jobs
- {
- class Trucker : Events.Script
- {
- public Checkpoint TruckLoadingCheck = null;
- public Checkpoint TruckDeliverCheck = null;
- public Blip truckingBlip = null;
- public Trucker()
- {
- Events.Add("startTrucking", StartTruckingEvent);
- Events.Add("deliverGoods", DeliverGoodsEvent);
- Events.Add("attachTrailer", AttachTrailerEvent);
- Events.OnPlayerEnterCheckpoint += OnPlayerEnterCheckpoint;
- }
- private void AttachTrailerEvent(object[] args)
- {
- Vehicle vehicle = (Vehicle)args[0];
- Vehicle trailer = (Vehicle)args[1];
- RAGE.Game.Vehicle.AttachVehicleToTrailer(vehicle.Id, trailer.Id, 10.0f);
- }
- private void DeliverGoodsEvent(object[] args)
- {
- Vector3 pos = (Vector3)args[0];
- uint checkpointType = Convert.ToUInt32(args[1]);
- float distance = Pathfind.CalculateTravelDistanceBetweenPoints(TruckLoadingCheck.Position.X, TruckLoadingCheck.Position.Y, TruckLoadingCheck.Position.Z, pos.X, pos.Y, pos.Z);
- DeleteCheck(TruckLoadingCheck);
- Events.CallRemote("setDistance", distance);
- if (truckingBlip == null)
- {
- truckingBlip = new Blip(1, pos, string.Empty, 1, 1);
- }
- else
- {
- truckingBlip.Position = pos;
- }
- truckingBlip.SetRoute(true);
- TruckDeliverCheck = new Checkpoint(checkpointType, pos, 4.0f, new Vector3(), new RGBA(150, 150, 0, 200));
- }
- private void StartTruckingEvent(object[] args)
- {
- Vector3 checkpoint = (Vector3)args[0];
- uint checkpointType = Convert.ToUInt32(args[1]);
- truckingBlip = new Blip(1, checkpoint, string.Empty, 1, 5);
- TruckLoadingCheck = new Checkpoint(checkpointType, checkpoint, 4.0f, new Vector3(), new RGBA(150, 150, 0, 200));
- RAGE.Ui.Console.Log(RAGE.Ui.ConsoleVerbosity.Info, $"Checkpoint ID: {TruckLoadingCheck.Id}, {TruckLoadingCheck.IsNull}, {TruckLoadingCheck.Position}");
- truckingBlip.SetRoute(true);
- }
- private void DeleteCheck(Checkpoint check)
- {
- check.Destroy();
- truckingBlip.Destroy();
- }
- private void ClearTrucking()
- {
- TruckDeliverCheck = null;
- TruckLoadingCheck = null;
- truckingBlip = null;
- }
- private void OnPlayerEnterCheckpoint(Checkpoint checkpoint, Events.CancelEventArgs cancel)
- {
- Chat.Output($"Entered Checkpoint {checkpoint.Handle} {checkpoint.Id}");
- if (checkpoint == TruckLoadingCheck)
- {
- Events.CallRemote("truckingLoad");
- }
- if(checkpoint == TruckDeliverCheck)
- {
- Events.CallRemote("deliverLoad");
- DeleteCheck(checkpoint);
- ClearTrucking();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment