ID:175969
 
Ok in a game im making with hellgate_uk we are using some hud, a exp bar, and so on...But im wondering, how do i show it The persons exp in the bar, (it does) but it shows the player that logged in last, exp and so on...how do i get it to perminantly Show the player that sees it his/her own Var/s..instead of some other players..I hope i do make sence!
Wanabe wrote:
Ok in a game im making with hellgate_uk we are using some hud, a exp bar, and so on...But im wondering, how do i show it The persons exp in the bar, (it does) but it shows the player that logged in last, exp and so on...how do i get it to perminantly Show the player that sees it his/her own Var/s..instead of some other players..I hope i do make sence!

we can't really help much without seeing a piece of the code where you think the problem may be. unless you want some generic advice like, go check the demos and reference.

Canar
Wanabe wrote:
Ok in a game im making with hellgate_uk we are using some hud, a exp bar, and so on...But im wondering, how do i show it The persons exp in the bar, (it does) but it shows the player that logged in last, exp and so on...how do i get it to perminantly Show the player that sees it his/her own Var/s..instead of some other players..I hope i do make sence!

I have a few demos like that out.
go here to find them.

RaeKwon
In response to Canar
Canar wrote:
Wanabe wrote:
Ok in a game im making with hellgate_uk we are using some hud, a exp bar, and so on...But im wondering, how do i show it The persons exp in the bar, (it does) but it shows the player that logged in last, exp and so on...how do i get it to perminantly Show the player that sees it his/her own Var/s..instead of some other players..I hope i do make sence!

we can't really help much without seeing a piece of the code where you think the problem may be. unless you want some generic advice like, go check the demos and reference.

Canar

Oh ok
I have this:

obj/hud/HPBar
icon = 'meter.dmi'
layer = 5
New(client/C)
..()
screen_loc = "2,1"
icon_state = null
C.screen += src
Update(C)

proc/Update(client/C)
for(var/mob/M)
if(M.key && M.client)
src.icon_state = "[round(((M.hp / M.maxhp) * 100) / 3.33333333)]"
spawn (5) Update(C)

