• Open Derma on PlayerInitialSpawn
    7 replies, posted
Hello All! I'm currently making a HUD that has the player's current model displayed on it but am having issues. At the moment I can get the model to update to the current model but I cannot get the model to appear when the player initially connects to the server and spawns in. So far my code looks like this: --Player Model if (SERVER) then util.AddNetworkstring("playermodel")    hook.Add("PlayerInitialSpawn", "OpenDerma", function(ply)    net.Start("playermodel")    net.Send(ply)       end) end if (CLIENT) then    net.Receive("playermodel", function() panelcolor = Color( 0, 0, 0, 0) local Panel = vgui.Create( "DPanel" ) Panel:SetPos( 8, ScrH() - 200 ) Panel:SetSize( 200, 200 ) Panel:SetBackgroundColor( panelcolor ) Panel:ParentToHUD() local icon = vgui.Create( "DModelPanel", Panel ) icon:SetSize( 100, 100 ) icon:SetPos( 0, 50) icon:SetAnimated(true) icon.currentModel = LocalPlayer():GetModel() icon:SetModel( LocalPlayer():GetModel() ) local eyeposst = icon.Entity:GetBonePosition(icon.Entity:LookupBone("ValveBiped.Bip01_Head1") or 0)     eyeposst:Add(Vector(12, 0, 0)) icon:SetLookAt(eyeposst) icon:SetCamPos(eyeposst - Vector(-15, 0, 0))     icon.Entity:SetEyeTarget(eyeposst - Vector(-12, 0, 0)) function icon:Think()if LocalPlayer():GetModel() != self.currentModel then-- Only update if the model has actually changed to prevent lag self:SetModel(LocalPlayer():GetModel()) self.currentModel = LocalPlayer():GetModel() end end function icon:LayoutEntity( Entity )  return  end    end) end Without the networking it functions in the sense of "If I run the script in console, it will make the model appear on the HUD" but I want the model to appear automatically when the player has loaded in. I also don't know about the code's current functionality but I do want it to stay open until the player disconnects as it is apart of the HUD. So far I have been using this thread: How can I make that a Derma Menu opens once the player spawn? to try and guide myself through it, although some of the links to dropbox are broken and no longer work. P.S. Sorry about the code formatting, it won't color everything for some reason.
Either use a timer or check if the player has fully loaded (with HUDPaint for example) because PlayerInitialSpawn gets called too early.
I would just use “InitPostEntity” on the client. Not necessarily to have the server involved in this particular case.
@ButterKing5000 I'm still very new LUA, how would I integrate that? Would it be something like if ply:InitPostEntity() then ---derma code end or function ply:InitPostEntity() --dermacode end
hook.Add
@CupCakeR How would I implement it as a hook.Add. Like i said above, i'm still new.
Make you're Derma in a local function and use this: hook.Add("InitPostEntity", "omotd_initpostentity", function()   OpenMOTDDerma() end) Replacing OpenMOTDDerma() with the function you created obviously.
@Livaco @ButterKing5000 thank you for your help
Sorry, you need to Log In to post a reply to this thread.