• Problems That Don't Need Their Own Thread v3.0
    5,003 replies, posted
Is there a simple way to distinguish a click and a drag on a panel? The only thing that pops up for me right now is timers and hooks, and mouse positioning, but maybe there is a simpler function I don't know of.
[QUOTE=Coment;49634721]Is there a simple way to distinguish a click and a drag on a panel? The only thing that pops up for me right now is timers and hooks, and mouse positioning, but maybe there is a simpler function I don't know of.[/QUOTE] You could just create a variable containing the X and Y values of the mouse when the button was first clicked, then check if they're the same or not when it gets released [editline]30th January 2016[/editline] [QUOTE=Jonzky;49631698]Is there anyway/hooks to hide all derma windows for a few frames without closing them or drawing over them?[/QUOTE] I think you'd have to hook into the [URL="https://wiki.garrysmod.com/page/vgui/Create"]vgui.Create[/URL] function (although I don't know how to do that) and then whenever it gets called, add the panel that got created to a table. Then, when you call your function, loop through the table doing an [URL="https://wiki.garrysmod.com/page/Global/IsValid"]IsValid[/URL] check on all the panels on it, then if they are valid, then [URL="https://wiki.garrysmod.com/page/Panel/SetVisible"]set their visibility to false[/URL] and after an amount of time, do the same loop, but set their visibility to true. [B] EDIT:[/B] Or you could just try what was posted below - [CODE] vgui.GetWorldPanel():SetVisible( bool ) [/CODE]
[quote]Is there anyway/hooks to hide all derma windows for a few frames without closing them or drawing over them?[/quote] [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/vgui/GetWorldPanel"]vgui.GetWorldPanel[/URL] [code]vgui.GetWorldPanel( ):SetVisible( bool )[/code] Fixed because I'm an idiot and quoted the wrong post...
This isn't really a problem, more of a question, why does [URL="https://wiki.garrysmod.com/page/Player/SetPlayerColor"]SetPlayerColor[/URL] only accept a vector, not a color? How much sense does that make? Also, yes, I know you can make a color into a vector easily
[code] function CanPlayerSuicide(player) if player:Team(TEAM_SPECTATOR) or player:Team(TEAM_UNASSIGNED) then return false else return true end end hook.Add("CanPlayerSuicide", "CanPlayerSuicide", CanPlayerSuicide) [/code] For some reason, this disables suiciding no matter the circumstances, even when the player's team is set to something else.
[QUOTE=Metasync;49635858][code] function CanPlayerSuicide(player) if player:Team(TEAM_SPECTATOR) or player:Team(TEAM_UNASSIGNED) then return false else return true end end hook.Add("CanPlayerSuicide", "CanPlayerSuicide", CanPlayerSuicide) [/code] For some reason, this disables suiciding no matter the circumstances, even when the player's team is set to something else.[/QUOTE] Because [CODE] player:Team(TEAM_SPECTATOR) [/CODE] Doesn't work [sp]ply:Team doesn't check if the arguments provided are equal to the player's team, it just returns the team[/sp] [CODE] player:Team() == TEAM_SPECTATOR [/CODE] Probably will [editline]30th January 2016[/editline] How could I make a DPanel smoothly move onto screen from the top-center to the center in about 1 second? I looked at [URL="https://wiki.garrysmod.com/page/Panel/MoveTo"]MoveTo[/URL] but I don't know what to use for the X and Y coordinates. I tried dividing the screen width by 2 and then taking away the DPanel's width divided by 2 (and the same thing for the height), but it didn't seem to work. Also, the DPanel is parented to another panel - a DFrame - so I have a feeling the DFrame is offsetting the coordinates by it's coordinates, if that makes sense. Any idea what to do? Or, can someone tell me how the Panel:Center function manages to center a panel to it's parent as well as itself?
How do I compare a table with TEAM_JOB with player:Team()?
[QUOTE=keeperman;49636192]How do I compare a table with TEAM_JOB with player:Team()?[/QUOTE] Loops, so [lua]local tble = { TEAM_BOOTY, TEAM_HUEHUE } for i, v in ipairs(tbl) do if ply:Team() == v then --<code here> end end [/lua]
[QUOTE=YourStalker;49636767]Loops, so [lua]local tble = { TEAM_BOOTY, TEAM_HUEHUE } for i, v in ipairs(tbl) do if ply:Team() == v then --<code here> end end [/lua][/QUOTE] [lua]local tbl = {TEAM_COP, TEAM_ROBBER} if tbl[ply:Team()] then <code> end[/lua] Oh wow, forgot the brackets :pudge:
[QUOTE=keeperman;49636192]How do I compare a table with TEAM_JOB with player:Team()?[/QUOTE] [code] local tbl = { job = TEAM_JOB } for i = 1,#tbl do local tData = tbl[ i ] if ply:Team() == tData.job then --code goes here end end [/code]
Is there a way to reload a CPanel? I have a button there that changes all settings to default, but the sliders and checkboxes don't change.
[QUOTE=MaxShadow;49637170]Is there a way to reload a CPanel? I have a button there that changes all settings to default, but the sliders and checkboxes don't change.[/QUOTE] You have to do it manually. One way to do it would be to add the panels that you would like to restart and when the button is presed it loops throught that table and resets each panel with each corresoponding function depending on the type of panel.
Thanks but, I have another problem. I'm trying to get the default value of each ConVar with this: [CODE]for k,v in pairs(pan) do v[2]:SetValue(tonumber(GetConVar(v[1]):GetDefault())) end[/CODE] However, GetDefault() doesn't return anything. I tried running that line in LuaPad, and GetConVar is returning userdata, but GetDefault is not working for some reason. Is it serverside only?
Is there a way to remove/disable a simple timer?
Right I am trying to create a NPC for Garry's Mod that you can press 'E' on and it says in chat "Hello (Player name)!" and then it opens a derma window where you can purchase health. The thing is that for some reason I can not get the text to appear in chat. I have used the garrys mod wiki link : [url]http://wiki.garrysmod.com/page/chat/AddText[/url] and it still doesn't seem to work. Here is the code so far: [url]https://imgur.com/xIbytjl[/url] As you can see under the ENT:Use function it says 'chat.AddText("Hello World") <-- This was just saving me typing a big long string for it then not to work. But whenever I walk up to the NPC and press 'E' all it does is set my health and doesn't put the text in chat ? There isn't even a error ? I don't know what I have done wrong in the code but it is probably something that is easy to solve. Thank you for any support you give and thank you for at least reading the post! -Shadow
[QUOTE=keeperman;49637787]Is there a way to remove/disable a simple timer?[/QUOTE] You can't, you're going to have to make a normal timer as simple timers are for simple stuff.
[QUOTE=Author.;49637862]You can't, you're going to have to make a normal timer as simple timers are for simple stuff.[/QUOTE] ok what would be the best way of doing that?
[QUOTE=keeperman;49637787]Is there a way to remove/disable a simple timer?[/QUOTE] I don't think so, they have no identifier. Just use timer.Create instead. Or you can place a condition inside the simple timer, so it only executes if a variable is true.
[QUOTE=keeperman;49637891]ok what would be the best way of doing that?[/QUOTE] Read the wiki
[QUOTE=BillyOnWiiU;49637940]Read the wiki[/QUOTE] let me rephrase, most efficient way
[QUOTE=keeperman;49637955]let me rephrase, most efficient way[/QUOTE] what do you mean efficient..? [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/timer/Stop]timer.Stop[/url]
[QUOTE=BillyOnWiiU;49637963]what do you mean efficient..? [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/timer/Stop]timer.Stop[/url][/QUOTE] most efficient way of making a normal timer into a countdown/simple timer
[QUOTE=keeperman;49637969]most efficient way of making a normal timer into a countdown/simple timer[/QUOTE] [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/timer/Create]timer.Create[/url]
[QUOTE=keeperman;49637969]most efficient way of making a normal timer into a countdown/simple timer[/QUOTE] As far as I know, simple timers are just like normal timers, but without an ID, and they only run once. Just use: [CODE]timer.Create("something",delay,1,function() -- do something end)[/CODE] Then you can stop it with timer.Stop("something")
[QUOTE=MaxShadow;49638009]As far as I know, simple timers are just like normal timers, but without an ID, and they only run once. Just use: [CODE]timer.Create("something",delay,1,function() -- do something end)[/CODE] Then you can stop it with timer.Stop("something")[/QUOTE] Yea they seem to work in the same way, thanks though.
[QUOTE=Shenesis;49636921][lua]local tbl = {[TEAM_COP] = true, [TEAM_ROBBER] = true} if tbl[ply:Team()] then <code> end[/lua][/QUOTE] Isn't it unnecessary to add the "[] = true" because if the job didn't exist in the table then it would return nil which would evaluate to false.
[QUOTE=YourStalker;49639196]Isn't it unnecessary to add the "[] = true" because if the job didn't exist in the table then it would return nil which would evaluate to false.[/QUOTE] The [TEAM_COP] is to get the TEAM_COP variable that's already in place instead of making a new one inside the table, which will do something completely different than what requested. Then it checks if the table has the same number as the player's team which in this case it does, returning true which is what was assigned.
[QUOTE=YourStalker;49639196]Isn't it unnecessary to add the "[] = true" because if the job didn't exist in the table then it would return nil which would evaluate to false.[/QUOTE] If you just put the job variable itself then it would be numerically indexed and you'd have to loop through it to see if the team is in the table. It's only being set to true so it has a value in the table that can be checked.
What's the max possible folder size if you want to upload an addon to Steam workshop again?
[QUOTE=P4sca1;49639763]What's the max possible folder size if you want to upload an addon to Steam workshop again?[/QUOTE] [URL]https://facepunch.com/showthread.php?t=1192696&p=36482713&viewfull=1#post36482713[/URL] [editline]31st January 2016[/editline] I get an error whenever I call the DTBool on an entity in the world through a autorun script. attempt to call method 'GetDTBool' (a nil value) [code]local entity = ents.FindByClass("entity") local bool1 = entity:GetDTBool(0) local bool2 = entity:GetDTBool(2) if bool1 and not bool2 then --code end[/code]
Sorry, you need to Log In to post a reply to this thread.