• Problems That Don't Need Their Own Thread v5
    4,111 replies, posted
[QUOTE=arow1234;51911670]According to "lua/includes/extensions/game.lua", game.BuildAmmoTypes only prints used defined ammotypes, what about default ones? Would those be hardcoded?[/QUOTE] Yes. You can get the values with this [url]https://github.com/garrynewman/garrysmod/pull/1305[/url]
Is it possible to add new DTVars from an add-on when the gamemode sets them up through the player class system?
[QUOTE=Revenge282;51913462]Is it possible to add new DTVars from an add-on when the gamemode sets them up through the player class system?[/QUOTE] If you know the free slots, you can wait until the datatable is installed then add yours.
[QUOTE=code_gs;51913582]If you know the free slots, you can wait until the datatable is installed then add yours.[/QUOTE] There's no hook or anything for that I am assuming? I'm probably going to have to make the player class SetupDataTables function call something that the addon can use?
[QUOTE=Revenge282;51913607]There's no hook or anything for that I am assuming? I'm probably going to have to make the player class SetupDataTables function call something that the addon can use?[/QUOTE] No, but you can use hooks like PlayerInitialSpawn or OnEntityCreated and judge the time from there. Once the datatable is installed, you can create DTVars at any time. But unfortunately, this is no formal SetupDataTables hook for players.
s nip
[QUOTE=TehBigA;51910309]You have to find the hook in the registry and replace the value there. I haven't used this code in a while but I gave this to someone in the past and it worked for them to detour the cached value: :snip:[/QUOTE] Somewhat hard to follow that code, though considering it's probably stored as a reference, you should just need to loop through the integer keys in the registry. It's in spot 66 for me, though considering that could change you'd probably want something like the below [code] _oldHookCall = _oldHookCall or hook.Call function hook.Call(...) if ... == "Tick" then print(1) end return _oldHookCall(...) end for k, v in ipairs(debug.getregistry()) do if v == _oldHookCall then debug.getregistry()[k] = hook.Call break end end [/code]
[QUOTE=bigdogmat;51914722]Somewhat hard to follow that code, though considering it's probably stored as a reference, you should just need to loop through the integer keys in the registry. It's in spot 66 for me, though considering that could change you'd probably want something like the below snip [/QUOTE] 73 for me... Anyway, thanks to both of you :) Also I just noticed that as soon as you detour it, that reference is removed.
I'm not sure where to start, how would I go about creating a SWEP for TTT, that when held out would allow for bunnyhopping? Essentially increasing sv_airaccelerate only to that player Also removing "sticky feet" allowing for continued speed gain Would love any help or suggestions (:
Why some people said about SetNW variables are bad to use?
Using mysqloo V8: [I]I know it's updated but I haven't updated the one on my server.[/I] I need to run lua from an entry in the database, this is what I currently have: [CODE] local q = self:query( "SELECT * FROM `commands` WHERE `exec` =0" ) function q:onSuccess( data ) print( "Query successful!" ) PrintTable( data ) for k, v in pairs( data ) do RunConsoleCommand( "lua_run", v['cmd'] ) end end[/CODE] But lua_run is blocked, is there any other way of doing it? [CODE] RunConsoleCommand: Command is blocked! (lua_run)[/CODE] [B]Edit:[/B] Someone told be about RunString
Store the code where you should be storing it... In functions located in lua files... Then fetch info from database and run the functions or code appropriately there, loading actual code from database like that is a horrible way to do it.
[QUOTE=Deepsy02;51915617]73 for me... Anyway, thanks to both of you :) Also I just noticed that as soon as you detour it, that reference is removed.[/QUOTE] Not sure what you mean by this, but if you're talking about comparing hook.Call to the registry, you have to compare the older version, otherwise you'll never find it. Likewise if you want auto refresh to work, you'll be better off overwriting hook.Call after you find it in the registry.
[QUOTE=Author.;51916697]Store the code where you should be storing it... In functions located in lua files... Then fetch info from database and run the functions or code appropriately there, loading actual code from database like that is a horrible way to do it.[/QUOTE] Since our talk on discord I've started moving the code to the gmod files.
Appearently I can only call Give on server sided script but how do I do that with derma? I am making a menu where admins can spawn sweps but it doesnt work [code]Button1.DoClick = function( ) surface.PlaySound( "garrysmod/ui_click.wav" ) if ( LocalPlayer():IsAdmin() ) then LocalPlayer():Give("weapon_fists") end end[/code] what should I do?
[QUOTE=MGFear;51917868]Appearently I can only call Give on server sided script but how do I do that with derma? I am making a menu where admins can spawn sweps but it doesnt work [code]Button1.DoClick = function( ) surface.PlaySound( "garrysmod/ui_click.wav" ) if ( LocalPlayer():IsAdmin() ) then LocalPlayer():Give("weapon_fists") end end[/code] what should I do?[/QUOTE] When the client clicks the button to give the weapon send a message to the server and check if they're an admin on the server, if they are then give them the weapon.
Heya! I consider my 'issue' minor and therefore Im chosing to post it here. Guessing this questions might have been asked before, maybe once, a thousand times. You are allowed to consider me stupid or ignorant, but here goes; [B]I would like to [U]disable the billboard somehow[/U] since my server will function better with previous /advert [Advert] or not containing the 'advert' feature at all.[/B] Already tried; [URL="http://forum.darkrp.com/threads/classic-advert.8022/"]http://forum.darkrp.com/threads/classic-advert.8022/[/URL] - Fillipuster's Classic Advert [I]It does not really disable the billboard feature, only adds an command for the previous /advert[/I] [I]Disclaimer: I do not dislike the advert billboard in any way, it's just that it doesn't fit in how I want my server to work out.[/I]
Looks like you want the [b][url=http://wiki.darkrp.com/index.php?title=Hooks/Server/canAdvert]canAdvert hook[/url][/b]
Does anyone have any suggestions for easy code documentation for GLua? I've written a whole slew of functions between my game mode and add-ons, and it would be nice to make a mini wiki of sorts. Second, what's the best way to handle translations for in-game strings? (Multiple languages)
[QUOTE=Revenge282;51918410]Does anyone have any suggestions for easy code documentation for GLua? I've written a whole slew of functions between my game mode and add-ons, and it would be nice to make a mini wiki of sorts. Second, what's the best way to handle translations? (Multiple languages)[/QUOTE] Haven't tried it myself, but heard that [url=https://stevedonovan.github.io/ldoc/]LDoc[/url] works well. Just make sure you use only Lua syntax (no //, &&, || and probably continue as well) so it doesn't break. As for translations, do you mean in the documentation or in the game? The game provides a good system for translation, will edit this post with a link or two. Edit: so basically, there's [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/language/GetPhrase]language.GetPhrase[/url] where you input a phrase's code name and it returns the string in the user's language. Phrases are added via language files, which are txt files in valve's format. In general don't use language.Add, that makes the whole thing accomplish nothing. However, you don't need to use language.GetPhrase either. When a string like "#limit_physgun" is displayed on the screen via any means - surface.DrawText, print, derma labels, etc - it will get translated automatically.
[QUOTE=NeatNit;51919958]Haven't tried it myself, but heard that [url=https://stevedonovan.github.io/ldoc/]LDoc[/url] works well. Just make sure you use only Lua syntax (no //, &&, || and probably continue as well) so it doesn't break. As for translations, do you mean in the documentation or in the game? The game provides a good system for translation, will edit this post with a link or two.[/QUOTE] Edited it for clarity. But I meant translations for in-game strings.
Edited my post above before I saw yours. Here is an example language file: [url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/resource/language/sandbox-cleanup_english.txt[/url]
[QUOTE=NeatNit;51920016]Edited my post above before I saw yours. Here is an example language file: [url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/resource/language/sandbox-cleanup_english.txt[/url][/QUOTE] I never saw the utility in the language.GetPhrase/Add functions since they didn't seem to have an option for specifying what language they are translated to. (Unless they use whatever the game is set to in the menu?) If that is the case, is there a list of the languages that it supports?
[QUOTE=MGFear;51917868]Appearently I can only call Give on server sided script but how do I do that with derma? I am making a menu where admins can spawn sweps but it doesnt work [code]Button1.DoClick = function( ) surface.PlaySound( "garrysmod/ui_click.wav" ) if ( LocalPlayer():IsAdmin() ) then LocalPlayer():Give("weapon_fists") end end[/code] what should I do?[/QUOTE] Server-side: [LUA] util.AddNetworkString("Spawn Weapon") net.Receive("Spawn Weapon", function(len, client) if not (client:IsAdmin() or client:IsSuperAdmin()) then return end local class = net.ReadString() if class then client:Give(class) end end) [/LUA] Client-side: [LUA] DoClick = function() ... net.Start("Spawn Weapon") net.WriteString("weapon_fists") net.SendToServer() [/LUA] If you want them to be able to specify weapon, do above. If not, just replace the net.ReadString with your own class, and remove net.WriteString from client. Please do read this regardless: [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Net_Library_Usage]Net Library Usage[/url]
[QUOTE=Revenge282;51920067]I never saw the utility in the language.GetPhrase/Add functions since they didn't seem to have an option for specifying what language they are translated to. (Unless they use whatever the game is set to in the menu?) If that is the case, is there a list of the languages that it supports?[/QUOTE] As I said, you generally don't need to use them. Take, for example, the toolgun tools: [url]https://github.com/garrynewman/garrysmod/blob/784cd57576d85712fa13a7cea3a9523b4df966b0/garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/finger.lua[/url] TOOL.Name = "#tool.finger.name" In a language file (different file for each language), the phrase "tool.finger.name" is defined. [url]https://github.com/garrynewman/garrysmod/blob/784cd57576d85712fa13a7cea3a9523b4df966b0/garrysmod/resource/localization/en/tool.properties#L363[/url] (non-English files are not on GitHub) Then when it's drawn on the screen, all Lua does is draw "#tool.finger.name", and it gets automagically translated: [url]https://github.com/garrynewman/garrysmod/blob/784cd57576d85712fa13a7cea3a9523b4df966b0/garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/cl_init.lua#L77[/url] There is, in fact, no way to disable automatic phrase translation. This causes problems. If you set your steam name to a phrase, it will be drawn on screen as the full translated phrase, and dealing with stuff like that as a dev is annoying. However, when you want it to happen, it's great! Edit: example 1 at [url]http://wiki.garrysmod.com/page/Panel/SetText[/url] shows this in action.
I was wondering if there is a way of using math.clamp on a screen position, but instead of square a rounded box.
[QUOTE=rtm516;51920635]I was wondering if there is a way of using math.clamp on a screen position, but instead of square a rounded box.[/QUOTE] What are you trying to achieve?
[QUOTE=NeatNit;51920653]What are you trying to achieve?[/QUOTE] I have created a top down view and when a player is off the screen they become there avatar 100px from the edge and I would like it to have smooth corders for the limits.
for the rounded corners you might have to use stencils with a surface.DrawPoly. But I still don't understand what you want, so a mock-up would help if you could make one
[QUOTE=NeatNit;51920736]for the rounded corners you might have to use stencils with a surface.DrawPoly. But I still don't understand what you want, so a mock-up would help if you could make one[/QUOTE] Will do when I get home, I'll post screenshots of what I have and annotate with what I want
Sorry, you need to Log In to post a reply to this thread.