• What do you need help with? V3
    6,419 replies, posted
I am trying to get weapons to drop when the player presses the Q key, in a game mode I am working on. I have this poorly written dump: [lua] local function KeyPress() if input.IsKeyDown(KEY_Q) then if !QIsDown then --if Q wasnt pressed last time RunConsoleCommand( "drop_weapon" ) QIsDown = true end else QIsDown = false end end hook.Add("Think","BM - Clients - Key",KeyPress) [/lua] QIsDown is defined as a global variable. It works, which is great, but it ALSO works when the chat box is open. So if someone wanted to type "I have a [b]q[/b]uestion" suddenly they throw their guns all over the place and fun times can no longer be had. So, what is a better way of doing this? Or, at least some kind of fix so that they don't drop the weapon if they have the chat box open? Thanks! [editline]6th August 2012[/editline] I was thinking maybe make a custom bind to Q for the client? Is that bad practice?
[QUOTE=Trumple;37105470]I am trying to get weapons to drop when the player presses the Q key, in a game mode I am working on. I have this poorly written dump: [lua] local function KeyPress() if input.IsKeyDown(KEY_Q) then if !QIsDown then --if Q wasnt pressed last time RunConsoleCommand( "drop_weapon" ) QIsDown = true end else QIsDown = false end end hook.Add("Think","BM - Clients - Key",KeyPress) [/lua] QIsDown is defined as a global variable. It works, which is great, but it ALSO works when the chat box is open. So if someone wanted to type "I have a [b]q[/b]uestion" suddenly they throw their guns all over the place and fun times can no longer be had. So, what is a better way of doing this? Or, at least some kind of fix so that they don't drop the weapon if they have the chat box open? Thanks! [editline]6th August 2012[/editline] I was thinking maybe make a custom bind to Q for the client? Is that bad practice?[/QUOTE] Handle it with this: [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexf0f2.html[/url]
Well thanks for the help so far, i implemented the scissor rects and it works great. [img]http://i.imgur.com/8A4LK.jpg[/img] Next problem: Scrolling doesn't work. I derived my custom panel list from DPanelList and for some reason, list:AddScroll(1) just gives me an error. Did i overwrite something or am i missing something?
[QUOTE=Deadman123;37105621]Handle it with this: [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexf0f2.html[/url][/QUOTE] That doesn't let me use the Q key, it is limited to IN_ keys Thanks anyway Anyone else have any ideas?
[QUOTE=Trumple;37105971]That doesn't let me use the Q key, it is limited to IN_ keys Thanks anyway Anyone else have any ideas?[/QUOTE] First things first; why a global variable? Make it local to your script.
[QUOTE=initrd.gz;37106073]First things first; why a global variable? Make it local to your script.[/QUOTE] Sorry I meant global for my client_init script...it is local to that Second things second, any other ideas? :v: Cheers
[QUOTE=Trumple;37105470]I am trying to get weapons to drop when the player presses the Q key, in a game mode I am working on. I have this poorly written dump: [lua] local function KeyPress() if input.IsKeyDown(KEY_Q) then if !QIsDown then --if Q wasnt pressed last time RunConsoleCommand( "drop_weapon" ) QIsDown = true end else QIsDown = false end end hook.Add("Think","BM - Clients - Key",KeyPress) [/lua] QIsDown is defined as a global variable. It works, which is great, but it ALSO works when the chat box is open. So if someone wanted to type "I have a [b]q[/b]uestion" suddenly they throw their guns all over the place and fun times can no longer be had. So, what is a better way of doing this? Or, at least some kind of fix so that they don't drop the weapon if they have the chat box open? Thanks! [editline]6th August 2012[/editline] I was thinking maybe make a custom bind to Q for the client? Is that bad practice?[/QUOTE] What's wrong with PlayerBindPress? [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4d65.html[/url]
[QUOTE=FPtje;37107321]What's wrong with PlayerBindPress? [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4d65.html[/url][/QUOTE] Excellent, thank you very much Just so happens q is bound to +menu so I'm in luck Cheers!
I'm working on a gamemode and I have several soundtracks in my content folder. I want my server to play the tracks one after the other and everyone who is on the server should hear what the server is currently playing, but I don't know what script I would need for that action.. Can someone help me out there :o
How do I network a table with an entity? If that isn't feasible, how can I make sure that clients constantly have table data generated by the server?
Render Clipping seems to have died, Thread [URL=http://www.facepunch.com/showthread.php?t=1202822] Bumpity[/URL]
[QUOTE=Bletotum;37115644]How do I network a table with an entity? If that isn't feasible, how can I make sure that clients constantly have table data generated by the server?[/QUOTE] I'm not sure if this would work, but try SetNetworkedVar("some_table", some_table) I don't see why that wouldn't work. Remember setting a networked variable causes it to be synced between the client and server, so adding to your table serverside will allow the client to access new entities in your table. At least, that is my understanding
NWVars don't accept tables afaik. if the table is small, send the individual values if the table is big, use the net library (in gmod 13) or until then datastream to send the table. Make it entity specific by sending the entity with it. [editline]7th August 2012[/editline] But how about my own question? [QUOTE=FPtje;37102460]Is there any way I can get the trace of a [url=http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index2e8a.html]ent:FireBullets[/url] [b]before[/b] the bullet is actually shot? The callback appears to be called [u]after[/u] the shot. The information I need is mostly the HitPos, HitEntity and stuff like that. I would use a normal tracer and shoot the bullet based on that tracer, but if you want any kind of randomized bullet spread, you'd be fucked because the client would generate a different trace than the server. The nice thing about :FireBullets is that the spread is in sync between server and client, and that the bullets actually impact where the clients see them impact. So how would I find out the HitPos of a bullet before it is actually fired (and decide whether the bullet should be fired at all)?[/QUOTE]
Without a module, you can't.
[QUOTE=Lexic;37123924]Without a module, you can't.[/QUOTE] That's stupid. I figure it would be very easy to make for Garry. Just another callback in the Bullet table which returns a boolean to not shoot the bullet. :/
[QUOTE=FPtje;37126853]That's stupid. I figure it would be very easy to make for Garry. Just another callback in the Bullet table which returns a boolean to not shoot the bullet. :/[/QUOTE] It would certainly be very handy for aimbots.
Can someone please tell me how to generate a simple cube using Entity.PhysicsFromMesh (I think?) In my previous attempts, only the shadow of the entity has come out.
Are there any post processing tutorials? I'm trying to adjust saturation in-game etc. Make it look like black and white.
Is there anyway at all to control a prop held by a player with LUA functions? Since SmartSnap seems to broken, was hoping to work on something similar to placing props more effectively. I haven't had any luck looking through the wiki thus far, and a lot of the pages are missing/broken right now.
[QUOTE=Sezasm;37008733]In theory, assuming I don't need to exchange variables between files, if I were to do this: [CODE]local newg = getfenv(0) setfenv(1, newg)[/CODE] Would it eliminate the need for typing 'local' before all of my variables to keep them localized inside a file, and if not, how would I do this?[/QUOTE] getfenv(0) returns _G so no.
I want my players to be able to move with a derma menu (or something similar) open, is that possible?
[QUOTE=Grondo4;37135985]I want my players to be able to move with a derma menu (or something similar) open, is that possible?[/QUOTE] Don't call MakePopup() on the menu? [editline]8th August 2012[/editline] I've seen a lot of people confused about that actually, the old Wikis derma tutorial says MakePopup makes the derma appear on the screen - it doesn't, it focuses it and activates the cursor and keyboard. It's the vgui.Create which makes it appear on the screen.
Is there any way to undo the effects of SetRenderOrigin? [editline]8th August 2012[/editline] Also, can anyone explain this: [vid]https://dl.dropbox.com/u/6769272/gm_construct 2012-8-8 15-53-09.webm[/vid] It happens whenever the entity is at 0,0,0 angles [code] hook.Add( "PostDrawOpaqueRenderables", "DrawOffset", function() for id, offset in pairs( t ) do local ent = Entity( id ) if not ent:IsValid() then t[ id ] = nil break end if not offset then return end ent:SetupBones() ent:SetRenderOrigin( ent:LocalToWorld( offset ) ) --if ent.Draw then ent:Draw() else ent:DrawModel() end end end ) [/code] [editline]edit lie[/editline] Never mind, got help from CapsAdmin [img]http://www.facepunch.com/fp/ratings/heart.png[/img]
[QUOTE=Falcqn;37137026] [editline]edit lie[/editline] Never mind, got help from CapsAdmin [img]http://www.facepunch.com/fp/ratings/heart.png[/img][/QUOTE] [img]http://imgs.xkcd.com/comics/wisdom_of_the_ancients.png[/img] Post the solution.
[QUOTE=Agent766;37148451][img]http://imgs.xkcd.com/comics/wisdom_of_the_ancients.png[/img] Post the solution.[/QUOTE] Call ent:SetRenderOrigin() after you've drawn it But the best way for him would be to use RenderOverride [lua]local offset = SOMETHING function ent:RenderOverride() ent:SetRenderOrigin(ent:LocalToWorld(offset)) ent:SetupBones() ent:DrawModel() ent:SetRenderOrigin() end[/lua]
[code] local rupee = ents.Create("peng") rupee:SetPos(Vector(victim:GetPos().x, victim:GetPos().y, victim:GetPos().z + 100)) rupee:SetOwner(killer) rupee:Spawn() rupee:Activate() constraint.Keepupright(rupee, Angle(0,0,0), 0, 100000) [/code] Keepupright is not working for me :( Please help
I need script which displays message (%player% joined to the game), when new player spawns in the map.
[QUOTE=airidas338;37150151]I need script which displays message (%player% joined to the game), when new player spawns in the map.[/QUOTE] As Garry Newman once said (roughly): "If I need something, but not sure how. I think to myself, where have I seen this before?". Evolve has this feature, go snoop around in it to try find it. See if you can replicate/copy it. If you get stuck, ask for further help here.
[QUOTE=timpo204;37149977][code] local rupee = ents.Create("peng") rupee:SetPos(Vector(victim:GetPos().x, victim:GetPos().y, victim:GetPos().z + 100)) rupee:SetOwner(killer) rupee:Spawn() rupee:Activate() constraint.Keepupright(rupee, Angle(0,0,0), 0, 100000) [/code] Keepupright is not working for me :( Please help[/QUOTE] I was playing with that the other day and could never get it to work either
I'm sure this has been asked before, but since the search option isn't available I think it would be cool to ask... Is it possible to push source-engine vehicle's top speed past the preset number ( around 120 - 130 mph )? If so, how, and by what means..
Sorry, you need to Log In to post a reply to this thread.