Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- namespace Oxide.Plugins
- {
- [Info("MinicopterSeating", "Bazz3l", "1.0.8")]
- [Description("Allows 2 extra seats on the mini copter")]
- class MinicopterSeating : RustPlugin
- {
- /* void OnEntitySpawned(MiniCopter mini)
- {
- if (mini == null || mini.ShortPrefabName != "minicopter.entity") return;
- if (mini.mountPoints.Length < 4)
- mini?.gameObject.AddComponent<CopterSeating>();
- }*/
- void OnServerInitialized()
- {
- permission.RegisterPermission("minicopterseating.vip", this);
- }
- string EvilPenguins = "<color=#5e1bb1>E</color><color=#5329ce>v</color><color=#4247ef>i</color><color=#3a56ff>l</color> <color=#3a56ff>P</color><color=#3959ff>e</color><color=#3567ff>n</color><color=#307aff>g</color><color=#2995ff>u</color><color=#25a6ff>i</color><color=#22b2ff>n</color><color=#21b8ff>s</color>";
- public string ChairPrefab = "assets/prefabs/vehicle/seats/passengerchair.prefab";
- void OnEntityMounted(BaseMountable entity, BasePlayer player)
- {
- BaseEntity entityParent = entity.GetParentEntity();
- if (entityParent == null || entityParent.ShortPrefabName != "minicopter.entity") return;
- MiniCopter mini = (MiniCopter)entityParent;
- if (!permission.UserHasPermission(player.UserIDString, "minicopterseating.vip"))
- {
- if((mini.mountPoints.Length>2) && entity.ShortPrefabName=="miniheliseat")
- {
- RemoveSeats(mini, player);
- }
- return;
- }
- if (mini.mountPoints.Length < 4 && entity.ShortPrefabName== "miniheliseat")
- {
- player.ChatMessage(EvilPenguins+" - Created more seats on the minicopter because of VIP..");
- mini?.gameObject.AddComponent<CopterSeating>();
- }
- }
- public void RemoveSeats(BaseVehicle mini, BasePlayer player)
- {
- List<BaseEntity> foundSeats = new List<BaseEntity>();
- foreach (BaseEntity item in mini.children)
- {
- if (item.PrefabName == ChairPrefab)
- {
- foundSeats.Add(item);
- //item.Kill();
- }
- }
- foreach (BaseEntity seat in foundSeats)
- {
- seat.Kill();
- }
- Array.Resize(ref mini.mountPoints, 2);
- player.ChatMessage(EvilPenguins + " - Removed extra seats as you are not VIP. /vip to buy.");
- }
- class CopterSeating : MonoBehaviour
- {
- public string ChairPrefab = "assets/prefabs/vehicle/seats/passengerchair.prefab";
- public BaseVehicle mini;
- void Awake()
- {
- mini = GetComponent<BaseVehicle>();
- if (mini == null)
- {
- Destroy(this);
- return;
- }
- BaseVehicle.MountPointInfo pilot = mini.mountPoints[0];
- BaseVehicle.MountPointInfo passenger1 = mini.mountPoints[1];
- Array.Resize(ref mini.mountPoints, 4);
- BaseVehicle.MountPointInfo passenger2 = new BaseVehicle.MountPointInfo
- {
- pos = new Vector3(0.6f, 0.2f, -0.2f),
- rot = mini.mountPoints[1].rot,
- prefab = mini.mountPoints[1].prefab,
- mountable = mini.mountPoints[1].mountable,
- };
- BaseVehicle.MountPointInfo passenger3 = new BaseVehicle.MountPointInfo
- {
- pos = new Vector3(-0.6f, 0.2f, -0.2f),
- rot = mini.mountPoints[1].rot,
- prefab = mini.mountPoints[1].prefab,
- mountable = mini.mountPoints[1].mountable,
- };
- mini.mountPoints[0] = pilot;
- mini.mountPoints[1] = passenger1;
- mini.mountPoints[2] = passenger2;
- mini.mountPoints[3] = passenger3;
- MakeSeat(mini, new Vector3(0.6f, 0.2f, -0.5f));
- MakeSeat(mini, new Vector3(-0.6f, 0.2f, -0.5f));
- }
- void MakeSeat(BaseVehicle mini, Vector3 locPos)
- {
- BaseEntity seat = GameManager.server.CreateEntity(ChairPrefab, mini.transform.position) as BaseEntity;
- if (seat == null) return;
- seat.SetParent(mini);
- seat.Spawn();
- seat.transform.localPosition = locPos;
- seat.SendNetworkUpdateImmediate(true);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement