[IMG]http://dl.dropbox.com/u/26392940/r1Bnl.png[/IMG](3)
Lua questions that don't deserve their own thread go here.
This means things like:
How to add jobs in DarkRP,
Where to find PERP,
How to shoot ponies out of a gun.
and if your IQ is above 30, then things like why vehicles aren't working on Linux servers.
[B]COOL STUFF TO LOOK AT!
[/B][U][B]General Faqs[/B][/U]: [URL]http://www.facepunch.com/threads/868561-Need-help-READ-THIS-FIRST[/URL]
[B][U]HOW TO LUA?[/U]:[/B] [url]http://wiki.garrysmod.com/?title=Lua_Tutorial_Series[/url]
[U][B]GLUA WIKI[/B][/U]: [url]http://wiki.garrysmod.com[/url]
[B]Previous threads that your probably wont look at:[/B]
[URL=http://www.facepunch.com/threads/931152-What-do-you-need-help-with-V1]Thread 1[/URL]
[URL=http://www.facepunch.com/threads/1068418]Thread 2[/URL]
Where do I find PERP?
[QUOTE=Hyper Iguana;34505558]Where do I find PERP?[/QUOTE]
on dramaunlimited :D
lol
[b]1.[/b]
Could someone give me a link were I can find gui.OpenURL?
Cause I want to creat a button that ween is pressed will open a webpage.
[b]2.[/b]
Is there any tutorial how to creat circle ?
[url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index2c41.html?title=Gui.OpenURL[/url]
[url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index7dc7.html?title=Surface.DrawCircle[/url]
These aren't hard to find you know.
My other thread like, died or something so This is what I have just now:
[lua]
hook.Add("PhysgunPickup", "SetVarOn", function(ply, ent)
ent.DontPush = 1
end)
hook.Add("PhysgunDrop", "SetVarOff", function(ply, ent)
ent.DontPush = 0
end)
hook.Add( "ShouldCollide", "StopMinges", function(ent1,ent2)
if (ent1.DontPush == 1 || ent2.DontPush == 1) and (ent1:IsPlayer() || ent2:IsPlayer()) then
ent1:SetColor( 255, 255, 255, 200 )
return false
else
ent1:SetColor( 255, 255, 255, 255 )
end
end)
[/lua]
Problem is, it goes through players but if it collides with something or someone shoots someone they go ghosted. I need the prop you pick up to only nocollide with players and not any other props.
[QUOTE=Chessnut;34510704][url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index2c41.html?title=Gui.OpenURL[/url]
[url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index7dc7.html?title=Surface.DrawCircle[/url]
These aren't hard to find you know.[/QUOTE]
Abot the Gui.OpenURL. After I creat the button using vgui.creat
[lua]
Tab = vgui.Create( "DPropertySheet")
Tab:SetParent( Banner )
Tab:SetPos( 248, 120 )
Tab:SetSize( 215, 60 )
[/lua]
And someone told me that I need to creat a GUI.Panel, and is not possible to add gui.OpenURL inside the button.
[editline]2nd February 2012[/editline]
And I want to ask if is possible to add Custom Font.
[QUOTE=Mrkrabz;34511515]My other thread like, died or something so This is what I have just now:
-code snip-
Problem is, it goes through players but if it collides with something or someone shoots someone they go ghosted. I need the prop you pick up to only nocollide with players and not any other props.[/QUOTE]
Don't set the color in the collision hook. Also, changing the collisions like that would normally break the physics engine.
[lua]function _R.Entity:CollisionRulesChanged() -- [url]http://www.facepunch.com/threads/1150631[/url]
-- HACK!
local cg = self:GetCollisionGroup()
self:SetCollisionGroup(COLLISION_GROUP_DEBRIS)
self:SetCollisionGroup(cg)
end
hook.Add("PhysgunPickup", "SetVarOn", function(ply, ent)
ent.DontPush = true
ent:SetColor( 255, 255, 255, 200 )
ent:CollisionRulesChanged()
end)
hook.Add("PhysgunDrop", "SetVarOff", function(ply, ent)
ent.DontPush = false
ent:SetColor( 255, 255, 255, 255 )
ent:CollisionRulesChanged()
end)
hook.Add( "ShouldCollide", "StopMinges", function(ent1,ent2)
if (ent1.DontPush || ent2.DontPush) and (ent1:IsPlayer() || ent2:IsPlayer()) then
return false
end
end)[/lua]
Try that.
Anyone know of an up-to-date list of particle effects in HL2 that doesn't involve me going to the game's internal editor?
Just need some debug particles that look semi-pretty.
I need help taking the blood effect and setting it to follow dead bodies. (ParticleEffectAttach)
How would I create a simple speedometer that shows speed on a cars dashboard in digital (a number)? Thanks.
Guys this is "help with" thread, not "ask for people to do it for you" thread, go do your homework and come back asking why something is not working as you think it would!
@Killer_Steel: The Source engine wiki has a complete list of effects, google it
@Mogarf: Read the gmod Lua wiki, there should be some pointers on how to use the particle functions around there
@Jinx786: I'd suggest you read the HUD tutorials in the wiki and then read a bit of the "ent" class, you should be able to figure it out from there.
[QUOTE=R@Rdeathmatch;34511551]Abot the Gui.OpenURL. After I creat the button using vgui.creat
[lua]
Tab = vgui.Create( "DPropertySheet")
Tab:SetParent( Banner )
Tab:SetPos( 248, 120 )
Tab:SetSize( 215, 60 )
[/lua]
And someone told me that I need to creat a GUI.Panel, and is not possible to add gui.OpenURL inside the button.
[editline]2nd February 2012[/editline]
And I want to ask if is possible to add Custom Font.[/QUOTE]
[url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexbd06-2.html?title=Panel.SetHTML[/url]
[url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index3f71.html?title=Surface.CreateFont[/url]
Are you even trying to search for these, at all?
[QUOTE=Chessnut;34521777][url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexbd06-2.html?title=Panel.SetHTML[/url]
[url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index3f71.html?title=Surface.CreateFont[/url]
Are you even trying to search for these, at all?[/QUOTE]
Yes i'm trying but gmod.wiki is not working properly.
[editline]3rd February 2012[/editline]
[QUOTE=Chessnut;34521777][url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexbd06-2.html?title=Panel.SetHTML[/url]
[url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index3f71.html?title=Surface.CreateFont[/url]
Are you even trying to search for these, at all?[/QUOTE]
About Custom Font, I don't want to add this : [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index5b6d.html?title=Working_with_Fonts[/url]
I want to try this.[url]http://www.dafont.com/batman-forever.font[/url]
If you do not understand, the first argument is the (custom) font.
Since clients probbly do not have the custom font, you have to resource.AddFile it.
Custom fonts go into resources/fonts.
[QUOTE=Chessnut;34526873]If you do not understand, the first argument is the (custom) font.
Since clients probbly do not have the custom font, you have to resource.AddFile it.
Custom fonts go into resources/fonts.[/QUOTE]
This is everything what I want to know. Thx
Does anybody have a code snippet for a decent looking chat and scoreboard?
[QUOTE=Dorkslayz;34528319]Does anybody have a code snippet for a decent looking chat and scoreboard?[/QUOTE]
That's not exactly a 'code snippet'. If either work well or are decent lookings between the 2 it will be atleast 750 lines.
[QUOTE=JustSoFaded;34528460]That's not exactly a 'code snippet'. If either work well or are decent lookings between the 2 it will be atleast 750 lines.[/QUOTE]
I dont mean something really advanced, Just something that looks nice and operates like the normal GMod Chat and Scoreboard.
[QUOTE=meoiswa;34519750]I'd suggest you read the HUD tutorials in the wiki and then read a bit of the "ent" class, you should be able to figure it out from there.[/QUOTE]
Thanks, this helped a little bit but could you give me a hint on how to get the current velocity? Thanks!
Just wondering whether there is a way to stop a player opening the console or main menu?
[QUOTE=Dorkslayz;34528509]I dont mean something really advanced, Just something that looks nice and operates like the normal GMod Chat and Scoreboard.[/QUOTE]
I start to creat a Custom ScoreBoard for Deathrun or for other gamemodes that have 2 team.
Rather long post, but what I'm aiming for is to display Text over the job "Icon" so you can see what the job title is without having to put your mouse over it. I cant find the exact place in this function to do this. (This is for the Darkrp F4 job menu)
[lua]
function JobsTab()
local hordiv = vgui.Create("DHorizontalDivider")
hordiv:SetLeftWidth(370)
function hordiv.m_DragBar:OnMousePressed() end
hordiv.m_DragBar:SetCursor("none")
local Panel
local Information
function hordiv:Update()
if Panel and Panel:IsValid() then
Panel:Remove()
end
Panel = vgui.Create( "DPanelList")
Panel:SetSize(370, 540)
Panel:SetSpacing(1)
Panel:EnableHorizontal( true )
Panel:EnableVerticalScrollbar( true )
Panel:SetSkin("DarkRP")
local Info = {}
local model
local modelpanel
local function UpdateInfo(a)
if Information and Information:IsValid() then
Information:Remove()
end
Information = vgui.Create( "DPanelList" )
Information:SetPos(378,0)
Information:SetSize(370, 540)
Information:SetSpacing(10)
Information:EnableHorizontal( false )
Information:EnableVerticalScrollbar( true )
Information:SetSkin("DarkRP")
function Information:Rebuild() -- YES IM OVERRIDING IT AND CHANGING ONLY ONE LINE BUT I HAVE A FUCKING GOOD REASON TO DO IT!
local Offset = 0
if ( self.Horizontal ) then
local x, y = self.Padding, self.Padding;
for k, panel in pairs( self.Items ) do
local w = panel:GetWide()
local h = panel:GetTall()
if ( x + w > self:GetWide() ) then
x = self.Padding
y = y + h + self.Spacing
end
panel:SetPos( x, y )
x = x + w + self.Spacing
Offset = y + h + self.Spacing
end
else
for k, panel in pairs( self.Items ) do
if not panel:IsValid() then return end
panel:SetSize( self:GetCanvas():GetWide() - self.Padding * 2, panel:GetTall() )
panel:SetPos( self.Padding, self.Padding + Offset )
panel:InvalidateLayout( true )
Offset = Offset + panel:GetTall() + self.Spacing
end
Offset = Offset + self.Padding
end
self:GetCanvas():SetTall( Offset + (self.Padding) - self.Spacing )
end
if type(Info) == "table" and #Info > 0 then
for k,v in ipairs(Info) do
local label = vgui.Create("DLabel")
label:SetText(v)
label:SizeToContents()
if label:IsValid() then
Information:AddItem(label)
end
end
end
if model and type(model) == "string" and a ~= false then
modelpanel = vgui.Create("DModelPanel")
modelpanel:SetModel(model)
modelpanel:SetSize(90,230)
modelpanel:SetAnimated(true)
modelpanel:SetFOV(90)
modelpanel:SetAnimSpeed(1)
if modelpanel:IsValid() then
Information:AddItem(modelpanel)
end
end
hordiv:SetLeft(Panel)
hordiv:SetRight(Information)
end
UpdateInfo()
local function AddIcon(Model, name, description, Weapons, command, special, specialcommand)
local icon = vgui.Create("SpawnIcon")
local IconModel = Model
if type(Model) == "table" then
IconModel = Model[math.random(#Model)]
end
icon:SetModel(IconModel)
icon:SetIconSize(120)
icon:SetToolTip()
icon.OnCursorEntered = function()
icon.PaintOverOld = icon.PaintOver
icon.PaintOver = icon.PaintOverHovered
Info[1] = LANGUAGE.job_name .. name
Info[2] = LANGUAGE.job_description .. description
Info[3] = LANGUAGE.job_weapons .. Weapons
model = IconModel
UpdateInfo()
end
icon.OnCursorExited = function()
if ( icon.PaintOver == icon.PaintOverHovered ) then
icon.PaintOver = icon.PaintOverOld
end
Info = {}
if modelpanel and modelpanel:IsValid() and icon:IsValid() then
modelpanel:Remove()
UpdateInfo(false)
end
end
icon.DoClick = function()
local function DoChatCommand(frame)
if special then
local menu = DermaMenu()
menu:AddOption("Vote", function() LocalPlayer():ConCommand("say "..command) frame:Close() end)
menu:AddOption("Do not vote", function() LocalPlayer():ConCommand("say " .. specialcommand) frame:Close() end)
menu:Open()
else
LocalPlayer():ConCommand("say " .. command)
frame:Close()
end
end
if type(Model) == "table" and #Model > 0 then
hordiv:GetParent():GetParent():Close()
local frame = vgui.Create( "DFrame" )
frame:SetTitle( "Choose model" )
frame:SetVisible(true)
frame:MakePopup()
local levels = 1
local IconsPerLevel = math.floor(ScrW()/64)
while #Model * (64/levels) > ScrW() do
levels = levels + 1
end
frame:SetSize(math.Min(#Model * 64, IconsPerLevel*64), math.Min(90+(64*(levels-1)), ScrH()))
frame:Center()
local CurLevel = 1
for k,v in pairs(Model) do
local icon = vgui.Create("SpawnIcon", frame)
if (k-IconsPerLevel*(CurLevel-1)) > IconsPerLevel then
CurLevel = CurLevel + 1
end
icon:SetPos((k-1-(CurLevel-1)*IconsPerLevel) * 64, 25+(64*(CurLevel-1)))
icon:SetModel(v)
icon:SetIconSize(64)
icon:SetToolTip()
icon.DoClick = function()
RunConsoleCommand("rp_playermodel", v)
RunConsoleCommand("_rp_ChosenModel", v)
DoChatCommand(frame)
end
end
else
DoChatCommand(hordiv:GetParent():GetParent())
end
end
if icon:IsValid() then
Panel:AddItem(icon)
end
end
for k,v in ipairs(RPExtraTeams) do
if LocalPlayer():Team() ~= k then
local nodude = true
if v.admin == 1 and not LocalPlayer():IsAdmin() then
nodude = false
end
if v.admin > 1 and not LocalPlayer():IsSuperAdmin() then
nodude = false
end
if v.customCheck and not v.customCheck(LocalPlayer()) then
nodude = false
end
if (type(v.NeedToChangeFrom) == "number" and LocalPlayer():Team() ~= v.NeedToChangeFrom) or (type(v.NeedToChangeFrom) == "table" and not table.HasValue(v.NeedToChangeFrom, LocalPlayer():Team())) then
nodude = false
end
if nodude then
local weps = "no extra weapons"
if #v.Weapons > 0 then
weps = table.concat(v.Weapons, "\n")
end
if v.Vote then
local condition = ((v.admin == 0 and LocalPlayer():IsAdmin()) or (v.admin == 1 and LocalPlayer():IsSuperAdmin()) or LocalPlayer().DarkRPVars["Priv"..v.command])
if not v.model or not v.name or not v.Des or not v.command then chat.AddText(Color(255,0,0,255), "Incorrect team! Fix your shared.lua!") return end
AddIcon(v.model, v.name, v.Des, weps, "/vote"..v.command, condition, "/"..v.command)
else
if not v.model or not v.name or not v.Des or not v.command then chat.AddText(Color(255,0,0,255), "Incorrect team! Fix your shared.lua!") return end
AddIcon(v.model, v.name, v.Des, weps, "/"..v.command)
end
end
end
end
end
hordiv:Update()
return hordiv
end
[/lua]
I've tried with icon: and Information: but cant seem to get it right. I'm not entirely sure on how to go about doing this.
So I was following this tutorial: [url]http://www.youtube.com/watch?v=oZWf3flrFSg[/url] and I get this error
[CODE][addons\velocity\lua\autorun\velocity.lua:8] attempt to index global 'GM' (a nil value)[/CODE]
(I named it velocity because I want to make a speedometer later)
It hides the hud perfectly but then I get the error at line
[CODE]function GM:HUDPaint()[/CODE]
Any ideas why would that be? Thanks.
GM:HUDPaint is for gamemodes, which is loaded after autorun hence it's nil when your file is ran.
Use this instead:
[lua]hook.Add( "HUDPaint", "DrawSpeedo?", function()
-- your code here
end )[/lua]
Im kinda wondering how. to add world props to a map. that will spawn when server starts or a script that can spawn em :)
Something like:
[lua]
local function CreateWorldProp( model, pos, ang )
local ent = ents.Create( "prop_physics" )
ent:SetModel( model )
ent:SetPos( pos )
ent:SetAngles( ang )
ent:Spawn()
return ent
end
hook.Add( "InitPostEntity", "CreateWorldProps", function()
CreateWorldProp( "models/props_borealis/bluebarrel001.mdl", Vector( 0, 0, 0 ), Angle( 0, 0, 0 ) )
-- etc
end )
[/lua]
Anywhere serverside (lua/autorun/server/asdf.lua)
thanks
So I've been working on a gamemode and decided to make a character creation screen, but the DTextEntry I'm using doesn't want to take focus. Any suggestions?
Here's some of the code:
--snip--
[b]EDIT:[/b] Fixed by using MakePopup on the EditablePanel.
Sorry, you need to Log In to post a reply to this thread.