[QUOTE=Nalestom;37536886]I've run into a bit of a problem with my custom HUD for a gamemode I'm making.
I'm working on the gamemode from two different computers, which isn't as big of a problem as it sounds: whenever I finish modifying the lua files, I just copy and overwrite the files onto the second computer. Everything works perfectly except for my custom HUD. The code is extremely simple and shouldn't be causing any problems.
[lua]
function DrawHudBackground()
surface.SetTexture(surface.GetTextureID("MonopolyInterface/hudfinal"))
surface.SetDrawColor(255, 255, 255, 255)
surface.DrawTexturedRect(0, 0, ScrW(), ScrH())
end
[/lua]
The function is later called with a typical HUDPaint hook.
On my primary computer, the HUD works perfectly. On the secondary computer, I get a missing texture. The file is most definitely there and follows the same filepath on both computers. I can't think of anything else that would be causing an issue.
Any thoughts?
I don't get any lua errors at all - just a missing texture screen.[/QUOTE]
Any ideas on this? I've looked at everything and still can't find a reason why this is happening.
[QUOTE=ralle105;37548866][lua]
local plys = player.GetAll()
for i=1, #plys/4 do
table.remove(plys,math.random(#plys)):SetTeam(2)
end
[/lua][/QUOTE] Thanks very much :D so will this set the players to team 2 before the round starts and will spawn them in the right place?
It will change their team, no more no less. Where you put the code is up to you.
[QUOTE=ralle105;37550877]It will change their team, no more no less. Where you put the code is up to you.[/QUOTE] Okay thanks :) thats code is a massive help anyway, I'll trial and error this in different places and with other functions etc. :)
Do you think this will work:
[lua]function GM:PreRoundStart
local plys = player.GetAll()
for i=1, #plys/4 do
table.remove(plys,math.random(#plys)):SetTeam(2)
end[/lua]
well last question!, what sthe best way to handle custom weapon movement? i.e when the player is moving based on direction make his weapon "Bob", i.e move slightly to left and righ and a bit up
what i got this far was just interpolate between 2 position vectors if the player is moving but the effect i got is pretty much too bad to even use it
[QUOTE=werewolf0020;37551566]well last question!, what sthe best way to handle custom weapon movement? i.e when the player is moving based on direction make his weapon "Bob", i.e move slightly to left and righ and a bit up
what i got this far was just interpolate between 2 position vectors if the player is moving but the effect i got is pretty much too bad to even use it[/QUOTE]
Again, sin/cos is probably your best bet, generally if you want anything to oscillate smoothly between two numbers use sin/cos.
[QUOTE=georgeface;37551327]Okay thanks :) thats code is a massive help anyway, I'll trial and error this in different places and with other functions etc. :)
Do you think this will work:
[lua]function GM:PreRoundStart
local plys = player.GetAll()
for i=1, #plys/4 do
table.remove(plys,math.random(#plys)):SetTeam(2)
end[/lua][/QUOTE]
No, that will error.
[lua]
function GM:PreRoundStart
local plys = player.GetAll();
for i = 1, #plys/4 do
table.remove(plys, math.random( #plys )):SetTeam(2);
end
end
[/lua]
[QUOTE=JustSoFaded;37552262]No, that will error.
[/QUOTE]
[lua]
function GM:PreRoundStart() //forgot ()
local plys = player.GetAll();
for i = 1, #plys/4 do
table.remove(plys, math.random( #plys )):SetTeam(2);
end
end
[/lua]
[QUOTE=Drakehawke;37551925]Again, sin/cos is probably your best bet, generally if you want anything to oscillate smoothly between two numbers use sin/cos.[/QUOTE]
well for movement i dont want to have smooth change between 2 numbers but rather than that like move weapon up a bit every step, etc so yeah
I want to learn how to make Sweps for Gmod. Where do I start? I want to know what SWEP bases are suitable for beginners. If anyone can show me how to get started with SWEP making, that'd be great!
Thanks!
[QUOTE=brandokid25;37553600]I want to learn how to make Sweps for Gmod. Where do I start? I want to know what SWEP bases are suitable for beginners. If anyone can show me how to get started with SWEP making, that'd be great!
Thanks![/QUOTE]
Hey man, here's a good link, when your done follow the tutorial series, or check the lua tutorials on the side :) [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index8e50.html[/url] I also use this site for any help before I post here
How do I create a working particle effect? Here's a list of pages I've been looking at.
[url]https://developer.valvesoftware.com/wiki/List_of_TF2_Particles[/url]
[url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index1a54-2.html[/url]
[url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index09d2.html[/url]
[url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index2a9e.html[/url]
And perhaps most useful, [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index15bb.html[/url]
No matter what I do, I cannot get anything to show. The console tells me things like
[code]
Attemped to precache unknown particle system "medicgun_beam_blue"!
Attempting to create unknown particle system 'medicgun_beam_blue'
[/code]
Could someone please find a working particle and tell me how to make it appear?
[editline]5th September 2012[/editline]
This is in gm13, by the way.
[QUOTE=georgeface;37554793]Hey man, here's a good link, when your done follow the tutorial series, or check the lua tutorials on the side :) [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index8e50.html[/url] I also use this site for any help before I post here[/QUOTE]
Much appreciated
I need help making a VGUI menu or whatever, currently I have this
[lua]function DrawMenu()
local DermaPanel = vgui.Create("DFrame")
DermaPanel:SetPos(50,50)
DermaPanel:SetSize(500,500)
DermaPanel:SetTitle("Settings Menu")
DermaPanel:SetVisible(true)
DermaPanel:SetDraggable(true)
DermaPanel:ShowCloseButton(true)
DermaPanel:MakePopup()
local propsheet = vgui.Create("DPropertySheet")
propsheet:SetParent(DermaPanel)
propsheet:SetPos(5, 30)
propsheet:SetSize(340, 315)
local item1 = vgui.Create( "DCheckBoxLabel" )
item1:SetText("Enabled")
item1:SetConVar(toggle)
item1:SetValue(not toggle)
item1:SizeToContents()
local item2 = vgui.Create( "DCheckBoxLabel" )
item2:SetText("Toggle")
item2:SetConVar(toggle)
item2:SetValue(not toggle)
item2:SizeToContents()
propsheet:AddSheet("Settings",item1, false, false)
end[/lua]
I'm trying to get two check boxes in one sheet or whatever, can't seem to figure it out. Anyone know how?
[QUOTE=skar;37555552]I need help making a VGUI menu or whatever, currently I have this
[lua]function DrawMenu()
local DermaPanel = vgui.Create("DFrame")
DermaPanel:SetPos(50,50)
DermaPanel:SetSize(500,500)
DermaPanel:SetTitle("Settings Menu")
DermaPanel:SetVisible(true)
DermaPanel:SetDraggable(true)
DermaPanel:ShowCloseButton(true)
DermaPanel:MakePopup()
local propsheet = vgui.Create("DPropertySheet")
propsheet:SetParent(DermaPanel)
propsheet:SetPos(5, 30)
propsheet:SetSize(340, 315)
local item1 = vgui.Create( "DCheckBoxLabel" )
item1:SetText("Enabled")
item1:SetConVar(toggle)
item1:SetValue(not toggle)
item1:SizeToContents()
local item2 = vgui.Create( "DCheckBoxLabel" )
item2:SetText("Toggle")
item2:SetConVar(toggle)
item2:SetValue(not toggle)
item2:SizeToContents()
propsheet:AddSheet("Settings",item1, false, false)
end[/lua]
I'm trying to get two check boxes in one sheet or whatever, can't seem to figure it out. Anyone know how?[/QUOTE]
Make DPanel, put stuff on DPanel, add the DPanel to the DPropertySheet
[QUOTE=Deadman123;37556879]Make DPanel, put stuff on DPanel, add the DPanel to the DPropertySheet[/QUOTE]
[lua] local frame = vgui.Create("DFrame")
frame:SetPos(50,50)
frame:SetSize(500,500)
frame:SetTitle("Settings Menu")
frame:SetVisible(true)
frame:SetDraggable(true)
frame:ShowCloseButton(true)
frame:MakePopup()
local dpanel = vgui.Create("DPanel",frame)
dpanel:SetPos(55, 55)
dpanel:SetSize(495, 495)
dpanel.Paint = function()
surface.SetDrawColor(50, 50, 50, 255)
surface.DrawRect(0, 0, dpanel:GetWide(), dpanel:GetTall())
end
local propsheet = vgui.Create("DPropertySheet")
propsheet:SetParent(frame)
propsheet:SetPos(5, 30)
propsheet:SetSize(340, 315)
local item1 = vgui.Create( "DCheckBoxLabel" )
item1:SetText("Enabled")
item1:SetConVar(enabled)
item1:SetValue(not enabled)
item1:SizeToContents()
local item2 = vgui.Create( "DCheckBoxLabel" )
item2:SetText("Toggle")
item2:SetConVar(toggle)
item2:SetValue(not toggle)
item2:SizeToContents()
propsheet:AddSheet("Settings",dpanel, false, false)[/lua]
Like that..?
[QUOTE=skar;37557722][lua] local frame = vgui.Create("DFrame")
frame:SetPos(50,50)
frame:SetSize(500,500)
frame:SetTitle("Settings Menu")
frame:SetVisible(true)
frame:SetDraggable(true)
frame:ShowCloseButton(true)
frame:MakePopup()
local dpanel = vgui.Create("DPanel",frame)
dpanel:SetPos(55, 55)
dpanel:SetSize(495, 495)
dpanel.Paint = function()
surface.SetDrawColor(50, 50, 50, 255)
surface.DrawRect(0, 0, dpanel:GetWide(), dpanel:GetTall())
end
local propsheet = vgui.Create("DPropertySheet")
propsheet:SetParent(frame)
propsheet:SetPos(5, 30)
propsheet:SetSize(340, 315)
local item1 = vgui.Create( "DCheckBoxLabel" )
item1:SetText("Enabled")
item1:SetConVar(enabled)
item1:SetValue(not enabled)
item1:SizeToContents()
local item2 = vgui.Create( "DCheckBoxLabel" )
item2:SetText("Toggle")
item2:SetConVar(toggle)
item2:SetValue(not toggle)
item2:SizeToContents()
propsheet:AddSheet("Settings",dpanel, false, false)[/lua]
Like that..?[/QUOTE]
Uhh on the right track, parent the check boxes to the DPanel, unparent the dpanel from the frame.
[QUOTE=Deadman123;37558212]Uhh on the right track, parent the check boxes to the DPanel, unparent the dpanel from the frame.[/QUOTE]
Okay, and I'm confused about the SetConVar() and SetValue() functions. Am I using them right? I'm trying to change the variable to the opposite of that (i.e. if enabled = true, enabled should be false when I untick the checkbox).
Also, how would I get two checkboxes on one sheet, and have others on other sheets, if they're all parented to the same panel?
[editline]6th September 2012[/editline]
If it helps, I want something like this except with checkboxes and sliders instead of the file system.
[url]http://www.constructivenews.net/wp-content/uploads/2011/10/2011-08-30_00002.jpg[/url]
I'm keen on making an SNPC from scratch in Garry's Mod. Does anyone have any documentation or the original code for the NPCs that come with the base game?
Alright, my friend's fix didn't fix the error, so here we go again:
Basically, I'm fixing Tiramisu 2 for GMod 13 for a friend of mine, and timer.Create() does not seem to want to work.
Here's the code:
[lua]init.lua, Line 52 - timer.Create( "timesave", 120, 0, CAKE.SaveTime )[/lua]
Here's the error it gives me:
[lua]timer.Create - called wrong!
1. lua/includes/modules/timer.lua:59 (Create)
2. gamemodes/tiramisu/gamemode/init.lua:52 (unknown)
3. [C]:-1 (pcall)
4. lua/includes/modules/hook.lua:105 (unknown)
[/lua]
CAKE.SaveTime is created in schemas/global/plugins/time/sv_time.lua on line 44:
[lua]function CAKE.SaveTime()
local clumpedtime = CAKE.ClockDay .. " " .. CAKE.ClockMonth .. " " .. CAKE.ClockYear .. " " .. CAKE.ClockMins
file.Write(CAKE.Name .. "/time/" .. CAKE.ConVars[ "Schema" ] .. "/time.txt", clumpedtime)
end[/lua]
CAKE.SaveTime is nil. Make sure you define it before creating the timer.
[editline]6th September 2012[/editline]
Ninja snipper!
[QUOTE=ralle105;37563409]CAKE.SaveTime is nil. Make sure you define it before creating the timer.
[editline]6th September 2012[/editline]
Ninja snipper![/QUOTE]
But it is defined in sv_time.lua
[QUOTE=my_hat_stinks;37563579]Try
[lua]timer.Create( "timesave", 120, 0, function() CAKE.SaveTime() end)[/lua][/QUOTE]
Thanks, that actually got rid of the error.
So, since that worked for the first timer.Create, I tried doing the same thing to the second timer.Create which previously got the exact same error as the first one:
[lua]timer.Create( "sendtime", 1, 0, function() CAKE.SendTime() end )[/lua]
However, while the fix worked for the first timer.Create, it caused a whole new error for this one:
[lua]Timer 'sendtime' Error: [gamemodes/tiramisu/gamemode/init.lua:57] attempt to call field 'SendTime' (a nil value)
1. lua/includes/modules/timer.lua:172 (unknown)
2. [C]:-1 (pcall)
3. lua/includes/modules/hook.lua:80 (unknown)[/lua]
CAKE.SendTime() shouldn't return a nil value. It makes no sense.
[QUOTE=Jocken300;37563619]Thanks, that actually got rid of the error.
So, since that worked for the first timer.Create, I tried doing the same thing to the second timer.Create which previously got the exact same error as the first one:
[lua]timer.Create( "sendtime", 1, 0, function() CAKE.SendTime() end )[/lua]
However, while the fix worked for the first timer.Create, it caused a whole new error for this one:
[lua]Timer 'sendtime' Error: [gamemodes/tiramisu/gamemode/init.lua:57] attempt to call field 'SendTime' (a nil value)
1. lua/includes/modules/timer.lua:172 (unknown)
2. [C]:-1 (pcall)
3. lua/includes/modules/hook.lua:80 (unknown)[/lua]
CAKE.SendTime() shouldn't return a nil value. It makes no sense.[/QUOTE]
That error means the function "SendTime" itself is a nil value, not that it returns one (aka the function doesn't exist).
[QUOTE=Jocken300;37563520]But it is defined in sv_time.lua[/QUOTE]
Then you're creating the timer before loading sv_time.lua
anyways, back to my vgui questions..
Is there an alternative to net.WriteByte since it was removed in Update 22?
[QUOTE=Jocken300;37566509]Is there an alternative to net.WriteByte since it was removed in Update 22?[/QUOTE]
Well, there's [url]http://wiki.garrysmod.com/page/Libraries/net/WriteInt[/url]
Or [url]http://wiki.garrysmod.com/page/Libraries/net/WriteBit[/url] if it's a boolean you're after
Or it looks like you can use this [url]http://wiki.garrysmod.com/page/Libraries/net/WriteData[/url] if it's really important for you to send exactly a byte
[QUOTE=skullorz;37552392][lua]
function GM:PreRoundStart() //forgot ()
local plys = player.GetAll();
for i = 1, #plys/4 do
table.remove(plys, math.random( #plys )):SetTeam(2);
end
end
[/lua][/QUOTE]
[img]http://www.facepunch.com/fp/ratings/winner.png[/img]
Sorry, you need to Log In to post a reply to this thread.