• Problems That Don't Need Their Own Thread v3.0
    5,003 replies, posted
[QUOTE=YourStalker;48015830]Anyone know why IN_ATTACK2 isn't working? Jump and attack seem to work fine though. [lua]hook.Add( "KeyPress", "doThatStuff", function( ply, key ) local spwnKeys = { IN_JUMP, IN_ATTACK, IN_ATTACK2 } if spwnKeys[key] then doStuff() end end )[/lua] Also, here is a nice bump:[/QUOTE] Because you're placing them in the table as the value. You'd want to do this: [lua] local spwnKeys = { IN_JUMP = true, IN_ATTACK = true, IN_ATTACK2 = true, } [/lua]
[QUOTE=LUModder;48011693]I'm trying to make a money printer for my sandbox server's money system. The problem is I have multiple values set in the entity (time,maxtime,ink,value and cash). Time gets set just fine in the think hook but Ink and Cash only get set clientside and not serverside making it so I can't get money. [code] Code [/code][/QUOTE]Use networked values [url]http://wiki.garrysmod.com/page/Entity/SetNWInt[/url] Use that function and set it serverside then you'll be able to retrieve the value anywhere using [url]http://wiki.garrysmod.com/page/Entity/GetNWInt[/url].
Is there a hook that I can use to make cam.Start3D2D appear behind glass and walls? (Trying to make name tags fancier)
[QUOTE=Revenge282;48016956]Is there a hook that I can use to make cam.Start3D2D appear behind glass and walls? (Trying to make name tags fancier)[/QUOTE] PreDrawTranslucentRenderables? [editline]asd[/editline] Actually, that would draw under every translucent object. Hmm, I don't know. PostPlayerDraw?
[QUOTE=xaviergmail;48017143]PreDrawTranslucentRenderables? [editline]asd[/editline] Actually, that would draw under every translucent object. Hmm, I don't know. PostPlayerDraw?[/QUOTE] PostDrawTranslucentRenderables?
I'm using this in an entities init.lua to open a menu, but nothings happening [CODE]function ENT:Use( ply ) --self.SongOne:Play() if ( ply:IsPlayer() ) then print( "test1" ) self.OpenMenu() end end function ENT:OpenMenu() print( "test2") if ( CLIENT ) then print( "test3" ) local Frame = vgui.Create( "DFrame" ) Frame:SetPos( 5, 5 ) Frame:SetSize( 300, 150 ) Frame:SetTitle( "Song Selection" ) Frame:SetVisible( true ) Frame:SetDraggable( false ) Frame:ShowCloseButton( true ) Frame:MakePopup() local Button = vgui.Create( "DButton", Frame ) Button:SetText( "Midnight Crew" ) Button:SetTextColor( Color( 255, 255, 255 ) ) Button:SetPos( 100, 100 ) Button:SetSize( 100, 30 ) Button.Paint = function( self, w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 41, 0, 0, 0 ) ) end Button.DoClick = function() print( "Working!" ) self.SongOne:Play() end end end[/CODE] "test1" prints, and "test2" prints, but "test3" does not. Am I using the CLIENT thing correctly? Or should this whole function be put in shared or cl?
[QUOTE=Becomeimp;48019159]I'm using this in an entities init.lua to open a menu, but nothings happening [CODE]function ENT:Use( ply ) --self.SongOne:Play() if ( ply:IsPlayer() ) then print( "test1" ) self.OpenMenu() end end function ENT:OpenMenu() print( "test2") if ( CLIENT ) then print( "test3" ) local Frame = vgui.Create( "DFrame" ) Frame:SetPos( 5, 5 ) Frame:SetSize( 300, 150 ) Frame:SetTitle( "Song Selection" ) Frame:SetVisible( true ) Frame:SetDraggable( false ) Frame:ShowCloseButton( true ) Frame:MakePopup() local Button = vgui.Create( "DButton", Frame ) Button:SetText( "Midnight Crew" ) Button:SetTextColor( Color( 255, 255, 255 ) ) Button:SetPos( 100, 100 ) Button:SetSize( 100, 30 ) Button.Paint = function( self, w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 41, 0, 0, 0 ) ) end Button.DoClick = function() print( "Working!" ) self.SongOne:Play() end end end[/CODE] "test1" prints, and "test2" prints, but "test3" does not. Am I using the CLIENT thing correctly? Or should this whole function be put in shared or cl?[/QUOTE] ENT:Use is serverside, therefore the code called from it is only run on the server, where CLIENT is false. You will want to put your function clientside, and call it via a net message.
The thread I was linked to didn't help, bump :c [QUOTE=A Fghtr Pilot;48010648]Alright, I've already asked this on another thread, but this is my last resort for doing something like this, as noone is helping me... I want to make a 3 round burst code. I've heard of using a delay variable in a think hook, though I have no idea how I'd use that. Please, help...[/QUOTE]
Thanks for the quick reply! After reading some tutorials I added in init having: [CODE] util.AddNetworkString( "OpenMenu" ) function ENT:Use( ply ) --self.SongOne:Play() net.Start( "OpenMenu" ) net.Send( ply ) end [/CODE] and cl having: [CODE] net.Receive( "OpenMenu", function( length, client ) end )[/CODE] But what do I add in so that it calls the function? The [URL="http://wiki.garrysmod.com/page/Net_Library_Usage"]wiki page[/URL] only covers sending strings and tables.
[QUOTE=Becomeimp;48019772]Thanks for the quick reply! After reading some tutorials I added in init having: [CODE] util.AddNetworkString( "OpenMenu" ) function ENT:Use( ply ) --self.SongOne:Play() net.Start( "OpenMenu" ) net.Send( ply ) end [/CODE] and cl having: [CODE] net.Receive( "OpenMenu", function( length, client ) end )[/CODE] But what do I add in so that it calls the function? The [URL="http://wiki.garrysmod.com/page/Net_Library_Usage"]wiki page[/URL] only covers sending strings and tables.[/QUOTE] Something like this? [lua] -- Server util.AddNetworkString( "OpenMenu" ) function ENT:Use( ply ) net.Start( "OpenMenu" ) net.SendEntity( self ) net.Send( ply ) end -- Client net.Receive( "OpenMenu", function( length ) -- Client is nil when sending from server to client local ent = net.ReadEntity() if ( not IsValid( ent ) ) then return end local Frame = vgui.Create( "DFrame" ) Frame:SetPos( 5, 5 ) Frame:SetSize( 300, 150 ) Frame:SetTitle( "Song Selection" ) Frame:SetVisible( true ) Frame:SetDraggable( false ) Frame:ShowCloseButton( true ) Frame:MakePopup() local Button = vgui.Create( "DButton", Frame ) Button:SetText( "Midnight Crew" ) Button:SetTextColor( Color( 255, 255, 255 ) ) Button:SetPos( 100, 100 ) Button:SetSize( 100, 30 ) Button.Paint = function( self, w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 41, 0, 0, 0 ) ) end Button.DoClick = function() print( "Working!" ) ent.SongOne:Play() -- not sure what SongOne is, assuming its a member of the entity. end end) [/lua]
[QUOTE=James xX;48019796]Something like this? [/QUOTE] Oh! So I put the function as part of the Recieve. That all makes sense to me, but the game is giving me this: [CODE] [ERROR] init.lua:69: attempt to call field 'SendEntity' (a nil value) 1. unknown - init.lua:69 [/CODE] EDIT: found the issue: net.SendEntity isn't a thing. I'm assuming the correct one is[URL="http://wiki.garrysmod.com/page/net/WriteEntity"] net.WriteEntity[/URL]
[QUOTE=xaviergmail;48017143]PreDrawTranslucentRenderables? [editline]asd[/editline] Actually, that would draw under every translucent object. Hmm, I don't know. PostPlayerDraw?[/QUOTE] You would think that works, but it also draws behind some random entities and the a few other materials that the player is in font of. [QUOTE=polivlas;48017337]PostDrawTranslucentRenderables?[/QUOTE] That draws on top of pretty much everything. But it's the best I've found so far.
[QUOTE=Becomeimp;48019919]Oh! So I put the function as part of the Recieve. That all makes sense to me, but the game is giving me this: [CODE] [ERROR] init.lua:69: attempt to call field 'SendEntity' (a nil value) 1. unknown - init.lua:69 [/CODE] EDIT: found the issue: net.SendEntity isn't a thing. I'm assuming the correct one is[URL="http://wiki.garrysmod.com/page/net/WriteEntity"] net.WriteEntity[/URL][/QUOTE] Sorry about that, I wasn't concentrating on it.
Hey with the new ability to change textures on player models is there anyway you can layer different textures on top of each other with them having different transparencies?
[QUOTE=A Fghtr Pilot;48008547]Anyone know how I could play a sound if a player has fallen a certain distance? Like if I jump off a cliff, if I fall a certain distance then I play a sound.[/QUOTE] I believe you would have to use speed to do this, but if you have a server with vehicles, it could pose a problem. -Edit- I believe it is fall speed or gravity.
[QUOTE=MatureGamersNetwork;48022681]I believe you would have to use speed to do this, but if you have a server with vehicles, it could pose a problem.[/QUOTE] You could just check if the player is in a vehicle, though.
How do you get every button that is down with CMoveData? [editline]22nd June 2015[/editline] I'm aware the GetButtons exists, but I want to find out what buttons are down rather than just getting a number.
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/CMoveData/KeyDown]CMoveData:KeyDown[/url] ? [editline]22nd June 2015[/editline] There is no "proper" way to do it the way you want, you can just hardcode the IN_* enums in a table and then iterate it while calling KeyDown if you really don't want to use the bit library.
Is there a reason why [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/GetSkin]Entity:GetSkin[/url] doesn't work in [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/EntityRemoved]GM/EntityRemoved[/url] ?
[QUOTE=Giraffen93;48027853]Is there a reason why [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/GetSkin]Entity:GetSkin[/url] doesn't work in [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/EntityRemoved]GM/EntityRemoved[/url] ?[/QUOTE] A lot of functions will no longer work on entities that are marked for deletion ( To prevent crashing (c) Kilburn )
[QUOTE=Robotboy655;48027876]A lot of functions will no longer work on entities that are marked for deletion ( To prevent crashing (c) Kilburn )[/QUOTE] well shit i guess i gotta make a whole bunch of workarounds then
How does the filesystem for an addon that overrides gamemode files work? So like, for example, if I wanted to modify garrysmod\gamemodes\terrortown\gamemode\cl_hud.lua, where in my addon should I put the lua file to replace it? (Not actually the file I want to modify, but for example's sake) I could swear I've seen other addons do this, but I can't remember how. Apparently the most obvious way doesn't work.
[QUOTE=zeaga;48029065]How does the filesystem for an addon that overrides gamemode files work? So like, for example, if I wanted to modify garrysmod\gamemodes\terrortown\gamemode\cl_hud.lua, where in my addon should I put the lua file to replace it? (Not actually the file I want to modify, but for example's sake) I could swear I've seen other addons do this, but I can't remember how. Apparently the most obvious way doesn't work.[/QUOTE] Don't do this. Ever. Just don't. Even if it does work right now, it may stop working in the future.
[img]http://i.imgur.com/QL9bygB.png[/img] is there a way to get the exe version (used by servers) in lua?
[QUOTE=PortalGod;48029948][img]http://i.imgur.com/QL9bygB.png[/img] is there a way to get the exe version (used by servers) in lua?[/QUOTE] steam.inf in the main garrysmod directory. [quote]PatchVersion=15.04.03 ProductName=garrysmod appID=4000[/quote] [code]local patchVersion = (file.Read("steam.inf", "MOD") or ""):match("PatchVersion=([^\n]+)") print(patchVersion)[/code] [quote]15.04.03[/quote]
What is this: Bad SetLocalOrigin(-19249.634766,-1100.335938,-0.968758) on gmod_hands (1393) and would it effect a server bad enough to cause a crash? (I don't think it is the cause of the crash atm)
[QUOTE=Robotboy655;48029358]Don't do this. Ever. Just don't. Even if it does work right now, it may stop working in the future.[/QUOTE] Well alrighty then. I guess I'll just deal with overwriting the files. Thanks!
Hello! I have two scripts and I'd like some help debugging. This first one is supposed to make a file: [CODE]------------------------------ Loadout -------------------------- function ulx.loadout( calling_ply, weapon ) local identifier = calling_ply:SteamID64() local wep = weapons.Get( weapon ) local kind = wep.Kind if kind == WEAPON_HEAVY then file.Write( "loadout/" .. identifier .. "_primary.txt", weapon ) calling_ply:PrintMessage( HUD_PRINTTALK, "You will now spawn with a " .. weapon ) elseif kind == WEAPON_PISTOL then file.Write( "loadout/" .. identifier .. "_pistol.txt", weapon ) calling_ply:PrintMessage( HUD_PRINTTALK, "You will now spawn with a " .. weapon ) elseif kind == WEAPON_NADE then file.Write( "loadout/" .. identifier .. "_equipment.txt", weapon ) calling_ply:PrintMessage( HUD_PRINTTALK, "You will now spawn with a " .. weapon ) else calling_ply:PrintMessage( HUD_PRINTTALK, "You're not allowed to spawn with that weapon!" ) end end local loadout = ulx.command( CATEGORY_NAME, "ulx loadout", ulx.loadout, "!loadout" ) loadout:addParam{ type=ULib.cmds.StringArg, hint="Weapon", ULib.cmds.optional, ULib.cmds.takeRestOfLine } loadout:defaultAccess( ULib.ACCESS_SUPERADMIN ) loadout:help( "Adds a weapon to your loadout." )[/CODE] And this second one is supposed to read that file and give the player weapons. Steps 1, 3, 5, and 7 run. [CODE]---Weapon Loadout - Master ----------------------------------- hook.Add( "TTTBeginRound", "Master Loadout", function() if SERVER then for _, pl in pairs(player.GetAll()) do if pl:IsSpec() ~= true and pl:SteamID() == "STEAM_0:1:41036632" then local identifier = pl:SteamID64() pl:PrintMessage( HUD_PRINTTALK, "Step 1" ) if file.Exists( "loadout/" .. identifier .. "_primary.txt", "DATA" ) then pl:PrintMessage( HUD_PRINTTALK, "Step 2" ) local weapon = file.Read( "loadout/" .. identifier .. "_primary.txt", "DATA" ) local wep = weapons.Get( weapon ) for _, k in pairs(pl:GetWeapons()) do local wepclass = k:GetClass() if weapons.Get( wepclass ).Kind == wep.Kind then print( wepclass ) --Here to tell me if it successfully found the correct weapons (which it did) pl:StripWeapon( wepclass ) end end local ammoamt = wep.Primary.ClipMax local ammotype = wep.Primary.Ammo pl:Give( weapon ) pl:SetAmmo( ammoamt, ammotype, true ) end pl:PrintMessage( HUD_PRINTTALK, "Step 3" ) if file.Exists( "loadout/" .. identifier .. "_pistol.txt", "DATA" ) then pl:PrintMessage( HUD_PRINTTALK, "Step 4" ) local primary = file.Read( "loadout/" .. identifier .. "_pistol.txt", "DATA" ) local wep = weapons.Get( primary ) for _, k in pairs(pl:GetWeapons()) do local wepclass = k:GetClass() if weapons.Get( wepclass ).Kind == wep.Kind then print( wepclass ) --Here to tell me if it successfully found the correct weapons (which it did) pl:StripWeapon( wepclass ) end end local ammoamt = wep.Primary.ClipMax local ammotype = wep.Primary.Ammo pl:Give( weapon ) pl:SetAmmo( ammoamt, ammotype, true ) end pl:PrintMessage( HUD_PRINTTALK, "Step 5" ) if file.Exists( "loadout/" .. identifier .. "_equipment.txt", "DATA" ) then pl:PrintMessage( HUD_PRINTTALK, "Step 6" ) local primary = file.Read( "loadout/" .. identifier .. "_equipment.txt", "DATA" ) local wep = weapons.Get( primary ) for _, k in pairs(pl:GetWeapons()) do local wepclass = k:GetClass() if weapons.Get( wepclass ).Kind == wep.Kind then print( wepclass ) --Here to tell me if it successfully found the correct weapons (which it did) pl:StripWeapon( wepclass ) end end pl:Give( weapon ) pl:SetAmmo( ammoamt, ammotype, true ) end pl:PrintMessage( HUD_PRINTTALK, "Step 7" ) --if wep.Kind == WEAPON_HEAVY then pl:SelectWeapon( primary ) --end sound.Play( 'items/gift_pickup.wav', pl:GetPos() ) end end end end )[/CODE] So both of the functions are functional (hahaha) but clearly the if statements in function #2 are not running. Could somebody help me determine whether the problem lies in the first script, or the second?
I need some help with a weapon, it's a zombine weapon and what I want it to do when you use secondary fire for the grenade suicide I want it to spawn a grenade model with the trail and attach it to the players right hand but sadly so far it doesn't seem to work the model is invisible and it goes waaaay off nowhere near the hand. Here is the code [code] SWEP.NextGrenade = 0 function SWEP:SecondaryAttack() if CurTime() < self.NextGrenade then return end if SERVER then local grenade = ents.Create("zombine_grenade") if grenade:IsValid() then local bone = self.Owner:LookupBone("ValveBiped.Bip01_R_Hand") local attachment = self.Owner:LookupAttachment("anim_attachment_RH") grenade:SetPos(self.Owner:GetBonePositionMatrixed(bone)) grenade:SetOwner(self.Owner) grenade:Spawn() grenade:FollowBone(self.Owner, bone) grenade:SetParent(self.Owner, attachment) end end self:SendWeaponAnim(ACT_VM_SECONDARYATTACK) -- grenade animation self.Owner:DoAnimationEvent(ACT_GMOD_GESTURE_TAUNT_ZOMBIE) self.Owner:EmitSound("weapons/npc/zombine/zombie_voice_idle"..math.random(14)..".wav") timer.Simple(0.9, function(wep) self:SendWeaponAnim(ACT_VM_THROW) end) -- timer to pull up grenade if (SERVER) then timer.Simple(3, function(wep) self:Grenade() end) end self.NextGrenade = CurTime() + 5 -- to make sure you can't spam the grenade end if SERVER then local ENT = {} ENT.Type = "anim" function ENT:Initialize() self:SetModel("models/weapons/w_grenade.mdl") self:SetSolid(SOLID_NONE) self:SetMoveType(MOVETYPE_NONE) self:AddEFlags(EFL_SETTING_UP_BONES) self.SpriteTrail = util.SpriteTrail(self, self:LookupAttachment("fuse"), Color(255,0,0), false, 8.0, 1, 0.5, 0.01, "trails/laser.vmt") end function ENT:Think() local owner = self.Owner; if owner:IsPlayer() then if not owner:Alive() then if IsValid(self.SpriteTrail) then self.SpriteTrail:Fire("kill", 1, 2) end self:Remove() end end end scripted_ents.Register( ENT, "zombine_grenade", true ) end[/code]
Is there anyway to make a trace hit a player that is inside of a vehicle?
Sorry, you need to Log In to post a reply to this thread.