[QUOTE=PigeonTroll;48918589][code]
if IsValid(self.btnMaxim) then self.btnMaxim:Remove() end
if IsValid(self.btnMinim) then self.btnMinim:Remove() end
[/code]
gives me this
[code]
[ERROR] lua/vgui/dframe.lua:259: Tried to use invalid object (type Panel) (Object was NULL or not of the right type)
1. SetPos - [C]:-1
2. unknown - lua/vgui/dframe.lua:259
[ERROR] lua/vgui/dframe.lua:259: Tried to use invalid object (type Panel) (Object was NULL or not of the right type)
1. SetPos - [C]:-1
2. unknown - lua/vgui/dframe.lua:259
[/code][/QUOTE]
Remove works properly, the problem is that dframe still tries to use those buttons, resulting in errors.
I seem to have an issue with net.WriteString (or perhaps net.ReadString, I'm not sure). When I attempt to write a string containing special characters (that look like NUL, DLE, SOH, EOT and stuff like that), some of them appear to be discarded/removed. To see what I mean, try using file.Read to read any kind of image file (that contains those kind of special characters), then use net.WriteString on a shorter version of it, then check the length of the string before and after you send it.
[QUOTE=MPan1;48920957]I seem to have an issue with net.WriteString (or perhaps net.ReadString, I'm not sure). When I attempt to write a string containing special characters (that look like NUL, DLE, SOH, EOT and stuff like that), some of them appear to be discarded/removed. To see what I mean, try using file.Read to read any kind of image file (that contains those kind of special characters), then use net.WriteString on a shorter version of it, then check the length of the string before and after you send it.[/QUOTE]
use net.WriteData
When it says 'the length of the binary data to be sent, in bytes', how am I meant to find the byte size of a string? Or is it just the string's length? Probably obvious, but I don't know.
Edit: Ah, it's the string's length. THANKS SO MUCH, MAN!
I CAN NOW LAG A WHOLE SERVER BY SENDING AN IMAGE FROM ONE CLIENT TO ANOTHER!
-snip-
I have another issue- how can I get this DScrollPanel's scrolling bar to not show when it's children get removed?
[CODE]
concommand.Add( 'ScrollTest', function()
local base = vgui.Create( 'DFrame' )
base:SetSize( 200, 200 )
base:Center()
base:MakePopup()
local scroll = vgui.Create( 'DScrollPanel', base )
scroll:Dock( FILL )
local tbl = {}
for i = 1, 3 do
tbl[ #tbl+1 ] = vgui.Create( 'DPanel', scroll )
tbl[ #tbl ]:Dock( TOP )
tbl[ #tbl ]:SetSize( 0, 70 )
end
timer.Simple( 1, function()
for k, v in pairs( tbl ) do v:Remove() tbl[k] = nil end
end )
timer.Simple( 2, function()
scroll:InvalidateLayout() -- Doesn't work
end )
end )
[/CODE]
[QUOTE=MPan1;48921396]I have another issue- how can I get this DScrollPanel's scrolling bar to not show when it's children get removed?[/QUOTE]
Can't you just hook to the panels think function and set EnableVerticalScrollbar to false if #tbl = 0?
[QUOTE=DeathWard;48921432]Hook the think function to setting EnableVerticalScrollbar to false if #tbl = 0[/QUOTE]
EnableVerticalScrollbar throws an error for me, and even doing self.VBar:SetEnabled(false) doesn't work.
[editline]17th October 2015[/editline]
Jesus, to get it to do anything I have to do
[CODE]
function scroll:Think()
if #tbl == 0 then
self.pnlCanvas:SetVisible( false )
self.VBar:SetVisible( false )
for k, v in pairs( self.VBar:GetChildren() ) do v:SetVisible( false ) end
else
self.pnlCanvas:SetVisible( true )
self.VBar:SetVisible( true )
for k, v in pairs( self.VBar:GetChildren() ) do v:SetVisible( true ) end
end
end
[/CODE]
Surely there's a better way?
[code]
concommand.Add( 'ScrollTest', function()
local base = vgui.Create( 'DFrame' )
base:SetSize( 200, 200 )
base:Center()
base:MakePopup()
local scroll = vgui.Create( 'DScrollPanel', base )
scroll:Dock( FILL )
local tbl = {}
for i = 1, 3 do
tbl[ #tbl+1 ] = vgui.Create( 'DPanel', scroll )
tbl[ #tbl ]:Dock( TOP )
tbl[ #tbl ]:SetSize( 0, 70 )
end
timer.Simple( 1, function()
for k, v in pairs( tbl ) do v:Remove() tbl[k] = nil end
end )
timer.Simple( 1.1, function()
scroll.VBar:SetVisible(false)
end )
end )
[/code]
This works for me.
Wow, works for me as well... thanks!
[QUOTE=AIX-Who;48917453][CODE]
for k,v in pairs( ents.FindByClass("gmod_dynamite") ) do
v:Explode( delay, player )
end
Player does not have to be defined aswell, delay does though.
[/CODE][/QUOTE]
This works partially...it only blows up one dynamite and not all...(i tried server side as well just got NULL entity errors... It works clientside but only does one...
[QUOTE=Blakestr;48923459]This works partially...it only blows up one dynamite and not all...(i tried server side as well just got NULL entity errors... It works clientside but only does one...[/QUOTE]
That code runs perfectly fine on a single player game for me, it explodes all of the dynamite.
I am trying to create a functional weapon flashlight attachment for [url=http://steamcommunity.com/sharedfiles/filedetails/?id=349050451]Customizable Weaponry 2[/url].
what I do, is use ents.Create to create an env_projectedtexture. my problem with this, is that when the code I use is run, the following error is printed to the console:
[code]
[Customizable Weaponry 2.0] lua/cw/shared/attachments/cyn_md_flashlight_test.lua:24: attempt to call field 'Create' (a nil value)
1. attachFunc - lua/cw/shared/attachments/cyn_md_flashlight_test.lua:24
2. _attach - lua/weapons/cw_base/sh_attachments.lua:45
3. Function - lua/weapons/cw_base/sh_attachments.lua:307
4. unknown - lua/includes/modules/usermessage.lua:87[/code]
the code I am using (irrelevant code has been excluded):
[lua]
function att:attachFunc()
if CLIENT then
self.projectedlight = ents.Create("env_projectedtexture") -- line 24
if (!IsValid(self.projectedlight)) then return end
self.projectedlight:SetParent(self.AttachmentModelsVM.cyn_md_flashlight_test.ent)
self.projectedlight:SetPos(self.AttachmentModelsVM.cyn_md_flashlight_test.ent:GetAttachment(1).Pos)
self.projectedlight:SetAngles(self.AttachmentModelsVM.cyn_md_flashlight_test.ent:GetAttachment(1).Ang)
self.projectedlight:SetKeyValue("enableshadows", 1)
self.projectedlight:SetKeyValue("nearz", 4)
self.projectedlight:SetKeyValue("farz", 750.0)
self.projectedlight:SetKeyValue("lightfov", 70 )
self.projectedlight:Spawn()
self.projectedlight:Input("spotlighttexture", NULL, NULL, "effects/flashlight/hard")
end
end
[/lua]
[QUOTE=Blakestr;48923459]This works partially...it only blows up one dynamite and not all...(i tried server side as well just got NULL entity errors... It works clientside but only does one...[/QUOTE]
I made the changes live. I'll try restarting and see if that makes a difference.
[QUOTE=cynaraos;48925590]I am trying to create a functional weapon flashlight attachment for [url=http://steamcommunity.com/sharedfiles/filedetails/?id=349050451]Customizable Weaponry 2[/url].
what I do, is use ents.Create to create an env_projectedtexture. my problem with this, is that when the code I use is run, the following error is printed to the console:
[code]
[Customizable Weaponry 2.0] lua/cw/shared/attachments/cyn_md_flashlight_test.lua:24: attempt to call field 'Create' (a nil value)
1. attachFunc - lua/cw/shared/attachments/cyn_md_flashlight_test.lua:24
2. _attach - lua/weapons/cw_base/sh_attachments.lua:45
3. Function - lua/weapons/cw_base/sh_attachments.lua:307
4. unknown - lua/includes/modules/usermessage.lua:87[/code]
the code I am using (irrelevant code has been excluded):
[lua]
function att:attachFunc()
if CLIENT then
self.projectedlight = ents.Create("env_projectedtexture") -- line 24
if (!IsValid(self.projectedlight)) then return end
self.projectedlight:SetParent(self.AttachmentModelsVM.cyn_md_flashlight_test.ent)
self.projectedlight:SetPos(self.AttachmentModelsVM.cyn_md_flashlight_test.ent:GetAttachment(1).Pos)
self.projectedlight:SetAngles(self.AttachmentModelsVM.cyn_md_flashlight_test.ent:GetAttachment(1).Ang)
self.projectedlight:SetKeyValue("enableshadows", 1)
self.projectedlight:SetKeyValue("nearz", 4)
self.projectedlight:SetKeyValue("farz", 750.0)
self.projectedlight:SetKeyValue("lightfov", 70 )
self.projectedlight:Spawn()
self.projectedlight:Input("spotlighttexture", NULL, NULL, "effects/flashlight/hard")
end
end
[/lua][/QUOTE]
It's because ents.Create is a serversided function.
-snip-
i solved my issue
How can I add new buttons to the "C"-Context menu and the Right-Click Context menu? Is there a hook to use or a list to add to?
You mean this, [url]http://wiki.garrysmod.com/page/properties/Add[/url]?
Is there any way to Add/Set proxies on IMaterial ? Or atleast override already loaded material ?
Anyone know what's wrong with this code?
[code]
function DrawEyeLines()
local players = player.GetAll() -- Get all player entities.
if not tobool(DrawEyeTraces:GetInt()) then return end -- If this is false, do not continue.
local vm = players:EyePos() -- Get all players eye position. (I think?)
local t = util.GetPlayerTrace(players) -- Starts trace at targets viewpos and goes along a set line.
local tr = util.TraceLine(t) -- Does a "trace" with the playertrace data. Returns tr.HitPos where it touches something(?)
cam.Start3D(EyePos(), EyeAngles())
--Draw the laser beam.
render.SetMaterial(Material("sprites/bluelaser1"))
render.DrawBeam(vm.Pos, tr.HitPos, 2, 0, 12.5, Color(255, 0, 0, 255)) -- Draw a beam from the target's eyes to whatever they are aiming at.
--Draw a laser dot at the end of the beam.
local Size = math.random() * 1.35 --That .65 makes all the difference, Im sure.
render.SetMaterial(Material("Sprites/light_glow02_add_noz"))
render.DrawQuadEasy(tr.HitPos, (EyePos() - tr.HitPos):GetNormal(), Size, Size, Color(255,0,0,255), 0)
cam.End3D()
end
hook.Add("PostDrawTranslucentRenderables", "THISISUNIQUE", DrawEyeLines)
[/code]
[I]Sorry for the stupid amount of comments, I kept forgetting what each bit did.[/I] :downs:
Im trying to draw a beam from every players eye position to wherever they are looking, but I keep getting the following error:
[code]
lookinglines.lua:51: attempt to call method 'EyePos' (a nil value)
lookinglines.lua:51
[/code]
Ive been up all night trying to figure this out and im a bit stumped.
Any help would be much appreciated =)
Entity:EyePos is a function that can be used on an entity.
You used it on a table on Entities, a table doesn't have a function/method named EyePos.
[code] Get all players eye position. (I think?)[/code]
How do you expect that to work?
Can ent:Ignite() ignite the entity forever?
[QUOTE=deinemudda32;48929525]Can ent:Ignite() ignite the entity forever?[/QUOTE]
Use time like 9999999999
[QUOTE=Robotboy655;48929279]
How do you expect that to work?[/QUOTE]
I don't know, Im a bit confused.
How would you suggest going about what I'm trying to do?
Thank you.
You need to for-loop through each player and call the drawing code for each player.
[QUOTE=Robotboy655;48929999]You need to for-loop through each player and call the drawing code for each player.[/QUOTE]
So, something like this?
[code]
function DrawEyeLines()
for k, v in pairs( player.GetAll() ) do
if not tobool(DrawEyeTraces:GetInt()) then return end -- If this is false, do not continue.
local vm = v:EyePos()
local t = util.GetPlayerTrace(v) -- Starts trace at targets viewpos and goes along a set line.
local tr = util.TraceLine(t) -- Does a "trace" with the playertrace data. Returns tr.HitPos where it touches something(?)
cam.Start3D(EyePos(), EyeAngles())
//Draw the laser beam.
render.SetMaterial(Material("sprites/bluelaser1"))
render.DrawBeam(EyePos(), tr.HitPos, 2, 0, 12.5, Color(255, 0, 0, 255))
//Draw a laser dot at the end of the beam.
local Size = math.random() * 1.35 //That .65 makes all the difference
render.SetMaterial(Material("Sprites/light_glow02_add_noz"))
render.DrawQuadEasy(tr.HitPos, (EyePos() - tr.HitPos):GetNormal(), Size, Size, Color(255,0,0,255), 0)
cam.End3D()
end
end
hook.Add("PostDrawTranslucentRenderables", "THISISUNIQUE", DrawEyeLines)
[/code]
Sorry to keep bugging you. I really have no clue about this.
Yeah, but you do not need the cam.Start3D() stuff, PostDrawTranslucentRenderables hook is already has 3D rendering context.
[QUOTE=Robotboy655;48930240]Yeah, but you do not need the cam.Start3D() stuff, PostDrawTranslucentRenderables hook is already has 3D rendering context.[/QUOTE]
Hmm. This code doesn't seem to do anything, can you see what I did wrong?
[code]
function DrawEyeLines()
for k, v in pairs( player.GetAll() ) do
if not tobool(DrawEyeTraces:GetInt()) then return end
local vm = v:EyePos()
local t = util.GetPlayerTrace(v)
local tr = util.TraceLine(t)
render.SetMaterial(Material("sprites/bluelaser1"))
render.DrawBeam(EyePos(), tr.HitPos, 2, 0, 12.5, Color(255, 0, 0, 255))
local Size = math.random() * 1.35
render.SetMaterial(Material("Sprites/light_glow02_add_noz"))
render.DrawQuadEasy(tr.HitPos, (EyePos() - tr.HitPos):GetNormal(), Size, Size, Color(255,0,0,255), 0)
end
end
hook.Add("PostDrawTranslucentRenderables", "THISISUNIQUE", DrawEyeLines)
[/code]
Also, I can't seem to rate posts on here, is that because I haven't been a member long enough?
Thanks =)
Add in print("some string")'s in between every line and see what is called and what is not.
[QUOTE=Robotboy655;48930590]Add in print("some string")'s in between every line and see what is called and what is not.[/QUOTE]
[code]
function DrawEyeLines()
for k, v in pairs( player.GetAll() ) do
print("Got player")
if not tobool(DrawEyeTraces:GetInt()) then return end
print("Got past check")
local vm = v:EyePos()
print("Got eye pos")
local t = util.GetPlayerTrace(v)
print("Done playertrace")
local tr = util.TraceLine(t)
print("Done linetrace")
render.SetMaterial(Material("cable/new_cable_lit"))--sprites/bluelaser1
print("Set material")
render.DrawBeam(EyePos(), tr.HitPos, 5, 0, 12.5, Color(255, 0, 0, 255)) --2
print("Drawing beam")
local Size = math.random() * 1.35
print("Size random is working")
render.SetMaterial(Material("Sprites/light_glow02_add_noz"))
print("Set laser dot material")
render.DrawQuadEasy(tr.HitPos, (EyePos() - tr.HitPos):GetNormal(), Size, Size, Color(255,0,0,255), 0)
print("Drawing quad.")
end
end
hook.Add("PostDrawTranslucentRenderables", "THISISUNIQUE", DrawEyeLines)
[/code]
All of those show up in console when the script is run.
I changed the line material to make sure it wasn't just drawing an invisible line, but even with something I know works it still isn't showing.
This is what I was originally working from:
[url]https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexdd58.html[/url]
I guess it doesn't work anymore?
Sorry, you need to Log In to post a reply to this thread.