ID:159726
 
Ok, I'm using a list to add my leaders into one list, so when they log on, they get special stuff. But before I can add them. I wanna put a safety check, so none of the leaders get overwritten.

I try and check and see if anyone has the leader's title before I make them the leader.

for(var/mob/M in leaders)
if(leaders["[M.name]"] != "Star Captain")


But everytime I try and run it, nothing happens. So I don't know if I'm doing it wrong or what. Can I get some help?
You're most likely setting it wrong.

Also, this shouldn't affect it in any way but, name is a built-in text variable. You don't need to put it in quotes.
In response to Kaiochao
Kaiochao wrote:
You're most likely setting it wrong.

Also, this shouldn't affect it in any way but, name is a built-in text variable. You don't need to put it in quotes.

Seems like he was attempting to reference their name in the list, in which case he would be doing it somewhat correctly, but I don't think that's what he wants to be doing.
for(var/mob/M in leaders)
if(M.Rank != "Star Captain")

//or maybe this, not sure which you're going for lol

for(var/mob/M in world)
if(leaders[M.name] != "Star Captain")
In response to Falacy
var/list/L = list("Lundex"="Star Captain")

Like that..
In response to Falacy
I think it's just a safety check.
In response to Lundex
You mean var/list/leaders. Looks like what you have here would work perfectly.

Posting actual code would help.
And this belongs in Code Problems.
In response to Lundex
Lundex wrote:
var/list/L = list("Lundex"="Star Captain")



Then just do this
for(var/mob/M in world)
if(leaders[M.name] != "Star Captain")

Unless you're running this on Login() or in some other place where you already know which player you want to check it on.
then you could just do something like this
if(leaders[src.name] != "Star Captain")
In response to Kaiochao
Kaiochao wrote:
You mean var/list/leaders. Looks like what you have here would work perfectly.

What hes doing now is running a loop through all the mobs in leaders, and then checking if the rank of that mob's name (also in leaders) is Star Captain. Since there's not actually any mobs in the leaders list, it doesn't do anything.
In response to Falacy
Oh snap. He's looking through mobs, instead of the names.
Hehe, whoops.
Good call.