ID:2269583
 
Code: Random Login Screen Code
    src.client.view=12
src.random = rand(1,2)
if(src.random == 1)
src.loc = locate(9,9,6)
if(src.random == 2)
src.loc = locate(45,9,6)


Problem description: I like to make a few random login screens, is this the right way to go? I keep getting a warning that the if statement has no effect.

src.client.view=12
src.random = rand(1,2)
if(src.random == 1)
src.loc = locate(9,9,6)
if(src.random == 2)
src.loc = locate(45,9,6)

Code that runs when an if statement is true needs to be indented underneath it.

I'd also recommend you change your code to:

client.view = 12 //src. isn't needed when acting on src's variables
random = rand(1,2) //Do you only use this number here? if so it shouldn't be on src and should instead just be a local, var/random = rand(1,2)
switch(random) //the switch() statement lets you compare a value or var to several constant values
if(1) //this block only runs if random == 1
loc = locate(9,9,6)
if(2) //this block only runs if random == 2
loc = locate(45,9,6)

You need to indent your code.

if statement
SUCCESS
//END OR FAILURE


if statement
//SUCCESS
else
//FAILURE
//END


    client.view=12
var/rand = rand(1,2)
if(rand == 1)
loc = locate(9,9,6)
if(rand == 2)
loc = locate(45,9,6)


Also, there's another pattern that's useful in a situation where you have a single value with multiple outcomes: the switch statement.

    client.view=12
var/rand = rand(1,2)
switch(rand)
if(1)
loc = locate(9,9,6)
if(2)
loc = locate(45,9,6)
if(3)
loc = herp
if(4)
loc = derp



Or you could get rid of the logic flow statements completely:

    client.view=12
var/rand = rand(1,2)
loc = locate("titlescreen[rand]") || locate("titlescreen1")


Then in the map editor, you can edit the tag variable of each turf that acts as a title screen. When we use a text string in the locate() function, it will locate the object that's got a tag variable set to that value. This way, you can actually add titlescreens dynamically, you just need to update the number in this procedure.
Thanks for the help guys! I appreciate it!

I have made the following now and it works!

    var/randomlogin = rand(1,2)
if(randomlogin == 1)
loc = locate(9,9,6)
if(randomlogin == 2)
loc = locate(45,9,6)
To make it easier, why not tag those turfs in the map editor? That way you can look them up by tag and not have to worry about exact positions.