proc/Found_Most(var/list/L)
if(!L||!L.len) return
var/list/found=list()
var/mostfound=1
var/foundmost=L[1]
for(var/v in L)
found[v]++ //This line has the error
if(found[v]>mostfound)
mostfound=v
foundmost=found[v]
return foundmost
I marked the line that has this runtime error:
runtime error: list index out of bounds
proc name: Found Most (/proc/Found_Most)
source file: Years.dm,111
Help is appreciated thanks.
I didn't make this proc and don't fully understand what it does, so I can't fix it.
And if that is not the problem, here is an example of how I used it:
mob/proc/Spawn_Check()
var/list/Zs=new
for(var/mob/P)
Zs+=P.z
var/Spawn_Z=Found_Most(Zs)
It checks what z plane of the map all the players are on, adds their z variable to a list. Then Found_Most() is supposed to return the z plane that has the most players.
found is an empty list, so trying to access something in nothing, logically won't work.