The title pretty much sums it up.
The ability to prevent (perhaps the owner or maybe the last person to provide LGF ) a Mining Quarry from working while offline.
kind regards, C-Block.
Rust Cease offline Quarry gather
Discussion in 'Plugin Requests' started by C-Block, Jul 5, 2016.
-
Code:
void OnPlayerDisconnected(BasePlayer player) { var quarries = GameObject.FindObjectsOfType<MiningQuarry>(); for(int i = 0; i < quarries.Count(); i++) { var quarry = quarries[i]; if (quarry == null || quarry.OwnerID == 0 || !quarry.IsEngineOn()) continue; if (quarry.OwnerID == player.OwnerID) { quarry.EngineSwitch(false); } } } void OnQuarryEnabled(MiningQuarry quarry) { if (quarry.OwnerID == 0) return; for(int i = 0; i < BasePlayer.sleepingPlayerList.Count; i++) { var player = BasePlayer.sleepingPlayerList[i]; if (player.IsConnected()) continue; if (player.userID == quarry.OwnerID) { NextTick(() => { quarry.EngineSwitch(false); }); break; } } }
The code for getting the quarries on disconnect is probably decently slow, but I didn't feel like posting a nearly full plugin using OnEntitySpawned/OnEntityDeath and a list/hashset. If someone else wants to expand on this code, go ahead. -
Thank you kidnly for the speedy reply - I shall endeavour to try do.... something... with this code. (script kiddy lol)
-
Just take a base template from the docs and paste the code in there, that's about all you have to do. I'd do it for you, but I'd have to submit it as a full plugin, since last I knew they weren't allowed to be posted here in code, and I don't really wanna make a full plugin for it, lol. -
Thank you kindly. I appreciate what you and all the other developers do for the community.