Two questions

First, I want to render a view of a model on the client’s HUD. I tried using this:
[lua]
if not(PlyModel) then
PlyModel = vgui.Create(“DModelPanel”)
PlyModel:SetPos(10, ScrH() - 410)
PlyModel:SetSize(400, 400)
PlyModel:SetModel(LocalPlayer():GetModel())
PlyModel:SetFOV(90)
PlyModel.LayoutEntity = function() end
end
[/lua]

inside of HUDPaint, but that gives me the error:


ClientsideModel cannot be called while rendering

Second, is there a way to run a server command from the client?
I need a player to be unfrozen when client variables are true, and I’m currently using a concommand, but that means it can be done any time from the console.

For the first problem, create the panel outside of the HUDPaint hook (DModelPanel uses ClientsideModel and garry blocked that from being called inside render hooks)

Alright, but is there a way I could have parts of the HUD be drawn behind it, and other parts in front of it?

I think its layered on the last thing to be called is at the front so if you want stuff to be a background use

**[Gamemode.HUDPaintBackground

http://wiki.garrysmod.com/favicon.ico](wiki.garrysmod.com/?title=Gamemode.HUDPaintBackground)**

as its called before hudpaint

The issue with running server commands from the client is that you have no control over when the client will do something. You have to assume that the client has the ability to run this command at any time. So, you should make it dependent on serverside variables as to when they can run it.

I tried:

[lua]
PlyModel = vgui.Create(“DModelPanel”)
PlyModel:SetPos(0, ScrH() - 410)
PlyModel:SetSize(600, 600)
PlyModel:SetModel(“models/humans/group03/male_01.mdl”)
PlyModel:SetFOV(90)
PlyModel.LayoutEntity = function() end
PlyModel:SetVisible(false)

function BattleScreenBG()
draw.TexturedQuad({x = 0, y = 0, w = ScrW(), h = ScrH(), texture = surface.GetTextureID(“battlescreen/BG”)})
PlyModel:SetVisible(true)
end
hook.Add(“HUDPaintBackground”, “BattleScreenBG”, BattleScreenBG)

function BattleScreen()
//Blah blah
end
hook.Add(“HUDPaint”, “BattleScreen”, BattleScreen)
[/lua]
But it was still on top of the things in BattleScreen().

EDIT:
I dunno how, but by messing with the CamPos, LookAt, Size, and Pos, I got it to look like it’s underneath of it, so I don’t need that anymore.

How would I move it to the left, lower than 0? EDIT: Figured this out.

How would I manage client-side variables from the server? By assigning them from the server with Ply.Var?

Bump.
When I tried to animate my DModelPanel with:
[lua]PlyModel.Entity:SetSequence(PlyModel.Entity:LookupSequence(“swing”))[/lua]

All he does is acts like he’s holding a crowbar, he doesn’t swing.
Yes, I’ve checked, the model has the animation.

How would I manage client-side variables from the server? By assigning them from the server with Ply.Var?

  1. Did you try PlyModel.Entity:SetPlaybackRate?

  2. You’d wanna use networked variables for that (ent:Set/GetNWString/Bool/Number/etc)

The model still won’t animate.
This is what it looks like:

http://img707.imageshack.us/img707/4626/dmodelpanel.png

Bump. No problems with networked variables so far.

Are you sure the model has a “Swing” as an animation?

??

I tried doing
[lua] lua_run_cl PlyModel:SetAnimated(ACT_MELEE_ATTACK_SWING_GESTURE) function PlyModel:LayoutEntity() self:RunAnimation() end [/lua]
From console, but that made the model do the walk animation.

[lua]
PlyModel:SetAnimation(ACT_MELEE_ATTACK_SWING_GESTURE)
PlyModel:SetAnimated(true)
function PlyModel:LayoutEntity()

self:RunAnimation()

end
[/lua]

There is no function “SetAnimation”.
I was trying to do it like the example on **[DModelPanel.SetAnimSpeed

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=DModelPanel.SetAnimSpeed)**

According to the wiki **[DModelPanel.SetAnimated

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=DModelPanel.SetAnimated)** takes a bool.
What would seem most logical to me was if :RunAnimation would take the ACT_ enum as parameter, you should try that even though it’s not on the wiki.

Nope, all that did was run the walk animation.

Bump.