ID:263213
 
Im running a proc when a user logs in along with when a user gets attacked as so
UpdateHealth()

and im then calling screen several times within the proc as so
for(var/obj/screen_objs/Healthbar1/X in src.client.screen)

But when i get run timessaying screen is null for this line the first time it is used in the proc only and only when it is updated during login although it still works.

Client is null when you're trying to update it. Simple fix: if(!client) return
In response to Jp
well that stops the runtimes but it also stops the proc from working where as before it was still working it just gave runtimes-that was a really fast reply btw
In response to Dragon-wars
There's no way to figure out the problem unless you post more than two lines of your code. Don't just post a single line at a time, because that's useless. You don't need to post all of it, but post the parts that are relevant at least.

Lummox JR
In response to Lummox JR
ok basically at login it runs this check
mob/Login()
UpdateHealth()
UpdateExp()
UpdateMP()
my other stuff is inbetween that but it should do anything.
i have the objects defined with this
obj
screen_objs
Healthbar1
icon = 'Healthbar.dmi'
icon_state = "50"
name = "Health bar"
Healthbar2
icon = 'Healthbar.dmi'
icon_state = "100"
name = "Health bar"
and then placed on the screen map file but there shouldn't be any problem with that.
This is the proc
mob/proc/UpdateHealth()
if(src.Health <= (src.MaxHealth/10))
for(var/obj/screen_objs/Healthbar1/X in src.client.screen)
X.icon_state = "10"
for(var/obj/screen_objs/Healthbar2/X in src.client.screen)
X.icon_state = "blank"
else if(src.Health <= (src.MaxHealth/5) && src.Health >= (src.MaxHealth/10))
for(var/obj/screen_objs/Healthbar1/X in src.client.screen)
X.icon_state = "20"
for(var/obj/screen_objs/Healthbar2/X in src.client.screen)
X.icon_state = "blank"
else if(src.Health <= (src.MaxHealth*3/10) && src.Health >= (src.MaxHealth/5))
for(var/obj/screen_objs/Healthbar1/X in src.client.screen)
X.icon_state = "30"
for(var/obj/screen_objs/Healthbar2/X in src.client.screen)
X.icon_state = "blank"
and so on...

When i run the proc from the login part i get runtimes but it still works and it works without runtimes when a player is attacked.

The full runtime is
runtime error: Cannot read null.screen
proc name: UpdateHealth (/mob/proc/UpdateHealth)
source file: Screen.dm,667
usr: Dragon-wars (/mob/game)
src: Dragon-wars (/mob/game)
call stack:
Dragon-wars (/mob/game): UpdateHealth()
Dragon-wars (/mob/game): Login()
Dragon-wars (/mob/game): Login()
Dragon-wars (/mob/game): Login()
runtime error: Cannot read null.screen
proc name: UpdateExp (/mob/proc/UpdateExp)
source file: Screen.dm,224
usr: Dragon-wars (/mob/game)
src: Dragon-wars (/mob/game)
call stack:
Dragon-wars (/mob/game): UpdateExp()
Dragon-wars (/mob/game): Login()
Dragon-wars (/mob/game): Login()
Dragon-wars (/mob/game): Login()
runtime error: Cannot read null.screen
proc name: UpdateMP (/mob/proc/UpdateMP)
source file: Screen.dm,719
usr: Dragon-wars (/mob/game)
src: Dragon-wars (/mob/game)
call stack:
Dragon-wars (/mob/game): UpdateMP()
Dragon-wars (/mob/game): Login()
Dragon-wars (/mob/game): Login()
Dragon-wars (/mob/game): Login()
In response to Dragon-wars
can any1 give me some advice on this please i want to get this fixed before i finish making the rest of the update for the game and I have no real idea how to fix it.
well make sure you have all your variables defined at run time even if it = 0. That will stop it if it is just saying that the clients HP is null.
In response to Niran
the health isnt null, client is null i think i just dont know another way of defining it