ID:138955
 
Code: character/attack
//This is all my character handeling//
mob
Write(var/savefile/F)
..()
F["x"] << x
F["y"] << y
F["z"] << z
F["name"] << name
F["wepequip"] << wepequip
F["armourequip"] << armourequip
F["hairequip"] << hairequip
F["hp"]<< hp

Read(var/savefile/F)
..()
var/x
var/y
var/z
F["name"] >> name
F["wepequip"] >> wepequip
F["armourequip"] >> armourequip
F["hairequip"] >> hairequip
F["hp"]>> hp
F["x"] >> x
F["y"] >> y
F["z"] >> z
loc = locate(x,y,z)
src.overlays = 0
src.overlays += src.wepequip
src.overlays += src.armourequip
src.overlays += src.hairequip



mob/verb/relay(id as text)
set hidden=1
if(!id)return 0
var/msg=winget(src, "[id]", "text")
winset(src,"[id]","text")
src<<output(msg,"[id]")

mob/verb/submit()
set hidden=1
name=winget(src,"Input_Name", "text")
if(!name) return 1
world<<"[name] has entered the world."
winshow(src,"Name",0)
src.loc = locate(10,3,1)
src.icon = 'Base.dmi'
new/obj/hudmetres/hpbar(src.client)
new/obj/hair/Comb_Over(usr)
new/obj/hair/Spikey(usr)
new/obj/hair/Emo(usr)
src.updateHealth()
src.MOTD()





client
proc
Savemob()
usr << "Your progress has been saved."
var/savefile/F = new("players/[usr.key].sav")
usr.Write(F)



mob
proc
LoadC()
if(fexists("players/[src.key].sav"))
var/savefile/F=new("players/[src.key].sav")
Read(F)
src<<"Savefile Loaded"
winshow(src,"Login",0)
world<<"[src.name] has entered the world."
new/obj/hudmetres/hpbar(src.client)
src.updateHealth()
src.MOTD()
if(src.week != current_week) src.Wipe_Scores()

else
src<<"You dont have a savefile."

DeleC()
var/conf = rand(1000,9999)
if(fexists("players/[src.key].sav"))
var/conf1 = input("insert this number [conf].") as num
if(conf1 == conf)
fdel("players/[src.key].sav")
src << "Savefile deleted!"
else
src<< "The number you entered didn't match the specified number."
else
src<<"You don't have a savefile to delete"

NewC()
if(fexists("players/[src.key].sav"))
src<<"Delete your old savefile first!"
return
winshow(src,"Name",1)
winshow(src,"Login",0)
mob
verb
Save()
src.client.Savemob()
Load()
set hidden = 1
src.LoadC()
Dele()
set hidden = 1
src.DeleC()
Newc()
set hidden = 1
src.NewC()



mob
Login()
world<<"[src.key] had logged into the server."
winshow(src,"Login",1)



Logout()
del(src)
//This is my attack verb//
mob
verb
Attack(mob/M as mob in get_step(src,usr.dir))
var/dmg = pick(1,2,3) + usr.str + usr.wepatk - (M.def+M.armour)
if(canatk == 1 && wepequip != 0)
if(dmg <= 0)
view(5) << output("[M.name] blocks [usr.name]'s attack!","battle")
else
flick("attack",usr)
flick("attack",usr.wepequip)
flick("attack",usr.armourequip)
M.hp -= dmg
if(usr.lvl >= 20)
usr.exp = 0
else
usr.exp += 5
usr.money += M.lvl
M.death()
usr.levelup()
usr.levelup()
M.attacker = usr
usr.canatk = 0
spawn(5)
usr.canatk = 1


Problem description:Well, the save verb works perfectly up until I attack someone or get attacked by someone else. After this point the save verb just crashes Dream Deamon, and corrupts the file it's saving to.