• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
Maybe you can find your answers in this[URL="https://github.com/garrynewman/garrysmod/blob/master/garrysmod/gamemodes/terrortown/gamemode/player.lua"] GitHub[/URL] page , another question what is this bone "ValveBiped.Bip01_Spine2" ??
[QUOTE=sm69baller;45468305]Maybe you can find your answers in this[URL="https://github.com/garrynewman/garrysmod/blob/master/garrysmod/gamemodes/terrortown/gamemode/player.lua"] GitHub[/URL] page , another question what is this bone "ValveBiped.Bip01_Spine2" ??[/QUOTE] The midle of the spine
Hey guys I have a simple question. When you use the surface.setmaterial, where exactly is it coming from. Like will it be in my gamemodes folder or garrysmod/garrysmod. Example, it being in my gamemodes folder [code]surface.SetMaterial("images/logo.png")[/code]
[QUOTE=:0;45472769]Hey guys I have a simple question. When you use the surface.setmaterial, where exactly is it coming from. Like will it be in my gamemodes folder or garrysmod/garrysmod. Example, it being in my gamemodes folder [code]surface.SetMaterial("images/logo.png")[/code][/QUOTE] that method takes a IMaterial value.. So more like you get your material instance by calling [lua]local logomat = Material("images/logo.png")[/lua] and then doing [code]surface.SetMaterial(logomat)[/code] make sure to never call Material() within a paint hook though. It's unnecessary to call it more than once.
[QUOTE=Mista Tea;45462991]I really don't mean to sound harsh, but how are you even running this at all? 1. Doing something like [1] and [3] by itself is not valid Lua syntax (unexpected symbol near '[') 2. You shouldn't need to loop through player.GetAll() during CanTool. It gives you the specific player that tried tooling something. 3. AFAIK pairs() does not take varargs. It takes one table only (please correct me if I am mistaken). Only your limits table is being looped through. 4. You really shouldn't use CanTool to regulate prop limits either. Just because they are tooling something doesn't mean they are spawning it (e.g., updating the settings of an already spawned entity). That is what the following hooks are for in Sandbox: PlayerSpawnedEffect PlayerSpawnedNPC PlayerSpawnedProp PlayerSpawnedRagdoll PlayerSpawnedSENT PlayerSpawnedSWEP PlayerSpawnedVehicle PlayerSpawnEffect PlayerSpawnNPC PlayerSpawnObject PlayerSpawnProp PlayerSpawnRagdoll PlayerSpawnSENT PlayerSpawnSWEP PlayerSpawnVehicle[/QUOTE] ofc, i ment v[1] instead of just [1], If i dont need to loop through it, point to where the wiki says that, pairs() does take varargs, and i'm not regulating prop limits. i'm regulating thruster limits.
[QUOTE=74pantera;45473650]ofc, i ment v[1] instead of just [1], If i dont need to loop through it, point to where the wiki says that, pairs() does take varargs, and i'm not regulating prop limits. i'm regulating thruster limits.[/QUOTE] [URL]http://wiki.garrysmod.com/page/Global/pairs[/URL] Takes one table, not multiple arguments. [CODE] ] lua_run_cl for k, v in pairs( { 1, 2, 3 }, { 4, 5, 6 } ) do print( k, v ) end 1 1 2 2 3 3 [/CODE] Prints only the first table. When I said props I meant entities in general. My 4th point still stands. Just because they are tooling doesn't mean they are spawning a new entity. Nor should you be checking thruster limits [B]every single time[/B] they use the toolgun, regardless of which tool they are using. Your current setup would prevent a player from being able to tool anything if they had too many thrusters out, even if they were trying to use any other tool except thruster. You would be much better off overriding [URL="http://wiki.garrysmod.com/page/Player/CheckLimit"]PLAYER:CheckLimit[/URL] (called prior to the thruster being created), [URL="http://wiki.garrysmod.com/page/cleanup/Add"]cleanup.Add[/URL], [URL="http://wiki.garrysmod.com/page/Player/AddCount"]PLAYER:AddCount[/URL], and even the [URL="http://wiki.garrysmod.com/page/undo"]undo library[/URL] so you can regulate thrusters (among nearly anything else) being created in a majority of contexts (duplicator, advdupe, advdupe2, etc), without having to loop through every player for every limit every time a single person uses their tool gun (or whatever you're trying to do). That's incredibly inefficient.
Are you unable to use file.Write() for any type of file besides *.txt? I am trying to write a .json file. The content is in JSON format, using util.TableToJSON(), but it is not showing up in /data/.
[QUOTE=camer0n;45475327]Are you unable to use file.Write() for any type of file besides *.txt? I am trying to write a .json file. The content is in JSON format, using util.TableToJSON(), but it is not showing up in /data/.[/QUOTE] [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexbca1.html[/url]
[QUOTE=Revenge282;45475345][url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexbca1.html[/url][/QUOTE] Thank you, I was using the new wiki. I suppose there's no work-around unless I were to make a module for it?
Just wondering, does GMod handle functional Photoshop layers well? Or is there other way to achieve this effect: [img]http://docs.worldviz.com/vizard/images/postprocess_boxblur.jpg[/img] [editline]23rd July 2014[/editline] Forgot to mention, ways other than: [code]Derma_DrawBackgroundBlur( self, self.m_fCreateTime )[/code]
[lua]local settings = {favorite_car = "Skyline";} local cars = {["Skyline"] = "nissan_skyline";} local car = cars[settings["favorite_car"]] [/lua] That code is meant to retrieve the user's favorite car's model (not it's name). How can I do that without throwing an error and without re-organizing my table system? (I understand that the error is caused because I cannot have brackets inside of brackets) Or is there no way to do this without adding another local variable? (I don't really want to add another line for it - it would bother me if I did)
you can have brackets inside brackets though [lua] for k, v in pairs(chunk.blocks) do if(v >= 1) then types[v] = types[v] or {} types[v][#types[v] + 1] = k end end [/lua] just looking through stuff I've done, that runs without any errors if you're still not convinced, you could do [lua] local favorite = settings["favorite_car"] local car = cars[favorite] --or local car = cars[settings.favorite_car] [/lua]
[QUOTE=Netheous;45475587]Just wondering, does GMod handle functional Photoshop layers well? Or is there other way to achieve this effect: [img]http://docs.worldviz.com/vizard/images/postprocess_boxblur.jpg[/img] [editline]23rd July 2014[/editline] Forgot to mention, ways other than: [code]Derma_DrawBackgroundBlur( self, self.m_fCreateTime )[/code][/QUOTE] No. GMod can't open photoshop files.
I'm attempting to remove duplicate strings from a table of gamemodes, this is what I have but it doesn't seem to work. [code]function RemoveTableDupes(t) local returnTable ={} for i,v in pairs(t) do if(t[v] ~= nil) then table.insert(returnTable, v) end t[v] = i end return returnTable end[/code] Or is there a better way to achieve this?
[code] function RemoveDuplicateValues( t ) local tempTable = {} -- First build a table of values without duplicates for k, v in pairs( t ) do if( tempTable[ v ] == nil ) then tempTable[ v ] = true end end local returnTable = {} -- Now build a table of key-values without duplicates for k, v in pairs( t ) do if( tempTable[ v ] ) then returnTable[ k ] = v tempTable[ v ] = nil end end return returnTable end[/code] There are probably better solutions.
[QUOTE=Robotboy655;45476114][code] function RemoveDuplicateValues( t ) local tempTable = {} -- First build a table of values without duplicates for k, v in pairs( t ) do if( tempTable[ v ] == nil ) then tempTable[ v ] = true end end local returnTable = {} -- Now build a table of key-values without duplicates for k, v in pairs( t ) do if( tempTable[ v ] ) then returnTable[ k ] = v tempTable[ v ] = nil end end return returnTable end[/code] There are probably better solutions.[/QUOTE] Without removing dupes I get [quote]1 = sandbox 2 = sandbox 3 = sandbox 4 = ttt 5 = melonbomber [/quote] and with it I get [quote] 1 = sandbox 2 = sandbox 4 = ttt 5 = melonbomber [/quote]
[QUOTE=JakeAM;45476153]Without removing dupes I get and with it I get[/QUOTE] I beg to differ: [img]http://i.imgur.com/6VrPwqB.png[/img] [editline]23rd July 2014[/editline] [QUOTE=Revenge282;45475345][url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexbca1.html[/url][/QUOTE] Stop linking the old wiki. If there's something on the new wiki that is missing, let me know. The old one has a lot of incorrect information by now, I have updated the page on the new one: [url]http://wiki.garrysmod.com/page/file/Write[/url]
[QUOTE=Robotboy655;45476323] Stop linking the old wiki. If there's something on the new wiki that is missing, let me know. The old one has a lot of incorrect information by now, I have updated the page on the new one: [url]http://wiki.garrysmod.com/page/file/Write[/url][/QUOTE] What about the realm types that are missing from the new wiki? Additional notes and caveats like the old wiki? Better usage examples for a lot of things? I tend to prefer the old wiki when trying to find stuff and only really use the new one to check what inputs are taken or if they still exist.
[QUOTE=Blasteh;45476426]What about the realm types that are missing from the new wiki? Additional notes and caveats like the old wiki? Better usage examples for a lot of things? I tend to prefer the old wiki when trying to find stuff and only really use the new one to check what inputs are taken or if they still exist.[/QUOTE] The realm is put on the bottom of each function definition, additional notes must be merged into the description of the function, its arguments and return values. You know, you are free to edit the wiki, if you are only going to bitch about missing shit on it, it won't get better by itself.
I'm trying to make a 'walking spectate' mode for TTT; and I have the spectators viewing the world through a black/white color mod in RenderScreenSpaceEffects. However, I want the spectators to see each other with a bit of color, so I've added this after the colormod; [lua]if LocalPlayer():IsSpec() then plys = player.GetAll() cam.Start3D(EyePos(), EyeAngles()) for i=1, #plys do ply = plys[i] if not ply:IsSpec() then continue end render.SuppressEngineLighting(true) render.SetBlend(0.5) ply:DrawModel() render.SuppressEngineLighting(false) render.MaterialOverride(nil) end end cam.End3D() [/lua] but it crashes during round changes
How can I remove new lines from a table of strings? [code]function RemoveNewlines(t) local returnTable = {} for k,v in pairs(t) do local vv = string.gsub(s, "n", "") table.insert(returnTable, vv) end return returnTable end[/code] Doesn't seem to work :/
[QUOTE=JakeAM;45477175]How can I remove new lines from a table of strings? [code]function RemoveNewlines(t) local returnTable = {} for k,v in pairs(t) do local vv = string.gsub(s, "n", "") table.insert(returnTable, vv) end return returnTable end[/code] Doesn't seem to work :/[/QUOTE] s isn't defined. "n" isn't a newline, "\n" is.
[QUOTE=Robotboy655;45476611]The realm is put on the bottom of each function definition, additional notes must be merged into the description of the function, its arguments and return values. You know, you are free to edit the wiki, if you are only going to bitch about missing shit on it, it won't get better by itself.[/QUOTE] Easy now, he wasn't really bitching, just stating why he uses the old wiki. You even said "If there's something on the new wiki that is missing, let me know," and he did. I use the old wiki ~90% of the time as well for the reasons reasons Blasteh mentioned, not as a slight against yourself or your work.
[QUOTE=camer0n;45475361]Thank you, I was using the new wiki. I suppose there's no work-around unless I were to make a module for it?[/QUOTE] What is the problem with writing JSON to a txt file? It's not like the contents of the file are any different...
Is there any way to create only a shared.lua for an entity that uses a base entity?
Getting an odd error, can anyone else? [quote][ERROR] addons/jamv/lua/autorun/server/vote_sv.lua:22: attempt to call global 'sortGMTable' (a nil value) [/quote] [code] --defaults defaultTime = 0.1 defaultGMMapList = file.Read("maplist.txt", "DATA") defultVoteTime = 5 mapTable = {} --net util.AddNetworkString("JAMV") util.AddNetworkString("JAMV Vote") --dynamic vars timeLeft = defaultTime * 60 voteTime = defultVoteTime --timer timer.Create("TimeUntilVote", 1, timeLeft, function() timeLeft = timeLeft - 1 RunConsoleCommand("say", timeLeft) StartVote() end) --funcs function StartVote() if(timeLeft == 0) then local mapGMTable = RemoveDuplicateValues(RemoveNewlines(GetGMS(MapListToTable(defaultMapList)))) SendToClients(sortGMTable(mapGMTable)) PrintTable(SortGMTable(mapTable)) end end function MapListToTable(s) local mapList = string.Explode(",", s) local returnTable = {} for i,v in pairs(mapList) do returnTable[i] = string.Explode(" ", v) end return returnTable end function SortGMTable(t) local returnTable = SortTableKeys(RemoveDuplicateValues(RemoveNewlines(GetGMS(MapListToTable(t))))) return returnTable end function SortTableKeys(t) local returnTable = {} for k,v in pairs(t) do table.insert(returnTable, v) end return returnTable end function GetGMS(t) local returnTable = {} for i,v in pairs(t) do for ii,vv in pairs(v) do if(ii == 1) then returnTable[i] = vv end end end return returnTable end function RemoveDuplicateValues(t) local tempTable = {} for k,v in pairs(t) do if(tempTable[v] == nil) then tempTable[v] = true end end local returnTable = {} for k,v in pairs(t) do if(tempTable[v]) then returnTable[k] = v tempTable[v] = nil end end return returnTable end function GetMapsForGM(t, s) local returnTable = {} for i,v in pairs(t) do for ii,vv in pairs(v) do returnTable[i] = vv end end return returnTable end function RemoveNewlines(t) local returnTable = {} for k,v in pairs(t) do local char = string.gsub(v, "\n", "") table.insert(returnTable, char) end return returnTable end function SendToClients(t) net.Start("JAMV") net.WriteTable(t) net.Broadcast() end[/code]
Use table.sort()?
Hey guys, so, I am pretty new with lua. I have started up my own DarkRP server but can't seem to find out how to make it so that players spawn with more money than they currently do. For example, how do servers that have 50k Start in their name make it so that player actually do tart with 50k? I thought maybe making it execute rp_setmoney on initial spawn but tang would mean that players get reset every time they join, would it not? Thanks for the help, RogerThat!
[QUOTE=JakeAM;45478213]Getting an odd error, can anyone else? [/QUOTE] function SortGMTable(t) you're using sortGMTable
Is there a way to get spectators to switch weapons properly? SelectWeapon doesn't work and SetActiveWeapon makes viewmodels go funny
Sorry, you need to Log In to post a reply to this thread.