• What do you need help with? V3
    6,419 replies, posted
[QUOTE=walkmanguy;37227318]So there's another problem that I had with these printers, they wouldn't continue printing, would this fix the problem?[/QUOTE] If you're getting lua errors yes.. These printers are directly from the svn? When you're testing something like this I would set the timer to about 10 seconds instead of 1m30s saves time.
[QUOTE=kragmars102;37224258]I have [code] local colorCircle = vgui.Create( "DColorCircle" ) colorCircle:SetPos( 35, 75 ) colorCircle:SetSize( 200, 200 ) colorCircle.PaintOver = function() print(colorCircle:GetRGB()); end[/code] The issue i'm facing is the fact that it's constantly printing the color to console, even though it's not actively being changed. Is there a way to make it so it only registers when the player actually changes the value?[/QUOTE] Use OnMouseReleased hook instead of PaintOver.
-snip- fixed itself.
Try AddCSLuaFile("autorun/roundsong.lua") instead
Problem fixed itself. I forced the server to make a new lua cache and it started working with the new one. (Why the new lua file didnt tell the server to make the cache is strange.)
Anyone know the proper way of playing a clientside sound on PlayerInitialSpawn? Apparently RunConsoleCommand and surface.PlaySound don't work on a server. Also might need to know how to properly loop sounds.
[QUOTE=Katazuro;37235364]Anyone know the proper way of playing a clientside sound on PlayerInitialSpawn? Apparently RunConsoleCommand and surface.PlaySound don't work on a server. Also might need to know how to properly loop sounds.[/QUOTE] Maybe try PlayerAuthed hook instead? It's basically the same, but for some reasons it gets called a bit after PlayerInitialSpawn, so it might work using it.
Can someone explain why this same script acts differently between client and server after freezing? I run this after spawning the entity, and after freezing it. After spawning, the client and server both print the same value, as expected. After freezing, the client gets something different (and wrong) than the server does. [lua] local angle = Angle( math.NormalizeAngle(self:GetAngles().p+90), math.NormalizeAngle(self:GetAngles().y), math.NormalizeAngle(0) ) local pos = ( Vector(7,7,0) ) pos:Rotate(Angle( math.NormalizeAngle(self:GetAngles().p+90), math.NormalizeAngle(self:GetAngles().y), math.NormalizeAngle(0) )) pos = pos+self:GetPos()+angle:Up() print(pos.x..","..pos.y..","..pos.z) [/lua] edit: Actually, if I run that again client and serverside at a manual time post-freezing, they both return the same incorrect value. The angle is the same as when it is first spawned, when frozen, so what gives? The client is being told by the server that the item has been frozen, at which point it builds its own position. So it sounds like the server calculates a correct position, then something happens to make the data that builds the position different, then the client builds the position using that new bad data.
Am I doing something wrong here? [lua] function ITEM:Use(user) if !user:FlashlightIsOn() then user:Flashlight(true) else user:Flashlight(false) end end [/lua] or did garry break flashlight functions?
[QUOTE=jrj996;37236666]Am I doing something wrong here? [lua] function ITEM:Use(user) if !user:FlashlightIsOn() then user:Flashlight(true) else user:Flashlight(false) end end [/lua] or did garry break flashlight functions?[/QUOTE] Try this: [lua] function ITEM:Use(user) return user:Flashlight(!user:FlashlightIsOn()) end [/lua]
[QUOTE=brandonj4;37237351]Try this: [lua] function ITEM:Use(user) return user:Flashlight(!user:FlashlightIsOn()) end [/lua][/QUOTE] I tried something similar to that earlier that's why I changed my code and ended up with the same result :/
[QUOTE=jrj996;37237460]I tried something similar to that earlier that's why I changed my code and ended up with the same result :/[/QUOTE] What happens? That code I posted is supposed to be a toggle.
Absolutely nothing which is the weird part. No light pops up at all.
The method now returns 0 and 1 if it's off or on, rather than false or true.
Hey guys, thanks for the help on the remover tool. got it working :D. I have a question. Im trying to fix an old addon called PointShop and I ran into an error that I cant seem to botch. Here is the code. The part that isnt working has a comment following it. [LUA]usermessage.Hook("PointShop_Menu", function(um) if um:ReadBool() then POINTSHOP.Menu = vgui.Create("DFrame") POINTSHOP.Menu:SetSize(477, 477) POINTSHOP.Menu:SetTitle("PointShop - " .. LocalPlayer():PS_GetPoints() .. " Points!") POINTSHOP.Menu:SetVisible(true) POINTSHOP.Menu:SetDraggable(true) POINTSHOP.Menu:ShowCloseButton(true) POINTSHOP.Menu:MakePopup() POINTSHOP.Menu:Center() POINTSHOP.Menu:SizeToContents() local Tabs = vgui.Create("DPropertySheet", POINTSHOP.Menu) Tabs:SetPos(5, 30) Tabs:SetSize(POINTSHOP.Menu:GetWide() - 10, POINTSHOP.Menu:GetTall() - 35) -- Feel free to add your own tabs. local ShopCategoryTabs = vgui.Create("DColumnSheet") ShopCategoryTabs:SetSize(Tabs:GetWide() - 10, Tabs:GetTall() - 10) ShopCategoryTabs.Navigation:SetWidth(24) ShopCategoryTabs.Navigation:DockMargin(0, 0, 4, 0) local npc_id = um:ReadLong() local is_npc_menu = false if npc_id > 0 then is_npc_menu = true npcs = POINTSHOP.Config.Sellers[game.GetMap()] npc = npcs[npc_id] npc_categories = npc.Categories end for c_id, category in pairs(POINTSHOP.Items) do if category.Enabled then if (is_npc_menu and table.HasValue(npc_categories, category.Name)) or not is_npc_menu then local CategoryTab = vgui.Create("DPanelList", ShopCategoryTabs) CategoryTab:SetSpacing(5) CategoryTab:SetPadding(5) CategoryTab:EnableHorizontal(true) CategoryTab:EnableVerticalScrollbar(true) CategoryTab:Dock(FILL) for item_id, item in pairs(category.Items) do if item.Enabled then if not table.HasValue(LocalPlayer():PS_GetItems(), item_id) then if item.Model then local Icon = vgui.Create("DShopModel") Icon:SetData(item) Icon:SetSize(96, 96) Icon.DoClick = function() if LocalPlayer():PS_CanAfford(item.Cost) then Derma_Query("Do you want to buy '" .. item.Name .. "' for " .. item.Cost .. " points?", "Buy Item", "Yes", function() RunConsoleCommand("pointshop_buy", item_id) end, "No", function() end ) else Derma_Message("You can't afford this item!", "PointShop", "Close") end end CategoryTab:AddItem(Icon) elseif item.Material then local Icon = vgui.Create("DShopMaterial") Icon:SetData(item) Icon:SetSize(96, 96) Icon.DoClick = function() if LocalPlayer():PS_CanAfford(item.Cost) then Derma_Query("Do you want to buy '" .. item.Name .. "' for " .. item.Cost .. " points?", "Buy Item", "Yes", function() RunConsoleCommand("pointshop_buy", item_id) end, "No", function() end ) else Derma_Message("You can't afford this item!", "PointShop", "Close") end end CategoryTab:AddItem(Icon) end end end end ShopCategoryTabs:AddSheet(category.Name, CategoryTab, "gui/silkicons/" .. category.Icon, category.Name) end end end Tabs:AddSheet("Shop", ShopCategoryTabs, "gui/silkicons/application_view_tile", false, false, "Browse the shop!") -- Inventory Tab local InventoryContainer = vgui.Create("DPanelList", POINTSHOP.Menu) InventoryContainer:SetSize(Tabs:GetWide() - 10, Tabs:GetTall() - 30) InventoryContainer:SetSpacing(5) InventoryContainer:SetPadding(5) InventoryContainer:EnableHorizontal(true) InventoryContainer:EnableVerticalScrollbar(false) for id, item_id in pairs(LocalPlayer():PS_GetItems()) do local item = POINTSHOP.FindItemByID(item_id) if item then if item.Model then local Icon = vgui.Create("DShopModel") Icon:SetData(item) Icon:SetSize(96, 96) Icon.Sell = true Icon.DoClick = function() local menu = DermaMenu() menu:AddOption("Sell", function() Derma_Query("Do you want to sell '" .. item.Name .. "' for " .. POINTSHOP.Config.SellCost(item.Cost) .. " points?", "Sell Item", "Yes", function() RunConsoleCommand("pointshop_sell", item_id) end, "No", function() end ) end) if item.Respawnable then menu:AddOption("Respawn", function() RunConsoleCommand("pointshop_respawn", item_id) end) end menu:Open() end InventoryContainer:AddItem(Icon) elseif item.Material then Icon = vgui.Create("DShopMaterial") Icon:SetData(item) Icon:SetSize(96, 96) Icon.Sell = true Icon.DoClick = function() local menu = DermaMenu() menu:AddOption("Sell", function() Derma_Query("Do you want to sell '" .. item.Name .. "' for " .. POINTSHOP.Config.SellCost(item.Cost) .. " points?", "Sell Item", "Yes", function() RunConsoleCommand("pointshop_sell", item_id) end, "No", function() end ) end) if item.Respawnable then menu:AddOption("Respawn", function() RunConsoleCommand("pointshop_respawn", item_id) end) end menu:Open() end InventoryContainer:AddItem(Icon) end end end Tabs:AddSheet("Inventory", InventoryContainer, "gui/silkicons/box", false, false, "Browse your inventory!") else if POINTSHOP.Menu then POINTSHOP.Menu:Remove() end end end) usermessage.Hook("PointShop_Notify", function(um) local text = um:ReadString() if text then chat.AddText(Color(131, 255, 0), "[PS] ", Color(255, 255, 255), text) end end) usermessage.Hook("PointShop_AddHat", function(um) local ply = um:ReadEntity() local item_id = um:ReadString() if not ply or not item_id then return end local item = POINTSHOP.FindItemByID(item_id) if not item then return end if not ply._Hats then ply._Hats = {} end //--------------------------------------------------------------------------------------------------------- if ply._Hats[item_id] then return end // This is where the error is occuring --------------------- //--------------------------------------------------------------------------------------------------------- local mdl = ClientsideModel(item.Model, RENDERGROUP_OPAQUE) mdl:SetNoDraw(true) ply._Hats[item_id] = { Model = mdl, Attachment = item.Attachment or nil, Bone = item.Bone or nil, Modify = item.Functions.ModifyHat or function(ent, pos, ang) return ent, pos, ang end } end) usermessage.Hook("PointShop_RemoveHat", function(um) local ply = um:ReadEntity() local item_id = um:ReadString() if not ply or not ply:IsValid() or not ply:IsPlayer() or not item_id then return end if not ply._Hats then return end if not ply._Hats[item_id] then return end ply._Hats[item_id] = nil end) hook.Add("InitPostEntity", "PointShop_InitPostEntity", function() LocalPlayer().PS_Points = 0 LocalPlayer().PS_Items = {} end) hook.Add("Initialize", "PointShop_DColumnSheet_AddSheet_Override", function() function DColumnSheet:AddSheet(label, panel, material, tooltip) if not IsValid(panel) then return end local Sheet = {} if self.ButtonOnly then Sheet.Button = vgui.Create("DImageButton", self.Navigation) else Sheet.Button = vgui.Create("DButton", self.Navigation) end Sheet.Button:SetImage(material) Sheet.Button.Target = panel Sheet.Button:Dock(TOP) Sheet.Button:SetText(label) Sheet.Button:DockMargin(0, 1, 0, 0) if tooltip then Sheet.Button:SetToolTip(tooltip) end Sheet.Button.DoClick = function() self:SetActiveButton(Sheet.Button) end Sheet.Panel = panel Sheet.Panel:SetParent(self.Content) Sheet.Panel:SetVisible(false) if self.ButtonOnly then Sheet.Button:SizeToContents()
[QUOTE=Undefined;37229919]Use OnMouseReleased hook instead of PaintOver.[/QUOTE] Thanks, but now my mouse won't work without the color circle area. I can move it out, just not click or do anything else. I'm looking for a way to choose a color, then choose the lightness and darkness of the color. Is there a pre-made vgui for this?
kinda unrelated but has anyone else noticed the lua tag now stretches the page like crazy and the numbers are off?
So i ghetto rigged my vgui elements to scroll properly since i have no idea how the inherited scrolling shit works (i get errors when i use AddScroll so i made my own). Basically, how i've interpreted scrolling works: [lua]function PANEL:DoScrollShit( amt ) self.CanvasPanelThing:SetPos( 0, amt ) end[/lua] When i do something like this with my panels, the canvas panel doesn't stay where i've moved it to, it just resets back to 0,0 in the next frame. What's going on?
[QUOTE=Mythikos;37239072]Hey guys, thanks for the help on the remover tool. got it working :D. I have a question. Im trying to fix an old addon called PointShop and I ran into an error that I cant seem to botch. Here is the code. The part that isnt working has a comment following it. -snip- The error is "[cl_pointshop.lua:178] attempt to index field '_Hats' (a nil value)". Any help or advice would be appreciated. I would like to see this addon updated and re-released. Thanks![/QUOTE] My old addon is horribly coded. I'm actually rewriting it to work with Garry's Mod 13, if you can wait a few weeks/months.
-snip-
[QUOTE=_Undefined;37245918]My old addon is horribly coded. I'm actually rewriting it to work with Garry's Mod 13, if you can wait a few weeks/months.[/QUOTE] Omg thats awesome. I thought you dumped the project. Don't worry, I can wait :)! Do you have an SVN?
[QUOTE=Mythikos;37239072]Hey guys, thanks for the help on the remover tool. got it working :D. I have a question. Im trying to fix an old addon called PointShop and I ran into an error that I cant seem to botch. Here is the code. The part that isnt working has a comment following it. -code- The error is "[cl_pointshop.lua:178] attempt to index field '_Hats' (a nil value)". Any help or advice would be appreciated. I would like to see this addon updated and re-released. Thanks![/QUOTE] I would help but the line numbers get fucked up when they reach the hundreds [img]http://puu.sh/VuJA[/img] garry![img]http://facepunch.com/fp/emoot/argh.gif[/img]
[QUOTE=ralle105;37246637]I would help but the line numbers get fucked up when they reach the hundreds [img]http://puu.sh/VuJA[/img] garry![img]http://facepunch.com/fp/emoot/argh.gif[/img][/QUOTE] (is puush down?)
Hello How I can create a table in the server database using SQLite. I tried to do so, but nothing came of it: [lua] if SERVER then hook.Add("Initialize","init_tbl",function() if !sql.TableExists("test_tbl") then sql.Query("CREATE TABLE test_tbl ( time int, text text )") end end) end [/lua]
[QUOTE=Banana Lord.;37246688](is puush down?)[/QUOTE] puush.me works fine but puu.sh is down for me.
How can I restrict a console command, to be specific, I want it so players can't use gm_spawn.
I want an entity to freeze as soon as it hits the end of the skybox. In this case the entity is a flare. What code should I use for this? Searched the wiki already but couldn't find it.
Is there a version of [code]vgui.Create( "DColorMixer");[/code] without the transparency bar?
[QUOTE=kragmars102;37249530]Is there a version of [code]vgui.Create( "DColorMixer");[/code] without the transparency bar?[/QUOTE] No. But for the hell of it, I just made one for you. [lua]--[[ _ ( ) _| | __ _ __ ___ ___ _ _ /'_` | /'__`\( '__ )/' _ ` _ `\ /'_` ) ( ( _| |( ___/| | | ( ) ( ) |( ( _| | `\__,_ )`\____ )( _ ) ( _ ) ( _ ) ( _ )`\__,_ ) DColorMixerNoAlpha --]] local PANEL = {} AccessorFunc( PANEL, "m_ConVarR", "ConVarR" ) AccessorFunc( PANEL, "m_ConVarG", "ConVarG" ) AccessorFunc( PANEL, "m_ConVarB", "ConVarB" ) AccessorFunc( PANEL, "m_Palette", "Palette" ) --[[--------------------------------------------------------- Name: Init -----------------------------------------------------------]] function PANEL:Init( ) self.HSV = vgui.Create( "DColorCube", self ) self.HSV:Dock( FILL ) self.HSV.OnUserChanged = function( ) self:ColorCubeChanged( ) end self.Palette = vgui.Create( "DColorPalette", self ) self.Palette:Dock( RIGHT ) self.Palette:SetVisible( true ) self.Palette:SetWidth( 84 ) self.Palette:SetButtonSize( 14 ) self.Palette.DoClick = function( panel, color, x, y ) self:SetColor( color ) end self.Palette:DockMargin( 12, 0, 0, 0 ) self.RGB = vgui.Create( "DRGBPicker", self ) self.RGB:Dock( RIGHT ) self.RGB:SetWidth( 24 ) self.RGB.OnChange = function( ctrl, color ) self:SetBaseColor( color ); self:ColorCubeChanged( ) end self.RGB:DockMargin( 4, 0, 0, 0 ) self:SetColor( Color( 255, 100, 100, 255 ) ) end --[[--------------------------------------------------------- Name: SetPalette -----------------------------------------------------------]] function PANEL:SetPalette( val ) self.m_Palette = val self.Palette:SetDisabled( !val ) self.Palette:SetVisible( val ) end --[[--------------------------------------------------------- Name: ConVarR -----------------------------------------------------------]] function PANEL:SetConVarR( val ) self.m_ConVarR = val self.Palette:SetConVarR( val ) end --[[--------------------------------------------------------- Name: ConVarG -----------------------------------------------------------]] function PANEL:SetConVarG( val ) self.m_ConVarG = val self.Palette:SetConVarG( val ) end --[[--------------------------------------------------------- Name: ConVarB -----------------------------------------------------------]] function PANEL:SetConVarB( val ) self.m_ConVarB = val self.Palette:SetConVarB( val ) end --[[--------------------------------------------------------- Name: Paint -----------------------------------------------------------]] function PANEL:Paint( ) end --[[--------------------------------------------------------- -----------------------------------------------------------]] function PANEL:TranslateValues( x, y ) end --[[--------------------------------------------------------- -----------------------------------------------------------]] function PANEL:SetColor( color ) self.HSV:SetColor( color ) end --[[--------------------------------------------------------- -----------------------------------------------------------]] function PANEL:SetBaseColor( color ) self.HSV:SetBaseRGB( color ) end --[[--------------------------------------------------------- -----------------------------------------------------------]] function PANEL:UpdateConVar( strName, strKey, color ) if ( !strName ) then return end RunConsoleCommand( strName, tostring( color[ strKey ] ) ) end --[[--------------------------------------------------------- -----------------------------------------------------------]] function PANEL:UpdateConVars( color ) self.NextConVarCheck = SysTime( ) + 1 self:UpdateConVar( self.m_ConVarR, 'r', color ) self:UpdateConVar( self.m_ConVarG, 'g', color ) self:UpdateConVar( self.m_ConVarB, 'b', color ) self:UpdateConVar( self.m_ConVarA, 'a', color ) end --[[--------------------------------------------------------- -----------------------------------------------------------]] function PANEL:ColorCubeChanged( ) self:UpdateConVars( self:GetColor( ) ) end --[[--------------------------------------------------------- -----------------------------------------------------------]] function PANEL:GetColor( ) local color = self.HSV:GetRGB( ) color.a = 255 return color end --[[--------------------------------------------------------- -----------------------------------------------------------]] function PANEL:Think( ) self:ConVarThink( ) end --[[--------------------------------------------------------- -----------------------------------------------------------]] function PANEL:ConVarThink( ) -- Don't update the convars while we're changing them! if ( input.IsMouseDown( MOUSE_LEFT ) ) then return end self:DoConVarThink( self.m_ConVarR, 'r' ) self:DoConVarThink( self.m_ConVarG, 'g' ) self:DoConVarThink( self.m_ConVarB, 'b' ) self:DoConVarThink( self.m_ConVarA, 'a' ) end --[[--------------------------------------------------------- -----------------------------------------------------------]] function PANEL:DoConVarThink( convar, key ) if ( !convar ) then return end local fValue = GetConVarNumber( convar ) local fOldValue = self[ 'ConVarOld'..convar ] if ( fOldValue && fValue == fOldValue ) then return end self[ 'ConVarOld'..convar ] = fValue local r = GetConVarNumber( self.m_ConVarR ) local g = GetConVarNumber( self.m_ConVarG ) local b = GetConVarNumber( self.m_ConVarB ) local a = 255 if ( self.m_ConVarA ) then a = GetConVarNumber( self.m_ConVarA ) end local color = Color( r, g, b, a ) self:SetColor( color ) end --[[--------------------------------------------------------- Name: GenerateExample -----------------------------------------------------------]] function PANEL:GenerateExample( ClassName, PropertySheet, Width, Height ) local ctrl = vgui.Create( ClassName ) ctrl:SetSize( 256, 256 ) PropertySheet:AddSheet( ClassName, ctrl, nil, true, true ) end vgui.Register( "DColorMixerNoAlpha", PANEL, "DPanel" ) --derma.DefineControl( "DColorMixerNoAlpha", "", PANEL, "DPanel" ) [/lua]
[QUOTE=kragmars102;37249530]Is there a version of [code]vgui.Create( "DColorMixer");[/code] without the transparency bar?[/QUOTE] Look at the soruce: [url]http://glua.me/bin/?path=/lua/vgui/DColorMixer.lua[/url] Try mymixer.AlphaBar:SetVisible(false)
Sorry, you need to Log In to post a reply to this thread.