Just get a reference to the entity object and you can run those functions from there:
[lua]
for k, v in pairs(ents.FindByClass("custom_ent")) do
v:SetAmount(5000)
end
[/lua]
[QUOTE=Z0mb1n3;48760582][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/DermaMenu]Global.DermaMenu[/url]
"...closes any current menus."
Opening your own dermamenu when the user right clicks and having no content inside it and removing it shortly thereafter should serve your purpose.[/QUOTE]
For me, both menus get created at once (note I'm using the OnMousePressed hook and checking for MOUSE_RIGHT, if that makes a difference)
[QUOTE=LegoGuy;48759882]Anyone got some easy-to-read code regarding 3D stencils and all that? I once saw a guy do a button within the breen bust, how do I do something like that?[/QUOTE]
The stencil buffer is always 2D, as in it is only a screen sized buffer you can write to. I once made a stencil guide covering most of the stuff you need to know about it, you can find it here: [url]https://facepunch.com/showthread.php?t=1408855[/url]
Does anyone have the code for doing circular steam avatars? I know it's to do with stencils but i cannot find it
i've found some old code from handsomematt, but for an rounded box.
[url]http://pastebin.com/FVEKbxM9[/url]
haven't worked with stencils before, maybe you can modify that.
Is there any way to just directly copy a texture into a rendertarget? using render.DrawTextureToScreenRect takes care of the color, but not the alpha. I need to copy the alpha value too.
[QUOTE=TFA;48763427]Is there any way to just directly copy a texture into a rendertarget? using render.DrawTextureToScreenRect takes care of the color, but not the alpha. I need to copy the alpha value too.[/QUOTE]
Alpha and render targets don't really play well in Source as far as I know.
How can I make a player's view rotate with respect to an altered pitch?
Example, pitch of view is rotated by 90, so the ground is to your "right", and moving the mouse up and down makes your camera look in the direction of absolute up and down, rather than relative.
How in garrys mod do i use lua to spawn in working ladders at vectors ?
"models/props_c17/metalladder002.mdl"
Hello there,
I have been running into a small problem regarding drawing the local player on [B]OSX[/B] when in thirdperson, on a Windows machine it works just fine. The CalcView offset works on OSX but I assume the ShouldDrawLocalPlayer hook does not!
Here is the clientside code I am using:
[lua]
-- Third Person for pigeons
hook.Add( "CalcView", "ThirdPersonView", function( ply, pos, angles, fov )
if ply:Team() == TEAM_PIGEON and ply:Alive() and not ply:IsPlayingTaunt() then
local view = {}
view.origin = pos - ( angles:Forward() * 85 ) + ( angles:Right() * 0 ) + ( angles:Up() * -10 )
view.angles = ply:EyeAngles() + Angle( 1, 1, 0 )
view.fov = fov
return GAMEMODE:CalcView( ply, view.origin, view.angles, view.fov )
end
end )
hook.Add( "ShouldDrawLocalPlayer", "ThirdPersonDrawPlayer", function()
if LocalPlayer():Team() == TEAM_PIGEON and LocalPlayer():Alive() then
return true
end
end )
[/lua]
Does anyone know what is causing this, or am I doing something wrong here?
Alright, I hate to ask so many questions in just a few days, but... how do I cut out a portion of a model when rendering it?
Has anyone ever draw a rounded box but had the top one colour and the bottom another?
Like this
[img]http://i.imgur.com/93C23yQ.png[/img]
Wondering how it'd work since you can't draw two separate things that are touching like with a plain old rectangle although half way through this post I realized it'd probably be better to just go with materials :v:
You can do that with two draw.RoundedBoxEx calls.
[url]http://wiki.garrysmod.com/page/draw/RoundedBoxEx[/url]
1) Is there a function that can get a sound's total time played, or a function that calls whenever an EmitSound ends?
2) If I create a local table in a SWEP file that has Sound(whateverpath) in it, do I still need to precache it?
If for whatever reason I don't have access to the server console, is there a hook I can use that will allow me to read the stack trace/error text of a lua error? Wanted to make a neat little error viewer that logs errors and the likes.
[QUOTE=Robotboy655;48766466]You can do that with two draw.RoundedBoxEx calls.
[url]http://wiki.garrysmod.com/page/draw/RoundedBoxEx[/url][/QUOTE]
Oh shit, I had no idea that was a thing, tyvm
[QUOTE=PigeonTroll;48767671]1) Is there a function that can get a sound's total time played, or a function that calls whenever an EmitSound ends?
2) If I create a local table in a SWEP file that has Sound(whateverpath) in it, do I still need to precache it?[/QUOTE]
1) I don't think so. Why do you need to do this?
For pure curiosity: what is the second argument of net.Start (and maybe a use of it?)
[url]http://wiki.garrysmod.com/page/net/Start[/url]
[QUOTE=guigui;48773993]For pure curiosity: what is the second argument of net.Start (and maybe a use of it?)
[url]http://wiki.garrysmod.com/page/net/Start[/url][/QUOTE]
The description is pretty descriptive. If it's set to true the message [b]isn't[/b] guaranteed to be sent to the client but will be slightly faster than if it was set to false.
I'm pretty sure when it's sent "unreliably" that it follows all the rules UDP packets usually would. It's not guaranteed to arrive and it's certainly not guaranteed to arrive in the same order that it was sent.
[QUOTE=>>oubliette<<;48774727]The description is pretty descriptive. If it's set to true the message [b]isn't[/b] guaranteed to be sent to the client but will be slightly faster than if it was set to false.
I'm pretty sure when it's sent "unreliably" that it follows all the rules UDP packets usually would. It's not guaranteed to arrive and it's certainly not guaranteed to arrive in the same order that it was sent.[/QUOTE]
Yeah, just wanted to know the "plus" of placing true here
Thx
Anyone know how to get a DModelPanel's model to have a vector on it get positioned EXACTLY to the camera's view?
What I mean is, for example if you had a model of a sphere and you had a vector on the sphere's surface, how would you rotate the sphere's angles so this vector on it was in line with the camera and could be seen?
Just a small question, I'm creating an addon that replaces sound, but I don't know where to place my custom sound at >.>, can anyone help plz
[QUOTE=Z0mb1n3;48768653]If for whatever reason I don't have access to the server console, is there a hook I can use that will allow me to read the stack trace/error text of a lua error? Wanted to make a neat little error viewer that logs errors and the likes.[/QUOTE] [url]https://github.com/Metastruct/EPOE[/url]
I'm not very good with Dot related things. Would anyone be willing to share a function with me that can check if a player's view angles are within a certain range of an entity? Not in terms of 3D space, but like 2D distance between crosshair and entity?
Is it just me, or do CSS Calc() functions not work in the loading screen? An element on my loading screen wont position using CSS calc, but yet works fine elsewhere.
[QUOTE=Z0mb1n3;48778056]I'm not very good with Dot related things. Would anyone be willing to share a function with me that can check if a player's view angles are within a certain range of an entity? Not in terms of 3D space, but like 2D distance between crosshair and entity?[/QUOTE]
No need for dot products in this case.
This should work, but I have not tested it since I'm not home at the moment.
[code]
local function IsAimingAt(pos, dist)
local screenPos = pos:ToScreen()
if not screenPos.visible then return false end
local xDiff = (ScrW() / 2) - screenPos.x
local yDiff = (ScrH() / 2) - screenPos.y
local currDist = math.sqrt(xDiff * xDiff + yDiff * yDiff)
return currDist <= dist
end
[/code]
Edit: I just realized you might want this serverside, for another player's view. Then could use dot products, but there's no good way to make the distance in 2D space.
This should work relatively well for what you need it for, I believe. Make sure 'dir' is normalized. 'dist' is the distance in 3D space.
[code]
local function IsAimingAt(origin, dir, pos, dist)
local newPos = origin + (dir * origin:Distance(pos))
local currDist = newPos:Distance(pos)
return currDist <= dist
end
-- You can use it like this:
local aimingAt = IsAimingAt(ply:GetShootPos(), ply:GetAimVector(), Vector(0, 0, 0), 100)
[/code]
[QUOTE=Metamist;48778184]No need for dot products in this case.
This should work, but I have not tested it since I'm not home at the moment.
[code]
local function IsAimingAt(pos, dist)
local screenPos = pos:ToScreen()
if not screenPos.visible then return false end
local xDiff = (ScrW() / 2) - screenPos.x
local yDiff = (ScrH() / 2) - screenPos.y
local currDist = math.sqrt(xDiff * xDiff + yDiff * yDiff)
return currDist <= dist
end
[/code]
Edit: I just realized you might want this serverside, for another player's view. Then could use dot products, but there's no good way to make the distance in 2D space.
This should work relatively well for what you need it for, I believe. Make sure 'dir' is normalized. 'dist' is the distance in 3D space.
[code]
local function IsAimingAt(origin, dir, pos, dist)
local newPos = origin + (dir * origin:Distance(pos))
local currDist = newPos:Distance(pos)
return currDist <= dist
end
-- You can use it like this:
local aimingAt = IsAimingAt(ply:GetShootPos(), ply:GetAimVector(), Vector(0, 0, 0), 100)
[/code][/QUOTE]
Wow, thank you so much. A lot more than I was hoping to get, and the first function works perfectly for what I need!
[QUOTE=DarthTealc;48778486]Gmod's HTML element uses Awesomium which is equivalent to Chrome 18, released in 2012. Incredibly outdated. Anything added to browsers since mid 2012 isn't going to work in Gmod. Makes it painful to develop for.
CSS's calc() function wasn't supported until Chrome 19 (webkit prefixed).[/QUOTE]
I think it's a Chromium build from 2009 actually
[QUOTE=DarthTealc;48778714]At some point I got the idea it was based on Chrome/Chromium 18 though I can't back that up with evidence. Not sure if it was the useragent or something in documentation. I've mostly given up hope of being able to develop anything cool for it though, so I haven't looked into it lately.[/QUOTE]
You're thinking of the newest version of Awesomium I think. iirc Garry's Mod is on Chrome 3.0.195.24 or something horrific like that.
After a quick Google I even found an alternate source (hint: it is you): [url]https://github.com/Facepunch/garrysmod-issues/issues/2005[/url].
[url]http://www.cvedetails.com/vulnerability-list.php?vendor_id=1224&product_id=15031&version_id=83431&page=1&order=3[/url]
The user agent is fabricated by GMod, it does not come from Awesomium. I can put put everything there to 1337.
Sorry, you need to Log In to post a reply to this thread.