ID:263358
 
Code:
var/list/IPsentered=list()
var/list/keysentered=list()
var/contestants=0

mob/proc/Entercontest()
if(src.client.address in IPsentered)
src << "You've already entered another key!"
else
IPsentered+="[src.client.address]"
keysentered+="[src.key]"
src<<"Key recorded."
contestants+=1
src << "You are contestant [contestants]."
src << "Note: You do not need to stay logged in to win."

mob/Admin/verb/Pick_Winner()
var/winner=pick(keysentered)
world << "And the winner is..."
src << sound("drumroll.wav")
sleep(47.7)
world << "[winner]!"


Problem description:
Everytime it picks from the list, it always returns all the keys combined.

For the record, I do not THINK you need to put "[..]" for src.key and src.client.address as they should return as a text value anyways (very minor pointout).

I do not see anything wrong in the snippet you provided, is there a save/load system for that list or something similar which may be reverting the list from a list value to a string value?

Also: "src << sound("drumroll.wav")" do you mean that to be world<< ? BTW, try converting that .wav to .ogg if you want to reduce RSC space >_>

- GhostAnime
In response to GhostAnime
Thanks for the tips, and yes, there is a save/load system for the lists. Is there any way I could load them properly?
In response to Eternal_Dread
Well, after loading the list, make sure that the list is NOT a null value, which generally happens as the loading comes before saving at first and the usual value is null rahter than what you have defined, so:
Savefile["List"]>>List//er, this is when you load the value into the list
if(!List)List=list()//checks if List is a FALSE value. If so, it defaults that value to list() rather than leaving it as a null


- GhostAnime
In response to GhostAnime
I already have a system that checks if there is a savefile. The problem is that when it picks from the list, it appears as something like this:"Eternal_DreadEternal_Dread".
In response to Eternal_Dread
What I mean to say is check the VALUE of the VARIABLE in which the SAVED VALUE is LOADED into... (notice the second line in the snippet I posted, that is the important line).

Think about it: If you have a save/load system, which is activated first, the saving or the loading?

The loading obviously otherwise the saving will always overwrite whatever value you were suppose to have with the default value.

Now, if you load the variable, what would be the very first value of the loaded variable? Simple, it'll be 'null' since the values were not saved yet.

Hence the second like in the snippet I posted, it evaluated the variable which has been loaded. It was checking if it was a FALSE value [which usually is null by the loading system for the stated reason], and if it was null, it would reforce the variable with the value of "list()" rather than the value "null".

When you add a string to a null value'd variable, it'll just add the string together (as how it happened with you).

Err hope you understood that rant >_>

- GhostAnime
In response to GhostAnime
I did before you said it...

I already have a system that checks if there is a savefile. If there is, it loads. Otherwise, not.
In response to Eternal_Dread
Every well than, show us your loading part of the lists.

- GhostAnime
In response to GhostAnime
proc/Loadlists()
var/savefile/F=new("lists.sav")
if(F)
F["IPsentered"] >> IPsentered
F["keysentered"] >> keysentered
F["contestants"] >> contestants
In response to Eternal_Dread
Reread my posts VERY carefully, you are assume about something else.... the problem is that the VALUE of the VARIABLE AFTER LOADING is null by default, force it to be a list().

Also, read the comments made.

If you do not believe me, add this after the snippet you showed (I'll add it in so you know where):
    if(F)
F["IPsentered"] >> IPsentered//When the loading occurs before the variable was first saved, it'll be set as 'null' and NOT the default variable you had specified, which should be =list()
F["keysentered"] >> keysentered
F["contestants"] >> contestants
//Now add this after all the if(F) stuff:
if(!IPsentered)IPsentered=list()//Checks if the VARIABLE has a FALSE VALUE. If so, it forces the variable to have the VALUE =list() ... precautions as what is happening to you is due to the lack of this safety check - that being the value is =null rather than =list()
if(!keysentered)keysentered=list()
if(!contestants)contestants=list()


- GhostAnime
In response to GhostAnime
Okay, but, when the game announces the winner, it still says this:"Eternal_DreadEternal_DreadEternal_DreadEternal_DreadEt ernal_Dread"
In response to Eternal_Dread
Try deleating your previous saved file before actually testing something new in the save/load system(s) incase the variable you have been testing has been saved before (which is in the current case - remember, we were checking for FALSE values but if it already had that string problem saved, it is a TRUE variable as it is neither a 0, FALSE, null or an empty string)

- GhostAnime
In response to GhostAnime
Thanks, it works now.
In response to Eternal_Dread
No problem, just remember to use safety checks whenever possible. If something goes wrong, ask yourself: Why does it do this rather than that? Evntually you'll find out the problem and can resolve it.

- GhostAnime