• What do you need help with? V3
    6,419 replies, posted
What's the most efficient way to find an entity spawned by the map each time. The entity's index changes.
[QUOTE=Disseminate;38878961]Are the lines parallel? If so, you can use util.DistanceToLine for any point. Are they skew? Then the distance varies. [/QUOTE] Could be either, think a don't-cross-the-beams sort of thing
Google intersection of two lines in R3.
[QUOTE=Hyper Iguana;38882914]What's the most efficient way to find an entity spawned by the map each time. The entity's index changes.[/QUOTE] Probably a quick for loop through ents.GetAll() [CODE]SoundScapeTable = {} function FindSoundScapes() //finds all of the map's soundscape entities and adds them to a table for k, v in pairs(ents.GetAll()) do if(v:GetClass()=="env_soundscape") then table.insert(SoundScapeTable, v); end end end FindSoundScapes()[/CODE]
I need some help figuring out how to make a polygon draw inside the viewmodel (Circular Render Target, RT scope n' all) [code] if CLIENT then function SWEP:ViewModelDrawn() self.AcogGlass = Material( "models/wystan/attachments/acog/lense" ) self.AcogRT = GetRenderTarget( "acog_glass_rt", 512, 512, false ) self.AcogGlass:SetTexture( "$basetexture", self.AcogRT ) local vm = self.Owner:GetViewModel() local bone = vm:LookupBone("v_weapon.sg552_Parent") if !bone then print("bone doesnt exist") end local pos, ang = Vector(0,0,0), Angle(0,0,0) local m = vm:GetBoneMatrix(bone) if (m) then pos, ang = m:GetTranslation(), m:GetAngles() end pos = pos + Vector(0,0,0) ang = ang + Angle(0,0,0) print(pos) print(ang) local Radar = {} Radar.circle= {} Radar.res = 52 Radar.radarRadius = 100; for i=1,Radar.res do Radar.circle[i] = {} Radar.circle[i].x = pos.x + math.cos(math.rad( (i*360)/Radar.res ))*Radar.radarRadius*0.99 Radar.circle[i].y = pos.y + math.sin(math.rad( (i*360)/Radar.res ))*Radar.radarRadius*0.99 Radar.circle[i].u = (math.cos(math.rad( (i*360)/Radar.res )) + 1)*0.5 Radar.circle[i].v = -(math.sin(math.rad( (i*360)/Radar.res )) + 1)*0.5 end cam.Start3D(pos, ang , 4, pos.x, pos.y, 512,512) surface.SetMaterial(self.AcogGlass) surface.SetDrawColor(255, 255, 255, 255) surface.DrawPoly(Radar.circle) cam.End3D() render.SetViewPort( pos.x, pos.y, 20, 20 ) render.SetRenderTarget( old ) end end) --circular radar code obviously jipped from BaseWars radar. With permission! [/code] All inside of ViewModelDrawn, and the drawpos is the same code from SWEP creation kit. i honestly cannot manage to do this. (edited to most recent code)
Can I somehow disable tabs painting on DPropertySheet? Using Paint will only make the background disappear :/ [IMG]http://puu.sh/1CIl8[/IMG]
[QUOTE=ollie;38890268]Can I somehow disable tabs painting on DPropertySheet? Using Paint will only make the background disappear :/ [IMG]http://puu.sh/1CIl8[/IMG][/QUOTE] Create your own skin and edit the DPropertySheet tabs with your own paint func.
[QUOTE=Archemyde;38890289]Create your own skin and edit the DPropertySheet tabs with your own paint func.[/QUOTE] Tried to do that but I couldn't find a good way. I think i'll just make fake property sheets.
[QUOTE=jrj996;38879621]I'm currently trying to make a fade effect that uses math.Approach, but if frames are low it fades away wayyy too slowly, how do I fix this?[/QUOTE] Multiply the rate by FrameTime() That being said you should just do it procedural instead of holding on to a variable.
[QUOTE=M0dSe7en;38853554]I'm trying to write an xp system. I'm using the net library and I'm wondering how I should use net.WriteUInt(). I'm learning c++ and I know an unsigned int has more range than the default int range. However, the second argument for net.WriteUInt() requires the size of the message. How would i find the size of the message?[/QUOTE] unsigned int has the same range as the signed one, it's just that all numbers have to be > 0 (correct me if I'm wrong, I'm really tired). And the message size is the integer's size in bits.
[lua] if CLIENT then concommand.add("Donate",function(pl, cmd, args) local Frame = vgui.Create("DFrame") Frame:SetSize(ScrW() - 20, ScrH() - 20) Frame:Center() Frame:SetTitle("Donate") Frame:MakePopup() Frame:SetMouseInputEnabled(true) local html = vgui.Create("DHTML", Frame) html:SetPos(5,25) html:SetSize(ScrW() - 30, ScrH() - 30) html:OpenURL("http://forum.ammgaming.com/index.php?page=Donate") end) end if SERVER then hook.Add("PlayerSay", "ChatHook", function(Player, Text, Public) if Text[1] == "!" then Text = Text:lower() if Text == "!donate" then Player:ConCommand("Donate") return "" end end end) end [/lua] Getting the error [ERROR] lua/autorun/donate.lua:20: '=' expected near 'Text' 1. unknown - lua/autorun/donate.lua:0 can some1 please tell me what im doing wrong? please can any1 help me with this?
[QUOTE=gemmono2;38891441][lua] if CLIENT then concommand.add("Donate",function(pl, cmd, args) local Frame = vgui.Create("DFrame") Frame:SetSize(ScrW() - 20, ScrH() - 20) Frame:Center() Frame:SetTitle("Donate") Frame:MakePopup() Frame:SetMouseInputEnabled(true) local html = vgui.Create("DHTML", Frame) html:SetPos(5,25) html:SetSize(ScrW() - 30, ScrH() - 30) html:OpenURL("http://forum.ammgaming.com/index.php?page=Donate") end) end if SERVER then hook.Add("PlayerSay", "ChatHook", function(Player, Text, Public) if Text[1] == "!" then Text = Text:lower() if Text == "!donate" then Player:ConCommand("Donate") return "" end end end) end [/lua] Getting the error [ERROR] lua/autorun/donate.lua:20: '=' expected near 'Text' 1. unknown - lua/autorun/donate.lua:0 can some1 please tell me what im doing wrong? please can any1 help me with this?[/QUOTE] [lua] if CLIENT then concommand.add("Donate",function(pl, cmd, args) local Frame = vgui.Create("DFrame") Frame:SetSize(ScrW() - 20, ScrH() - 20) Frame:Center() Frame:SetTitle("Donate") Frame:MakePopup() Frame:SetMouseInputEnabled(true) local html = vgui.Create("DHTML", Frame) html:SetPos(5,25) html:SetSize(ScrW() - 30, ScrH() - 30) html:OpenURL("http://forum.ammgaming.com/index.php?page=Donate") end) end if SERVER then hook.Add("PlayerSay", "ChatHook", function(Player, Text, Public) if Text[1] == "!" then Text = string.lower(Text) if Text == "!donate" then Player:ConCommand("Donate") return "" end end end) end [/lua] use string.lower(blah) to make it lowercase Also fix your indentation! [editline]19th December 2012[/editline] [QUOTE=M0dSe7en;38853554]I'm trying to write an xp system. I'm using the net library and I'm wondering how I should use net.WriteUInt(). I'm learning c++ and I know an unsigned int has more range than the default int range. However, the second argument for net.WriteUInt() requires the size of the message. How would i find the size of the message?[/QUOTE] (signed) integers use the first bit to signify +ve or -ve unsigned integers can therefore use the extra bit to signify a larger number, since they are always positive So on a 32 bit system, we have integers ranging from –2,147,483,648 to 2,147,483,647 (normal) and unsigned integers from 0 to 4,294,967,295 As you can see, both have the same size (32 bits) but can represent different ranges. As for getting the size of the integer... if you know you're dealing with small integers, such as 1 through 4 for example, you could get away with putting a size of 3 bits. This is purely for the sake of efficiency. If you have no idea what size, you can use 32, which would give you the range of the usigned integer above. It would be inefficient though, and I'd suggest looking into some sensible value ranges. If you're super keen, you could try detecting the size in bits of a number in Lua. To do that you could convert to binary using a fairly simple method, then convert that to a string and count how many elements in that string (representing the number of bits you need to send i.e the size argument)
[QUOTE=KatNotDinner;38891305]unsigned int has the same range as the signed one[/QUOTE] An unsigned int and an int use the same number of bytes, but the unsigned int has a much larger range than the regular int. Roughly twice as large actually. Since the number range that normally maps from a negative to a positive now only maps from 0 to positive. Here are the ranges of an average int. signed: -2147483648 to 2147483647 unsigned: 0 to 4294967295 Edit: Ninja'd with a better description anyway.
[QUOTE=Trumple;38891791][lua] if CLIENT then concommand.add("Donate",function(pl, cmd, args) local Frame = vgui.Create("DFrame") Frame:SetSize(ScrW() - 20, ScrH() - 20) Frame:Center() Frame:SetTitle("Donate") Frame:MakePopup() Frame:SetMouseInputEnabled(true) local html = vgui.Create("DHTML", Frame) html:SetPos(5,25) html:SetSize(ScrW() - 30, ScrH() - 30) html:OpenURL("http://forum.ammgaming.com/index.php?page=Donate") end) end if SERVER then hook.Add("PlayerSay", "ChatHook", function(Player, Text, Public) if Text[1] == "!" then Text = string.lower(Text) if Text == "!donate" then Player:ConCommand("Donate") return "" end end end) end [/lua] use string.lower(blah) to make it lowercase Also fix your indentation! [editline]19th December 2012[/editline] (signed) integers use the first bit to signify +ve or -ve unsigned integers can therefore use the extra bit to signify a larger number, since they are always positive So on a 32 bit system, we have integers ranging from –2,147,483,648 to 2,147,483,647 (normal) and unsigned integers from 0 to 4,294,967,295 As you can see, both have the same size (32 bits) but can represent different ranges. As for getting the size of the integer... if you know you're dealing with small integers, such as 1 through 4 for example, you could get away with putting a size of 3 bits. This is purely for the sake of efficiency. If you have no idea what size, you can use 32, which would give you the range of the usigned integer above. It would be inefficient though, and I'd suggest looking into some sensible value ranges. If you're super keen, you could try detecting the size in bits of a number in Lua. To do that you could convert to binary using a fairly simple method, then convert that to a string and count how many elements in that string (representing the number of bits you need to send i.e the size argument)[/QUOTE] I.LOVE.You
[QUOTE=ollie;38890268]Can I somehow disable tabs painting on DPropertySheet? Using Paint will only make the background disappear :/ [IMG]http://puu.sh/1CIl8[/IMG][/QUOTE] [lua] local sheet = dprop:AddSheet( /*args*/ ); sheet.Tab.Paint = function( self ) --do you tab painting here. end[/lua]
[QUOTE=JustSoFaded;38894068][lua] local sheet = dprop:AddSheet( /*args*/ ); sheet.Paint = function( self ) --do you tab painting here. end[/lua][/QUOTE] Are you sure? Looking at the [url=http://glua.me/bin/?path=/lua/vgui/dpropertysheet.lua]source[/url], it seems like he should be overriding sheet.Tab.Paint to me?
[QUOTE=M0dSe7en;38882002]Anyone know how to fix this PCF bug I'm getting? I made a small effect for testing, and I used this script to see if I'm using ParticleEffectAttach() correctly: [lua] if (CLIENT) then game.AddParticles( "particles/test1.pcf" ) end function AttachParticle() for k,v in pairs(player.GetAll()) do if v:IsPlayer() && v:Alive() then local id = v:LookupAttachment("eyes") //local att = v:GetAttachment(id) ParticleEffectAttach("test2",PATTACH_ABSORIGIN_FOLLOW,v,id) end end end concommand.Add("test_particle", AttachParticle) function StopParticles() for k,v in pairs(player.GetAll()) do if v:IsPlayer() then v:StopParticles() end end end concommand.Add("stop_particles", StopParticles) [/lua] The effect works, but it only spawn at Vector(0,0,0) on whatever map i choose. In gmod 12, I used ply.GetAttachment( attachmentID ) rather than just ply.LookupAttachment( string ) and it worked fine. This is the first effect I made, so I don't know if I'm using the function wrong, or if my effect is bugged. Thanks.[/QUOTE] Bumping, I really need to know this.
[QUOTE=Drakehawke;38894172]Are you sure? Looking at the [url=http://glua.me/bin/?path=/lua/vgui/dpropertysheet.lua]source[/url], it seems like he should be overriding sheet.Tab.Paint to me?[/QUOTE] Ah yes, I misread the code. Thanks for correcting me.
Hey, my gamemode doesn't start due to "something" creating script errors, I get these errors in the console. [lua][ERROR] gamemodes/jail/gamemode/init.lua:61: bad argument #2 to 'Exists' (string expected, got no value) 1. Exists - [C]:-1 2. unknown - gamemodes/jail/gamemode/init.lua:61[/lua] And this is the code at line 61 [code] if file.Exists("jail/"..game.GetMap()..".txt") then self.MapFile = util.KeyValuesToTable( file.Read("jail/"..game.GetMap()..".txt") ) for _, entt in pairs(self.MapFile.weapons) do entt = string.Explode(" ", entt) if entt and entt[1] then local ent = ents.Create(entt[1]) if IsValid( ent ) then ent:SetPos(Vector(entt[2] or 0, entt[3] or 0, entt[4] or 0)) ent:Spawn() ent:Activate() end end end end [/code]
[QUOTE=Source12;38895413]Hey, my gamemode doesn't start due to "something" creating script errors, I get these errors in the console. [code][ERROR] gamemodes/jail/gamemode/init.lua:61: bad argument #2 to 'Exists' (string expected, got no value) 1. Exists - [C]:-1 2. unknown - gamemodes/jail/gamemode/init.lua:61[/code] And this is the code at line 61 [code] if file.Exists("jail/"..game.GetMap()..".txt") then self.MapFile = util.KeyValuesToTable( file.Read("jail/"..game.GetMap()..".txt") ) for _, entt in pairs(self.MapFile.weapons) do entt = string.Explode(" ", entt) if entt and entt[1] then local ent = ents.Create(entt[1]) if IsValid( ent ) then ent:SetPos(Vector(entt[2] or 0, entt[3] or 0, entt[4] or 0)) ent:Spawn() ent:Activate() end end end end [/code][/QUOTE] [url]https://docs.google.com/document/d/1khSuIYrAMkqXu7wlH5YRJNwz6hOH6Xqi5lqBhE3x6gA/edit[/url]
-ninjad-
still need help with my RT Scope problem. [url]http://www.facepunch.com/showthread.php?t=1233845[/url]
[QUOTE=Archemyde;38895535]still need help with my RT Scope problem. [url]http://www.facepunch.com/showthread.php?t=1233845[/url][/QUOTE] You're bumping way too early and also advertising everywhere. Just wait some time and someone may answer.
[QUOTE=Leystryku;38895588]You're bumping way too early and also advertising everywhere. Just wait some time and someone may answer.[/QUOTE] okay. -snip, ill save it for a PM-
More errors: [code][ERROR] gamemodes/jail/entities/weapons/css_knife/shared.lua:52: bad argument #2 to 'CreateFont' (table expected, got number) 1. CreateFont - [C]:-1 2. unknown - gamemodes/jail/entities/weapons/css_knife/shared.lua:52[/code] [lua]surface.CreateFont("csd", ScreenScale(30), 500, true, true, "CSKillIcons")[/lua] Can't seem to find how Gmod 13 broke surface.CreateFont
[QUOTE=Source12;38895770]More errors: [code][ERROR] gamemodes/jail/entities/weapons/css_knife/shared.lua:52: bad argument #2 to 'CreateFont' (table expected, got number) 1. CreateFont - [C]:-1 2. unknown - gamemodes/jail/entities/weapons/css_knife/shared.lua:52[/code] [lua]surface.CreateFont("csd", ScreenScale(30), 500, true, true, "CSKillIcons")[/lua] Can't seem to find how Gmod 13 broke surface.CreateFont[/QUOTE] It's like people can't read the errors of their own code. "TABLE EXPECTED GOT NUMBER" got it ? No ? Perhaps, take a look at this [url]http://wiki.garrysmod.com/page/Libraries/surface/CreateFont[/url]
[QUOTE=ollie;38890268]Can I somehow disable tabs painting on DPropertySheet? Using Paint will only make the background disappear :/ [IMG]http://puu.sh/1CIl8[/IMG][/QUOTE] Tabs are made up of [URL="http://glua.me/bin/?path=/lua/vgui/dpropertysheet.lua"]tables[/URL], just do a loop or directly access it. [lua] for k,v in pairs(PropertySheet.Items) do function v.Tab.Paint(self) --Do stuff end end [/lua]
I already made my own version of DPropertySheet, thanks for helping out though!
Does anyone happen to know how to remove the default player description when you hover over someone? [img]http://i.imgur.com/y34yL.png[/img] Only thing I could find is returning false on CHudGMod in the HUDShouldDraw hook, which did work, but also disabled anything I drew with draw.* aswell.
I want to make it so if a key is pressed then it will do one thing, but then if it is pressed again it will do another thing. Any help on doing this?
Sorry, you need to Log In to post a reply to this thread.