ID:145558
 
Code:
#include <deadron/characterhandling>
#include <dantom/htmllib>


client/base_num_characters_allowed = 3




mob/BaseCamp/ChoosingCharacter
ChooseCharacterMenu(list/menu)
src << browse_rsc('lastwarriorbanner.bmp', "lastwarriorbanner.bmp")

var/menu_rows = ""
for (var/item in menu)
menu_rows += {"<tr><td align="center"><a href="?menu=choosing_character;choice=[item];src=\ref[src]">\[[item]]</a></td></tr>"}

var/page = {"
<body bgcolor=black scroll=no>
<center>
<h2><img src=lastwarriorbanner.bmp></h2>
<b><i>Choose a character</i></b><br><br>
<table border=1 cellpadding=3>
[menu_rows]
</table>
</center>
"}

src << browse(page, "window=CharacterMenu;titlebar=0;can_close=0;can_minimize=0;size=600x400")

DeleteCharacterMenu(list/menu)
var/menu_rows = ""
for (var/item in menu)
menu_rows += {"<tr><td align="center"><a href="?menu=deleting_character;choice=[item];src=\ref[src]">\[[item]]</a></td></tr>"}

var/page = {"
<body bgcolor=black scroll=no>
<center>
<h2><font color="blue">Deleting character!</font></h2>
<b><i><font color=red>Choose who to rub out<font></i></b><br><br>
<table border=1 cellpadding=3>
[menu_rows]
</table>
</center>
"}


src << browse(page, "window=CharacterMenu;titlebar=0;can_close=0;can_minimize=0;size=600x400")


Topic(href, href_list[])
var/menu = href_list["menu"]
switch(menu)
if ("choosing_character")
// Close the menu window.
src << browse(null, "window=CharacterMenu")

var/choice = href_list["choice"]
ChooseCharacterResult(choice)
return

if ("deleting_character")

src << browse(null, "window=CharacterMenu")

var/choice = href_list["choice"]
DeleteCharacterResult(choice)
return
return ..()


world/mob = /mob/creating_character

mob/creating_character
base_save_allowed = 0 var
Form/NewCharacter/char_form = new()
error_text = ""
Login()
spawn()
src.char_form.DisplayForm()

RemoveVerbs()
return

Stat()

return

proc/RemoveVerbs()
for (var/item in verbs)
verbs -= item
return

Form/NewCharacter
form_window = "window=NewCharacter;titlebar=0;can_close=0;can_minimize=0;size=600x400"

var
name

gender
gender_1 = "Male"
gender_2 = "Female"

class
class_values = list("cop", "nurse")

Initialize()
if (!name) name = usr.key
if (!gender) gender = "Male"
if (!class) class = "Cop"
usr << browse_rsc('face.png', "face.png")

HtmlLayout()
var/mob/creating_character/player = usr

var/page = {"<body bgcolor=black>
<center><img src="face.png"></center>
<font color=red><b>
[player.error_text]</b></font><br>
<table>
<tr><td><b><font color=red>Name:</font></b></td><td>
[name]</td></tr>
<tr><td>&nbsp;</td><td>&nbsp</td></tr>
<tr><td><b><font color=red>Gender:</font></b></td>
<td>
[gender_1] <font color=blue>Male<br>
[gender_2] Female</font>
</td>
<tr><td>&nbsp;</td><td>&nbsp</td></tr>
<tr><td><b><font color=red>Class:</font></b></td><td>
[class]</td>
<tr><td>&nbsp;</td><td>&nbsp</td></tr>
<tr><td>&nbsp;</td><td>
[submit]</td></tr>
</table>
"}

return page

ProcessForm()
var/mob/creating_character/player = usr

var/ckey_name = ckey(name)
if (!ckey_name || ckey_name == "")
player.error_text = "Your name must have alpha-numeric characters in it!"
DisplayForm()
return


var/mob/new_mob
switch(class)
if ("Cop") new_mob = new /mob/cop()
if ("Nurse") new_mob = new /mob/nurse()


new_mob.name = name
switch(gender)
if ("Male") new_mob.gender = MALE
if ("Female") new_mob.gender = FEMALE


usr.client.mob = new_mob


new_mob << browse(null, "window=NewCharacter")
return


mob
Login()
..()

sample_report()


verb
save_me()
src.client.base_SaveMob()
src << "\red You have been saved."

proc
sample_report()
src << "<BR><BR>"
src << "\blue You are a [gender] [name]."
src << "\blue Your class is [type]."

mob/cop
icon = 'keystone.dmi'

mob/nurse
icon = 'nurse.dmi'

turf
icon = 'floorgreen.dmi'


Problem description:

runtime error: Cannot modify null.name.
proc name: ProcessForm (/Form/NewCharacter/ProcessForm)
usr: Mxjerrett (/mob/creating_character)
src: Mxjerrett (/Form/NewCharacter)
call stack:
Mxjerrett (/Form/NewCharacter): ProcessForm()
Mxjerrett (/Form/NewCharacter): StopWaiting()
Mxjerrett (/Form/NewCharacter): Topic("

this appears when i go to create a character
Mxjerrett wrote:
Code:

switch(gender)
if ("Male") new_mob.gender = MALE
if ("Female") new_mob.gender = FEMALE

new_mob.name = name
usr.client.mob = new_mob


new_mob << browse(null, "window=NewCharacter")
return</dm>

That should fix it
In response to A.T.H.K
it doesnt work it still says the same thing
In response to Mxjerrett
Why make it so hard? There are much easyer character selection codes out there that do basicly the same thing. Try looking up some in demos or libraries and try some of those.

~Bamrulez
In response to Bamrulez
I recommend Deadron's Character Handling lib.
In response to Audeuro
Audeuro wrote:
I recommend Deadron's Character Handling lib.

Errhmm it is his lib...
In response to A.T.H.K
Ergh, didn't look. Deadron's should work nicely, you just have to make sure you know what you're doing if you modify it. Not sure what's up with this one.
In response to A.T.H.K
 
switch(gender)
if ("Male") new_mob.gender = MALE
if ("Female") new_mob.gender = FEMALE

usr.client.mob = new_mob
new_mob.name = name


new_mob << browse(null, "window=NewCharacter")
return


Hmm im stupid

usr.client.mob = new_mob
new_mob.name = name

Name must be under otherwise there is no mob to set the name to
In response to Audeuro
i cant get the indentions right on it