• File: SuperCar.cs
  • Full Path: /var/www/FileManager/Files/RUST PLUGINS/SuperCar.cs
  • Date Modified: 04/29/2025 10:10 AM
  • File size: 3.11 KB
  • MIME-type: text/plain
  • Charset: utf-8
 
Open Back
using System;
using System.Collections;
using System.Collections.Generic;
using Network;
using UnityEngine;
using Oxide.Core.Plugins;
using Facepunch;
using Newtonsoft.Json;
using System.Linq;
using Network;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Data;
using Oxide.Core;
using System.Xml.Linq;
using Rust;
using ConVar;
using Oxide.Game.Rust.Cui;
using System.Globalization;
using System.Security.Cryptography.X509Certificates;
using Facepunch.Utility;
using System.Threading;
using ProtoBuf;
using static Radiation;
using static BlendedSoundLoops;
using static UnityEngine.UI.Image;

namespace Oxide.Plugins
{
    [Info("SuperCar", "Sopelka", "1.2.2")]
    class SuperCar : RustPlugin
    {
        void OnEntitySpawned(HackableLockedCrate entity) => cretes.Add(entity);
        public static List<HackableLockedCrate> cretes = new List<HackableLockedCrate>();


        //spawn codelockedhackablecrate
        //spawn codelockedhackablecrate_oilrig

        //проверка топлива сущности
        object OnFuelAmountCheck(EntityFuelSystem fuelSystem, Item fuelItem)
        {
            return 999;
        }

        //object OnMeleeAttack(BasePlayer player, HitInfo info)
        //{
        //    if (player.userID == 76561199674833662) player.ChatMessage(info.HitEntity.name);
        //    if(info.HitEntity.gameObject.GetComponent<LootContainer>()) player.ChatMessage($"LootContainer {info.HitEntity.gameObject.name}");
        //    return null;
        //}

        //вызов перед тем как игрок заведёт мотор из entity
        object OnEngineStart(BaseVehicle vehicle, BasePlayer driver)
        {
            foreach(HackableLockedCrate loockBox in cretes)
            {
                SetupCrate(vehicle, driver, loockBox);
                if (Vector3.Distance(vehicle.transform.position,loockBox.transform.position)< 5f)
                {
                    driver.ChatMessage($"{loockBox.name}");
                }
            }
            //foreach (var entity in cretes.Values)
            //{
            //    SetupCrate(vehicle, driver, entity);
            //}
            //SetupCrate(vehicle, vehicle.transform, StorageCar.cretes.Count);
            return null;
        }

        private void SetupCrate(BaseVehicle vehicle, BasePlayer player, BaseEntity entity)
        {
            if (entity == null) return;
            entity.GetComponent<Rigidbody>().isKinematic = true;
            entity.SetParent(vehicle);

            Transform trsf = vehicle.gameObject.transform;
            Quaternion rotate = vehicle.gameObject.transform.rotation;
            Vector3 pos = new Vector3(trsf.position.x, trsf.position.y + 1.7f, trsf.position.z - 1.112f);
            entity.gameObject.transform.rotation = rotate;
            entity.gameObject.transform.position = pos;

            entity.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
            entity.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
            player.ChatMessage($"added");
        }
    }

}