• right its about derma menus
    28 replies, posted
i woud like to say i was done posting here but obv not my sent that works but what i am trying to do is once they have chosen there team the menu closes [lua] cl_init include('shared.lua') //[[--------------------------------------------------------- //Name: Draw Purpose: Draw the model in-game. //Remember, the things you render first will be underneath! //-------------------------------------------------------]] function ENT:Draw() self.Entity:DrawModel() -- Draw the model. end function dermahere() DermaPanel = vgui.Create("DFrame") -- Create the frame menu1 = vgui.Create("DButton") -- Create the button menu2 = vgui.Create("DButton") -- Create the button menu3 = vgui.Create("DButton") -- Create the button menu4 = vgui.Create("DButton") -- Create the button local DermaPanel = vgui.Create( "DFrame" ) DermaPanel:SetPos( 50,50 ) DermaPanel:SetSize( 500, 150 ) DermaPanel:SetTitle( "Choses Your Faction" ) DermaPanel:SetVisible( true ) DermaPanel:ShowCloseButton( true ) DermaPanel:SetDraggable( false ) DermaPanel:MakePopup() local menu1 = vgui.Create( "DButton" ) menu1:SetParent( DermaPanel ) -- Set parent to our "DermaPanel" menu1:SetText( "The Gears Corp" ) menu1:SetPos( 25, 50 ) menu1:SetSize( 100, 100 ) menu1.DoClick = function () RunConsoleCommand( "isb1" ) -- What happens when you press the button DermaMenu:close() end menu1.Paint = function() surface.SetDrawColor(125, 125, 125, 255) surface.DrawRect(0,0,menu1:GetWide(),menu1:GetTall()) end local menu2 = vgui.Create( "DButton" ) menu2:SetParent( DermaPanel ) -- Set parent to our "DermaPanel" menu2:SetText( "Organisation 13" ) menu2:SetPos( 125, 50 ) menu2:SetSize( 100, 100 ) menu2.DoClick = function () RunConsoleCommand( "isb2" ) -- What happens when you press the button DermaMenu:close() end menu2.Paint = function() surface.SetDrawColor(215, 215, 15, 255) surface.DrawRect(0,0,menu2:GetWide(),menu2:GetTall()) end local menu3 = vgui.Create( "DButton" ) menu3:SetParent( DermaPanel ) -- Set parent to our "DermaPanel" menu3:SetText( "Freelancing Miners" ) menu3:SetPos( 225, 50 ) menu3:SetSize( 100, 100 ) menu3.DoClick = function () RunConsoleCommand( "isb3" ) -- What happens when you press the button DermaMenu:close() end menu3.Paint = function() surface.SetDrawColor(30, 30, 10, 255) surface.DrawRect(0,0,menu3:GetWide(),menu3:GetTall()) end local menu4 = vgui.Create( "DButton" ) menu4:SetParent( DermaPanel ) -- Set parent to our "DermaPanel" menu4:SetText( "Citizen" ) menu4:SetPos( 325, 50 ) menu4:SetSize( 100, 100 ) menu4.DoClick = function () RunConsoleCommand( "isb4" ) -- What happens when you press the button DermaMenu:close() end menu4.Paint = function() surface.SetDrawColor(255, 155, 0, 255) surface.DrawRect(0,0,menu4:GetWide(),menu4:GetTall()) end end -- ending the function usermessage.Hook( "dermamenu", dermahere ) [/lua] [lua] AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) include('shared.lua') function ENT:SpawnFunction( ply, tr ) if ( !tr.Hit ) then return end local SpawnPos = tr.HitPos + tr.HitNormal * 0 + Vector(0,0,0) local ent = ents.Create("menu_sent") ent:SetPos( SpawnPos ) ent:Spawn() ent:Initialize() ent:Activate() return ent end function ENT:Initialize() self.Entity:SetModel( "models/SmallBridge/Other/sbconsole.mdl" ) self.Entity:PhysicsInit( SOLID_VPHYSICS ) -- Make us work with physics, self.Entity:SetMoveType( MOVETYPE_VPHYSICS ) -- after all, gmod is a physics self.Entity:SetSolid( SOLID_VPHYSICS ) -- Toolbox local phys = self.Entity:GetPhysicsObject() if (phys:IsValid()) then phys:Wake() end end hi function derma( ply, entity ) if entity:GetClass() == "menu_sent" then umsg.Start("dermamenu", ply) umsg.End() end end hook.Add( "PlayerUse", "dermamenu", derma ) [/lua]
You put the creation of vgui controls in the Draw function, it would create a lot of them.
He did indent it badly, but that's not true. Take a closer look. Your problem is that when you press the USE key, often times it will run more than once because you don't take your finger off the key fast enough. Here's a simple solution: [lua] function ENT:Initialize() self.LastUses = {} self.UseWaitTime = 2 end function ENT:Use( activator, caller ) if activator:IsPlayer() then if self.LastUses[activator:SteamID()] and CurTime() - self.LastUses[activator:SteamID()] < self.UseWaitTime then return end umsg.Start("dermamenu",activator) umsg.End() self.LastUses[activator:SteamID()] = CurTime() end end[/lua]
Oh wow you're right, it's not in the Draw function. My bad, thanks for correcting. Cap, make sure you indent your code properly or it can lead you and others to misread it. Thanks Entoros.
[QUOTE=yakahughes;21986619]You put the creation of vgui controls in the Draw function, it would create a lot of them.[/QUOTE] can u elaberate of what you mean
[QUOTE=cap5555;21987320]can u elaberate of what you mean[/QUOTE] Read Entoros' post
soz my bad ty for the help i posted that with out refreshing the page and could it get closed topic got it working ty guys [editline]08:12PM[/editline] btw there is still an error when trying to close the menu entities/menu_sent/cl_init.lua:34: attempt to call method 'close' (a nil also it puta a label in the corner and will not go away when the menu is closed by the x
Why don't you just use [b][url=http://wiki.garrysmod.com/?title=Entity.SetUseType]Entity.SetUseType [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]? This is what it is for.
[QUOTE=MakeR;21987965]Why don't you just use [b][url=http://wiki.garrysmod.com/?title=Entity.SetUseType]Entity.SetUseType [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]? This is what it is for.[/QUOTE] i have fixed that problem now on to a new problem
My last post was directed at Entoros. [editline]08:24PM[/editline] Lua is case sensitive, close should be Close.
I hear you Maker, it's just that I've had some problems in the past with USE_SIMPLE or whatnot in that it just doesn't seem to do it's job. Perhaps I'm crazy/it's been fixed, though.
[code]button.DoClick = function() DermaFrame:Close() end [/code]
[QUOTE=Entoros;21988225]I hear you Maker, it's just that I've had some problems in the past with USE_SIMPLE or whatnot in that it just doesn't seem to do it's job. Perhaps I'm crazy/it's been fixed, though.[/QUOTE] I have never had problems with it, strange.
can an admin close topic now plz before a troll comes in
Why are you so eager to get this closed? Just wait and see, you might get a problem.
i know i am bumping my own thread here but can any one tell me how to save the server at its current state so i can save players factions and money and score
Not sure what you mean about that [sp]Arent you glad it didnt get closed? Already more questions[/sp]
[QUOTE=Busymonkey;22006333]Not sure what you mean about that [sp]Arent you glad it didnt get closed? Already more questions[/sp][/QUOTE] yh what i ment is like save the players money and team with mysql or save it to a .txt file
use sql [url]http://wiki.garrysmod.com/?title=LUA:SQLite_Tutorial[/url]
Oh, yea. Use SQL as stated above. I didnt totally get what you meant, because you wrote factions, which I figured was kind of jobs-like things, and their scores. But meh.
for the sql database how would i get it to save if the server i am using is a internet bought server do i put these in the init or the shared or both AddCSLuaFile( "sql_database.lua" ) and include( "sql_database.lua" )
init.lua.
[QUOTE=Busymonkey;22021929]init.lua.[/QUOTE] ty and i know its off topic but any one wanting to be an admin post on our forums link is [url] http://mostlyharmless70.webs.com/ [/url]
[quote=cap5555;22023012]ty and i know its off topic but any one wanting to be an admin post on our forums link is [url="http://mostlyharmless70.webs.com/%3cbr%20/%3e"] http://mostlyharmless70.webs.com/ [/url][/quote] page not found
:x
[QUOTE=HeavyMtl123;22023177]page not found[/QUOTE] the server has its own website the address is [url]http://mostlyharmless70.webs.com/[/url] edit idk why the links keep braking on this thread if u still have problems add me on steam Captain-Britain{lua}
how would i get the data base to save if its a web server from the internet with only ftp proticals and rcon and that
guys how would you close a demar menu u know when u click close menu not the x
[b]I posted this the 16th of May[/b] [quote=Busymonkey][code]button.DoClick = function() DermaFrame:Close() end [/code] [/quote] Scroll up.
Sorry, you need to Log In to post a reply to this thread.