ID:1920443
 
(See the best response by Ter13.)
So im having a glitch where few instances when the player is saved during shut down, they wont get deleted. Why this only happens in rare occassions is very weird sense their isnt any if's in the shutdown process. For now as it seems like such a huge problem I just want to make an extra check when you hit someone. if their of type player and not a client destroy them. How would i do that?

just a quick fix on a larger problem

To fix the larger problem you'll have to show us some code.

if(istype(attacked,/mob/player) && !player.client)
// Destroy them


For your "quick fix".
In response to Nadrew
client
Del()//when the client is deleted
..()
var/mob/player/p=mob
spawn(1)//this was just another check to make sure glitch didnt happen, didnt work
p.hideHealth()
p.SaveMob()//save the mob
if(p.pet!=null)
DEL(p.pet)
del mob

world<<"[p] Has logged out"
if(p.icon_state=="dontSave")//makes sure it doesnt save at title screen
return
if(p.z>currentZ)//this code is just in case you exit in a instanced dungeon
occupied[p.z-currentZ]=0
var/zz=p.z
p.loc=locate(75,75,1)
p.respawn=locate(75,75,1)
for(var/obj/items/key/k in p.contents)
DEL(k)
// m.normalVision()
spawn(1)
for(var/x=1;x<=50;x++)
for(var/y=1;y<=50;y++)
for(var/atom/a in locate(x,y,zz))
if(istype(a,/mob/enemy))
var/mob/enemy/e=a
e.loc=e.respawn
e.icon_state=e.IS
e.knockout=0
e.density=1
e.hp=e.maxhp
e.walk=1//;DEL(p)
else if(istype(a,/obj/dungeon/keyed))
var/obj/door=a
door.density=1
door.icon_state="keyed"
else if(istype(a,/obj/dungeon/button))
var/obj/dungeon/button/but=a
but.gotKey=0;but.icon_state="button"
p.hideHealth()
p.SaveMob()//save the mob
if(p.pet!=null)
DEL(p.pet)
del (p)

//this is my new player

mob
step_size = 8
step_size = 4
Login()
var/mob/player/p=new()
p.client=src.client
del src

mob/player
icon='mainMob.dmi'
Login()
icon_state="dontSave"
bound_y=12
bound_x=4
bound_y=0
bound_width=24
bound_height=26
winshow(usr,"shop",0)
winset(usr, "default.map", "zoom=2")
var/obj/screen/o=new;o.layer=102;o.icon='windowSize.dmi';o.icon_state="titleScreen"
o.screen_loc="3:16,1:20";client.screen+=o;
var/obj/button/title/New/n=new;n.layer=103;n.icon='buttonTitle.dmi';n.icon_state="new"
n.screen_loc="8:16,6:20";client.screen+=n;
var/obj/button/title/Load/l=new;l.layer=103;l.icon='buttonTitle.dmi';l.icon_state="load"
l.screen_loc="8:16,4:20";client.screen+=n;;client.screen+=l
In response to Nadrew
is you can see to transfer to a new player type, i did something probably weird. I made it so when the mob logged in he transfered his client to mob/player got deleted and than mob/player was able to login and do its thing.

This method may have caused problems
Best response
client
Del()//when the client is deleted
var/mob/player/p=mob
p.hideHealth()
p.SaveMob()//save the mob
if(p.pet!=null)
DEL(p.pet)
del mob
..()


The default action of client/Del() deletes the client. Because the client is being deleted, the code below ..() is not being run.

You just need to move the supercall below the saving action.
Oooh that's probably when it started. I knew it started ages ago but could never remember what I changed.

Thank you tier I'll try it.