• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
-snip- Had to put silkicons outside hud
[QUOTE=RedNinja;46749994]How do I set a color to an entity on DModelPanel if the model is a playermodel? [CODE] local icon = vgui.Create( "DModelPanel", plypan ) icon:SetSize( 500,690 ) icon:SetPos( -150, -40 ) icon:SetModel( ply:GetModel() ) function icon:LayoutEntity( Entity ) return end -- disables default rotation local DColorPalette = vgui.Create( "DColorPalette", pan ) DColorPalette:SetPos( 370,545 ) DColorPalette:SetSize( 200, 25 ) DColorPalette.DoClick = function(b) icon:SetColor(DColorPalette:GetConVarR(),DColorPalette:GetConVarG(),DColorPalette:GetConVarB(),255) end [/CODE] [CODE] [ERROR] lua/vgui/dmodelpanel.lua:133: attempt to index field 'colColor' (a nil value) 1. unknown - lua/vgui/dmodelpanel.lua:133 [/CODE][/QUOTE] target the dmodelpanel.Entity to change color. Also use a timer.Simple 0 in the DoClick because it calls DoClick before it changes the color ( for the boxes mostly )..
Working on gsubbing a file.Read from my media player. I'm trying to remove anything in brackets (including the brackets themself) I already have a couple singular ones for the time being, so here's the examples of what I'm trying to do. [code] local newtitle = file.Read("nowplaying/streamnp.txt","DATA") newtitle = string.gsub(newtitle," %(Original Mix%)","") newtitle = string.gsub(newtitle," - Dubstep.NET Exclusive","") newtitle = string.gsub(newtitle," %[EDM.com Exclusive%]","") newtitle = string.gsub(newtitle," %[Dubstep.NET Exclusives%]","") newtitle = string.gsub(newtitle," %[EDM.com Exclusives%]","") newtitle = string.gsub(newtitle," %[--some pattern here to remove all characters--%]","") -- <--- This one is the one I need help with [/code]
[url]http://facepunch.com/showthread.php?t=1440912[/url] Inspired by this thread, I decided to create a Vehicle Damage script but I ran into a problem. For some stupid reason, seats are not picked up EntityTakeDamage so I decided to try a hacky way of doing it [code]function VehicleCheck() for k,v in pairs(ents.GetAll()) do if v:GetClass() == "prop_vehicle_prisoner_pod" or v:IsVehicle() then function v:OnTakeDamage( dmginfo ) print("anus2") end end end end hook.Add("Think","Vehicle Check",VehicleCheck)[/code] And this doesn't work, so much for trying. I pretty much pulled function v:OntakeDamage(dmginfo) out of my ass because it made sense in my head but I guess not :v:
[QUOTE=LUModder;46754747]Working on gsubbing a file.Read from my media player. I'm trying to remove anything in brackets (including the brackets themself) I already have a couple singular ones for the time being, so here's the examples of what I'm trying to do. [code] local newtitle = file.Read("nowplaying/streamnp.txt","DATA") newtitle = string.gsub(newtitle," %(Original Mix%)","") newtitle = string.gsub(newtitle," - Dubstep.NET Exclusive","") newtitle = string.gsub(newtitle," %[EDM.com Exclusive%]","") newtitle = string.gsub(newtitle," %[Dubstep.NET Exclusives%]","") newtitle = string.gsub(newtitle," %[EDM.com Exclusives%]","") newtitle = string.gsub(newtitle," %[--some pattern here to remove all characters--%]","") -- <--- This one is the one I need help with [/code][/QUOTE] try playing around with this: [LUA] local pattern = "^%s?%b[]%s?" print( ("[fukin sweet dubstep] cool.webm"):gsub( pattern, "" ) ) local pattern2 = "^.-%b[]%s?" print( ("track 1. [fukin sweet dubstep] cool.webm"):gsub( pattern2, "" ) ) [/LUA]
[QUOTE=ROFLBURGER;46754891][url]http://facepunch.com/showthread.php?t=1440912[/url] Inspired by this thread, I decided to create a Vehicle Damage script but I ran into a problem. For some stupid reason, seats are not picked up EntityTakeDamage so I decided to try a hacky way of doing it [code]function VehicleCheck() for k,v in pairs(ents.GetAll()) do if v:GetClass() == "prop_vehicle_prisoner_pod" or v:IsVehicle() then function v:OnTakeDamage( dmginfo ) print("anus2") end end end end hook.Add("Think","Vehicle Check",VehicleCheck)[/code] And this doesn't work, so much for trying. I pretty much pulled function v:OntakeDamage(dmginfo) out of my ass because it made sense in my head but I guess not :v:[/QUOTE] You need a bullet callback.. When the bullet callback is called it hit something.. If that something is a vehicle that do a hook.Call EntityTakeDamage with information from the bullet. You can also do the hook.Call on all children.
[QUOTE=Acecool;46755151]You need a bullet callback.. When the bullet callback is called it hit something.. If that something is a vehicle that do a hook.Call EntityTakeDamage with information from the bullet. You can also do the hook.Call on all children.[/QUOTE] Ok now how do I do a bullet callback that all weapons can use? [editline]19th December 2014[/editline] w/e I'll just make it exclusive to my weapon pack, thats what we use anyways
So uh... I've just come back to trying to learn coding... I tried to edit the sandbox gamemode so when a player is killed it will say so on the HUD. If someone could tell me whats wrong with what I have done that would be great :3 [CODE]function GM:HUDPaint() self:PaintWorldTips() -- Draw all of the default stuff BaseClass.HUDPaint( self ) surface.CreateFont( "Font", { font = "Arial", size = 50, weight = 500, blursize = 0, scanlines = 0, antialias = true, underline = false, italic = false, strikeout = false, symbol = false, rotary = false, shadow = false, additive = false, outline = false, } ) surface.SetTextColor( 0,110,0,255 ) surface.SetTextPos( 20, 20 ) surface.SetFont( "Font" ) hook.Add("PlayerDeath","EchoPlayerDeath",function(victim,inflictor,attacker) surface.DrawText(victim:Name() .. " Huehuehue " .. attacker:Name() .. " using " .. inflictor:GetModel()) end) self:PaintNotes() end[/CODE]
Ok I'm back with an issue I'm unable to fix myself this time. I'm making a house system, and instead of customly defining the houses' doors I'm simply defining two coordinates for ents.FindInBox for the whole house. [img]http://puu.sh/dC1ju/19c6373597.png[/img] Serverside it's picking up the doors perfectly fine, to synch the data between server and client I'm pushing a net.WriteTable to everybody when any information regarding a house has been updated. But clientside, it's not picking up ANY entities, the doors, the owner. I even popped a PrintTable(ents.GetAll()) in there and nothing appears. It's as if there's no such thing as an entity. [img]http://puu.sh/dC1d8/6a14ca2ee3.png[/img]
[QUOTE=ROFLBURGER;46755181]Ok now how do I do a bullet callback that all weapons can use? [editline]19th December 2014[/editline] w/e I'll just make it exclusive to my weapon pack, thats what we use anyways[/QUOTE] You'd need to change it in the swep code itself. If it is an addon, extract it and alter the Lua. If you have it in a collection that your server downloads, you'll need to remove it from the collection so it doesn't re-download and overwrite the extracted copy. Take a look at this: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/server_srcds_steamcmd/setting_up_downloads_using_recursive_resource_system.lua.html[/url] and [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/server_srcds_steamcmd/extracting_addons_to_remove_lua_etc.lua.html[/url] [editline]20th December 2014[/editline] [QUOTE=Red..;46755346]So uh... I've just come back to trying to learn coding... I tried to edit the sandbox gamemode so when a player is killed it will say so on the HUD. If someone could tell me whats wrong with what I have done that would be great :3 [CODE]function GM:HUDPaint() self:PaintWorldTips() -- Draw all of the default stuff BaseClass.HUDPaint( self ) surface.CreateFont( "Font", { font = "Arial", size = 50, weight = 500, blursize = 0, scanlines = 0, antialias = true, underline = false, italic = false, strikeout = false, symbol = false, rotary = false, shadow = false, additive = false, outline = false, } ) surface.SetTextColor( 0,110,0,255 ) surface.SetTextPos( 20, 20 ) surface.SetFont( "Font" ) hook.Add("PlayerDeath","EchoPlayerDeath",function(victim,inflictor,attacker) surface.DrawText(victim:Name() .. " Huehuehue " .. attacker:Name() .. " using " .. inflictor:GetModel()) end) self:PaintNotes() end[/CODE][/QUOTE] Don't add a hook in the HUDPaint hook otherwise it'll be re-added every frame. PlayerDeath is serverside so you'd need to network the death to everyone. Also, there are kill-messages built into the game. But, take a look at this for networking something to have it create a HUDPaint hook for x time before removing itself; but while the HUDPaint is active, it'll draw something on the screen: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/display_something_on_initial_spawn.lua.html[/url] [editline]20th December 2014[/editline] [QUOTE=Minteh Fresh;46755437]Ok I'm back with an issue I'm unable to fix myself this time. I'm making a house system, and instead of customly defining the houses' doors I'm simply defining two coordinates for ents.FindInBox for the whole house. [img]http://puu.sh/dC1ju/19c6373597.png[/img] Serverside it's picking up the doors perfectly fine, to synch the data between server and client I'm pushing a net.WriteTable to everybody when any information regarding a house has been updated. But clientside, it's not picking up ANY entities, the doors, the owner. I even popped a PrintTable(ents.GetAll()) in there and nothing appears. It's as if there's no such thing as an entity. [img]http://puu.sh/dC1d8/6a14ca2ee3.png[/img][/QUOTE] The reason it is showing as NULL Entity is because the client never saw the entity. When a player comes within range, it should output correctly. I'd recommend networking the ids of the doors instead. You could also force PVS to transmit on those entities so the client will be aware of what they are.
[QUOTE=Acecool;46755480]The reason it is showing as NULL Entity is because the client never saw the entity. When a player comes within range, it should output correctly. I'd recommend networking the ids of the doors instead. You could also force PVS to transmit on those entities so the client will be aware of what they are.[/QUOTE] I tried that, I'm doing a PrintTable for ents.GetAll() and it's giving me nothing :c I tried networking entindexes and then just finding the entity via its ent index through all these methods - ents.GetAll()[entindex], Entity(entindex) for k, v in pairs( ents.GetAll() ) do //compareentindex etc end But it just gave me nothing.. EDIT-- Now it's working, I didn't even change anything after I made this post and now it works..
If you get close enough then you should be able to see them. Make sure you add __tostring and __concat functions to the meta-tables in order to print( ) each type of data and to concatenate it. I already did it so this helps with dev work: [url]https://bitbucket.org/Acecool/acecooldev_base/src/master/gamemode/shared/_definitions/__metatables.lua?at=master[/url] [url]https://bitbucket.org/Acecool/acecooldev_base/src/master/gamemode/shared/_definitions/__metatables__tostring.lua?at=master[/url] [url]https://bitbucket.org/Acecool/acecooldev_base/src/master/gamemode/shared/core/print.lua?at=master[/url] [url]https://bitbucket.org/Acecool/acecooldev_base/src/master/gamemode/shared/core/toprint.lua?at=master[/url] [url]https://bitbucket.org/Acecool/acecooldev_base/src/master/gamemode/shared/core/ext_string.lua?at=master[/url]
Sorted it out myself <3 Ignore this post.
Hello guys, well this is a quick question, i've this: [code] local tbl = player.GetAll() table.sort(tbl, function(a, b) return (a:getDarkRPVar("kills") or 0) > (b:getDarkRPVar("kills") or 0) end) [/code] After all the code retrieve all the users online, is there a way to limit this to the TOP 5 ? like only show the first 5 ? Thanks !
Well, this code works perfectly, but there's this tiny problem... [code]local progress = vgui.Create( "DProgress", frame); progress:SetPos( 125, 250 ); progress:SetSize( 400, 40 ); local button1 = vgui.Create( "DButton", frame); button1:SetText( "Go Heavy" ); button1:SetPos( 25, 50 ); button1:SetSize( 150, 40 ); button1.DoClick = function( ) if progress:GetFraction( ) > 0.75 then ply:PrintMessage( HUD_PRINTTALK, "You can't restock anymore!") return end net.Start( "HeavyButtonPressed" ) net.SendToServer() progress:SetFraction( progress:GetFraction( ) + 0.25) end;[/code] Whenever you reopen the panel, the progress bar resets to 0, any way to hold it on a % until they die?
don't delete the parent panel, just hide it
Is there any way to mute Awesomium sound with lua?
[dumb question] how to make a gradient?
Unless you feel like drawing a lot of lines or rects, you have to use a material.
[QUOTE=Kogitsune;46759968]Unless you feel like drawing a lot of lines or rects, you have to use a material.[/QUOTE] Can't i just draw those lines with lua? using width and height?
[QUOTE=Scarface3353;46759988]Can't i just draw those lines with lua? using width and height?[/QUOTE] And have so much stuff being drawn, no thanks, I prefer performance over visuals sometimes.
There is a material gradient in Gmod. Its like gui/gradient or something
Is there a "best way" to implement a drowning system? I'm looking at one implementation and it relies on looping over every player every tick to check every player's waterlevel which seems suboptimal but I can't think of any other way to do it. Any advice?
-solved-
Anyone do know where is skeleton gamemode?
[QUOTE=rebel1324;46761873]Anyone do know where is skeleton gamemode?[/QUOTE] It's [COMING SOON].
i just tried your code. Windows local srcds. Working flawlessly (autorun/server)
Okay I've got a bunch of DButtons and DPanels added to a DIconLayout in order to 'build' a proper contact list. The problem is that whenever I run layout:LayoutIcons_TOP(), my search bar ends up at the bottom instead of staying at the top! All I need is either a way to set searchContacts to be first in the Icon Layout whenever it's layout is modified or just for LayoutIcons_TOP to ignore it. Thanks [video=youtube;hTaLz9kpmHs]http://www.youtube.com/watch?v=hTaLz9kpmHs[/video] [code] searchContacts.OnTextChanged = function( self ) local needle = self:GetText():lower() -- Nothing in the search bar if needle == nil or needle == "" then print("restore") for k, v in pairs( categoryPanels ) do v:SetVisible(true) end for k, v in pairs( contactPanels ) do v:SetVisible(true) end return end -- Start searching for k, v in pairs( categoryPanels ) do v:SetVisible(false) -- Hide letter categories end for k, v in pairs( contactPanels ) do local haystack = v:GetChildren()[1]:GetText():lower() -- Get the button's label's text --print(haystack, needle) if string.find(haystack, needle) then v:SetVisible(true) else v:SetVisible(false) end end layout:LayoutIcons_TOP() end [/code]
[QUOTE=Sereni;46760720]Is there a "best way" to implement a drowning system? I'm looking at one implementation and it relies on looping over every player every tick to check every player's waterlevel which seems suboptimal but I can't think of any other way to do it. Any advice?[/QUOTE] You kind of need to check the water-level to know if the player is in water >= 1 and submerged... >= 3 Here's a basic example of a drowning system: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/drowning.lua.html[/url] Instead of using CalcMainActivity you could use SetupMove, or whatever. Or, instead of having it run every "Tick" you can have it run every second or so in a timer ( if it doesn't fail ) so that when the player gets submerged start counting so each second you know how much damage to apply, etc... There are many ways to implement something.
Is there a way to save an icon in the material folder or way to keep rendered image to not let me have to render the model twice?
Sorry, you need to Log In to post a reply to this thread.