using Oxide.Core; using UnityEngine; namespace Oxide.Plugins { [Info("Road Respawn", "Toshik", "1.0.1")] public class RoadRespawn : RustPlugin { private object OnPlayerRespawn(BasePlayer player, BasePlayer.SpawnPoint spawnPoint) { Vector3 roadPosition = FindRandomRoadPosition(); if (roadPosition != Vector3.zero) { roadPosition.y += 3; spawnPoint.pos = roadPosition; spawnPoint.rot = Quaternion.identity; } else { } return null; } private Vector3 FindRandomRoadPosition() { var roads = TerrainMeta.Path.Roads; if (roads == null || roads.Count == 0) { Puts("Roads are not found on the map."); return Vector3.zero; } var randomRoad = roads[UnityEngine.Random.Range(0, roads.Count)]; if (randomRoad.Path == null || randomRoad.Path.Points == null || randomRoad.Path.Points.Length == 0) { Puts("No points were found on the road."); return Vector3.zero; } var randomPoint = randomRoad.Path.Points[UnityEngine.Random.Range(0, randomRoad.Path.Points.Length)]; return randomPoint; } } }