How would I go about removing/undrawing an element drawn with the surface/draw library such as
[CODE] surface.DrawRect( number x, number y, number width, number height ) [/CODE]
or
[CODE] draw.RoundedBox( number cornerRadius, number x, number y, number width, number height, table color ) [/CODE]
[QUOTE=Par;49612035]How would I go about removing/undrawing an element drawn with the surface/draw library such as
[CODE] surface.DrawRect( number x, number y, number width, number height ) [/CODE]
or
[CODE] draw.RoundedBox( number cornerRadius, number x, number y, number width, number height, table color ) [/CODE][/QUOTE]
These functions should be called in a draw hook like [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/HUDPaint]GM/HUDPaint[/url], so if you simply stop calling the function then it will disappear.
[QUOTE=Par;49612035]How would I go about removing/undrawing an element drawn with the surface/draw library such as
[CODE] surface.DrawRect( number x, number y, number width, number height ) [/CODE]
or
[CODE] draw.RoundedBox( number cornerRadius, number x, number y, number width, number height, table color ) [/CODE][/QUOTE]
Use a panel with DPanel as base and then you can remove the panel reference once you're ready
[QUOTE=Par;49612035]How would I go about removing/undrawing an element drawn with the surface/draw library such as
[CODE] surface.DrawRect( number x, number y, number width, number height ) [/CODE]
or
[CODE] draw.RoundedBox( number cornerRadius, number x, number y, number width, number height, table color ) [/CODE][/QUOTE]
Set the surface.SetDrawColor's opacity to 0? :v:
You still rendering that and wasting drawcalls
just kidding i'm stupid and can't read the wiki.
[QUOTE=CosmicSeagull;49614246]just kidding i'm stupid and can't read the wiki.[/QUOTE]
[url]http://wiki.garrysmod.com/page/Panel/LocalToScreen[/url]
I have a question. As far as I know, doing "something.a = 10" is the same as doing "something[a] = 10"
I'm using this as a "cheap" way to store entities related to an npc, like this:
[CODE]if npc.PatrolPoints then
for k,v in pairs(npc.PatrolPoints) do
if IsValid(v) then v:Remove() end
end
end
npc.PatrolPoints = {}
for i = 1,numPPoints do
local ent = ents.Create("patrolpoint")
-- Do Stuff
npc:DeleteOnRemove(ent)
end[/CODE]
This creates a list of patrol points for each NPC I shoot with the toolgun. Every time I call this piece of code, the old list of points of that NPC is replaced with the new one, and the previously created entities are removed. Those entities are marked for deletion when the npc is removed. However, if I delete the NPC, the list will still be there, filled with nil values. Will this list be removed by the garbage collector or I'm creating a memory leak?
Converted some M9K weapons to TTT and i noticed that if a gun has extra ammo for other clips, then the gun is thrown on the ground and picked back up, the extra ammo is gone.
[CODE]if SERVER then
AddCSLuaFile( "ttt_m9k_mp40.lua" )
end
SWEP.HoldType = "ar2" -- how others view you carrying the weapon
if CLIENT then
SWEP.PrintName = "MP40"
SWEP.Icon = "vgui/ttt/icon_ump"
SWEP.Slot = 2 -- Slot in the weapon selection menu
end
SWEP.Kind = WEAPON_HEAVY
SWEP.ViewModelFOV = 70
SWEP.ViewModelFlip = true
SWEP.ViewModel = "models/weapons/v_mp40smg.mdl" -- Weapon view model
SWEP.WorldModel = "models/weapons/w_mp40smg.mdl" -- Weapon world model
SWEP.Base = "weapon_tttbase"
SWEP.Spawnable = true
SWEP.AutoSpawnable = true
SWEP.Primary.Damage = 14
SWEP.Primary.Delay = 0.112
SWEP.Primary.Sound = Sound("mp40.Single") -- Script that calls the primary fire sound
SWEP.Primary.ClipSize = 25 -- Size of a clip
SWEP.Primary.DefaultClip = 25 -- Bullets you start with
SWEP.Primary.Automatic = true -- Automatic = true; Semi Auto = false
SWEP.Primary.Ammo = "smg1"
SWEP.AmmoEnt = "item_ammo_smg1_ttt"
SWEP.Secondary.IronFOV = 55 -- How much you 'zoom' in. Less is more!
SWEP.data = {} --The starting firemode
SWEP.data.ironsights = 1
SWEP.Primary.Spread = .022 -- Define from-the-hip accuracy 1 is terrible, .0001 is exact)
SWEP.Primary.IronAccuracy = .015 -- Ironsight accuracy, should be the same for shotguns
-- Enter iron sight info and bone mod info below
SWEP.IronSightsPos = Vector(3.881, 0.187, 1.626)
SWEP.IronSightsAng = Vector(-0.047, 0, 0)
SWEP.SightsPos = Vector(3.881, 0.187, 1.626)
SWEP.SightsAng = Vector(-0.047, 0, 0)
SWEP.RunSightsPos = Vector(-5.119, -4.173, 0.865)
SWEP.RunSightsAng = Vector(-9.094, -56.496, 0)
if GetConVar("M9KUniqueSlots") != nil then
if not (GetConVar("M9KUniqueSlots"):GetBool()) then
SWEP.SlotPos = 2
end
end[/CODE]
EDIT: Solved, the weapon didn't have SWEP.Primary.ClipMax
[QUOTE=geferon;49611037]Omg.
Define a table outside the loop, then make a loop for all the mapcreated ids, and get the entities with the function i gave you and then insert those entities in the table.
It doesnt have to go through entities.GetAll.
Ill suply code when i can.[/QUOTE]
I think you're confusing the guy asking on how to save the doors created by the map with another guy which wants to remove all map props...
[QUOTE=MaxShadow;49614472]I have a question. As far as I know, doing "something.a = 10" is the same as doing "something[a] = 10"
I'm using this as a "cheap" way to store entities related to an npc, like this:
[CODE]if npc.PatrolPoints then
for k,v in pairs(npc.PatrolPoints) do
if IsValid(v) then v:Remove() end
end
end
npc.PatrolPoints = {}
for i = 1,numPPoints do
local ent = ents.Create("patrolpoint")
-- Do Stuff
npc:DeleteOnRemove(ent)
end[/CODE]
This creates a list of patrol points for each NPC I shoot with the toolgun. Every time I call this piece of code, the old list of points of that NPC is replaced with the new one, and the previously created entities are removed. Those entities are marked for deletion when the npc is removed. However, if I delete the NPC, the list will still be there, filled with nil values. Will this list be removed by the garbage collector or I'm creating a memory leak?[/QUOTE]
it'll be gc'd as long as you aren't storing any references to it elsewhere
Anyone know the name of the Muzzle flash effect for the AR2?
[QUOTE=MysticLlama;49615474]Anyone know the name of the Muzzle flash effect for the AR2?[/QUOTE]
[url]https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexe14a.html[/url]
i think it's that one, but i remember reading something about closed source effects or something
[QUOTE=GGG KILLER;49615399]I think you're confusing the guy asking on how to save the doors created by the map with another guy which wants to remove all map props...[/QUOTE]
No, i was just telling the best method to get the map entities by map id, but he seems to ignore me / not understanding me
What's the opposite of the function [URL="http://wiki.garrysmod.com/page/input/GetKeyName"]input.GetKeyName[/URL]?
In other words - I'm looking for the function to turn back the key's name (string) into a number.
[QUOTE=geferon;49616519]No, i was just telling the best method to get the map entities by map id, but he seems to ignore me / not understanding me[/QUOTE]
But why would a person who wants to clean up map-created props on startup need prop's map ids if he's just going to delete em all, just loop through ents.GetByClass 'prop_physics' and remove them, no need to store useless info
[QUOTE=MaxShadow;49614472]I have a question. As far as I know, doing "something.a = 10" is the same as doing "something[a] = 10"[/QUOTE]
It is not the same. "something.a = 10" is the same as "something["a"] = 10". The difference is that when you use square brackets its expecting a variable. So for example:
[code]
local thisIsAKey = "variableName"
local tbl = {}
tbl[thisIsAKey] = "hello"
print(tbl.variableName) -- prints hello
[/code]
[QUOTE=MaxShadow;49614472]I have a question. As far as I know, doing "something.a = 10" is the same as doing "something[a] = 10"[/QUOTE]
In addition to the post above this one, it's not just variables that can be used-it can be anything, like numbers, strings, entities and anything else really, even another table.
You could set a variable as any one of those things, but my point is that you don't need to refer to a variable, you can do it directly:
[CODE]
local table = {}
local number = 1
table[1] = 'test' -- That does the same thing as:
table[number] = 'test'
[/CODE]
Also, the difference between doing
[CODE]
table[thing]
[/CODE]
and
[CODE]
table.thing
[/CODE]
Is that the second one makes whatever is after the dot into a string and sets that as the new key.
The table[thing] one sets the key to be whatever is in the brackets, and doesn't think of 'thing' being a string.
The post above explains that in a less dumb way though.
Thanks for the answers, now I have it more clear. However, my main question was if the GC deletes tables with nil values. If I use the toolgun in two npcs, I would get something like this:
npc1.patrolpoints = {point11, point12, point13}
npc2.patrolpoints = {point21,point22}
But if I remove the first NPC, then it will be something like this:
npc1.patrolpoints = {nil, nil, nil}
npc2.patrolpoints = {point21,point22}
I wanted to know if the first table would be removed. I can't reference it, because the npc doesn't exist anymore.
[QUOTE=Ducky3426;49617229]It is not the same. "something.a = 10" is the same as "something["a"] = 10". The difference is that when you use square brackets its expecting a variable. So for example:
[code]
local thisIsAKey = "variableName"
local tbl = {}
tbl[thisIsAKey] = "hello"
print(tbl.variableName) -- prints hello
[/code][/QUOTE]
Just for clarification, note that it doesn't have to be a variable.
[lua]
tab["hi"] = 5
[/lua]
How do I enforce this to redraw on clientside, since it's not using static model:
[lua]SWEP.VElements = {
["hoboswep"] = {
type = "Model",
model = SWEP.model,
bone = "ValveBiped.Grenade_body",
rel = "",
pos = Vector(1.241, 3.658, -1.887),
angle = Angle(180, 98.248, -12.959),
size = Vector(1.133, 1.133, 1.133),
color = Color(255, 255, 255, 255),
surpresslightning = false,
material = "",
skin = 0,
bodygroup = {}
}
}
SWEP.WElements = {
["hoboswep"] = {
type = "Model",
model = SWEP.model,
bone = "ValveBiped.Bip01_R_Hand",
rel = "",
pos = Vector(5.717, 2.634, 0.07),
angle = Angle(0, 0, -13.44),
size = Vector(1.049, 1.049, 1.049),
color = Color(255, 255, 255, 255),
surpresslightning = false,
material = "",
skin = 0,
bodygroup = {}
}
}[/lua]
[QUOTE=GGG KILLER;49616619]But why would a person who wants to clean up map-created props on startup need prop's map ids if he's just going to delete em all, just loop through ents.GetByClass 'prop_physics' and remove them, no need to store useless info[/QUOTE]
He said he wanted it for specific props, not for all the props.
How do I restrict guns to gundealer only? Ill send you a pastebin of my shipments.lua. Do I have to edit other file to restrict the guns to gundealer?
PasteBin - [url]http://pastebin.com/tCNe65qY[/url]
[QUOTE=RainbowJesus;49618039]How do I restrict guns to gundealer only? Ill send you a pastebin of my shipments.lua. Do I have to edit other file to restrict the guns to gundealer?
PasteBin - [url]http://pastebin.com/tCNe65qY[/url][/QUOTE]
[lua]
-- restrictbuypistol - Enabling this feature makes /buy available only to Gun Dealers.
GM.Config.restrictbuypistol = false <--
[/lua]
If you don't know where this is, you shouldn't be trying to make a server. (and someone save us if its already up)
[QUOTE=GGG KILLER;49618858][lua]
-- restrictbuypistol - Enabling this feature makes /buy available only to Gun Dealers.
GM.Config.restrictbuypistol = false <--
[/lua]
If you don't know where this is, you shouldn't be trying to make a server. (and someone save us if its already up)[/QUOTE]
I figured it out right after I posted it. I am also running on 48hours of no sleep, so forgive me if I sound retarded. I just derped for a second
Hello, is there any way to scroll a DListView to the top? :SelectFirstItem() is only selecting the first item and not actually scrolling to it.
[QUOTE=P4sca1;49619472]Hello, is there any way to scroll a DListView to the top? :SelectFirstItem() is only selecting the first item and not actually scrolling to it.[/QUOTE]
[code]listview.VBar:SetScroll( 0 )[/code]
Should do the trick.
Any way to use antialiasing with a stencil buffer? Or the anisotropy filter. This is going to be used in a 2D context.
This is probably a simple question, but how can I hook to a weapon's reload function? I want some code to run whenever any weapon gets reloaded, but not just for SWEPS, for default weapons as well. Is there some kind of way to do this?
Also, by 'reload', I mean when the user reloads the ammo of the weapon, not the actual script for the weapon, if any.
I probably have to do some sort of dodgy check in a Tick/Think hook, but I thought I may as well ask in case there's a better way.
[QUOTE=MPan1;49622381]This is probably a simple question, but how can I hook to a weapon's reload function? I want some code to run whenever any weapon gets reloaded, but not just for SWEPS, for default weapons as well. Is there some kind of way to do this?
Also, by 'reload', I mean when the user reloads the ammo of the weapon, not the actual script for the weapon, if any.
I probably have to do some sort of dodgy check in a Tick/Think hook, but I thought I may as well ask in case there's a better way.[/QUOTE]
You could try to override [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/DoReloadEvent]Player:DoReloadEvent[/url]
Sorry, you need to Log In to post a reply to this thread.