n
n
CC#
Created by n on 5/27/2024 in #help
Weird error to do with index out of range
hello, I'm getting this error:
[2024-05-27 15:36:55.317 +01:00] [STDOUT] ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
[2024-05-27 15:36:55.317 +01:00] [STDOUT] Parameter name: index
[2024-05-27 15:36:55.317 +01:00] [STDOUT] at System.Collections.Generic.List`1[T].get_Item (System.Int32 index) [0x00009] in <75633565436c42f0a6426b33f0132ade>:0
[2024-05-27 15:36:55.317 +01:00] [STDOUT] at AutoEvents.Controllers.EventVoteController..ctor () [0x00071] in <fa39906863294009a46013076a8f031d>:0
[2024-05-27 15:36:55.318 +01:00] [STDOUT] at AutoEvents.Controllers.CooldownController.StartEventVoting () [0x00021] in <fa39906863294009a46013076a8f031d>:0
[2024-05-27 15:36:55.318 +01:00] [STDOUT] at AutoEvents.Controllers.CooldownController+<AutoEvent>d__12.MoveNext () [0x00026] in <fa39906863294009a46013076a8f031d>:0
[2024-05-27 15:36:55.318 +01:00] [STDOUT] at MEC.Timing.RunCoroutineInternal (System.Collections.Generic.IEnumerator`1[T] coroutine, MEC.Segment segment, System.Int32 layer, System.Boolean layerHasValue, System.String tag, MEC.CoroutineHandle handle, System.Boolean prewarm) [0x001ce] in <e63b8eeff6444254a9bdd1e0f405d7a6>:0
[2024-05-27 15:36:55.318 +01:00] [STDOUT] UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
[2024-05-27 15:36:55.318 +01:00] [STDOUT] UnityEngine.DebugLogHandler:LogException(Exception, Object)
[2024-05-27 15:36:55.318 +01:00] [STDOUT] UnityEngine.Logger:LogException(Exception, Object)
[2024-05-27 15:36:55.318 +01:00] [STDOUT] UnityEngine.Debug:LogException(Exception)
[2024-05-27 15:36:55.319 +01:00] [STDOUT] MEC.Timing:RunCoroutineInternal(IEnumerator`1, Segment, Int32, Boolean, String, CoroutineHandle, Boolean)
[2024-05-27 15:36:55.319 +01:00] [STDOUT] MEC.Timing:RunCoroutine(IEnumerator`1, String)
[2024-05-27 15:36:55.319 +01:00] [STDOUT] AutoEvents.Controllers.CooldownController:OnWaitingForPlayers()
[2024-05-27 15:36:55.319 +01:00] [STDOUT] Exiled.Events.Features.Event:InvokeNormal()
[2024-05-27 15:36:55.319 +01:00] [STDOUT] Exiled.Events.Features.Event:InvokeSafely()
[2024-05-27 15:36:55.319 +01:00] [STDOUT] Exiled.Events.Handlers.Server:OnWaitingForPlayers()
[2024-05-27 15:36:55.320 +01:00] [STDOUT] MEC.<_DelayedCall>d__310:MoveNext()
[2024-05-27 15:36:55.320 +01:00] [STDOUT] MEC.Timing:Update()
[2024-05-27 15:36:55.317 +01:00] [STDOUT] ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
[2024-05-27 15:36:55.317 +01:00] [STDOUT] Parameter name: index
[2024-05-27 15:36:55.317 +01:00] [STDOUT] at System.Collections.Generic.List`1[T].get_Item (System.Int32 index) [0x00009] in <75633565436c42f0a6426b33f0132ade>:0
[2024-05-27 15:36:55.317 +01:00] [STDOUT] at AutoEvents.Controllers.EventVoteController..ctor () [0x00071] in <fa39906863294009a46013076a8f031d>:0
[2024-05-27 15:36:55.318 +01:00] [STDOUT] at AutoEvents.Controllers.CooldownController.StartEventVoting () [0x00021] in <fa39906863294009a46013076a8f031d>:0
[2024-05-27 15:36:55.318 +01:00] [STDOUT] at AutoEvents.Controllers.CooldownController+<AutoEvent>d__12.MoveNext () [0x00026] in <fa39906863294009a46013076a8f031d>:0
[2024-05-27 15:36:55.318 +01:00] [STDOUT] at MEC.Timing.RunCoroutineInternal (System.Collections.Generic.IEnumerator`1[T] coroutine, MEC.Segment segment, System.Int32 layer, System.Boolean layerHasValue, System.String tag, MEC.CoroutineHandle handle, System.Boolean prewarm) [0x001ce] in <e63b8eeff6444254a9bdd1e0f405d7a6>:0
[2024-05-27 15:36:55.318 +01:00] [STDOUT] UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
[2024-05-27 15:36:55.318 +01:00] [STDOUT] UnityEngine.DebugLogHandler:LogException(Exception, Object)
[2024-05-27 15:36:55.318 +01:00] [STDOUT] UnityEngine.Logger:LogException(Exception, Object)
[2024-05-27 15:36:55.318 +01:00] [STDOUT] UnityEngine.Debug:LogException(Exception)
[2024-05-27 15:36:55.319 +01:00] [STDOUT] MEC.Timing:RunCoroutineInternal(IEnumerator`1, Segment, Int32, Boolean, String, CoroutineHandle, Boolean)
[2024-05-27 15:36:55.319 +01:00] [STDOUT] MEC.Timing:RunCoroutine(IEnumerator`1, String)
[2024-05-27 15:36:55.319 +01:00] [STDOUT] AutoEvents.Controllers.CooldownController:OnWaitingForPlayers()
[2024-05-27 15:36:55.319 +01:00] [STDOUT] Exiled.Events.Features.Event:InvokeNormal()
[2024-05-27 15:36:55.319 +01:00] [STDOUT] Exiled.Events.Features.Event:InvokeSafely()
[2024-05-27 15:36:55.319 +01:00] [STDOUT] Exiled.Events.Handlers.Server:OnWaitingForPlayers()
[2024-05-27 15:36:55.320 +01:00] [STDOUT] MEC.<_DelayedCall>d__310:MoveNext()
[2024-05-27 15:36:55.320 +01:00] [STDOUT] MEC.Timing:Update()
In this area of code:
c#
public EventVoteController()
{
AutoEvents.isEventVoteRunning = true;

_killLoops = false;

_possibleEvents = new List<Event>(Event.Events);
_votingEvents = new List<VoteEvent>();
_cancelVotes = 0;

// initialise 3 random events
for (int i = 0; i < amountOfVotingEvents; i++)
{
Event eventPicked = _possibleEvents[Rand.Next(Event.Events.Count)];
_votingEvents.Add(new VoteEvent { Event = eventPicked, Votes = 0 });
_possibleEvents.Remove(eventPicked);
}

Map.ClearBroadcasts();
Round.IsLobbyLocked = true;
_coroutines.Add(Timing.RunCoroutine(ShowEventName(), "Show Event Name"));
_coroutines.Add(Timing.RunCoroutine(WaitToCheckVotes(), "Wait Check Votes"));
}
c#
public EventVoteController()
{
AutoEvents.isEventVoteRunning = true;

_killLoops = false;

_possibleEvents = new List<Event>(Event.Events);
_votingEvents = new List<VoteEvent>();
_cancelVotes = 0;

// initialise 3 random events
for (int i = 0; i < amountOfVotingEvents; i++)
{
Event eventPicked = _possibleEvents[Rand.Next(Event.Events.Count)];
_votingEvents.Add(new VoteEvent { Event = eventPicked, Votes = 0 });
_possibleEvents.Remove(eventPicked);
}

Map.ClearBroadcasts();
Round.IsLobbyLocked = true;
_coroutines.Add(Timing.RunCoroutine(ShowEventName(), "Show Event Name"));
_coroutines.Add(Timing.RunCoroutine(WaitToCheckVotes(), "Wait Check Votes"));
}
Does anyone see what might be wrong with what I'm doing with indexes? I'm not sure, I've been staring at this for ages and cannot figure it out
14 replies
CC#
Created by n on 1/16/2024 in #help
First time using delegates/lambda expressions
No description
33 replies