ID:155007
 
Hello, I'm trying to make a list where I add & save keys. But what I want is that after a ammount of time the key gets automatic removed from the list. But I have no clue how to.
I checked the DM reference since I never had to remove something from a list. I found out that -= can be used, hope this helps.
var/list/V = new/list()
mob/proc
Addtolist()
V.Add(src)
sleep(50)
V-=src



In response to Avainer1
The thing is..It must still check the list when the player is offline or when the world reboots. And btw I think its
V.Remove(src)
=p
In response to TheProductions
TheProductions wrote:
The thing is..It must still check the list when the player is offline or when the world reboots. And btw I think its
V.Remove(src)
=p

Remove works too. Also, list update even if he leaves.

If you wana save the list use Write()
In response to TheProductions
TheProductions wrote:
The thing is..It must still check the list when the player is offline or when the world reboots. And btw I think its
V.Remove(src)
=p

Actually I think both work.


Also when you add something to the list, you can have a proc that loops through the contents of the list and adds +1 to a time variable each time, and check to see if they exceed a time limit. If so, just remove them from the list.

This should also work if they are not online, as long as their name is part of the list and the proc is still running and the world is as well.

I'll try to maybe make an example but I can't do that at the library!