Render other players' info on HUD

Status
Not open for further replies.

Jay

I'm lazy, let's face it
So I've got a health script for something I'm working on. However, I plan to render other players' health bars smaller, and under the player's health bar. They all need to be offset a certain distance from each other, but I don't know what to set the Y coordinates to. Is there any way to get a player's playernum?

As I couldn't really find a better way to explain this, here is an example from Dying Light, as this is similar to what I'm trying to do.
 
Last edited:
You can use #player to get the player's node number, but nodes aren't guaranteed to be a linear sequence. (There may be unassigned nodes between assigned ones, leading to gaps.) Ideally, you'd solve your problem by just declaring a variable outside the for player in players.iterate loop and incrementing that by a certain amount each iteration, then just use that value as the base Y position. (You can also do if player == stplyr then continue end to avoid rendering the current player's health.)
 
What exactly do you mean by incrementing a variable each iteration? That part goes over my head. I think if you could explain that to me I'll be set.
 
Last edited:
Just something like this:

Code:
hud.add(function(v, stplyr, camera)
    local ypos = number
    for player in players.iterate do
        if player == stplyr then continue end
        do(stuff)
        v.someDrawingFunction(someXPos, ypos+someYPos, ...)
        ypos = $1+number
    end
end, "game")
"Iteration" referring to one cycle of a for/while loop. That may not be the proper technical term for it, but it's what I think of it as and it makes things easier for me.
 
Wow, can't thank you enough. It actually works now!

kidBOz6.png
 
I believe it's just a custom script for HUD. SRB2 2.2 will look pretty much the same as 2.1 with the HUD as far as I'm aware.

All it's doing is trying to replicate some big shooting games/team based stuff, by showing the healthbars of your fellow teammates... or enemies too, even. I dunno.

Only thing is, I can see this being REALLY awkward with many, many players. XD
 
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top