[QUOTE=ArtikNinetail;49602076]So I've got a table that is stored as
[code]local tbl = {
["SteamID 1"] = true,
["SteamID 2"] = true,
["SteamID 3"] = true,
}[/code]
How would I add to this table with something like table.Add()?[/QUOTE]
Could you just do
[code]for k, v in pairs(newTable) do
oldTable[v] = true
end[/code]
Replace the [v] with [k] if you want the keys to be used, obviously.
If you are using ttt base for M9K weapons, how would i get the sights and acogs to still work on TTT? I was told there's a workaround but not sure.
[QUOTE=Z0mb1n3;49602213]Could you just do
[code]for k, v in pairs(newTable) do
oldTable[v] = true
end[/code]
Replace the [v] with [k] if you want the keys to be used, obviously.[/QUOTE]
Is there no better way? That seems way overly complicated similar to doing the same thing with a normal table. It's just doesn't seem like the best way to do it.
[QUOTE=ArtikNinetail;49602231]Is there no better way? That seems way overly complicated similar to doing the same thing with a normal table. It's just doesn't seem like the best way to do it.[/QUOTE]
Well table.Add is a GMod specific function which does the same thing I gave you, but using table.insert instead.
[QUOTE=Z0mb1n3;49602292]Well table.Add is a GMod specific function which does the same thing I gave you, but using table.insert instead.[/QUOTE]
After trying a bunch of stuff, not even rewriting over it works since there is no way to add the type to the table. Can't even do what you suggested.
Edit:
Holy fuck I am retarded. Why was I even storing the strings in that way? Made it into a normal table and just used table.HasValue and got it working. I'm fucking retarded for storing a table that way.
[QUOTE=ROFLBURGER;49601032]Is there a possible way to exclude an entity class from being removed on a map cleanup?[/QUOTE]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/game/CleanUpMap]game.CleanUpMap[/url]
Is it possible and smart to save a variable onto a player?
[QUOTE=jack5500;49602474]Is it possible and smart to save a variable onto a player?[/QUOTE]
Other than it's lost when the player disconnects, i don't see why not. It retains it over deaths and events so yeah.
[QUOTE=ArtikNinetail;49602355]After trying a bunch of stuff, not even rewriting over it works since there is no way to add the type to the table. Can't even do what you suggested.
Edit:
Holy fuck I am retarded. Why was I even storing the strings in that way? Made it into a normal table and just used table.HasValue and got it working. I'm fucking retarded for storing a table that way.[/QUOTE]
Depending on where you're using it, you might want to switch back to the string indexes. It is a much more efficient way to look up values in your table instead of looping through the entire table which table.HasValue does. I don't understand why you're against the way of adding new values to the string indexed table, it's much easier in general.
If you want to add a value it's
mytable["steamid"] = true
And to remove a value it's
mytable["steamid"] = nil
[QUOTE=ms333;49602805]Depending on where you're using it, you might want to switch back to the string indexes. It is a much more efficient way to look up values in your table instead of looping through the entire table which table.HasValue does. I don't understand why you're against the way of adding new values to the string indexed table, it's much easier in general.
If you want to add a value it's
mytable["steamid"] = true
And to remove a value it's
mytable["steamid"] = nil[/QUOTE]
And its also better for bigger tables, as it doesnt have to loop throught it as table.HasValue does, wich is more ineficient
[QUOTE=YourStalker;49579669]You should put this in InitPostEntity and use ent:CreatedByMap() in your loop. Also make sure you are using hook.Add to make your hook.[/QUOTE]
We were both wrong. The entity isn't prop phsyics, its prop phdyics mutliplsyet but your suggested fix will work. Thanks.
[QUOTE=Strideynet;49603802]We were both wrong. The entity isn't prop phsyics, its prop phdyics mutliplsyet but your suggested fix will work. Thanks.[/QUOTE]
Instead of looping through every entity to get the one that has that id use this function.
Also, dont ignore me. Please.
[QUOTE=geferon;49571145]no.
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ents/GetMapCreatedEntity]ents.GetMapCreatedEntity[/url][/QUOTE]
[QUOTE=geferon;49604627]Instead of looping through every entity to get the one that has that id use this function.
Also, dont ignore me. Please.[/QUOTE]
That seems to only return a single entity and requires whatever a map creation id is.
I'm trying to do
[QUOTE]
CreateConVar( "ttt_malfunction_pistol_allocate_damage_to_traitor", "1",false)
print(GetConVarString("ttt_malfunction_pistol_allocate_damage_to_traitor"))[/QUOTE]
in the "EntityTakeDamage" hook, but it just prints a blank line.
(I'm trying to this inside of a SWEP)
What am I doing wrong?
-late-
Does anyone know how I can draw a rounded outlined rect?
much like surface.DrawOutlinedRect() just rounded, so it matches the cornerRadius in draw.RoundedBox
[QUOTE=Invule;49605964]Does anyone know how I can draw a rounded outlined rect?
much like surface.DrawOutlinedRect() just rounded, so it matches the cornerRadius in draw.RoundedBox[/QUOTE]
As far as I know there is no dedicated function, but you can try to modify [URL="https://github.com/garrynewman/garrysmod/blob/master/garrysmod/lua/includes/modules/draw.lua"]RoundedBoxEx[/URL] to suit your needs.
[QUOTE=YourStalker;49604736]That seems to only return a single entity and requires whatever a map creation id is.[/QUOTE]
You get that id with ent:CreatedByMap() wich he mentiones he was using.
He can also loop through those ids and get the entities with that function wich would be more efficient than looping through all entities and checking if the id is the same.
Is it possible/easy is it for C++ cheats to hide their stuff on a render.Capture?
Been noticing loads more C++ cheaters recently and as far as I'm aware if they're just using an ESP and not touching getting/touching the lua state its impossible (or extremely difficult) to detect via lua?
Edit:
And they all seem to be using the same public dlls, is getting them blacklisted with VAC out of the equation?
[QUOTE=Jonzky;49606814]
And they all seem to be using the same public dlls, is getting them blacklisted with VAC out of the equation?[/QUOTE]
I'm in no position to say this, though yes.
I don't understand how to make an addon that isn't for workshop. I've tried making every type of addon.txt and aming it the parent folder's name. I've even tried without an addon.txt
You don't need an addon.txt. To create an addon do the following:
1. Go to steamfolder/steamapps/Garrys Mod/garrysmod/addons and make a folder named anything.
2. In the folder you named anything make a folder name lua.
3. Make a folder in that lua folder named autorun.
4. Make two more folders named client and server.
5. Any randomname.lua file made in autorun/ is shared, in autorun/client is client only, in autorun/server is server only.
hello can anybody tell me how i make a entity hover do i use SetVelocity or what
just can anybody tell me how a make it hover and make move while hovering or just the function :) ?
I know I've asked about folders and stuff before but it's something I just struggle to fully get
This correctly prints prints the contents inside the file
[code]
local dir = file.Read("test_dir/test_file.txt", "DATA")
print(dir)
[/code]
How would I do this for every file in the folder? I thought using an * instead of the file name and a k,v pairs loop would work but that prints nil :(
[QUOTE=NiandraLades;49610026]I know I've asked about folders and stuff before but it's something I just struggle to fully get
This correctly prints prints the contents inside the file
[code]
local dir = file.Read("test_dir/test_file.txt", "DATA")
print(dir)
[/code]
How would I do this for every file in the folder? I thought using an * instead of the file name and a k,v pairs loop would work but that prints nil :([/QUOTE]
You need to use file.Find
[QUOTE=NiandraLades;49610026]I know I've asked about folders and stuff before but it's something I just struggle to fully get
This correctly prints prints the contents inside the file
[code]
local dir = file.Read("test_dir/test_file.txt", "DATA")
print(dir)
[/code]
How would I do this for every file in the folder? I thought using an * instead of the file name and a k,v pairs loop would work but that prints nil :([/QUOTE]
You need to use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/file/Find]file.Find[/url] for that.
[editline]26th January 2016[/editline]
Fuck.
kill me
(thanks!! works)
[QUOTE=geferon;49604627]Instead of looping through every entity to get the one that has that id use this function.
Also, dont ignore me. Please.[/QUOTE]
Can you explain how I would use that function without looping through all the entities? YourStalkers is far superior.
[QUOTE=Strideynet;49610411]Can you explain how I would use that function without looping through all the entities? YourStalkers is far superior.[/QUOTE]
[CODE]
for k, v in pairs (ents.FindByClass("entityhere")) do
--code
end
[/CODE]
[QUOTE=Strideynet;49610411]Can you explain how I would use that function without looping through all the entities? YourStalkers is far superior.[/QUOTE]
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.
Sorry, you need to Log In to post a reply to this thread.