ID:262136
 
sry this is long


mob
Login()
players++
if(!src.client.address)
host=src.client
world.status="<b><font color= blue><font size = 1>[world.name] <font color= red><font size = 1>([version]) <font color= green><font size = 1>Host - [host], <font color= yellow><font size = 1>Players - [players]"
usr.loc = locate(7,7,2)
..()

mob
Logout()
players--
world << "<b><font color= blue><font size = 1>\[[world.name]]--> [usr.name] has logged out!"
del(src)
..()

mob
proc
CreateChar()
var/prompt_title = "Character Creation"
var/help_text = "Please choose a name and use capitals letters infront of your name, or else it'll put a 'The' infront of your name."
var/default_value = ""
var/char_name = input(usr, help_text, prompt_title, default_value) as null|text
if (!char_name)
usr.CreateChar()
return
switch(input("Which race shall you be?","race")in list("Human","Android","Saiyan","Changling","Namek"))
if("Human")
usr.MaxPL = rand(5,500)
usr.MaxKI = rand(1,50)
usr.strength = rand(1,10)
usr.Zenni = rand(100,1000)
usr.race="Human"
usr.SexChoose()
usr.HairChoose()
if("Android")
usr.MaxPL = rand(100,5000)
usr.MaxKI = rand(50,100)
usr.strength = rand(1,20)
usr.race="Android"
usr.SexChoose()
usr.HairChoose()
if("Saiyan")
usr.MaxPL = rand(5,1000)
usr.MaxKI = rand(5,100)
usr.strength = rand(1,50)
usr.race="Saiyan"
usr.SexChoose()
usr.HairChoose()
if("Changling")
usr.MaxPL = rand(1,300)
usr.MaxKI = rand(1,50)
usr.strength = rand(1,25)
usr.race="Changling"
usr.icon='Changling.dmi'
if("Namek")
usr.MaxPL = rand(1,20)
usr.MaxKI = rand(100,1000)
usr.strength = rand(1,5)
usr.race="Namek"
usr.icon='namek_base.dmi'
switch(alert("Would you like to fight for the good or the evil forces?","Alignment","good","evil"))
if("good")
usr.alignment = "Good"
if("evil")
usr.alignment = "Evil"
usr.name = char_name
alert("Character generation complete!")
usr.techniques += /obj/techniques/Ki_Blast
world << "<b><font color= blue><font size = 1>\[[world.name]]--> [usr.name] has logged in!"
usr.loc = locate(4,4,1)
usr.sight = 0
usr.SaveChar()
usr.SkillCheck()
usr.hair2(usr)
usr.checkpos(usr)
usr.Racecheck()
..()

SexChoose()
switch(input("Choose your skin color now.")in list("Male","Female"))
if("Male")
usr.icon = 'base_white.dmi'
usr.sex = "Male"
if("Female")
usr.icon = 'female_white.dmi'
usr.sex = "Female"


HairChoose()
if(usr.sex == "Male")
switch(input("What hair style do you want?", "Customization", text) in list (,"Vegeta","Goku","Bald","Short","Afro","Mohawk","Spikey","Trunks"))
if("Bald")
usr.overlays = ""
if("Vegeta")
usr.hair="Vegeta"
var/new_rgb = F_Color_Selector.Get_Color(usr)
var/icon/I = new('vegeta_bottom.dmi')
I.Blend(new_rgb)
var/icon/O = new('vegeta_top.dmi')
O.Blend(new_rgb)
usr.overlays = ""
usr.overlays += I
usr.rbg = O

if("Goku")
usr.hair="Goku"
var/new_rgb = F_Color_Selector.Get_Color(usr)
var/icon/I = new('goku_bottom.dmi')
I.Blend(new_rgb)
var/icon/O = new('goku_top.dmi')
O.Blend(new_rgb)
usr.overlays = ""
usr.overlays += I
usr.rbg = O

if("Short")
usr.hair="Short"
var/new_rgb = F_Color_Selector.Get_Color(usr)
var/icon/I = new('short_bottom.dmi')
I.Blend(new_rgb)
var/icon/O = new('short_top.dmi')
O.Blend(new_rgb)
usr.overlays = ""
usr.overlays += I
usr.rbg = O

