• What do you need help with? V3
    6,419 replies, posted
So I borrowed some code from Ascension, for the side-scroller functions - but the mouse doesn't seem to change my player's view. It only does in a menu such as console. This was transferred from GM12 to GM13. [URL="https://dl.dropbox.com/u/15781683/gm_construct%202012-8-27%2011-38-25.webm"]https://dl.dropbox.com/u/15781683/gm_construct%202012-8-27%2011-38-25.webm[/URL] [code] function GM:CreateMove( cmd ) if ( not LocalPlayer():Alive() ) then return end local plyPos = ( LocalPlayer():GetPos() + Vector(0, 0, 64) ):ToScreen() local plyvec = Vector( plyPos.x, plyPos.y, 0 ) local pos = Vector( gui.MouseX(), gui.MouseY(), 0 ) local angle = ( pos-plyvec ):Angle() local dirang = 0 if ( pos.x > plyPos.x ) then dirang = 0 angle.y = math.AngleDifference( angle.y, 360 ) // This is needed to fix a nasty Out-of-range warning. (Works fine with or without this line though.) cmd:SetForwardMove( cmd:GetSideMove() ) else angle:RotateAroundAxis( Vector(0, 0, 1), 180 ) angle.y = -angle.y dirang = 180 cmd:SetForwardMove( -cmd:GetSideMove() ) end cmd:SetViewAngles( Angle(angle.y, dirang, 0) ) cmd:SetSideMove( 0 ) end [/code] I suspect it might be running an invisible VGUI on the screen but I can't be too sure. [editline]27th August 2012[/editline] Nevermind I got it, I didn't enable mouse clicking from the initialization.
[QUOTE=Crap-Head;37419631]Whats the issue with TMySQL4? Since i've moved to GMod 13, and began to develop there, i've been with TMySQL4. It seems nice and stable, has all the old tmysql functions, and it supports multi connections. Not sure if tmysql3 supports that, but if it does, mhe, then its basically the same as TMySQL4. So i see no reason to not use that instead. If you need help with TMySQL4, PM me. I can resend the message BlackAwps send to me when he send me the plugin. It explains how connecting, and making a query works.[/QUOTE] That would be great, thanks.
So I'm trying to make a system where I can add things to a table from the console and have that table save in a .txt file. [lua]local lol = (file.Exists("table.txt") and KeyValuesToTable(file.Read("table.txt")) or {}) concommand.Add("table_add", function(args) table.insert(lol, args) file.Write("table.txt", TableToKeyValues(lol)) end) [/lua] Why isn't that working as expected?
[QUOTE=boxxyy;37430918]So I'm trying to make a system where I can add things to a table from the console and have that table save in a .txt file. [lua]local lol = (file.Exists("table.txt") and KeyValuesToTable(file.Read("table.txt")) or {}) concommand.Add("table_add", function(args) table.insert(lol, args) file.Write("table.txt", TableToKeyValues(lol)) end) [/lua] Why isn't that working as expected?[/QUOTE] Define not as expected.
[QUOTE=boxxyy;37430918]So I'm trying to make a system where I can add things to a table from the console and have that table save in a .txt file. [lua]local lol = (file.Exists("table.txt") and KeyValuesToTable(file.Read("table.txt")) or {}) concommand.Add("table_add", function(args) table.insert(lol, args) file.Write("table.txt", TableToKeyValues(lol)) end) [/lua] Why isn't that working as expected?[/QUOTE] Are you running this serverside? Because if so the first parameter is the player, you have to use the third parameter instead: [lua] concommand.Add("table_add", function(ply,cmd,args) [/lua] Why not using glon instead? KeyValuesToTable/TableToKeyValues is here if you want your .txt to be human-readable. Also, encoders like VON and HON are even faster (but you really don't need them for small tables). [lua] if not file.Exists("table.txt") then file.Write( "table.txt", glon.encode({}) ) end local lol = glon.decode( file.Read( "table.txt" ) ) concommand.Add("table_add", function(ply, cmd, args) table.insert(lol, args) file.Write("table.txt", glon.encode(lol)) end) [/lua]
[QUOTE=Undefined;37431144]Are you running this serverside? Because if so the first parameter is the player, you have to use the third parameter instead: [lua] concommand.Add("table_add", function(ply,cmd,args) [/lua] Why not using glon instead? KeyValuesToTable/TableToKeyValues is here if you want your .txt to be human-readable. Also, encoders like VON and HON are even faster (but you really don't need them for small tables). [lua] if not file.Exists("table.txt") then file.Write( "table.txt", glon.encode({}) ) end local lol = glon.decode( file.Read( "table.txt" ) ) concommand.Add("table_add", function(ply, cmd, args) table.insert(lol, args) file.Write("table.txt", glon.encode(lol)) end) [/lua][/QUOTE] It's clientside and I want the .txt to be readable. It isn't really working at all; I don't [b]think[/b] it adds it to the table (I'll go check), and it doesn't save the file with the new table if it does.
How do i set custom sound volume when using sound.Add? It seems to completly ignore volume setting. Here's the line i use to add the sound. [lua]sound.Add({name="weapon_dn3d_pistol.Fire",channel="CHAN_WEAPON",volume=0.1,pitchstart=95.105,sound=[[weapons\dn3d_pistol\fire.wav]]})[/lua] It's still very loud, even if volume=1, or 0.1.
[IMG]http://gyazo.com/90439537f1a7fa096caa250ccea7e9fc.png[/IMG] Im trying to launching HL2RP scheme with openaura base in gmod singleplayer while pressing the Start Multiplayer button but the error above happens. It never use to happen but since i got back from holiday it has.
[QUOTE=Amic;37440488]How do i set custom sound volume when using sound.Add? It seems to completly ignore volume setting. Here's the line i use to add the sound. [lua]sound.Add({name="weapon_dn3d_pistol.Fire",channel="CHAN_WEAPON",volume=0.1,pitchstart=95.105,sound=[[weapons\dn3d_pistol\fire.wav]]})[/lua] It's still very loud, even if volume=1, or 0.1.[/QUOTE] Format is [lua]sound.Add( { name = "enzo_engine_idle", channel = CHAN_STATIC, volume = 1.0, soundlevel = 80, pitchstart = 95, pitchend = 110, sound = "vehicles/enzo/idle.wav" } )[/lua] I believe you're missing soundlevel and pitchend.
I have problem with sound. I create syntax for looping sound but the sound isnt looping. Here: [CODE]function SWEP:Think() (some code here, not important) self.canidle = CreateSound(self.Owner, "weapons/autocannon/auto_idle.wav") self.canidle:Play() end function SWEP:PrimaryAttack() if self.canidle then self.canidle:Stop() end end[/CODE] Is there anything wrong?
How do I iterate over nested tables using ipairs?
[QUOTE=JakeAM;37454988]How do I iterate over nested tables using ipairs?[/QUOTE] The best way of doing it depends on what your table looks like. If you want, you could post an example of your tables and I can make a more optimized snippet. Are you sure you want to use ipairs? Ipairs only loops through sequential and numeric indices. For now, have this snippet. Note: I prefer to use regular "for i=1,x do" loops over ipairs, since it's faster. You can always edit my code back to ipairs if you want [code]local function iterateTable( t ) for i=1,#t do if type(t[i]) == "table" then iterateTable( t[i] ) else -- Do something with the value here end end end[/code]
the plugin file to Permamute for Evolve doesn't seem to work. [B]No error. It wont even appear in the spellcheck like other addons do[/B] File: sh_permamute.lua [lua] local Plugin = {} Plugin.Title = "PermaMuter" Plugin.Description = "Permanently mute players." Plugin.Author = "Tom" Plugin.ChatCommand = "permamute" Plugin.Usage = "[players] [1/0]" Plugin.Privileges = { "PermaMute" } function Plugin:Call( ply, args ) if (!sql.TableExists( "permamuted_players" ) ) then query = "CREATE TABLE permamuted_players ( steamID varchar(255), isMuted int )" result = sql.Query(query) end if ( ply:EV_HasPrivilege( "PermaMute" )) then local enabled = ( tonumber( args[ #args ] ) or 1 ) > 0 local players = evolve:FindPlayer( args, ply, true ) for _, pl in ipairs( players ) do if ( enabled ) then query = "UPDATE permamuted_players SET isMuted = 1 WHERE steamID = '"..pl:SteamID().."'" sql.Query(query) evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has permanently muted ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, "." ) else query = "UPDATE permamuted_players SET isMuted = 0 WHERE steamID = '"..pl:SteamID().."'" sql.Query(query) evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has unmuted ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, "." ) end end end end function Plugin:PlayerCanHearPlayersVoice( _, ply ) ID = sql.QueryValue( "SELECT isMuted from permamuted_players WHERE steamID = '"..ply:SteamID().."'" ) if ( ID == 1 || ply.EV_MUTED) then return false end end end function Plugin:Menu( arg, players ) if ( arg ) then table.insert( players, arg ) RunConsoleCommand( "ev", "permamute", unpack( players ) ) else return "Permanently Mute", evolve.category.punishment, { { "Enable", 1 }, { "Disable", 0 } } end end evolve:RegisterPlugin( Plugin )[/lua]
How could I get money data send with usermessages to the client to show up on a scoreboard? Currently, their money is saved as myMoney. I tried looping through all the players, and afterwards doing v.myMoney, but that didn't work.
[QUOTE=Divran;37455050]The best way of doing it depends on what your table looks like. If you want, you could post an example of your tables and I can make a more optimized snippet. Are you sure you want to use ipairs? Ipairs only loops through sequential and numeric indices. For now, have this snippet. Note: I prefer to use regular "for i=1,x do" loops over ipairs, since it's faster. You can always edit my code back to ipairs if you want [code]local function iterateTable( t ) for i=1,#t do if type(t[i]) == "table" then iterateTable( t ) else -- Do something with the value here end end end[/code][/QUOTE] He should create a bool being passed as the secord arg, if table is serialized pass nil, if not pass true and loop using pairs rather then fori.
I need a tool when you left click it creates a rope to a perpendicular shot, and the basic settings from the rope tool.(Material,Width,Add Length,Rigid/Non-Rigid) Sorry but i don't really know anything about LUA. Thanks. I copied the right clicking ability from slider tool but I can not select the material, width, rigidity. Plus it does not make a sound when i right click. Any helps? [lua] TOOL.Category = "Constraints" TOOL.Name = "#Rope2" TOOL.Command = nil TOOL.ConfigName = nil TOOL.ClientConVar[ "forcelimit" ] = "0" TOOL.ClientConVar[ "addlength" ] = "0" TOOL.ClientConVar[ "material" ] = "cable/rope" TOOL.ClientConVar[ "width" ] = "2" TOOL.ClientConVar[ "rigid" ] = "0" if CLIENT then language.Add( "Tool_rope2_name", "Rope2. Adds Right Click." ) language.Add( "Tool_rope2_desc", "Ropes" ) language.Add( "Tool_rope2_0", "Click To Somewhere" ) language.Add( "Tool_rope2_1", "Click To SomeWhere" ) language.Add( "Tool_rope2", "Click To SomWhere" ) end function TOOL:LeftClick( trace ) if ( trace.Entity:IsValid() && trace.Entity:IsPlayer() ) then return end -- If there's no physics object then we can't constraint it! if ( SERVER && !util.IsValidPhysicsObject( trace.Entity, trace.PhysicsBone ) ) then return false end local iNum = self:NumObjects() local Phys = trace.Entity:GetPhysicsObjectNum( trace.PhysicsBone ) self:SetObject( iNum + 1, trace.Entity, trace.HitPos, Phys, trace.PhysicsBone, trace.HitNormal ) if ( iNum > 0 ) then if ( CLIENT ) then self:ClearObjects() return true end -- Get client's CVars local forcelimit = self:GetClientNumber( "forcelimit" ) local addlength = self:GetClientNumber( "addlength" ) local material = self:GetClientInfo( "material" ) local width = self:GetClientNumber( "width" ) local rigid = self:GetClientNumber( "rigid" ) == 1 -- Get information we're about to use local Ent1, Ent2 = self:GetEnt(1), self:GetEnt(2) local Bone1, Bone2 = self:GetBone(1), self:GetBone(2) local WPos1, WPos2 = self:GetPos(1), self:GetPos(2) local LPos1, LPos2 = self:GetLocalPos(1),self:GetLocalPos(2) local length = ( WPos1 - WPos2):Length() local constraint, rope = constraint.Rope( Ent1, Ent2, Bone1, Bone2, LPos1, LPos2, length, addlength, forcelimit, width, material, rigid ) -- Clear the objects so we're ready to go again self:ClearObjects() -- Add The constraint to the players undo table undo.Create("Rope") undo.AddEntity( constraint ) undo.AddEntity( rope ) undo.SetPlayer( self:GetOwner() ) undo.Finish() self:GetOwner():AddCleanup( "ropeconstraints", constraint ) self:GetOwner():AddCleanup( "ropeconstraints", rope ) else self:SetStage( iNum+1 ) end return true end function TOOL:RightClick( trace ) local iNum = self:NumObjects() local Phys = trace.Entity:GetPhysicsObjectNum( trace.PhysicsBone ) self:SetObject( 1, trace.Entity, trace.HitPos, Phys, trace.PhysicsBone, trace.HitNormal ) local tr = {} tr.start = trace.HitPos tr.endpos = tr.start + (trace.HitNormal * 16384) tr.filter = {} tr.filter[1] = self:GetOwner() if (trace.Entity:IsValid()) then tr.filter[2] = trace.Entity end local tr = util.TraceLine( tr ) if ( !tr.Hit ) then self:ClearObjects() return end -- Don't try to constrain world to world if ( trace.HitWorld && tr.HitWorld ) then self:ClearObjects() return end if ( trace.Entity:IsValid() && trace.Entity:IsPlayer() ) then self:ClearObjects() return end if ( tr.Entity:IsValid() && tr.Entity:IsPlayer() ) then self:ClearObjects() return end local Phys2 = tr.Entity:GetPhysicsObjectNum( tr.PhysicsBone ) self:SetObject( 2, tr.Entity, tr.HitPos, Phys2, tr.PhysicsBone, trace.HitNormal ) if ( CLIENT ) then self:ClearObjects() return true end -- Get client's CVars local forcelimit = self:GetClientNumber( "forcelimit" ) local addlength = self:GetClientNumber( "addlength" ) local material = self:GetClientInfo( "material" ) local width = self:GetClientNumber( "width" ) local rigid = self:GetClientNumber( "rigid" ) == 1 -- Get information we're about to use local Ent1, Ent2 = self:GetEnt(1), self:GetEnt(2) local Bone1, Bone2 = self:GetBone(1), self:GetBone(2) local WPos1, WPos2 = self:GetPos(1),self:GetPos(2) local LPos1, LPos2 = self:GetLocalPos(1),self:GetLocalPos(2) local length = ( WPos1 - WPos2 ):Length() local constraint, rope = constraint.Rope( Ent1, Ent2, Bone1, Bone2, LPos1, LPos2, length, addlength, forcelimit, width, material, 1 ) -- Clear the objects and set the last object as object 1 self:ClearObjects() iNum = self:NumObjects() self:SetObject( iNum + 1, Ent2, trace.HitPos, Phys, Bone2, trace.HitNormal ) self:SetStage( iNum+1 ) -- Add The constraint to the players undo table undo.Create("Rope") undo.AddEntity( constraint ) if rope then undo.AddEntity( rope ) end undo.SetPlayer( self:GetOwner() ) undo.Finish() self:GetOwner():AddCleanup( "ropeconstraints", constraint ) self:GetOwner():AddCleanup( "ropeconstraints", rope ) end function TOOL:Reload( trace ) if (!trace.Entity:IsValid() || trace.Entity:IsPlayer() ) then return false end if ( CLIENT ) then return true end local bool = constraint.RemoveConstraints( trace.Entity, "Rope" ) return bool end function TOOL.BuildCPanel( CPanel ) CPanel:AddControl( "Header", { Text = "#tool.rope.name", Description = "#tool.rope.help" } ) CPanel:AddControl( "ComboBox", { Label = "#tool.presets", MenuButton = 1, Folder = "rope", Options = { Default = { rope_forcelimit = '0', rope_addlength='0', rope_width='1', rope_material='cable/rope', rope_rigid='0' } }, CVars = { "rope_forcelimit", "rope_addlength", "rope_width", "rope_material", "rope_rigid" } }) CPanel:AddControl( "Slider", { Label = "#tool.forcelimit", Type = "Float", Command = "rope_forcelimit", Min = "0", Max = "1000", Help=true } ) CPanel:AddControl( "Slider", { Label = "#tool.rope.addlength", Type = "Float", Command = "rope_addlength", Min = "-500", Max = "500", Help=true } ) CPanel:AddControl( "CheckBox", { Label = "#tool.rope.rigid", Command = "rope_rigid", Help=true } ) CPanel:AddControl( "Slider", { Label = "#tool.rope.width", Type = "Float", Command = "rope_width", Min = "0", Max = "10" } ) CPanel:AddControl( "RopeMaterial", { Label = "#tool.rope.material", convar = "rope_material" } ) end[/lua]
[QUOTE=Persious;37459187]How could I get money data send with usermessages to the client to show up on a scoreboard? Currently, their money is saved as myMoney. I tried looping through all the players, and afterwards doing v.myMoney, but that didn't work.[/QUOTE] What code are you using?
[quote][img]http://cloud.steampowered.com/ugc/540684781147900133/724F9ADF5C483CE2A1F710CA3D6D5E3744AE8A93/1024x614.resizedimage[/img][/quote] Okay I'm mainly worried about optimization, so I have two questions. 1.) Does this net graph look good or bad, because my frames are dropping out the asshole. 2.) Any tips on optimization? (Where to look, how to do things, etc.) That's a server of 24 players by the way.
[QUOTE=Persious;37459187]How could I get money data send with usermessages to the client to show up on a scoreboard? Currently, their money is saved as myMoney. I tried looping through all the players, and afterwards doing v.myMoney, but that didn't work.[/QUOTE] Do a loop server side and in the usermessage send each players SteamID and the data. On your recieving function client side do another loop to match the SteamIDs, if they match then set the data you're sending to that player.
[QUOTE=jrj996;37462004]Okay I'm mainly worried about optimization, so I have two questions. 1.) Does this net graph look good or bad, because my frames are dropping out the asshole. 2.) Any tips on optimization? (Where to look, how to do things, etc.) That's a server of 24 players by the way.[/QUOTE] Netgraph is for networking. It has nothing to do with framerate. It will also only display the networking with you and the server.
[QUOTE=vexx21322;37465078]Netgraph is for networking. It has nothing to do with framerate. It will also only display the networking with you and the server.[/QUOTE] But other players takes up a majority of the graph
[QUOTE=Divran;37455050][code]local function iterateTable( t ) for i=1,#t do if type(t[i]) == "table" then iterateTable( t ) else -- Do something with the value here end end end[/code][/QUOTE] iterateTable( t[b][i][/b] )
[QUOTE=Lexic;37465691]iterateTable( t[b][i][/b] )[/QUOTE] right, sorry
Hi. I got a question regarding darkrp and entitys: Is it possible to make a spawned entity useable by the physgun? I want the player who spawned the entity to be able to use his phsygun on it. I already checked the methods from this documentation without success :/ [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexd46d.html[/url]
[QUOTE=itkuitkzhji;37467100]Hi. I got a question regarding darkrp and entitys: Is it possible to make a spawned entity useable by the physgun? I want the player who spawned the entity to be able to use his phsygun on it. I already checked the methods from this documentation without success :/ [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexd46d.html[/url][/QUOTE] My guess is you have to set the owner of the entity to the one who spawned it, using a darkrp set owner function. Look up the darkrp documentation (if there is any)
[QUOTE=itkuitkzhji;37467100]Hi. I got a question regarding darkrp and entitys: Is it possible to make a spawned entity useable by the physgun? I want the player who spawned the entity to be able to use his phsygun on it. I already checked the methods from this documentation without success :/ [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexd46d.html[/url][/QUOTE] Set ent.Owner = the player
sup :D Well i would like when it for my gamemode when somebody gets 5 kills he gets a fancy trail or glows :) i have this [PHP]Killstreak:AddStreak( 5, function(ply) ply:Give("weapon_real_cs_grenade") ply:GiveAmmo(1,"grenade")[/PHP] is the killstreak script i have right now :D what should i write instead of [PHP]ply:Give("weapon_real_cs_grenade") ply:GiveAmmo(1,"grenade")[/PHP]
Is it possible to slow down or speed up effects that are made with functions such as ParticleEffect and ParticleEffectAttach?
I'm working with Lua in Minecraft at the moment and I have noticed that when lines of code are executed they are executed in turn rather than simultaneously. What is the technical term for this? Also, I have this code to make accounts in an accounts table but it doesn't exactly function well. What would be a better way to do this? [IMG]http://i.imgur.com/Nu5hd.jpg[/IMG]
[QUOTE=PencilOnDesk;37462893]Do a loop server side and in the usermessage send each players SteamID and the data. On your recieving function client side do another loop to match the SteamIDs, if they match then set the data you're sending to that player.[/QUOTE] So, I sent the data to the client. How would I match the SteamID's, and set the data afterwards?
Sorry, you need to Log In to post a reply to this thread.