• Problems That Don't Need Their Own Thread v5
    4,111 replies, posted
[QUOTE=Spamppa2;52475102]...[/QUOTE] if statements in lua need a "then" keyword. [LUA] if ply:SteamID("STEAM_0:0:75977657") then PrintMessage( HUD_PRINTTALK, "I'm new here." ) end [/LUA]
[QUOTE=Spamppa2;52475102]so i have been trying to make message apear on peoples screens if person whit certain steam id joins but i get this error [LUA][ERROR] gamemodes/metro_online/gamemode/init.lua:48: 'then' expected near 'PrintMessage' 1. unknown - gamemodes/metro_online/gamemode/init.lua:0 [/LUA] code: [LUA]if ply:SteamID("STEAM_0:0:75977657") PrintMessage( HUD_PRINTTALK, "I'm new here." ) end[/LUA] i have it inside GM:PlayerSpawn[/QUOTE] Well the error said [lua]'then' expected near 'PrintMessage'[/lua] So if you put "then" before "PrintMessage"... [lua]if ply:SteamID("STEAM_0:0:75977657") then PrintMessage( HUD_PRINTTALK, "I'm new here." ) end[/lua] Ninja'd :v:
-snip-
Trying to find a good method to find and edit props spawned by the map, any help?
[QUOTE=Meninist;52475344]Trying to find a good method to find and edit props spawned by the map, any help?[/QUOTE] [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/MapCreationID]Entity:MapCreationID[/url] and [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ents/GetMapCreatedEntity]ents.GetMapCreatedEntity[/url]?
[QUOTE=bigdogmat;52475372][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/MapCreationID]Entity:MapCreationID[/url] and [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ents/GetMapCreatedEntity]ents.GetMapCreatedEntity[/url]?[/QUOTE] Hmm, I was told these wouldn't be useful for what I'm trying to do. Let me try to rephrase. I want to be able to find a random prop created by the map and use as a Scavenger Hunt item. Basically I want to change the model and have it do something when it is used. But a completely random prop.
-snip- I should refresh the page before I post.
[QUOTE=Meninist;52475392]Hmm, I was told these wouldn't be useful for what I'm trying to do. Let me try to rephrase. I want to be able to find a random prop created by the map and use as a Scavenger Hunt item. Basically I want to change the model and have it do something when it is used. But a completely random prop.[/QUOTE] Then those functions he linked are correct. You have to loop through all props and check with MapCreationID if it's a map prop.
[QUOTE=code_gs;52475412]Then those functions he linked are correct. You have to loop through all props and check with MapCreationID if it's a map prop.[/QUOTE] Still not quite what I'm trying to do.
[QUOTE=Meninist;52475639]Still not quite what I'm trying to do.[/QUOTE] I guess you could loop through all entities checking [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/CreatedByMap]Entity:CreatedByMap[/url], if it fails then remove it from the table. After that's done you can use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/math/random]math.random[/url] to get a random entity out of it.
[QUOTE=Meninist;52475639]Still not quite what I'm trying to do.[/QUOTE] 1. Loop through ents.FindByClass("prop_*") 2. Check [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/CreatedByMap]Entity:CreatedByMap[/url] 3. Put prop in your own table. 4. You now have a list of map props.
e.g. [code] local ents = ents.GetAll() for i = #ents, 1, -1 do if not ents[i]:CreatedByMap() then table.remove(ents, i) end end local randEnt = ents[math.random(#ents)] [/code] [editline]16th July 2017[/editline] rip automerge
Is there a way to get the amount a DScrollPanel is scrolled down, and then set that later on?
[QUOTE=bigdogmat;52475681]e.g. [code] local ents = ents.GetAll() for i = #ents, 1, -1 do if not ents[i]:CreatedByMap() then table.remove(ents, i) end end local randEnt = ents[math.random(#ents)] [/code] [editline]16th July 2017[/editline] rip automerge[/QUOTE] You can actually reduce having to count ents twice by caching the length form the beginning. Ex. [code]local tMapProps = ents.FindByClass("prop_*") local iMapProps = #tMapProps for i = iMapProps, 1, -1 do if (not tMapProps[i]:CreatedByMap()) then table.remove(tMapProps, i) iMapProps = iMapProps - 1 end end assert(iMapProps ~= 0) local pRandEntity = tMapProps[math.random(1, iMapProps)][/code] [editline]16th July 2017[/editline] After some testing with Meep, both methods seem to be just as efficient.
[QUOTE=Sean Bean;52465361]Is there a way I can mute a [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Category:HTML]HTML[/url] panel?[/QUOTE] Still looking for an answer.
How can I change the type of muzzle flash on weapons? I'm getting the AR2 one when I want the SMG one.
[QUOTE=JasonMan34;52475150]Well the error said [lua]'then' expected near 'PrintMessage'[/lua] So if you put "then" before "PrintMessage"... [lua]if ply:SteamID("STEAM_0:0:75977657") then PrintMessage( HUD_PRINTTALK, "I'm new here." ) end[/lua] Ninja'd :v:[/QUOTE] It's still wrong. SteamID does not pass an argument nor does it work like that. It has to be like so: [code] if ply:SteamID() == "STEAM_0:0:75977657" then PrintMessage( HUD_PRINTTALK, "I'm new here." ) end [/code]
[QUOTE=mib999;52478334]It's still wrong. SteamID does not pass an argument nor does it work like that. It has to be like so: [code] if ply:SteamID() == "STEAM_0:0:75977657" then PrintMessage( HUD_PRINTTALK, "I'm new here." ) end [/code][/QUOTE] True, I didn't really pay attention to the code I was just referencing the painfully obvious missing 'then'. My b
I've seen addons change the appearance of the notifications ([img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/notification/AddLegacy]notification.AddLegacy[/url]). How would one go about doing that?
[QUOTE=Shadow02;52478311]How can I change the type of muzzle flash on weapons? I'm getting the AR2 one when I want the SMG one.[/QUOTE] This hook allows you to block and send other effects: [url]https://wiki.garrysmod.com/page/WEAPON/FireAnimationEvent[/url] I forgot the event numbers for muzzle flashes, but there is a first and third-person version. [editline]17th July 2017[/editline] [QUOTE=Fillipuster;52478619]I've seen addons change the appearance of the notifications ([img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/notification/AddLegacy]notification.AddLegacy[/url]). How would one go about doing that?[/QUOTE] They probably override the NoticePanel declared here: [url]https://github.com/Facepunch/garrysmod/blob/784cd57576d85712fa13a7cea3a9523b4df966b0/garrysmod/lua/includes/modules/notification.lua[/url]
[QUOTE=code_gs;52478796] [editline]17th July 2017[/editline] They probably override the NoticePanel declared here: [url]https://github.com/Facepunch/garrysmod/blob/784cd57576d85712fa13a7cea3a9523b4df966b0/garrysmod/lua/includes/modules/notification.lua[/url][/QUOTE] I presume I'd simply make my own panel and override it with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/vgui/Register]vgui.Register[/url] by calling it the same?
[QUOTE=Fillipuster;52475762]Is there a way to get the amount a DScrollPanel is scrolled down, and then set that later on?[/QUOTE] If you're trying to mess with some of Gmod's derma panels, you can actually open the lua files for them yourself in garrysmod\lua\vgui, or on GitHub [url]https://github.com/Facepunch/garrysmod/blob/master/garrysmod/lua/vgui/dscrollpanel.lua[/url] If you look a DScrollPanel, you'll see it makes a child ui elment for it's grabbable bar and indexes it as self.VBar, which is a "DVScrollBar". [url]https://github.com/Facepunch/garrysmod/blob/master/garrysmod/lua/vgui/dvscrollbar.lua[/url] And it looks like that bar has functions called "GetScroll" and "SetScroll" So in short, you could do panel.VBar:GetScroll() and panel.VBar:SetScroll()
[QUOTE=bizzclaw;52478875]If you're trying to mess with some of Gmod's derma panels, you can actually open the lua files for them yourself in garrysmod\lua\vgui, or on GitHub [url]https://github.com/Facepunch/garrysmod/blob/master/garrysmod/lua/vgui/dscrollpanel.lua[/url] If you look a DScrollPanel, you'll see it makes a child ui elment for it's grabbable bar and indexes it as self.VBar, which is a "DVScrollBar". [url]https://github.com/Facepunch/garrysmod/blob/master/garrysmod/lua/vgui/dvscrollbar.lua[/url] And it looks like that bar has functions called "GetScroll" and "SetScroll" So in short, you could do panel.VBar:GetScroll() and panel.VBar:SetScroll()[/QUOTE] I tried that, and GetScroll seems to properly return the amount the bar is scrolled from the top. However, SetScroll seems to have no effect :/ I'll try some more testing. Thanks for the reply :)
Is there any type of function or what have you that could interfere with vanilla zombie NPCs of any type and cause them to do no damage with no pushback when swinging at a player? An addon on my server is doing this and I'm trying to figure out which one + how to fix it.
Does anyone know the function / piece of code that's used to automatically insert newlines into the toolmenu help text? [IMG]https://i.imgur.com/4wbmzgM.png[/IMG] I'm creating a derma panel and need to make a DLabel span multiple lines without knowing what the exact text is (so I can't just manually insert line breaks)
I'm trying to create a kind of info box with 3d2d and I want it to look like it is coming from a prop like a projector. The only problem right now is I am unable to find out why the 3d2d screen spawns really weird and moves really weird when the prop is moved. [CODE]include ("shared.lua") local serverinfo = "Cum" function ENT:Draw() local pos = self:GetPos() local ang = self:GetAngles() self:DrawModel() ang:RotateAroundAxis(ang:Up(),-90) cam.Start3D2D(pos+Vector(-50,0,110),ang+Angle(0,0,90),1) draw.RoundedBox(0,0,0,100,100,Color(120,255,120)) draw.SimpleText(serverinfo,"DermaDefault",0,0,Color(255,255,255)) cam.End3D2D() end[/CODE] [video]https://youtu.be/M2nDV95wQu4[/video]
[QUOTE=Meninist;52480155]I'm trying to create a kind of info box with 3d2d and I want it to look like it is coming from a prop like a projector. The only problem right now is I am unable to find out why the 3d2d screen spawns really weird and moves really weird when the prop is moved. [CODE]include ("shared.lua") local serverinfo = "Cum" function ENT:Draw() local pos = self:GetPos() local ang = self:GetAngles() self:DrawModel() ang:RotateAroundAxis(ang:Up(),-90) cam.Start3D2D(pos+Vector(-50,0,110),ang+Angle(0,0,90),1) draw.RoundedBox(0,0,0,100,100,Color(120,255,120)) draw.SimpleText(serverinfo,"DermaDefault",0,0,Color(255,255,255)) cam.End3D2D() end[/CODE] [video]https://youtu.be/M2nDV95wQu4[/video][/QUOTE] Use [url]http://wiki.garrysmod.com/page/Angle/RotateAroundAxis[/url] than adding an angle.
[QUOTE=rebel1324;52480492]Use [url]http://wiki.garrysmod.com/page/Angle/RotateAroundAxis[/url] than adding an angle.[/QUOTE] Yea I fixed it, thank you. I have another question about 3D2D, is there a way I can draw a players avatar on it? The only way I saw on the wiki to get an avatar was through panels, which don't work inside 3D2D.
I've run into a bit of an odd issue where the npc_combine_s that my gamemode spawns are incapable of dealing melee damage to the player. They can shoot the player just fine but if you move within melee range they will play the melee animation but deal no damage. Anyone happen to know what might be wrong?
[QUOTE=wazanator;52480818]I've run into a bit of an odd issue where the npc_combine_s that my gamemode spawns are incapable of dealing melee damage to the player. They can shoot the player just fine but if you move within melee range they will play the melee animation but deal no damage. Anyone happen to know what might be wrong?[/QUOTE] [url]https://github.com/Facepunch/garrysmod-issues/issues/1820[/url]
Sorry, you need to Log In to post a reply to this thread.