if("Afro")
usr.hair="Afro"
var/new_rgb = F_Color_Selector.Get_Color(usr)
var/icon/I = new('afro_bottom.dmi')
I.Blend(new_rgb)
var/icon/O = new('afro_top.dmi')
O.Blend(new_rgb)
usr.overlays = ""
usr.overlays += I
usr.rbg = O

if("Mohawk")
usr.hair="Mohawk"
var/new_rgb = F_Color_Selector.Get_Color(usr)
var/icon/I = new('mohawk_bottom.dmi')
I.Blend(new_rgb)
var/icon/O = new('mohawk_top.dmi')
O.Blend(new_rgb)
usr.overlays = ""
usr.overlays += I
usr.rbg = O
if("Spikey")
usr.hair="Spikey"
var/new_rgb = F_Color_Selector.Get_Color(usr)
var/icon/I = new('spikey_bottom.dmi')
I.Blend(new_rgb)
var/icon/O = new('spikey_top.dmi')
O.Blend(new_rgb)
usr.overlays = ""
usr.overlays += I
usr.rbg = O

if("Trunks")
usr.hair="Trunks"
var/new_rgb = F_Color_Selector.Get_Color(usr)
var/icon/I = new('trunks_bottom.dmi')
I.Blend(new_rgb)
var/icon/O = new('trunks_top.dmi')
O.Blend(new_rgb)
usr.overlays = ""
usr.overlays += I
usr.rbg = O
else
switch(input("What hair style do you want?", "Customization", text) in list (,"Chichi","Long","Ponytail"))
if("Chichi")
usr.hair="Chichi"
var/new_rgb = F_Color_Selector.Get_Color(usr)
var/icon/I = new('chichi_bottom.dmi')
I.Blend(new_rgb)
var/icon/O = new('chichi_top.dmi')
O.Blend(new_rgb)
usr.overlays = ""
usr.overlays += I
usr.rbg = O

if("Ponytail")
usr.hair="Ponytail"
var/new_rgb = F_Color_Selector.Get_Color(usr)
var/icon/I = new('ponytail_bottom.dmi')
I.Blend(new_rgb)
var/icon/O = new('ponytail_top.dmi')
O.Blend(new_rgb)
usr.overlays = ""
usr.overlays += I
usr.rbg = O

if("Long")
usr.hair="Long"
var/new_rgb = F_Color_Selector.Get_Color(usr)
var/icon/I = new('long_bottom.dmi')
I.Blend(new_rgb)
var/icon/O = new('long_top.dmi')
O.Blend(new_rgb)
usr.overlays = ""
usr.overlays += I
usr.rbg = O

Racecheck()
if(usr.race=="Human" == 1)
usr.loc=locate(1,1,1)
alert("Welcome to Planet Earth!")
if(usr.race=="Android" == 1)
usr.loc=locate(1,1,1)
alert("Welcome to Planet Earth!")
if(usr.race=="Saiyan" == 1)
usr.loc=locate(1,1,1)
alert("Welcome to Planet Vegeta!")
if(usr.race=="Changling" == 1)
usr.loc=locate(1,1,1)
alert("Welcome to Planet Freiza")
if(usr.race=="Namek" == 1)
usr.loc=locate(1,1,1)
alert("Welcome to Planet Namek")

SaveChar()
var/savefile/F = new("players/[src.ckey].sav")
F["name"] << name
F["X"] << src.x
F["Y"] << src.y
F["Z"] << src.z
F["Mob"] << usr.client.mob

LoadCharacter()
var/savefile/F = new("players/[src.ckey].sav")
var/X
var/Y
var/Z
var/mob/newmob = new()
F["name"] >> name
F["X"] >> X
F["Y"] >> Y
F["Z"] >> Z
F["Mob"] >> newmob
newmob.loc = locate(X,Y,Z)
newmob.client = src.client
newmob.hairon = 0

