ID:170761
 
Ok I got my login to create random jobs and make me the captain when I login but when I exit and relog and continue with a old character it does the random job generator instead of making my usr.job = "Captain".

Here is the coding.
mob
var
tiltle
Login()
ppl += 1
alert("Welcome to [world.name]!")
switch(input("What do you want to do?")in list("Make new character", "Continue with old character", "Quit"))
if("Quit")
del(usr)
if("Make new character")
switch(input("Are you sure? If you have an old character, it will be erased.")in list("Continue", "Go Back"))
if("Go Back")
return ..()
if("Continue")
usr.name = input("Name?")as text
if(usr.key == "Fraon2")
usr.icon = 'Fraon.dmi'
else
usr.icon = 'Characters.dmi'
switch(input("What type of hair do you want?","Hair")in list("Short Black","Short Blonde","Long Black","Long Blonde","Spikey Black","Spikey Blonde","Go back"))
if("Short Black")
usr.overlays+='Hair.dmi'
if("Short Blonde")
usr.overlays+='bh.dmi'
if("Long Black")
usr.overlays+='lh.dmi'
if("Long Blonde")
usr.overlays+='lb.dmi'
if("Spikey Black")
usr.overlays+='spiky.dmi'
if("Spikey Blonde")
usr.overlays+='bs.dmi'
if("Go back")
return(0)
usr.loc = locate(2,2,2)
usr.GMcheck()
usr << "<B> <I> <font color = yellow> Welcome please dont spam and have a good time"
world << "<font color = blue>**<font color = red>[usr], [usr.key] has logged in<font color = blue>**"
var/savefile/F = new(ckey)
Write(F)
if("Continue with old character")
var/savefile/F = new("Players Save/[usr.key]")
Read(F)
src.loc=locate(usr.lx,usr.ly,usr.lz)
src.job = src.lj
usr.GMcheck()
usr << "<B> <I> <font color = yellow> Welcome please dont spam and have a good time"
world << "<font color = blue>**<font color = red>[usr], [usr.key] has logged in<font color = blue>**"



Logout()
ppl -= 1
var/savefile/F = new("Players Save/[usr.key]")
usr.lx=usr.x
usr.ly=usr.y
usr.lz=usr.z
usr.lj=usr.job
var/ckey = ckey(src.name)
F[ckey] << src.ckey
Write(F)
world << "[usr] has logged out"
del(src)



mob/Login()
..()
var/list/jobs = list("Worker","Engineer","Special Forces") //a list of all possible jobs
var/myjob = pick(jobs) //pick a random job from the list of possible jobs
src.job = myjob //set the job
if(usr.key == "Chwgt")
if(usr.ca == 0)
usr.ca = 1
usr.job = "Captian"
usr.contents+=new/obj/Items/Captain_wings
usr.contents+=new/obj/Items/Captain_Suit
usr.suffix = "Owner/Coder"
if(usr.ca == 1)
usr.contents-=new/obj/Items/Captain_wings
usr.contents-=new/obj/Items/Captain_Suit
if(usr.job == "Worker")
if(usr.shirt == 0)
usr.contents+=new/obj/Items/Worker_Suit
usr.contents+=new/obj/Items/Lounge_Suit
usr.shirt = 1
if(usr.shirt == 1)
usr.contents-=new/obj/Items/Worker_Suit
usr.contents-=new/obj/Items/Lounge_Suit
return
if(usr.job == "Engineer")
if(usr.en == 0)
usr.en = 1
usr.contents+=new/obj/Items/Engineer_Suit
if(usr.en == 1)
usr.contents-=new/obj/Items/Engineer_Suit
return
if(usr.job == "Special Forces")
if(usr.sf == 0)
usr.sf = 1
usr.contents+=new/obj/Items/Special_Force_Gear
usr.verbs+=typesof(/mob/Special_Forces/verb)
if(usr.sf == 1)
usr.contents-=new/obj/Items/Special_Force_Gear
if(usr.key == "Chwgt")
if(usr.ca == 0)
usr.ca = 1
usr.job = "Captian"
usr.contents+=new/obj/Items/Captain_wings
usr.contents+=new/obj/Items/Captain_Suit
usr.suffix = "Owner/Coder"
if(usr.ca == 1)
usr.contents-=new/obj/Items/Captain_wings
usr.contents-=new/obj/Items/Captain_Suit



If you can help, thanks, if not thanks for reading this. =/
Bump!
In response to Chwgt
Wait 24 hours to bump, if it's not on the front page...
In response to Hell Ramen
Ok, but anyway here is my newest problem. When they login now it doesn't randomize the job for them.... but it gives me my job and saves it... Here is teh code
mob/proc/Jobs()
..()
var/list/jobs = list("Worker","Engineer","Special Forces") //a list of all possible jobs
var/myjob = pick(jobs) //pick a random job from the list of possible jobs
var/savefile/F = new("Players Save/[ckey]")
src.job = myjob //set the job
if(usr.key == "Chwgt")
if(usr.ca == 0)
usr.ca = 1
usr.job = "Captian"
usr.contents+=new/obj/Items/Captain_wings
usr.contents+=new/obj/Items/Captain_Suit
usr.suffix = "Owner/Coder"
if(usr.ca == 1)
usr.contents-=new/obj/Items/Captain_wings
usr.contents-=new/obj/Items/Captain_Suit
if(usr.job == "Worker")
if(usr.shirt == 0)
usr.contents+=new/obj/Items/Worker_Suit
usr.contents+=new/obj/Items/Lounge_Suit
usr.shirt = 1
if(usr.shirt == 1)
usr.contents-=new/obj/Items/Worker_Suit
usr.contents-=new/obj/Items/Lounge_Suit
return
if(usr.job == "Engineer")
if(usr.en == 0)
usr.en = 1
usr.contents+=new/obj/Items/Engineer_Suit
if(usr.en == 1)
usr.contents-=new/obj/Items/Engineer_Suit
return
if(usr.job == "Special Forces")
if(usr.sf == 0)
usr.sf = 1
usr.contents+=new/obj/Items/Special_Force_Gear
usr.verbs+=typesof(/mob/Special_Forces/verb)
if(usr.sf == 1)
usr.contents-=new/obj/Items/Special_Force_Gear
Write(F)


Any ideas whats wrong?
In response to Chwgt
Sort of. You should be using else. But, that's my only guess. =/
[Edit] No put usr in proc. Ungh. ~ Lummox JR
In response to Hell Ramen
Also, most people recommend you use if(ThisOrThat) instead of if(ThisOrThat == 1), as well as if(!ThisOrThat) instead of if(ThisOrThat == 0). Just going by what people tell me :P.
Besides the user abuse and the ==1 and ==0 problems previously mentioned, you've defined mob/Login() twice. Seems to me what you really need is a /mob/choosing_character type for the new arrivals, where you can define mob/choosing_character/Login() to handle the initial character choices (don't call ..() though), and then the second mob/Login() is probably the one to leave intact.

And even though usr is semi-okay in Login(), src is always correct, so use src. Whenever you use a character choice system that switches mobs, as I think you'll be doing soon, usr is no longer applicable.

Lummox JR