[edit]Ok Raekwon I looked into it i think its fixed, Thanks![/edit]
In response to Wanabe
... :-( Dang diddnt work..Heres my code now:
obj/hud/expBar
icon = 'xpm.dmi'
layer = 5
New(client/C)
..()
screen_loc = "4,1"
icon_state = null
C.screen += src
Update(C)

proc/Update(client/C)
for(var/mob/M)
if(M.key && M.client)
for(var/obj/hud/expBar/H in C.screen)
H.icon_state = "[round(((M.exp / M.expn) * 100) / 3.33333333)]"
spawn (5) Update(C)

Heres how i Create the bar:
mob
Login()
new/obj/hud/expBar(client)
In response to Wanabe
</dm>
Heres how i Create the bar:
> mob
> Login()
> new/obj/hud/expBar(client)
>


I think you should try this...
client
New()
new/obj/hud/expBar()

Canar
In response to Canar
Canar wrote:
</dm>
Heres how i Create the bar:
> > mob
> > Login()
> > new/obj/hud/expBar(client)
> >

I think you should try this...
> client
> New()
> new/obj/hud/expBar()
>
> Canar
>
Ok ill do it that Way.
In response to Wanabe
Still no luck!..It shows my exp and so on in the bar When im single player, but in multi player it shows the other players :-(
In response to Wanabe
[Edit]
Heh, I fixed the bit where it needed to be var/mob/owner... And I also took out the DM tags so it would wrap my lengthy comments instead of stretching out the post...lol
[/Edit]

I had this same problem with the HUD in DBTC... It worked fine for single player, but in multi, it went all to pieces...lol

The way I handled it was to give each screen object a variable that I called "Owner"... And when you create the object and add it to the player's client.screen, set it's Owner variable to the player...

That way, each player gets a unique instance of the screen object, and their objects are tied directly to them through that variable...

Then, in whatever proc you have to update the objects, use their Owner var in place of the mob references...

Here's what I mean (using your code):

obj/hud/expBar
var/mob/Owner
icon = 'xpm.dmi'
layer = 5
New()
..()
screen_loc = "4,1"
icon_state = null
Update()

// I removed all references to the client from the object's New() proc... I prefer to do all of that business in Login()...

proc
Update()
for(var/obj/hud/expBar/H in Owner.client.screen)
H.icon_state = "[round(((Owner.exp / Owner.expn) * 100) / 3.33333333)]"
spawn (5) Update()

// And here, I also removed the need for references to the client... The object's Owner var points directly to the player whose client.screen this object is in... So this object only uses that particular mob's stats...

mob
Login()
var/obj/hud/expBar/E = new()
src.client.screen += E
E.Owner = src

// As I said above, I moved all screen adding and object creation and assigning of the Owner variable to the mob Login() proc... I think this just makes it easier to use with the system I'm explaining...

Hope that helps! (of course, you'll probably have to tweak it a bit to get it to work for your game... but the methods I've shown work perfectly for DBTC in both single and multiplayer...
In response to SuperSaiyanGokuX
Hey thanks, Good idea...btw i get three errors, all saying owner is not defined

obj/hud/expBar
var/owner
icon = 'xpm.dmi'
layer = 5
New()
..()
screen_loc = "4,1"
icon_state = null
Update()

proc/Update()
for(var/obj/hud/expBar/H in owner.client.screen)
H.icon_state = "[round(((owner.exp / owner.expn) * 100) / 3.33333333)]"
spawn (5) Update()

mob
Login()
var/obj/hud/expBar/E = new()
src.client.screen += E
E.owner = src


well those erros dissapear when i put:
proc/Update(mob/owner)

But im not to sure if that will work... :-|

[#1edit] Ok i just tried it and got a million errors, No thats not the way..[/#1edit]
[#2edit] Any one help me? [/#2edit]
In response to Wanabe
On the second line of the code you posted, change var/owner to var/mob/owner
In response to Crispy
Ah, yeah, good catch...

"My bad"...lol

The compiler needs to know that the "owner" var is a mob in order for it to be used to call things like "owner.client.screen" and such... I just forgot to put it in...lol
In response to SuperSaiyanGokuX
SuperSaiyanGokuX wrote:
Ah, yeah, good catch...

"My bad"...lol

The compiler needs to know that the "owner" var is a mob in order for it to be used to call things like "owner.client.screen" and such... I just forgot to put it in...lol

Hehe i ddidnt even notice that part there :-| Thanks for all your help Guys.[edit] Sigh... [/edit]
In response to Wanabe
:| Run time errors every where now..In the game it says this line is an error "Cannot read null.client" BUt owner is defined now! :-|..Sorry for being Annoying by asking questions (but i spose ive got to start some where)...

        for(var/obj/hud/expBar/H in owner.client.screen)


And yes its defined...VVVV

obj/hud/expBar
var/mob/owner


Every things there except for the hp bars and so on...But then again...I diddnt change the normal Huds Programming..
In response to Wanabe
No one can help me??... :(
In response to Wanabe
Again, don't bump your posts if at least 24 hours has gone by, and the post is at least on the second page. Thank you.
In response to Nadrew
..it has been 24 hours

[edit] *looks at the dates* oh i c...it hasnt* sorry about that... im kinda confused with the forum now..

Author: Wanabe
Date: 2/24/03 10:57 am
Topic: Re: Hud help?..
Post [link]
Parent [link]
Next [link]


:| Run time errors every where now..In the game it says this line is an error "Cannot read null.client" BUt owner is defined now! :-|..Sorry for being Annoying by asking questions (but i spose ive got to start some where)...

Cause in that post..that was last night..and its today now? :-|..BTW where i am its 10:20 am and the date is 25 february 2003 Teusday.. i think thats what might of happend...
In response to Wanabe
                                    Re: Hud help?.. Wanabe (2/24/03 11:57 am)
Re: Hud help?.. Wanabe (2/24/03 2:06 pm)


Same date, 2 hours, and 3 minutes apart.
In response to Nadrew
...mkk, im a little confused cause that post i did last night..But yeah might as well go with forum time, ill be quiet now.
In response to Wanabe
The owner var must be set to null for some reason. Does it get changed anywhere else in the code? Maybe you created a HUD object in a different piece of code and forgot to set the owner var?
Page: 1 2