• Next Update v6.0 - October 2016
    1,799 replies, posted
[QUOTE=Gran PC;51358896]Used to work, garry removed it cuz it caused crashes[/QUOTE] If you're sure about that: [url]http://wiki.garrysmod.com/index.php?title=render/BrushMaterialOverride&action=formedit[/url]
[QUOTE=NeatNit;51358954]If you're sure about that: [url]http://wiki.garrysmod.com/index.php?title=render/BrushMaterialOverride&action=formedit[/url][/QUOTE] I sure am! (not sure I'd be able to get you a source though, I think he told me over skype back in the day, or maybe its in the old beta subforum). Feel free to add it in!
While looking through the garrysmod-issues for any I could address, I found [URL="https://github.com/Facepunch/garrysmod-issues/issues/2183"]#2183 - SortedPairsByMemberValue failing to unset __SortedIndex and bad performance[/URL] If you aren't familliar with SortedPairsByMemberValue, check its [URL="wiki.garrysmod.com/page/Global/SortedPairsByMemberValue#Examples"]examples[/URL] So I figured I could fix this issue as syl0r and Bo98 outlined it - change the function to create a shallow copy of the table instead of a deep one. I did so, and made [URL="https://github.com/garrynewman/garrysmod/pull/1273/commits/294373dbe170df94fcca0a311c052ba5d5cb944c"]a change[/URL]. However this made me wonder - why is the function even dealing with copies and an "__SortedIndex"? So I investigated. The [URL="https://github.com/garrynewman/garrysmod/blob/5e9d4fa05ea9cc69c56e5c0857d5247dcabdc192/garrysmod/lua/includes/extensions/table.lua#L469-L598"]default implementation[/URL] is... convoluted. First it copies the table (a shallow copy in the PR version). Then, it converts the table to a sequential format, then sorts it by the member value. Then, it constructs a "SortedIndex" table, which is a map from the table of sorted values to the original key. It's worth noting that doing this [b]relies on the implementation of table.SortByMember to leave behind an __key property on the sorted table that isn't cleared[/b]. Then, in the actual iterator called by lua, an O(n) lookup is performed to find the next key from the SortedIndex map... Anyway, it sucks. At this point, I noticed that syl0r himself had made a PR to reimplement these functions in a better way (but neglected to mention so on his issue :v:). [URL="https://github.com/syl0r/garrysmod/blob/18619a12a88c7273b848c72d1374b9f29c58c932/garrysmod/lua/includes/extensions/table.lua#L469-L529"]His version[/URL] is alright, but it still is a bit hard to follow in my opinion. (The biggest reason his hasn't been merged is probably that it just doesn't follow the GMod code style conventions, but whatever). Anyway, I decided to take a crack at rewriting these functions myself. [URL="https://github.com/bmwalters/garrysmod/blob/f467b1a4e16801fbc5c0d13b4a374df23f017c82/garrysmod/lua/includes/extensions/table.lua#L469-L564"]Here is my implementation[/URL]. It creates a helper function named "GenericSortedPairs" which models the Lua table.sort. It creates an iterator that iterates over the given values in a sorted order as dictated by the sorting function passed to it. I then made the other functions use this helper, which results in some really clean code in my opinion. Additionally, if said helper function were made global, it could help people who want a custom-style SortedPairs, for example if they wanted to iterate over a table sorted by the reverse of some property, the could write: [lua] local tab = { { foo = "bar" }, { foo = "baz" }, { foo = "qux" }, { foo = "nice" } } for k, v in GenericSortedPairs(tab, function(a, b) return tab[a].foo:reverse() > tab[b].foo:reverse() end) do print(k, v.foo) end [/lua] Thoughts?
wrong thread -snip-
[QUOTE=Gran PC;51360285]I sure am! (not sure I'd be able to get you a source though, I think he told me over skype back in the day, or maybe its in the old beta subforum). Feel free to add it in![/QUOTE] Tell me, why aren't you adding it yourself? The reason I ask is because I think anyone with anything to add to the wiki absolutely SHOULD add it to the wiki. Don't rely on anyone else to rediscover a mistake you've discovered and correct it, when you can easily do it yourself and it takes barely 2 minutes.
[URL=http://wiki.garrysmod.com/page/render/SetViewPort]render.SetViewPort[/URL] not allow fill texture if viewport size are better than screen resolution, it's just black. I usually use 640x480 to test HUD, so texture 512x512 will painted in bottom with black rectangle(512x32). Could this been fixed?
"Changing collision rules within a callback is likely to cause crashes!" Is there a list of things that can trigger this message? I know it was recently added, and I'm trying to fix an addon, but the addon doesn't call Entity:SetCollisionGroup in Entity:PhysicsCollide, so I'm a bit confused, as I've never dealt with this sort of stuff before.
[QUOTE=sannys;51373789]"Changing collision rules within a callback is likely to cause crashes!" Is there a list of things that can trigger this message? I know it was recently added, and I'm trying to fix an addon, but the addon doesn't call Entity:SetCollisionGroup in Entity:PhysicsCollide, so I'm a bit confused, as I've never dealt with this sort of stuff before.[/QUOTE] The message doesn't even make sense in some cases -- calling Remove on an entity in a touch/collide method will trigger the message even though it's queued.
I just noticed on dev that GetKeyValues returns no boolean types, SetKeyValue only accepts strings. Wouldn't it be better if SetKeyValue accepts variadic types, I can assume games that store the data and set it back at any point of time may cause errors.
[QUOTE=Zeh Matt;51387965]I just noticed on dev that GetKeyValues returns no boolean types, SetKeyValue only accepts strings. Wouldn't it be better if SetKeyValue accepts variadic types, I can assume games that store the data and set it back at any point of time may cause errors.[/QUOTE] No? Key values cannot be a boolean, they only can be a float, string or a vector. In fact, map entities can only have string key values. Just open up hammer.
[QUOTE=Robotboy655;51388024]No? Key values cannot be a boolean, they only can be a float, string or a vector. In fact, map entities can only have string key values. Just open up hammer.[/QUOTE] To add to this open up hammer and turn off smart edit in the entity properties window to see what the raw values actually are. Boolean values are actually just a 1 or 0
[QUOTE=Robotboy655;51388024]No? Key values cannot be a boolean, they only can be a float, string or a vector. In fact, map entities can only have string key values. Just open up hammer.[/QUOTE] Looks like you are right, something else between must convert it to a bool, ill take a look into it.
[QUOTE=Zeh Matt;51391443]Looks like you are right, something else between must convert it to a bool, ill take a look into it.[/QUOTE] [url]http://wiki.garrysmod.com/page/Global/tobool[/url]
Are clients incapable of getting the fake SteamID of bots? SteamID returns "NULL", SteamID64 returns nil, but this isn't documented in the wiki It's making testing my addon near impossible without other people, can someone confirm if this is intended behaviour?
Yeah, bots doesn't have valid steamids, although i would like to make them to return 0 or "BOT" as steamid64, because in testing you have to always verify if steamid64 is valid, although you shouldn't because you test stuff with bots
I really don't like how bots steamids are handled in our engine, the steam api can assign fake steamids to bots that can still be treated as normal steamids, and yet when you return one from a player there's all manner of fuckups, such as returning BOT or whatever arbitrary thing valve wanted. From the 64 bits of the steamid it is possible to see if the steamid is a "fake" one or not, but since we don't have an exposed steamid class, we have to do the checks ourselves with a lua library for that, which makes things annoying. (zerf or whoever made a lua library for that if I recall)
[QUOTE=Jvs;51395662]I really don't like how bots steamids are handled in our engine, the steam api can assign fake steamids to bots that can still be treated as normal steamids, and yet when you return one from a player there's all manner of fuckups, such as returning BOT or whatever arbitrary thing valve wanted. From the 64 bits of the steamid it is possible to see if the steamid is a "fake" one or not, but since we don't have an exposed steamid class, we have to do the checks ourselves with a lua library for that, which makes things annoying. (zerf or whoever made a lua library for that if I recall)[/QUOTE] Yep [IMG]http://i.imgur.com/mIvyfcw.png[/IMG] [url]https://gist.github.com/bmwalters/f4200ee7c1324306ffbd2faa6f879674#file-steamid_gmod-lua[/url] [editline]asdf[/editline] I realize the current implementation actually discards information from the SteamID64 (like things that could potentially better identify bots), I'll have a go at fixing that. [editline]19th November 2016[/editline] FUCK YEAH! old: [IMG]http://i.imgur.com/Zl9YQRq.png[/IMG] new: [IMG]http://i.imgur.com/1udovKn.png[/IMG] Since the numeric representation of the SteamID64 was too large to bitshift, I was previously just using the engine function util.SteamIDFrom64 and processing its output, throwing away information. Now, I wrote a function to return the binary representation of an arbitrarily large number (represented as a string), and used it to extract the bits of the steamid64 that correspond to each field. [lua] local function div_by_two(dec_str) local new_str = "" local prev_remainder = 0 for i = 1, #dec_str, 1 do local num = (prev_remainder * 10) + tonumber(string.sub(dec_str, i, i)) new_str = new_str .. math.floor(num / 2) prev_remainder = num % 2 end if new_str ~= "0" and string.sub(new_str, 1, 1) == "0" then new_str = string.sub(new_str, 2) end return new_str, prev_remainder end local function big_decimal_to_binary(dec_str) if dec_str == "0" or dec_str == "1" then return dec_str end local binary = "" while dec_str ~= "0" do local new_dec, remainder = div_by_two(dec_str) binary = string.format("%d%s", remainder, binary) dec_str = new_dec end return binary end -- and in the SteamID class constructor -- sid64 (community id) do if tonumber(sid) and #sid >= 16 then local binary_representation = big_decimal_to_binary(sid) local needed_zeroes = 64 - #binary_representation binary_representation = string.rep("0", needed_zeroes) .. binary_representation self.universe = tonumber(string.sub(binary_representation, 1, 8), 2) self.type = tonumber(string.sub(binary_representation, 9, 12), 2) self.instance = tonumber(string.sub(binary_representation, 13, 32), 2) self.accountid = tonumber(string.sub(binary_representation, 33, 64), 2) print(binary_representation) end end [/lua] Full code: [url]https://gist.github.com/bmwalters/f4200ee7c1324306ffbd2faa6f879674#file-steamid_gmod-lua[/url]
Does anyone have any idea why my dedicated server is throwing out this error when trying to update addons from a collection? [code]Processing addon 1 - 'Assmod 2.4 Content'... Addon needs downloading... Download Failed! Code: 37[/code] 37 is k_EResultIOFailure, so I expected some file issues, and I deleted all GMAs and download folders before retrying, but no luck.
[QUOTE=Revenge282;51401027]Does anyone have any idea why my dedicated server is throwing out this error when trying to update addons from a collection? [code]Processing addon 1 - 'Assmod 2.4 Content'... Addon needs downloading... Download Failed! Code: 37[/code] 37 is k_EResultIOFailure, so I expected some file issues, and I deleted all GMAs and download folders before retrying, but no luck.[/QUOTE] If the addon is too big the server just won't download it sometimes. You can instead download that addon on to your gmod, rename it to ds_addonid.gma and put that into your server's addons folder.
Will we get a method to check if a player is using a familyshare account and get the main steam id? I know its possible to check by sending a call to the SteamAPI using http.Fetch, but was just wondering if we will ever see a lua method.
[QUOTE=highwon;51401122]Will we get a method to check if a player is using a familyshare account and get the main steam id? I know its possible to check by sending a call to the SteamAPI using http.Fetch, but was just wondering if we will ever see a lua method.[/QUOTE] I'm curious, why do you need this?
[QUOTE=highwon;51401122]Will we get a method to check if a player is using a familyshare account and get the main steam id?[/QUOTE] This was requested a long time ago. [url]https://github.com/Facepunch/garrysmod-requests/issues/238[/url]
[QUOTE=YourStalker;51401062]If the addon is too big the server just won't download it sometimes. You can instead download that addon on to your gmod, rename it to ds_addonid.gma and put that into your server's addons folder.[/QUOTE] It's been able to download everything before, but I was thinking maybe this had to do with the new Steamworks stuff they were switching to? [QUOTE=NeatNit;51401198]I'm curious, why do you need this?[/QUOTE] Ban management
I forgot there were shitty people out there :(
[QUOTE=NeatNit;51401236]I forgot there were shitty people out there :([/QUOTE] Yeah, why filling the ban list if you can just throw these specific players from server?
[QUOTE=Revenge282;51401027]Does anyone have any idea why my dedicated server is throwing out this error when trying to update addons from a collection? [code]Processing addon 1 - 'Assmod 2.4 Content'... Addon needs downloading... Download Failed! Code: 37[/code] 37 is k_EResultIOFailure, so I expected some file issues, and I deleted all GMAs and download folders before retrying, but no luck.[/QUOTE] Is it just that addon or all addons? Does the steam_cache/ folder exist alongside the srcds.exe?
[QUOTE=Robotboy655;51401488]Is it just that addon or all addons? Does the steam_cache/ folder exist alongside the srcds.exe?[/QUOTE] I'm having the same problem and it's with every addon. No steam_cache folder there. Server is ubuntu.
You must have fucked up write permissions. srcds/steam must be able to write inside steam_cache/
[QUOTE=Robotboy655;51401488]Is it just that addon or all addons? Does the steam_cache/ folder exist alongside the srcds.exe?[/QUOTE] All addons from workshop collection. Also, this is Linux if it makes any difference. [editline]20th November 2016[/editline] No srcds_cache in the root folder either. Permissions are good as well it looks like.
[QUOTE=highwon;51401122]Will we get a method to check if a player is using a familyshare account and get the main steam id? I know its possible to check by sending a call to the SteamAPI using http.Fetch, but was just wondering if we will ever see a lua method.[/QUOTE] I used this for the longest time: [url]https://github.com/C0nw0nk/Garrys-Mod-Family-Sharing/blob/master/garrysmod/lua/autorun/familysharing.lua[/url] Edit: totally didnt read your whole post
Sorry, you need to Log In to post a reply to this thread.