For some reason, when I have a DMenu pop up, I can't click on any of the options. When I do, it just disappears. Not even the highlighting shows up.
Code:
[lua]item:SetMenu(function()
local menu = DermaMenu()
menu:SetPos(gui.MousePos())
menu:AddOption("Equip", function()
if IsValid(LocalPlayer():GetActiveItem()) then return end
RunConsoleCommand("msitems", "equip", class)
self:CheckCount(item, class, table)
end)
menu:AddOption("Drop", function()
RunConsoleCommand("msitems", "drop", class)
self:CheckCount(item, class, table)
end)
end)[/lua]
I'm probably going to get rated dumb like 100 times but my entity is not working in my gamemode.
I am trying to make an entity and spawn it near the player when they spawn.
Code:
Entity file
[CODE]
AddCSLuaFile( "makeshiftBoiler.lua" )
ENT.Type = 'anim'
ENT.Base = 'base_gmodentity'
ENT.PrintName = 'Makeshift Boiler'
ENT.Author = 'DerpShadow152'
ENT.Purpose = 'Connect this to any kind of liquid tube and a supply of coal to create steam!'
ENT.Spawnable = true
ENT.AdminSpawnable = true
local isActivated = true
//---
function ENT:Initialize()
self:SetHealth(100)
self:SetSolid(2)
self:SetModel('models/player/arctic.mdl')
self:SetMoveType( MOVETYPE_VPHYSICS )
local phys = self:GetPhysicsObject()
if( phys:IsValid() ) then
phys:Wake()
end
end
//---
function ENT:Draw()
self:DrawModel()
end
function ENT:Use(ply)
if(ply:IsPlayer() ) then
isActivated = true
end
end
[/CODE]
The arctic playermodel is just a placeholder.
PS: I am new to GMod scripting so please don't be mean.
[QUOTE=LUModder;46686982]For some reason, when I have a DMenu pop up, I can't click on any of the options. When I do, it just disappears. Not even the highlighting shows up.
Code:
[lua]item:SetMenu(function()
local menu = DermaMenu()
menu:SetPos(gui.MousePos())
menu:AddOption("Equip", function()
if IsValid(LocalPlayer():GetActiveItem()) then return end
RunConsoleCommand("msitems", "equip", class)
self:CheckCount(item, class, table)
end)
menu:AddOption("Drop", function()
RunConsoleCommand("msitems", "drop", class)
self:CheckCount(item, class, table)
end)
end)[/lua][/QUOTE]
try menu:MakePopup()
Can someone explain to me how to set a players animation in code? None of the functions I used worked.
I tried:
:setAnimation
:DoAnimationEvent
:SetSequence
:AnimRestartGesture
:ResetSequence
I am trying to make the player crouch and freeze the animation for a couple of seconds.
If you really need it I would try just hiding the player and having some entity appear in its place with the same playermodel and do the setsequence on that.
Player animations are just hacky as fuck.
[editline]10th December 2014[/editline]
You could also use the lua animation thing
How does one initialize a HUD along with TTT? I've tried function GM:HUDPaint() which returns GM as nil, even though it's a client file (e.g. in lua/autorun/client) unless I need to do something special? AddCSLua() maybe? *shrug* I've tried the HUDPaint hook but it seems to make the cursor flicker and generally break everything, heh. New to HUDs so I have no idea what to do.
Tried googling and looking at other HUDs but they all modified/overwrote the vanilla TTT Hud whereas I'm wanting to just add alongside it with an addon. Any ideas?
How do I use this?
[url]http://wiki.garrysmod.com/page/render/BrushMaterialOverride[/url]
[QUOTE=rebel1324;46690262]How do I use this?
[url]http://wiki.garrysmod.com/page/render/BrushMaterialOverride[/url][/QUOTE]
Only thing I found on it
[url]http://facepunch.com/showthread.php?t=1160598&p=38316128&viewfull=1#post38316128[/url]
[editline]11th December 2014[/editline]
[QUOTE=serfma;46689825]How does one initialize a HUD along with TTT? I've tried function GM:HUDPaint() which returns GM as nil, even though it's a client file (e.g. in lua/autorun/client) unless I need to do something special? AddCSLua() maybe? *shrug* I've tried the HUDPaint hook but it seems to make the cursor flicker and generally break everything, heh. New to HUDs so I have no idea what to do.
Tried googling and looking at other HUDs but they all modified/overwrote the vanilla TTT Hud whereas I'm wanting to just add alongside it with an addon. Any ideas?[/QUOTE]
Use hook.Add
i created a module in darkrp in this location \darkrpmodification\lua\darkrp_modules\my_module\ but it dosent automaticly load files in the folders, for example \darkrpmodification\lua\darkrp_modules\my_module\my_custom_folder\ is not getting loaded.
do i have to manually inlucde the files inside the folder or is there a smarter way?
[QUOTE=rebel1324;46690262]How do I use this?
[url]http://wiki.garrysmod.com/page/render/BrushMaterialOverride[/url][/QUOTE]
Call it before drawing the brush?
How do you paint the DScrollBar
[QUOTE=_Entity;46691154]How do you paint the DScrollBar[/QUOTE]
[url]http://facepunch.com/showthread.php?t=1435466[/url]
How do I parent a button outside of a panel
[QUOTE=rebel1324;46693753]How do I parent a button outside of a panel[/QUOTE]
Either don't parent it or parent it to something else.
----
How do I prevent a DModelPanel from deleting my player?
[lua]
function PlayerDisplay:Paint()
draw.RoundedBox(4,0,0,self:GetWide(),self:GetTall(),Color(53,53,53,200))
if !IsValid(self.Entity) then return end
local x, y = self:LocalToScreen(0,0)
local ang = self.aLookAngle
if ( !ang ) then
ang = self.Entity:GetAngles()+Angle(0,180,0)
end
local w, h = self:GetSize()
cam.Start3D(self.Entity:LocalToWorld(self.Entity:OBBCenter())-ang:Forward()*100,ang,self.fFOV,x,y,w,h,5,4096)
cam.IgnoreZ(true)
ShouldDrawLocalPlayer = true
local pac=pac
if pac then
pac.ForceRendering(true)
pac.RenderOverride(self.Entity,"opaque")
pac.RenderOverride(self.Entity,"translucent",true)
end
self.Entity:DrawModel()
if pac then
pac.ForceRendering(false)
end
ShouldDrawLocalPlayer = false
cam.IgnoreZ(false)
cam.End3D()
self.LastPaint = RealTime()
end
[/lua]
[QUOTE=Exho;46690351]Only thing I found on it
[url]http://facepunch.com/showthread.php?t=1160598&p=38316128&viewfull=1#post38316128[/url]
[editline]11th December 2014[/editline]
Use hook.Add[/QUOTE]
Ok this is the only way I can think of doing it:
[CODE]function EnchSwitcherButton()
local ESSwitchButton = vgui.Create("DButton")
ESSwitchButton:SetPos(374,ScrH()-109)
ESSwitchButton:SetSize(79,99)
ESSwitchButton:SetVisible(true)
ESSwitchButton:SetText("")
function ESSwitchButton:Paint(w,h)
if self:IsHovered() then
draw.RoundedBoxEx(0, 0, 0, w, h, Color(0,0,0,240), true, true, true, true)
draw.DrawText("Change", "EnchSwitch24", w/2, 24, Color(255,255,255), TEXT_ALIGN_CENTER)
draw.DrawText("Enchant", "EnchSwitch24", w/2, 48, Color(255,255,255), TEXT_ALIGN_CENTER)
end
end
ESSwitchButton.DoClick = function()
EnchSwitcher()
end
end
hook.Add( "HUDPaint", "EnchSwitchHUD", EnchSwitcherButton() )
[/CODE]
Something is obviously wrong, but I don't know what it is. It tosses a nil for EnchSwitcherButton though.
[QUOTE=serfma;46694349]
[CODE]function EnchSwitcherButton()[/CODE]
[/QUOTE]
pls make it local
[QUOTE=serfma;46694349]
[CODE]
hook.Add( "HUDPaint", "EnchSwitchHUD", EnchSwitcherButton() )
[/CODE]
[/QUOTE]
this is supposed to be EnchSwitcherButton
[QUOTE=MeepDarknessM;46694670]pls make it local
this is supposed to be EnchSwitcherButton[/QUOTE]
What do you mean "This is supposed to be EnchSwitcherButton"?
[QUOTE=serfma;46694701]What do you mean "This is supposed to be EnchSwitcherButton"?[/QUOTE]
without the ()
[editline]12th December 2014[/editline]
and besides this code will just create a bunch of buttons due to you creating it over and over again in a hook
[QUOTE=MeepDarknessM;46694712]without the ()
[editline]12th December 2014[/editline]
and besides this code will just create a bunch of buttons due to you creating it over and over again in a hook[/QUOTE]
-snip-
How would you go about not making the button if it already exists?
first:
Are you sure you want to create it in HUDPaint? That seems kind of like a bad thing to do. Just create it once or make a keybind to do it instead.
Second:
you only draw the roundedbox/text when your mouse is over the panel (so you won't be able to see it AT ALL when you spawn it
Third:
Consider not making the positions/width/height fixed and do it based on your width/height of screen
[code]
local basedon = {
w = 1280; -- your width dimension of your garrysmod window
h = 720; -- your height dimension of your garrysmod window
};
local function scale(x,y) -- yada yada yada table index calls no one cares
return (x or 0) / ScrW() * basedon.w, (y or 0) / ScrH() * basedon.h;
end
--[[use like
local newx = scale(374);
ESSwitchButton:SetPos(newx, ScrH() - 109)
or
local neww, newh = scale(79, 99);
ESSwitchButton:SetSize(neww, newh);
]]
[/code]
Fourth:
you are drawing the two strings on top of each other in the paint function
FIFTH AND FINALLY:
You obviously have no idea what you are doing since you are almost 100% likely copying from other places and you should probably learn lua a little better instead of just throwing together random stuff and asking for help when it doesn't work
[QUOTE=MeepDarknessM;46694821]first:
Are you sure you want to create it in HUDPaint? That seems kind of like a bad thing to do. Just create it once or make a keybind to do it instead.
Second:
you only draw the roundedbox/text when your mouse is over the panel (so you won't be able to see it AT ALL when you spawn it
Third:
Consider not making the positions/width/height fixed and do it based on your width/height of screen
[code]
local basedon = {
w = 1280; -- your width dimension of your garrysmod window
h = 720; -- your height dimension of your garrysmod window
};
local function scale(x,y) -- yada yada yada table index calls no one cares
return (x or 0) / ScrW() * basedon.w, (y or 0) / ScrH() * basedon.h;
end
--[[use like
local newx = scale(374);
ESSwitchButton:SetPos(newx, ScrH() - 109)
or
local neww, newh = scale(79, 99);
ESSwitchButton:SetSize(neww, newh);
]]
[/code]
Fourth:
you are drawing the two strings on top of each other in the paint function
FIFTH AND FINALLY:
You obviously have no idea what you are doing since you are almost 100% likely copying from other places and you should probably learn lua a little better instead of just throwing together random stuff and asking for help when it doesn't work[/QUOTE]
Yes I have no idea what I'm doing when it comes to stuff such as the HUD, not saying I know much about other, but I'm trying to learn. I've copied some of it from the tuts I've found around. What I did was instead of HUDPaint, just use the initialize hook. But thank you. :)
EDIT: Ok just realized you can use \n for new lines with draw.DrawText >.>
EDIT2: For future reference, how would I have it only create one instance of the button instead of creating one every single frame?
[t]http://i.gyazo.com/c9282edee376b7e3160607ce89ed8fe5.png[/t]
Anyway to stop 3d2d text from doing this?
[editline]12th December 2014[/editline]
Ah PostDrawTranslucentRenderables not PostDrawOpaqueRenderables
-snip-
[QUOTE=StonedPenguin;46695019][t]http://i.gyazo.com/c9282edee376b7e3160607ce89ed8fe5.png[/t]
Anyway to stop 3d2d text from doing this?
[editline]12th December 2014[/editline]
Ah PostDrawTranslucentRenderables not PostDrawOpaqueRenderables[/QUOTE]
cam.IgnoreZ( true )
<code>
cam.IgnoreZ( false )
Would also work, right?
[QUOTE=EthanTheGreat;46696610]cam.IgnoreZ( true )
<code>
cam.IgnoreZ( false )
Would also work, right?[/QUOTE]
Even if, switching the hook is probably less of a hassle.
How do I delete this bar on top in C menu
[t]http://i.imgur.com/Xa23Jjx.png[/t]
[QUOTE=rebel1324;46696718]How do I delete this bar on top in C menu
[t]http://i.imgur.com/Xa23Jjx.png[/t][/QUOTE]
EZ. menu.Control:Remove()
Be aware that this may break some things that force it to open/close.
[QUOTE=Robotboy655;46696749]EZ. menu.Control:Remove()
Be aware that this may break some things that force it to open/close.[/QUOTE]
I searched whole sandbox, there was no .Control
How do you use the drag n drop library in Garry's Mod? Has someone done a tutorial on it, or are there any examples anywhere?
Sorry, you need to Log In to post a reply to this thread.