Derma Tutorial2
From GMod Wiki
Created By:VaginalDischarge AkA DarkG AkA Gameguysz
OK in this tutorial we will be making a Derma Menu start up when you (And others) join the game. This script will be easy to edit! So enjoy!
Here is the script first.
P.S. I will be telling you where we our putting in the gamemode files but i will not be telling you how to create a gamemode. If you're interested in creating a gamemode!
Watch humblesnurp lua tutorials
init.lua
---- AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) include( 'shared.lua' ) function GM:PlayerInitialSpawn(ply) self.BaseClass:PlayerInitialSpawn(ply) -- don't know if you need baseclass here but it couldn't hurt umsg.Start("call_vgui", ply) umsg.End() end --And to set a player's model: function GM:PlayerSpawn(ply) self.BaseClass:PlayerSpawn(ply) ply:SetModel("models/Player/Group01/male_01.mdl") --Model you want when you spawn. end /*--------------------------------------------------------- Name: gamemode:PlayerLoadout( ) Desc: Give the player the default spawning weapons/ammo ---------------------------------------------------------*/ function GM:PlayerLoadout( pl ) pl:GiveAmmo( 27, "Pistol", true ) pl:Give( "cse_glock" ) end ----
Ok and here is our cl_init
---- include( 'shared.lua' ) function ShowTeamMenu() local DermaPanel = vgui.Create( "DFrame" ) DermaPanel:SetPos( 50,50 ) DermaPanel:SetSize( 200, 250 ) DermaPanel:SetTitle( "Choose Your Team" ) // Name of Fram DermaPanel:SetVisible( true ) DermaPanel:SetDraggable( false ) //Can the player drag the frame /True/False DermaPanel:ShowCloseButton( false ) //Show the X (Close button) /True/False DermaPanel:MakePopup() local DermaButton = vgui.Create( "DButton" ) DermaButton:SetParent( DermaPanel ) // Set parent to our "DermaPanel" DermaButton:SetText( "Combine" ) DermaButton:SetPos( 25, 50 ) DermaButton:SetSize( 150, 50 ) DermaButton.DoClick = function () RunConsoleCommand( "kill" ) // What happens when you press the button end local DermaButton = vgui.Create( "DButton" ) DermaButton:SetParent( DermaPanel ) // Set parent to our "DermaPanel" DermaButton:SetText( "Zombie" ) DermaButton:SetPos( 25, 300 ) DermaButton:SetSize( 150, 50 ) DermaButton.DoClick = function () RunConsoleCommand( "kill" ) // What happens when you press the button end end usermessage.Hook( "call_vgui", ShowTeamMenu ) // Clientside only stuff goes here ----
OK here is how everything works.
the cl_init is for client, so what that means is that client (meaning the players computer) will get the data not everyone at the same time. Example for noobs: If a player types something everyone will get to read it. It sends the words to the server. if the player dies the server sent data to a client. the player who died.
Get it? If not look at more tutorials.
Here's something that might help you to understabd Chair_Throwing_SWEP
OK! First thing we will learn (That we will need to know.
ply:SetModel("models/Player/Group01/male_01.mdl") --Model you want when you spawn.
This is in the init.lua file, AKA the server.
Change the
models/Player/Group01/male_01.mdl
to the model you want. like if i want a combine solder i will use the combines solders directory. where the .mdl file is at. Which is
models/Player/combine_soldier.mdl
Ok that's all you really need to know in that file.
The next one is a lot..... MORE!
First off, I will post the code with // on the side of the line, that will tell you what that line is for. ^_^
function ShowTeamMenu() //This is our function, everything under it defines the function we just created. local DermaPanel = vgui.Create( "DFrame" ) //This creates the Derma Panel (Simple) DermaPanel:SetPos( 50,50 ) // This is where our Panel will be placed at. DermaPanel:SetSize( 200, 250 ) // This is the size of our panel DermaPanel:SetTitle( "Choose Your Team" ) // Name of the Frame DermaPanel:SetVisible( true ) // Don't worry about this leave as true DermaPanel:SetDraggable( false ) //Can the player drag the frame /True/False DermaPanel:ShowCloseButton( true ) //Show the X (Close button) /True/False DermaPanel:MakePopup() //Creates/Finishes the frame
OK The next one I will tell you is just the button, the one we are creating we will have two. They both will do the same thing, i was just asked "How do i add two?" I will explain the same way.
local DermaButton = vgui.Create( "DButton" ) //Creates the button/looks DermaButton:SetParent( DermaPanel ) // Set parent to our "DermaPanel" DermaButton:SetText( "Combine" ) // Name of our Button DermaButton:SetPos( 25, 50 ) //Position of our button DermaButton:SetSize( 150, 50 ) //Size of our button DermaButton.DoClick = function () // When we click it does... RunConsoleCommand( "kill" ) // What happens when you press the button end
Now before i end this i will tell you where to add you commands.
If you do not want the button to kill you when you press it, take this line off.
RunConsoleCommand( "kill" ) // What happens when you press the button
Then add your own.
Now i will post another button under our own it looks like this.
local DermaButton = vgui.Create( "DButton" ) DermaButton:SetParent( DermaPanel ) // Set parent to our "DermaPanel" DermaButton:SetText( "Combine" ) DermaButton:SetPos( 25, 50 ) DermaButton:SetSize( 150, 50 ) DermaButton.DoClick = function () RunConsoleCommand( "kill" ) end local DermaButton = vgui.Create( "DButton" ) DermaButton:SetParent( DermaPanel ) // Set parent to our "DermaPanel" DermaButton:SetText( "Zombie" ) DermaButton:SetPos( 25, 300 ) DermaButton:SetSize( 150, 50 ) DermaButton.DoClick = function () RunConsoleCommand( "kill" ) end end
Now then they both do the same thing but they have two different names and they our in different places.
Like before change the.
RunConsoleCommand( "kill" )
To your own.
LAST THING!
usermessage.Hook( "call_vgui", ShowTeamMenu )
Brings up our VGUI DERMA!
Hope you enjoy this, I will edit it and add new things.