• Problems That Don't Need Their Own Thread v3.0
    5,003 replies, posted
Is it possible to block users from running console commands? For example, my admins can change to jobs that have a custom check for a certain steamid on them by just typing "rp_whateverjobhere <playername>"
Is there a limit on the size of a font using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/surface/CreateFont]surface.CreateFont[/url]? Similarly, is there a limit to how small the scale on a [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/cam/Start3D2D]cam.Start3D2D[/url]? Trying to get my fonts nice and sharp.:downs:
[QUOTE=Revenge282;47726057]Is there a limit on the size of a font using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/surface/CreateFont]surface.CreateFont[/url]? Similarly, is there a limit to how small the scale on a [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/cam/Start3D2D]cam.Start3D2D[/url]? Trying to get my fonts nice and sharp.:downs:[/QUOTE] I don't think there's a limit besides the practical limits, but keep in mind that the lower the scale, the higher the effective "resolution" you're rendering at.
Is file.write supposed to not make its own directories? It's very annoying to have to add directory checks everywhere
[QUOTE=vexx21322;47726070]I don't think there's a limit besides the practical limits, but keep in mind that the lower the scale, the higher the effective "resolution" you're rendering at.[/QUOTE] Right, I don't plan on going something like .00001 with 5bil font size. I just wanted to make sure I wasn't going to run into any weird graphical glitches.
[QUOTE=Revenge282;47726057]Is there a limit on the size of a font using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/surface/CreateFont]surface.CreateFont[/url]? Similarly, is there a limit to how small the scale on a [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/cam/Start3D2D]cam.Start3D2D[/url]? Trying to get my fonts nice and sharp.:downs:[/QUOTE] Limit for [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/surface/CreateFont]surface.CreateFont[/url] is 120 if I'm not mistaken.
[QUOTE=Kevlon;47726131]Is file.write supposed to not make its own directories? It's very annoying to have to add directory checks everywhere[/QUOTE] Create a helper function.
Would anyone here happen to use Combine Control? I made some sweps for the framework and set the ammo to unlimited on each weapon, which will allow you to continuously reload. But, I have a problem where that doesn't work. The gun doesn't reload and once you get to 0 bullets, and swap to a different tool, and go back to the gun, it dissapears and doesn't show up on your world model or anything. Any ideas?
[QUOTE=zerf;47720961]Bang! [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/GetMaterialType]Entity:GetMaterialType[/url] Pow! [url]http://wiki.garrysmod.com/page/Enums/MAT[/url] [editline]13th May 2015[/editline] Example for show: [lua] function BackwardsEnums(enumname) local backenums = {} for k, v in pairs(_G) do if type(k) == "string" and string.find(k, "^"..enumname) then backenums[v] = k end end return backenums end local MAT = BackwardsEnums("MAT_") local validclasses = {prop_physics = true, prop_physics_multiplayer = true, prop_dynamic = true} for k,v in pairs(ents.GetAll()) do if validclasses[v:GetClass()] then print(v:GetModel(), MAT[v:GetMaterialType()]) end end [/lua] Output is something like this: [code] models/props_interiors/furniture_couch01a.mdl MAT_DIRT models/props/cs_office/offinspd.mdl MAT_GLASS models/props/cs_office/offinspf.mdl MAT_GLASS models/props_wasteland/controlroom_desk001b.mdl MAT_METAL models/props_junk/wood_crate002a.mdl MAT_WOOD models/props_junk/wood_crate002a.mdl MAT_WOOD models/props_junk/wood_crate001a_damaged.mdl MAT_WOOD models/props_wasteland/controlroom_desk001a.mdl MAT_METAL models/props_wasteland/controlroom_chair001a.mdl MAT_METAL models/props_c17/tools_wrench01a.mdl MAT_METAL models/props/cs_office/radio.mdl MAT_COMPUTER models/props_junk/pushcart01a.mdl MAT_METAL models/props_wasteland/kitchen_shelf001a.mdl MAT_METAL models/props_wasteland/cafeteria_table001a.mdl MAT_WOOD models/props_c17/furniturecouch001a.mdl MAT_DIRT models/props_c17/furnituretable003a.mdl MAT_WOOD models/combine_gate_vehicle.mdl nil models/props_junk/sawblade001a.mdl MAT_METAL models/props/cs_office/offinspf.mdl MAT_GLASS models/props_junk/wood_crate001a.mdl MAT_WOOD ... [/code][/QUOTE] Well, then... I must be blind. Thank you very much, fine sir or madam.
Does anyone know how to get a scrollbar on a DTextEntry? edit: just put it in a scroll panel
[QUOTE=Busan1;47728092]Does anyone know how to get a scrollbar on a DTextEntry?[/QUOTE] Try this [url]http://wiki.garrysmod.com/page/Panel/SetVerticalScrollbarEnabled[/url] seeing as DTextEntry is derived from TextEntry
Is there a way to set the client's point of view depending on ply:GetModelScale()? And is there a way to scale the player's collisions and hitboxes as well? So, if the player is super small, the view position would be lower, and he would be able to pass through small areas, and be harder to hit.
[QUOTE=Mornedil;47728903]Is there a way to set the client's point of view depending on ply:GetModelScale()? And is there a way to scale the player's collisions and hitboxes as well? So, if the player is super small, the view position would be lower, and he would be able to pass through small areas, and be harder to hit.[/QUOTE] Search the wiki for: ViewOffset and SetHull
[QUOTE=vexx21322;47731228]Search the wiki for: ViewOffset and SetHull[/QUOTE] Any examples how to use them? I'm still not that experienced in lua, and the wiki rarely clarifies things so newbies understand them. Setting the view offset vector seems pretty straight forward. But even after reading [URL="http://wiki.garrysmod.com/page/Player/SetHull"]SetHull's wiki page[/URL], I have no clue how to actually make use of it. Edit: Another question: I need to check if a player is airbourne. My first thought is to do a raytrace downwards from the player's position. (or perhaps check Z velocity?) Or is there another way to do an "in-air" check for players with gmod lua? Like, if there's some built-in variable or check to see if a player is falling?
How can I find out how tall a DLabel is after making it SetAutoStretchVertical( true ) and SetWrap( true )? I try #string.Explode( "\n", dlabel:GetValue() ) and multiply that with the offset variable, and I tried just dlabel:GetTall().. I don't know how I can find out how many lines it is? Unless I have to like count the length of one line and see it like that somehow.
I'm not even sure how to word this question because I'm so frazzled. I'm making a Tomba gamemode. I've got the sidescrolling aspect down, but I'm having trouble finding a way to keep the player in a straight line. Basically, I want the player to only be able to move horizontally left or right so that they don't run into any walls. The problem I'm running into is when I want the player to move "up" or "down" horizontally. The easiest way I can explain this is by making a video: [video=youtube;1pR9quohrLw]http://www.youtube.com/watch?v=1pR9quohrLw[/video] If someone could just point me in the right direction that would be much appreciated. Thanks for your time.
[QUOTE=Obswalq;47734447]I'm not even sure how to word this question because I'm so frazzled. I'm making a Tomba gamemode. I've got the sidescrolling aspect down, but I'm having trouble finding a way to keep the player in a straight line. Basically, I want the player to only be able to move horizontally left or right so that they don't run into any walls. The problem I'm running into is when I want the player to move "up" or "down" horizontally. The easiest way I can explain this is by making a video: If someone could just point me in the right direction that would be much appreciated. Thanks for your time.[/QUOTE] Here's a theory: in the video, are you moving up/down by moving your mouse? I would probably tackle this type of gameplay by disabling horizontal mouse aiming completely, so you could not turn with the mouse (pitch aiming could still work if your gamemode needs it). Then control movement on the X/Y axis directly by the input of WASD. Could probably be done by setting the player's view angles from a vector that gets it's values from the WASD keys, and then bind all 4 keys to walk forward. So if you hold D your player would look right and start walking, W and you'd look up (on the horizontal plane), etc. Then disallow up/down movement if the player is closer than X units from the wall, perhaps with a trace? Like, let's say your corridors are 128 units wide normally. then if the player is in the center of the corridor, it should be 64 units to both the up/down walls from the player's position. so, you could make a trace both upwards and downwards, and then disallow the player to get closer than 64 units from the upwards/downwards walls. Again, just a theory, but I think something like this should work in gmod
I'm working on a menu which uses DHorizontalScroller: [IMG]http://i.imgur.com/ep4lQpB.png?1[/IMG] Is there anyway to give a custom size and paint function to the scroll arrows (circled in blue)?
How would I disable sprinting with a GM: hook?
Why does this result in invisible text? [CODE]surface.SetFont("HudHintTextLarge") surface.SetTextPos( x-30, y-7 ) surface.SetTextColor( 0, 0, 0, 255 ) surface.DrawText("TEST")[/CODE] the color seems to also use the RGB values to determine alpha? I tried [B]surface.SetTextColor( 0, 50, 0, 255 )[/B], which resulted in a dark green text which was almost fully transparent.
[QUOTE=Mornedil;47736521]Why does this result in invisible text? [CODE]surface.SetFont("HudHintTextLarge") surface.SetTextPos( x-30, y-7 ) surface.SetTextColor( 0, 0, 0, 255 ) surface.DrawText("Jetpack fucker")[/CODE] the color seems to also use the RGB values to determine alpha? I tried [B]surface.SetTextColor( 0, 50, 0, 255 )[/B], which resulted in a dark green text which was almost fully transparent.[/QUOTE] The font you are using has the "additive" flag on it. That means that it will always be translucent. [url]http://en.wikipedia.org/wiki/Additive_color[/url] Basically it means that each pixel the text is on gets added 0, 0, 0 to its color, which doesn't modify it at all.
ah, I did not realise the fonts had those flags, I was looking for a render mode function on the wiki but didn't find any. I'll change the font :>
[QUOTE=A Fghtr Pilot;47736491]How would I disable sprinting with a GM: hook?[/QUOTE] As the EnableSprint/DisableSprint functions don't work, just [CODE] function GM:PlayerInitialSpawn(ply) ply:SetRunSpeed( ply:GetWalkSpeed() ) end [/CODE] Hacky, yes it is however the proper functions do not work according to wiki.
Another question, how would I check if a function is being called? Here's my code: [code]function LockPlayers() for k, v in pairs(player.GetAll()) do v:Lock() end end [/code] [code]function CallLockFuncOnGameStart() LockPlayers() end hook.Add( "Initialize", "LockDemPlayahs", CallLockFuncOnGameStart ) [/code] Basically, what I want to do is, upon a player joining the game, if the lock function is being called, it will lock them. That also brings up another question, actually, what hook is called upon a player joining? Could I use PlayerSpawn or PlayerInitialSpawn?
[QUOTE=A Fghtr Pilot;47736921]Another question, how would I check if a function is being called? Here's my code: [code]function LockPlayers() for k, v in pairs(player.GetAll()) do v:Lock() end end [/code] [code]function CallLockFuncOnGameStart() LockPlayers() end hook.Add( "Initialize", "LockDemPlayahs", CallLockFuncOnGameStart ) [/code] Basically, what I want to do is, upon a player joining the game, if the lock function is being called, it will lock them. That also brings up another question, actually, what hook is called upon a player joining? Could I use PlayerSpawn or PlayerInitialSpawn?[/QUOTE] When a player JOINS use CheckPassword. When a player SPAWNS use PlayerSpawn. When a spawns for the first time use PlayerInitialSpawn.
If you want to check when a function is being called you could easily use hooks. [url]http://wiki.garrysmod.com/page/hook/Call[/url] Then call the hook, whenever the function is executed the hooked function will be too. Is that what you wanted?
[QUOTE=AIX-Who;47737190]If you want to check when a function is being called you could easily use hooks. [url]http://wiki.garrysmod.com/page/hook/Call[/url] Then call the hook, whenever the function is executed the hooked function will be too. Is that what you wanted?[/QUOTE] Or he could add prints.
[QUOTE=Sereni;47735708]I'm working on a menu which uses DHorizontalScroller: [IMG]http://i.imgur.com/ep4lQpB.png?1[/IMG] Is there anyway to give a custom size and paint function to the scroll arrows (circled in blue)?[/QUOTE] scroller.btnLeft scroller.btnRight [url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/lua/vgui/dhorizontalscroller.lua[/url] With most vgui elements you can work out which part is which by looking at the source file.
[QUOTE=Mornedil;47734899]Here's a theory: in the video, are you moving up/down by moving your mouse? I would probably tackle this type of gameplay by disabling horizontal mouse aiming completely, so you could not turn with the mouse (pitch aiming could still work if your gamemode needs it). Then control movement on the X/Y axis directly by the input of WASD. Could probably be done by setting the player's view angles from a vector that gets it's values from the WASD keys, and then bind all 4 keys to walk forward. So if you hold D your player would look right and start walking, W and you'd look up (on the horizontal plane), etc. Then disallow up/down movement if the player is closer than X units from the wall, perhaps with a trace? Like, let's say your corridors are 128 units wide normally. then if the player is in the center of the corridor, it should be 64 units to both the up/down walls from the player's position. so, you could make a trace both upwards and downwards, and then disallow the player to get closer than 64 units from the upwards/downwards walls. Again, just a theory, but I think something like this should work in gmod[/QUOTE] Oh, crap. Yes, I forgot to mention that I am moving up and down with the mouse. I would like to get rid of the mouse altogether if I could and eventually implement a gamepad option. That won't be for awhile because I still suck at Lua scripting. That sounds like a great idea in theory, but I'm not sure how I would even start tackling something like that. If I could figure it out, that's probably the way I would go. I appreciate the idea you gave me because it actually motivated me to learn more :).
[QUOTE=Obswalq;47739013]Oh, crap. Yes, I forgot to mention that I am moving up and down with the mouse. I would like to get rid of the mouse altogether if I could and eventually implement a gamepad option. That won't be for awhile because I still suck at Lua scripting. That sounds like a great idea in theory, but I'm not sure how I would even start tackling something like that. If I could figure it out, that's probably the way I would go. I appreciate the idea you gave me because it actually motivated me to learn more :).[/QUOTE] I'm also pretty new at lua, but have some experience with game programming before :P. As for controlling the player's angles with WASD, you should look into [URL="http://wiki.garrysmod.com/page/Player/SetEyeAngles"]SetEyeAngles[/URL]. To turn movement keys into numeric variables, you can do the following: (This can be very useful in order to use those key presses to calculate the eye angle vectors) [CODE]--ply should be the player entity local w = ply:KeyDown(IN_FORWARD) and 1 or 0 --set variable to 1 if KeyDown is true, or set it to 0 if KeyDown is false. local s = ply:KeyDown(IN_BACK) and 1 or 0 local a = ply:KeyDown(IN_MOVELEFT) and 1 or 0 local d = ply:KeyDown(IN_MOVERIGHT) and 1 or 0[/CODE] I just learned about how to do that, so.. if it gives an error, enclose within ( ), like: [CODE]local w = ( ply:KeyDown(IN_FORWARD) and 1 or 0 )[/CODE] KeyDown returns either true or false depending on if you press the key or not. so in the above code, the variables w, a, s and d will be set to 1 if you're holding the key, and 0 if you're not. I'm not sure how to make the player always walk forward with WASD, instead of strafing or moving backwards. As for checking for walls to prevent players from walking up/down in corridors, maybe [URL="http://wiki.garrysmod.com/page/util/TraceLine"]TraceLine[/URL] ?
Sorry, you need to Log In to post a reply to this thread.