turf/Character_Handling
Title
icon = 'splash.bmp'
NewChar
Click()
usr.sight = 1
if(fexists("players/[usr.ckey].sav"))
switch(alert("If you proceed with creating a new character your previous character will be erased. Do you wish to proceed?","[world.name]","Yes","No"))
if ("Yes")
alert("The new character creation process will commince now.")
usr.CreateChar()
return ..()
if ("No")
alert("You will now be disconnected please reconnect and choose \"LOAD GAME\"")
del(usr)
return ..()
else
usr.CreateChar()
return ..()
..()

LoadChar
Click()
if(fexists("players/[usr.ckey].sav"))
usr.LoadCharacter()
usr << "<b><font color= green><font size = 1>Welcome back [usr]"
usr.checkpos(usr)
usr.hair2(usr)
return ..()
else
alert("Sorry your data has not been found in our databases!")
return ..()
..()

Info
Click()
usr <<browse(info())


when i log in

runtime error: Failed to write variable client to savefile players/dranzersolo.sav. The value being written was Dranzer_Solo (/client).
proc name: SaveChar (/mob/proc/SaveChar)
usr: Dave (/mob)
src: Dave (/mob)
call stack:
Dave (/mob): SaveChar()
Dave (/mob): CreateChar()
NewChar (4,3,2) (/turf/Character_Handling/NewChar): Click
(NewChar (4,3,2) (/turf/Character_Handling/NewChar))

when i try to save

BYOND(341.877) Error: removal of locked savefile path '/.1'
BYOND(341.877) Error: removal of locked savefile path '/Mob/.1'
runtime error: Failed to write variable client to savefile players/dranzersolo.sav. The value being written was Dranzer_Solo (/client).
proc name: SaveChar (/mob/proc/SaveChar)
usr: Dave (/mob)
src: Dave (/mob)
call stack:
Dave (/mob): SaveChar()
Dave (/mob): Save()
Well, your main problem there is usr abuse. It's causing this runtime error.

No put usr in procs. Ungh.

Everywhere in that code where I see usr, right up until the /turf procs like Click(), it's replaceable with src. (atom/Click() doesn't quite count as a proc, even though it is one, because by default it's always called directly by client/Click().)

Likewise, anywhere you're using input() or alert() in those procs, you should send it to src instead of letting it default to usr. That'd be input(src,"Choose your race"), and so on. You might also want to attend to a copy/paste error in SexChoose(), where your input() box is actually asking for a skin color. I'd also suggest, for the sake of presentation, changing that one to an alert() since it's a simple either/or choice.

Finally, in HairChoose() you've got a lot of redundant code that you don't need to put inside each if() block. In particular this code can all run after the switch(), as long as you handle the "Bald" hair choice somewhere else:
I.Blend(new_rgb)
O.Blend(new_rgb)
overlays = "" // no put usr in proc!
overlays += I
rbg = O

To do that, first you'll have to define var/new_rgb, var/icon/I, and var/icon/O before the switch(). You don't have to set up those vars until later. You'd also do better to call the color selection in just one place, since that always has to be done except in the case of baldness. So your code could much more efficiently be changed to this:
// no idea why you have the sex var when you can use gender
var/list/hairchoices
if(gender=="male")
/*
each of your lists that were previously used for input() should
go in these if() and else blocks, with one exception: In each list
you had a leading comma that should NOT be there.

I also fixed the spelling of "Spiky".
*/

hairchoices = list("Vegeta","Goku","Bald","Short","Afro","Mohawk","Spiky","Trunks")
else
hairchoices = list("Chichi","Long","Ponytail")
var/hairstyle = input(src, "What hair style do you want?", "Customization") \
as null|anything in hairchoices

// handle Cancel button (from "as null|anything")
if(!hairstyle) return

// handle this special case here
if(hairstyle == "Bald")
overlays = list()
return

var/new_rgb = F_Color_Selector.Get_Color(src)
var/icon
I, O
switch(hairstyle)
/*
In this section all you need for each style are the lines that
load icons I and O. The blending and everything else is done later.
*/

...

// since baldness was handled above, assume I and O are valid
I.Blend(new_rgb)
O.Blend(new_rgb)
overlays = ""
overlays += I
rbg = O

Notice how much cleaner all this code is.

Lummox JR
In response to Lummox JR
thanks