ID:146508
 
Code:
obj
hud
invis
layer = MOB_LAYER + 1
icon = 'Chars.dmi'
icon_state = "button"
Click()//When clicked
usr.test()
New(client/C)
screen_loc = "2,20"
C.screen+=src
back
icon = 'Chars.dmi'
icon_state = "bbutton"
Click()
usr.test()
New(client/C)
screen_loc = "1,21 to 3,19"
C.screen+=src

client/New()
..()
if(usr.class=="Infiltrator")
new/obj/hud/invis(src)
new/obj/hud/back(src)


Problem description:Well when i choose my class infil the hud won't show up. But if i take out the if(usr.class=="Infiltrator") and choose any class it works...So i wnat it to show up only when the class infil is picked.

Is the class changed BEFORE client/New()? (I doubt it)
In response to Hell Ramen
No sir. I have the Login() place me in the title screen from there you click the title screen and then choose your class.
In response to DaGoat787
Well, I can't really help. You're showing no other code which makes a new mob and yatayata.
In response to Hell Ramen
mob/proc
Class()
usr.name = input("Choose a name for your character.",
"Your Name",
usr.name)
switch(input("What class do you want to be?","Class") in list("Trooper","Sniper","Scout","Infiltrator","Vet Trooper","Engineer","Heavy Weapons"))
if("Trooper")
src.icon= new /mob/Chars/Trooper
src.icon_state="troop"
src.class="Trooper"
if("Sniper")
src.icon='Chars.dmi'
src.icon_state="sniper"
src.class="Sniper"
if("Scout")
src.icon='Chars.dmi'
src.icon_state="scout"
src.class="Scout"
if("Infiltrator")
src.icon='Chars.dmi'
src.icon_state="infil"
src.class="Infiltrator"
if("Vet Trooper")
src.icon='Chars.dmi'
src.icon_state="troop"
src.class="Vet Trooper"
if("Engineer")
src.icon='Chars.dmi'
src.icon_state="engy"
src.class="Engineer"
if("Heavy Weapons")
src.icon='Chars.dmi'
src.icon_state="hw"
src.class="Heavy Weapons"
src<<"You have logged into HVPB."
world.contents - src<<"[src] has just logged into HVPB."
src.loc=locate(25,21,1)

That the only really other code that is invovle
In response to DaGoat787
See, it won't work. Client/New() is being called before you pick a character.
In response to Hell Ramen
OK good reply. How i make it be call after?
In response to DaGoat787
Just take out that stuff from client/New() and add it at the bottom of your login code.
In response to Hell Ramen
Well i did that and nothing. I've tryed bunch of stuff like changing the client/New() to mob/New() and couple other nothing seems to work.
In response to DaGoat787
Er, whoops, that's in a proc, I didn't know that, sorry!

Add it to the end of that proc.
You might want to try a different approach I use this style. I wouldn't copy because im just doing it from scratch.
Code:
mob/Login()
src.LoadHud()
..()

mob/proc/LoadHud()
if(src.Class == "Infiltrator")
src.client.screen += typesof(/obj/Hud/Infiltrator)
//if that doesn't work try this
src.client.screen += new/obj/Hud/Infiltrator/invis
src.client.screen += new/obj/Hud/Infiltrator/back

obj
Hud
icon = 'Chars.dmi'
layer = MOB_LAYER + 10
Infiltrator
invis
icon_state = "button"
screen_loc = "2,20"
Click()
usr.test()
back
icon_state = "bbutton"
screen_loc = "1,21 to 3,19"
Click()
usr.test()

I hope this helps...
-Travis(Niran)


In response to Niran
yes i did it this way right after a few mins of my last post and got this runtime

runtime error: undefined variable /mob/var/screen
proc name: New (/obj/hud/invis/New)
usr: DaGoat787 (/mob)
src: the invis (/obj/hud/invis)
call stack:
the invis (/obj/hud/invis): New(DaGoat787 (/mob))
DaGoat787 (/mob): Class()
DaGoat787 (/mob): Login()
runtime error: undefined variable /mob/var/screen
proc name: New (/obj/hud/back/New)
usr: DaGoat787 (/mob)
src: the back (/obj/hud/back)
call stack:
the back (/obj/hud/back): New(DaGoat787 (/mob))
DaGoat787 (/mob): Class()
DaGoat787 (/mob): Login()

Don't know how ti fix it.
In response to Hell Ramen
if your trying to get it to create a diffrent hud after every character there is diffrent ways to approch this...
1.)if it is one HUD for all characters and you have a login screen that the player picks from you can have the login screen postioned near the middle of the map and have the map layer be 100 and make it big enough to cover the screen that will gid the hud untill they login.

2.)you can go ahead and add the hud and if it is not all that big make all the hub icons blank untill u need them then just use.
for(var/obj/nameofhuditem/s in src.client.screen)
s:icon = 'blah.dmi'
s:icon_state = "blah"

and if that doesnt work page me on either msn = [email protected] or aim = [email protected] and i will tell u what i did for one of my games i hope i can help
In response to Smokymcpot
Well only this class Infiltrator has a hud item. And it's a 6x6 button top left corner. It's use for when clicked, you have a special skill to go invis.
In response to DaGoat787
so let me see im reading you right u have one button for one class okay..
client
New()
new/obj/invis(src)
//then//*

obj
invis
icon ='blah.dmi'
icon_state = ""//make sure that w.e u call its blank so the player cant see it untill they need it
New(client/C) screen_loc = "7,7",C.screen+=src
Click()
if(usr.invis == 0)
usr.invis = 1
usr.icon = 'blah.dmi'//what ever ur invis thing is
else//so if they click it again
if(usr.invis==1)
usr.invis = 0
usr.icon = 'player.dmi'//make em return


switch(input("Select Character","Blah") in list ("Blah","The One u need","Blah")
if("The One u need")
for(var/obj/invis/i in usr.client.screen)//then change it right here where the player can see it.
i:icon = 'Blah.dmi'
i:icon_state = "blah"
usr.icon = 'w.e.dmi'
Ect.

In response to Smokymcpot
I got everything correct all my invis code and suhc work the only thing im having problem with is that runtime error. The button shows up and all just as soon as i log in i get that error.