ID:1561557
 
(See the best response by Ss4toby.)
Code:
runtime error: bad client
proc name: UpdXpBar (/Player/UpdXpBar)
source file: Player.dm,131
usr: Daniel (/Player)
src: Daniel (/Player)
call stack:
Daniel (/Player): UpdXpBar()
Daniel (/Player): nLoadLocation()
Daniel (/Player): nLoad()
Daniel (/Player): ContinueGame()
runtime error: bad client
proc name: AddBars (/Player/proc/AddBars)
source file: Player.dm,1709
usr: Daniel (/Player)
src: Daniel (/Player)
call stack:


Problem description:
Not really sure what causes the error but it's happened quite alot.

And it brings with it a whole slew of errors and causes a chain reaction of problems.

What can I do to fix or prevent this? As it is bugging games of my players.
Maybe you could start with pasting that part of code.
In response to FishMan123
FishMan123 wrote:
Maybe you could start with pasting that part of code.

There is no "part of the code" to paste.
It's a sometimes occasional error that results when the client turns null. That's what is confusing about it.

//attached to the mob.
UpdXpBar()
if(isnull(src))return
var/minn=Exp.Cur/Exp.Max
minn*=100
winset(src,"expbar","value=[minn]")


nLoad()
if(fexists("saves/Players/Slot[num2text(current_slot)]/[src.ckey]"))
var/savefile/F=new /savefile("saves/Players/Slot[num2text(current_slot)]/[src.ckey]")
src.Read(F)
nLoadLocation()
src.icon_state=""
src.BuildBasicClothes()
src.ResetStats()
src<<"Game Loaded."
if(creators.Find(src.ckey)||assistant.Find(src.ckey))
src.is_admin=1
return 1
else
return 0


nLoadLocation()
playing=1
if(!isnull(Last))
src.loc=locate(Last.x,Last.y,Last.z)
Last=null
if(src.z==0||src.z==null||src.z==20)
Respawn()
UpdXpBar()
AddName("[src.name][MyClan.name]")
spawn(10)
client.SoundOn()


Those are the procs in question however.
Best response
This "may" fix your problem..

UpdXpBar()
if(isnull(src))return
if(!src.client)return
var/minn=Exp.Cur/Exp.Max
minn*=100
winset(src,"expbar","value=[minn]")


I'm thinking the bad client runtime error is being caused by winset(). Therefore, you want to make sure the mob has a client, before trying to run the proc with it in the parameters.

I went ahead and ran a test, for this code:
mob/verb/WinsetTest()
var/mob/m=new(src.loc)
winset(m,"mapwindow.map","icon-size=16")


I got this runtime error:
runtime error: bad client
proc name: WinsetTest (/mob/verb/WinsetTest)
source file: Pixel Projectile.dm,14
usr: Ss4toby (/mob/Attackable/Player)
src: Ss4toby (/mob/Attackable/Player)
call stack:
Ss4toby (/mob/Attackable/Player): WinsetTest()
thanks soooo very much