// Home: a perk for a group. Players with the permission home.use (the vip group, and admins) save a home with /sethome // and go back to it with /home: 10 seconds standing still, then a teleport, once every 15 minutes (admins: at once, // no wait). Everyone else is told the command is a VIP perk. Grant it to another group with rl_perm grant home.use. // Install: copy this file into the server's data folder, plugins/Home.cs. Settings: plugins/config/Home.json. // Script engine rules: test objects with != null, no static fields that change, callbacks with one parameter at most. using RustLegacy; public class HomeConfig { public float WarmupSeconds { get; set; } = 10f; public float CooldownMinutes { get; set; } = 15f; } public class HomeData { public Dictionary Homes { get; set; } = new Dictionary(); /// The vip group got home.use once: the server owner can take it back, it is not given again. public bool DefaultsGranted { get; set; } } public class Home : RustPlugin { HomeConfig _config; HomeData _data; /// SteamID → RealTime of the last teleport. readonly Dictionary _lastUse = new Dictionary(); public override void OnLoaded() { _config = LoadConfig(); _data = LoadData(); RegisterPermission( "home.use" ); if ( !_data.DefaultsGranted ) { CreateGroup( "vip" ); GrantPermission( "vip", "home.use" ); _data.DefaultsGranted = true; SaveData( _data ); } AddCommand( "sethome", OnSetHome, "Save your home here (VIP)" ); AddCommand( "home", OnHome, "Go back to your home (VIP)" ); } bool Allowed( RustPlayer p ) { if ( HasPermission( p.SteamId, "home.use" ) ) return true; Reply( p, "Homes are a VIP perk on this server." ); return false; } void OnSetHome( ChatCommand cmd ) { var p = cmd.Player; if ( !Allowed( p ) || p.IsDead ) return; _data.Homes[p.SteamId] = p.WorldPosition; SaveData( _data ); Reply( p, $"Home saved (map {MapCell( p.WorldPosition )}). /home to come back." ); } void OnHome( ChatCommand cmd ) { var p = cmd.Player; if ( !Allowed( p ) || p.IsDead ) return; if ( !_data.Homes.ContainsKey( p.SteamId ) ) { Reply( p, "No home yet: /sethome where you want it." ); return; } var admin = IsAdmin( p ); var since = _lastUse.ContainsKey( p.SteamId ) ? RealTime.Now - _lastUse[p.SteamId] : 1e9f; if ( !admin && since < _config.CooldownMinutes * 60f ) { Reply( p, $"/home again in {(int)((_config.CooldownMinutes * 60f - since) / 60f) + 1} min." ); return; } var home = _data.Homes[p.SteamId]; if ( admin ) { p.Teleport( home ); return; } var from = p.WorldPosition; Reply( p, $"Teleporting home in {_config.WarmupSeconds:0} s: don't move." ); After( _config.WarmupSeconds, () => Arrive( p, from, home ) ); } void Arrive( RustPlayer p, Vector3 from, Vector3 home ) { if ( p == null || !p.IsValid || p.IsDead ) return; if ( p.WorldPosition.Distance( from ) > 50f ) { Reply( p, "You moved: teleport cancelled." ); return; } _lastUse[p.SteamId] = RealTime.Now; p.Teleport( home ); Reply( p, "Welcome home." ); } }