• Delete 3D2D Text above head
    1 replies, posted
Hey reader, currently I have a little probleme I made a simple Holocron Script for our SWRP Server, and I want that the player has a text above his head while he is holding the entity. But currently it creates the text above the head but doesnt delete it after dropping the entity. cl_init.lua include('shared.lua') local ply = LocalPlayer() surface.CreateFont( "3d2d_font", { font = "BrandonGrotesque-Bold", size = 30, weight = 500, antialias = true, } ) surface.CreateFont( "font_headline", { font = "Arial",  extended = false, size = 400, weight = 1000, blursize = 0, scanlines = 0, antialias = true, underline = true, italic = false, strikeout = false, symbol = false, rotary = false, shadow = false, additive = false, outline = true, } ) function jedi_kodex() myMenu = vgui.Create("DFrame")     myMenu:SetTitle("Sith Kodex") myMenu:SetSize(325, 428)     myMenu:Center()     myMenu:MakePopup() myMenu:ShowCloseButton( false ) myMenu:SetDraggable( false ) myMenu.Paint = function() -- The paint function surface.SetDrawColor( 0, 0, 0, 0 ) -- What color do You want to paint the button (R, B, G, A) surface.DrawRect( 0, 0, myMenu:GetWide(), myMenu:GetTall() ) end local html = vgui.Create( "DHTML", myMenu ) html:Dock( FILL ) html:OpenURL( "https://i.imgur.com/OrTO9Za.png" ) local DermaButton = vgui.Create( "DButton" ) // Create the button and parent it to the frame DermaButton:MakePopup() DermaButton:SetText( "Schließen" ) // Set the text on the button DermaButton:SetTextColor( Color( 255, 255, 255 ) ) DermaButton:SetPos( 802, 755 ) // Set the position on the frame DermaButton:SetSize( 295, 60 ) // Set the size DermaButton:SetFont( "Trebuchet24" ) DermaButton.Paint = function() -- The paint function surface.SetDrawColor( 0, 0, 0, 255 ) -- What color do You want to paint the button (R, B, G, A) surface.DrawRect( 0, 0, DermaButton:GetWide(), DermaButton:GetTall() ) end DermaButton.DoClick = function() surface.PlaySound( "UI/buttonclick.wav" ) myMenu:Close() DermaButton:Remove() end end function nichtbefugt_jedi() local myMenu = vgui.Create("DFrame")     myMenu:SetTitle("") myMenu:SetSize(800, 500)     myMenu:Center()     myMenu:MakePopup() myMenu:ShowCloseButton( false ) myMenu:SetDraggable( false ) myMenu.Paint = function() -- The paint function surface.SetDrawColor( 0, 0, 0, 255 ) -- What color do You want to paint the button (R, B, G, A) surface.DrawRect( 0, 0, myMenu:GetWide(), myMenu:GetTall() ) end --local DPanel = vgui.Create( "DPanel", myMenu ) --DPanel:SetPos( 10, 30 ) -- Set the position of the panel --DPanel:SetSize( 200, 200 ) -- Set the size of the panel local DPanel = vgui.Create( "DLabel", myMenu ) DPanel:SetPos( 0, 0 ) -- Set the position of the label DPanel:SetSize(500, 100) DPanel:Center() -- Set the position of the label DPanel:SetText( "Du kannst dieses Holocron nicht öffnen" ) -- Set the text of the label DPanel:SetFont( "Trebuchet24" ) DPanel:SetDark( 0 ) -- Set the colour of the text inside the label to a darker one local abbruch_nichtbefugt = vgui.Create( "DButton", DPanel ) // Create the button and parent it to the frame abbruch_nichtbefugt:MakePopup() abbruch_nichtbefugt:SetText( "Abbrechen" ) // Set the text on the button abbruch_nichtbefugt:SetTextColor( Color( 255, 255, 255 ) ) abbruch_nichtbefugt:SetPos( 800, 700 ) // Set the position on the frame abbruch_nichtbefugt:SetSize( 295, 60 ) // Set the size abbruch_nichtbefugt:SetFont( "Trebuchet24" ) abbruch_nichtbefugt.Paint = function() -- The paint function surface.SetDrawColor( 255, 231, 53, 255 ) -- What color do You want to paint the button (R, B, G, A) surface.DrawRect( 0, 0, abbruch_nichtbefugt:GetWide(), abbruch_nichtbefugt:GetTall() ) end abbruch_nichtbefugt.DoClick = function() surface.PlaySound( "UI/buttonclick.wav" ) myMenu:Close() end end net.Receive("MyEntity_OpenMenu_jedi", function()local myMenu = vgui.Create("DFrame")     myMenu:SetTitle("") myMenu:SetSize(800, 500)     myMenu:Center()     myMenu:MakePopup() myMenu:ShowCloseButton( false ) myMenu:SetDraggable( false ) myMenu.Paint = function() -- The paint function surface.SetDrawColor( 0, 0, 0, 255 ) -- What color do You want to paint the button (R, B, G, A) surface.DrawRect( 0, 0, myMenu:GetWide(), myMenu:GetTall() ) end --local DPanel = vgui.Create( "DPanel", myMenu ) --DPanel:SetPos( 10, 30 ) -- Set the position of the panel --DPanel:SetSize( 200, 200 ) -- Set the size of the panel local DPanel = vgui.Create( "DLabel", myMenu ) DPanel:SetPos( 0, 0 ) -- Set the position of the label DPanel:SetSize(500, 100) DPanel:Center() -- Set the position of the label DPanel:SetText( "Du bist gerade dabei ein Jedi Holocron zu öffnen . . ." ) -- Set the text of the label DPanel:SetFont( "Trebuchet24" ) DPanel:SetDark( 0 ) -- Set the colour of the text inside the label to a darker one local DermaButton = vgui.Create( "DButton", DPanel ) // Create the button and parent it to the frame DermaButton:MakePopup() DermaButton:SetText( "Weiter" ) // Set the text on the button DermaButton:SetTextColor( Color( 255, 255, 255 ) ) DermaButton:SetPos( 1000, 700 ) // Set the position on the frame DermaButton:SetSize( 295, 60 ) // Set the size DermaButton:SetFont( "Trebuchet24" ) DermaButton.Paint = function() -- The paint function surface.SetDrawColor( 255, 231, 53, 255 ) -- What color do You want to paint the button (R, B, G, A) surface.DrawRect( 0, 0, DermaButton:GetWide(), DermaButton:GetTall() ) end DermaButton.DoClick = function() surface.PlaySound( "UI/buttonclick.wav" ) myMenu:Close() if ply:Team() == TEAM_GESANDTER then jedi_kodex() end if (ply:GetJobRank()) < 5 then nichtbefugt_jedi() else jedi_kodex() end  end local abbruch = vgui.Create( "DButton", DPanel ) // Create the button and parent it to the frame abbruch:MakePopup() abbruch:SetText( "Abbrechen" ) // Set the text on the button abbruch:SetTextColor( Color( 255, 255, 255 ) ) abbruch:SetPos( 620, 700 ) // Set the position on the frame abbruch:SetSize( 295, 60 ) // Set the size abbruch:SetFont( "Trebuchet24" ) abbruch.Paint = function() -- The paint function surface.SetDrawColor( 255, 231, 53, 255 ) -- What color do You want to paint the button (R, B, G, A) surface.DrawRect( 0, 0, abbruch:GetWide(), abbruch:GetTall() ) end abbruch.DoClick = function() surface.PlaySound( "UI/buttonclick.wav" ) myMenu:Close() end end) net.Receive("holocron3d2dtext", function() function DrawOtherPlayersHolocron( ply ) if not ply:GetNW2Bool("isholding", true) then return end local eyeang = EyeAngles() local pos = ply:GetPos() + Vector(2,0,75) local ang = Angle(0, eyeang.y, 90) ang:RotateAroundAxis(vector_up, -90) cam.Start3D2D( pos, ang, 0.2 ) surface.SetDrawColor( 0, 0, 0, 100 ) surface.DrawRect( -100, -10, 240, 32 ) surface.SetFont( "3d2d_font" ) surface.SetTextColor( 255,255, 255, 255 ) surface.SetTextPos( -83, -7 ) surface.DrawText( "HOLOCRON TRÄGER" ) cam.End3D2D() end hook.Add( "PostPlayerDraw", "Holocron3d2d", function( ply ) DrawOtherPlayersHolocron( ply ) end ) end)   function ENT:Draw() self:DrawModel() // The text to display local text = "Jedi Holocron" // The position. We use model bounds to make the text appear just above the model. Customize this to your liking. local mins, maxs = self:GetModelBounds() local pos = self:GetPos() + Vector( 0, 0, maxs.z + 10 ) // The angle local ang = Angle( 0, SysTime() * 100 % 360, 90 ) // Draw front cam.Start3D2D( pos, ang, 0.05 ) // Actually draw the text. Customize this to your liking. draw.DrawText( text, "font_headline", 0, 0, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER ) cam.End3D2D() // Flip the angle 180 degress around the UP axis ang:RotateAroundAxis( Vector( 0, 0, 1 ), 180 ) // Draw back cam.Start3D2D( pos, ang, 0.05 ) // Actually draw the text. Customize this to your liking. draw.DrawText( text, "font_headline", 0, 0, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER ) cam.End3D2D() end init.lua AddCSLuaFile( "cl_init.lua" ) -- Make sure clientside AddCSLuaFile( "shared.lua" ) -- and shared scripts are sent. include('shared.lua') ENT.LebenspunkteStart = 50 function ENT:Initialize() -- Wire Keypad für "Knopf" models/beer/wiremod/numpad.mdl self:SetModel( "models/jediholo/jediholo.mdl" ) self:PhysicsInit( SOLID_VPHYSICS ) -- Make us work with physics, self:SetMoveType( MOVETYPE_VPHYSICS ) -- after all, gmod is a physics self:SetSolid( SOLID_VPHYSICS ) -- Toolbox self:SetUseType( SIMPLE_USE ) local phys = self:GetPhysicsObject() if (phys:IsValid()) then phys:Wake() end end util.AddNetworkString("MyEntity_OpenMenu_jedi") util.AddNetworkString("holocron3d2dtext") function ENT:Use(ply, activator, caller)     net.Start("MyEntity_OpenMenu_jedi")     net.Send(ply) if ( activator:IsPlayer() ) then if  ( self:IsPlayerHolding() ) then  return --net.Start("holocron3d2dtext")     --net.Send(ply) end   activator:PickupObject( self ) if self:IsPlayerHolding() then ply:SetNW2Bool("isholding", true ) net.Start("holocron3d2dtext")     net.Send(ply) else end end  end function ENT:Think() end
You can try to use hook PlayerUse. As wiki says: Continuously runs until USE is released So you can check if this hook is stopped running Or try Entity:Use as toggle
Sorry, you need to Log In to post a reply to this thread.