How to do it by looping through the sleeper list? I tried
But it just crashes the plugin.Code:for (var p = 0; p < BasePlayer.sleepingPlayerList.Count; p++) { BasePlayer player = BasePlayer.sleepingPlayerList[p]; player.Hurt(1000,Rust.DamageType.Suicide,null); }
Killing all sleepers on the server
Discussion in 'Rust Development' started by ThunderZ, Jun 24, 2016.
-
Wulf Community Admin
player.Die()
-
Is there a list of these functions? I don't see them in the API Docs.
-
Wulf Community Admin
It's not from Oxide, it's from Rust. You'd need to use JustDecompile or another decompiler to view most of it. -
Hm it's still crashing regardless.
I'm probably doing this wrong but i'm getting this error:
Code:05:28 [Info] NukeTown was compiled successfully in 2111ms 05:28 [Info] Loaded plugin NukeTown v1.0.0 by Delusion 05:28 [Error] Failed to run a 1.00 timer in 'NukeTown v1.0.0' (InvalidOperationException: Collection was modified; enumeration operation may not execute.) 05:28 [Debug] at System.Collections.Generic.List`1+Enumerator[BasePlayer].VerifyState () [0x00000] in <filename unknown>:0 at System.Collections.Generic.List`1+Enumerator[BasePlayer].MoveNext () [0x00000] in <filename unknown>:0 at Oxide.Plugins.NukeTown.<Init>m__0 () [0x00000] in <filename unknown>:0 at Oxide.Core.Libraries.Timer+TimerInstance.FireCallback () [0x00000] in <filename unknown>:0
is the code running im thinking i shouldnt be using timer repeat? is whats causing it?
[DOUBLEPOST=1466746249][/DOUBLEPOST]Nevermind i forgot to remove a piece of code lol lemme try that derp.Code:timer.Repeat(1f, 0, () => { if(currTick == maxTick-5){ rust.BroadcastChat(string.Format("[NukeTown] Switching to {0} in 5.", nextMap),null,null); } if(currTick == maxTick-4){ rust.BroadcastChat(string.Format("[NukeTown] Switching to {0} in 4.", nextMap),null,null); } if(currTick == maxTick-3){ rust.BroadcastChat(string.Format("[NukeTown] Switching to {0} in 3.", nextMap),null,null); } if(currTick == maxTick-2){ rust.BroadcastChat(string.Format("[NukeTown] Switching to {0} in 2.", nextMap),null,null); } if(currTick == maxTick-1){ rust.BroadcastChat(string.Format("[NukeTown] Switching to {0} in 1.", nextMap),null,null); } if(currTick == minute*3){ rust.BroadcastChat(string.Format("[NukeTown] 5 Minutes left.", nextMap),null,null); } if(currTick == minute*5){ rust.BroadcastChat(string.Format("[NukeTown] 3 Minutes left.", nextMap),null,null); } if(currTick == minute*7){ rust.BroadcastChat(string.Format("[NukeTown] 1 Minute left.", nextMap),null,null); } if(currTick > maxTick){ rust.BroadcastChat(string.Format("[NukeTown] Switching to {0}.", nextMap),null,null); foreach (var sleeper in BasePlayer.sleepingPlayerList){ sleeper.Hurt(1000,Rust.DamageType.Suicide,null); } relocatePlayers(nextMap); if(nextMap == "Powerplant"){ spawnsname = "Powerplant"; nextMap = "Satellite"; } else if(nextMap == "Satellite"){ spawnsname = "Satellite"; nextMap = "Water Treatment"; } else if(nextMap == "Water Treatment"){ spawnsname = "Water Treatment"; nextMap = "Powerplant"; } currTick = 0; } rust.BroadcastChat(string.Format("{0} {1} {3}/{2}", currTick, maxTick, nextMap, spawnsname),null,null); currTick++; }); -
You already got your question resolved so this is a bit unrelated and you don't have to answer but i'm curious why do you want to kill all sleepers? Is your server unique in its purpose or what?
