I get an NRE error.Code:private Timer[] PlayerTimer;void OnPlayerInit(BasePlayer player) { PlayerTimer[player.userID] = timer.Repeat(60*10, 0, () = > { PrintToChat(player, "Test"); } }
How to properlycreate a variable?
Solved Timer variable for players (C#)
Discussion in 'Rust Development' started by SwipoStyle, Aug 20, 2015.
-
private Timer[] PlayerTimer = new Timer[size of array];
Also you can use a List<Timer> timers = new List<Timer>(); and then timers.Add(your timer); -
Code:IndexOutOfRangeException: Array index is out of range.
-
PlayerTimer is zero-sized array.
And you're passing userID (Steam ID) to array indexer.
You need a dictionary here.