GMOD Overriding models to render above props/maps?

1.4k Views Asked by At

I am trying to make a specific player render above everything else. I've tried to do multiple things, including using ClientsideModel(), DrawModel() and stuff like that to no avail. If someone could help, that'd be nice! I couldn't find anyone else asking this.

1

There are 1 best solutions below

1
On BEST ANSWER

The best way to do this is to use the player's HUDPaint rather than a model draw, as that's called last. So we can start with:

hook.Add("HUDPaint", "playerOverride", function()

end)

This is a 2D Rendering context, so we need to start a 3D one, which is easy enough with cam.start3D()

hook.Add("HUDPaint", "playerOverride", function()
    cam.Start3D()
    cam.End3D()
end)

Then of course, we just draw the target model with Entity:DrawModel()

hook.Add("HUDPaint", "playerOverride", function()
    cam.Start3D()
        target:DrawModel()
    cam.End3D()
end)

The above code assumes you've got a target in mind, which you can either set target to, or replace it.

If you'd prefer to apply this to everyone, (I do hope you're not writing wallhacks), then you can loop through the list of players with player.getAll()

hook.Add("HUDPaint", "playerOverride", function()
    cam.Start3D()
        for k,v in pairs(player.GetAll()) do
            if v ~= LocalPlayer() then -- Make sure we don't redraw ourselves
                v:DrawModel()
            end
        end
    cam.End3D()
end)

(Note, I'm not able to test this just at the moment, but I'm fairly confident in it)