• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
[QUOTE=HumbleTH;45977003]When overriding PlayerSpawn, some hooks you need to call manually for them to work. I know one of the is PlayerSetModel, not sure about the other ones though.[/QUOTE] If only you'd give enough bothers to look it up yourself. [url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/gamemodes/base/gamemode/player.lua#L268[/url]
[QUOTE=HumbleTH;45977003]When overriding PlayerSpawn, some hooks you need to call manually for them to work. I know one of the is PlayerSetModel, not sure about the other ones though.[/QUOTE] You should consider calling the base function rather than reproducing its behaviour.
How would I use [code] render.RenderView( CamData ) [/code] with [url]http://wiki.garrysmod.com/page/render/SetScissorRect[/url] Im trying to crop into a circle instead of a square/rectangle.
[QUOTE=BlackMadd;45978272]How would I use [code] render.RenderView( CamData ) [/code] with [url]http://wiki.garrysmod.com/page/render/SetScissorRect[/url] Im trying to crop into a circle instead of a square/rectangle.[/QUOTE] Render the view to a texture and apply a mask to it, or use the function you want.
Stencils would work too.
Ok so basically I'm trying to add firemodes to my scripted weapon base but it's quite laggy probably because it doesn't use "proper networking". I don't know what commands to use for that. Do I use GetNWect and SetNWect? This is what I use [code]function SWEP:PrimaryAttack() if !self:CanPrimaryAttack() then return end if self.EnableBurst == true then self.Primary.Delay = 0.39 self.Primary.Automatic = false if self.Weapon:Clip1() >= 3 then self:TakePrimaryAmmo(2) self.Primary.NumShots = 3 self.Primary.Sound = Sound("weapons/smg1/smg1_fireburst1.wav") else self:TakePrimaryAmmo(self.Weapon:Clip1()-1) self.Primary.NumShots = self.Weapon:Clip1() self.Primary.Sound = Sound("weapons/smg1/smg1_fire1.wav") end else self.Primary.NumShots = 1 self.Primary.Delay = 0.13 self.Primary.Sound = Sound("weapons/smg1/smg1_fire1.wav") self.Primary.Automatic = true end self:Shoot() end function SWEP:SecondaryAttack() if self.EnableBurst == false then self.EnableBurst = true self.Weapon:EmitSound("weapons/smg1/switch_burst.wav") self.Owner:PrintMessage( HUD_PRINTCENTER, "Switched to Burst Fire Mode" ) else self.EnableBurst = false self.Weapon:EmitSound("weapons/smg1/switch_single.wav") self.Owner:PrintMessage( HUD_PRINTCENTER, "Switched to Automatic" ) end end[/code] [QUOTE=Kogitsune;45974540]If you mean the list of activities they have, then something like [code]function GetActivities( ent ) local k, v, t t = { } for k, v in ipairs( ent:GetSequenceList( ) ) do table.insert( t, { id = k, act = ent:GetSequenceActivity( k ), actname = ent:GetSequenceActivityName( k ) } ) end return t end[/code] If that's not what you meant, you'll need to clarify.[/QUOTE] This works thanks.
[QUOTE=ROFLBURGER;45981358]Ok so basically I'm trying to add firemodes to my scripted weapon base but it's quite laggy probably because it doesn't use "proper networking". I don't know what commands to use for that. Do I use GetNWect and SetNWect? This is what I use [code]function SWEP:PrimaryAttack() if !self:CanPrimaryAttack() then return end if self.EnableBurst == true then self.Primary.Delay = 0.39 self.Primary.Automatic = false if self.Weapon:Clip1() >= 3 then self:TakePrimaryAmmo(2) self.Primary.NumShots = 3 self.Primary.Sound = Sound("weapons/smg1/smg1_fireburst1.wav") else self:TakePrimaryAmmo(self.Weapon:Clip1()-1) self.Primary.NumShots = self.Weapon:Clip1() self.Primary.Sound = Sound("weapons/smg1/smg1_fire1.wav") end else self.Primary.NumShots = 1 self.Primary.Delay = 0.13 self.Primary.Sound = Sound("weapons/smg1/smg1_fire1.wav") self.Primary.Automatic = true end self:Shoot() end function SWEP:SecondaryAttack() if self.EnableBurst == false then self.EnableBurst = true self.Weapon:EmitSound("weapons/smg1/switch_burst.wav") self.Owner:PrintMessage( HUD_PRINTCENTER, "Switched to Burst Fire Mode" ) else self.EnableBurst = false self.Weapon:EmitSound("weapons/smg1/switch_single.wav") self.Owner:PrintMessage( HUD_PRINTCENTER, "Switched to Automatic" ) end end[/code] This works thanks.[/QUOTE] [code] local SINGLE, BURST, AUTO = 0, 1, 2 function SWEP:SetupDataTables( ) self:NetworkVar( "Int", 0, "FireMode" ) if SERVER then self:SetFireMode( AUTO ) --defualt to auto end end -- if self:GetFireMode( ) == SINGLE then ... end [/code] It'd be pretty simple from there - it is automatically networked and follows the weapon.
How can I make a DHTML panel that plays audio silent?
[QUOTE=nubskrub;45982836]How can I make a DHTML panel that plays audio silent?[/QUOTE] Use soundchannels instead of DHTML panels with audio.
what's the difference between doing table.insert(tbl, val) and tbl[#tbl + 1] = val Which one is better?
[QUOTE=AnonTakesOver;45984410]what's the difference between doing table.insert(tbl, val) and tbl[#tbl + 1] = val Which one is better?[/QUOTE] tbl[#tbl+1] only works if you don't have string indexes in your table as # only returns the highest number index.
[QUOTE=AnonTakesOver;45984410]what's the difference between doing table.insert(tbl, val) and tbl[#tbl + 1] = val Which one is better?[/QUOTE] tbl[#tbl + 1] is cheaper put insert has an argument for position that moves the other entries around
[QUOTE=PaellaPablo;45983084]Use soundchannels instead of DHTML panels with audio.[/QUOTE] Er. I phrased that pretty badly. I mean, let's say I have a website open in a DHTML panel, and it has to be in a DHTML panel, and it plays audio, and I want the audio it plays to be silenced.
[QUOTE=nubskrub;45988274]Er. I phrased that pretty badly. I mean, let's say I have a website open in a DHTML panel, and it has to be in a DHTML panel, and it plays audio, and I want the audio it plays to be silenced.[/QUOTE] Then it really depends on exactly how the audio is being played (YouTube, HTML5 audio, etc?) and the only solution I can think of is to run Javascript on the DHTML panel to stop it from playing/mute.
Why does ply:SpectateEntity create a player above the object you are spectating? It doesnt have hitboxes and stays in that position but its weird as hell and defeats the purpose of my prop disguiser... [t]http://i.gyazo.com/e7cecd1d34819a8b31ff0fe0ce5b8cc8.png[/t] Here is what I am currently using, the NoDraw part was an attempt to hide it [code] -- Spectate it ply:Spectate(OBS_MODE_CHASE) ply:SpectateEntity(self.Prop) ply:SelectWeapon(self:GetClass()) ply:SetNoDraw(true) ply:DrawViewModel(false) ply:DrawWorldModel(false) [/code]
[QUOTE=Exho;45990337]Why does ply:SpectateEntity create a player above the object you are spectating? It doesnt have hitboxes and stays in that position but its weird as hell and defeats the purpose of my prop disguiser... [t]http://i.gyazo.com/e7cecd1d34819a8b31ff0fe0ce5b8cc8.png[/t] Here is what I am currently using, the NoDraw part was an attempt to hide it [code] -- Spectate it ply:Spectate(OBS_MODE_CHASE) ply:SpectateEntity(self.Prop) ply:SelectWeapon(self:GetClass()) ply:SetNoDraw(true) ply:DrawViewModel(false) ply:DrawWorldModel(false) [/code][/QUOTE] Does everyone else see you as well or you just see yourself? I recall there being some hook that would draw yourself if you went thirdperson. Trying to find it. EDIT: [URL="https://github.com/garrynewman/garrysmod/blob/4eb9bb19dcfac06007691376ecaf2dbc56efa6b2/garrysmod/gamemodes/sandbox/gamemode/player_class/player_sandbox.lua#L116"]Player:ShouldDrawLocal?[/URL] I'm not sure, that should only affect you if you're using taunt cameras I think. Try the other OBS_MODEs?
Everyone sees it except local player.
I'ma guess that you're doing it for TTT. I'm also guess that TTT has a function build in that works out if your speccing a prop and put a name above. I'd suggest you go have a look in the gamemode folder, I believe theres a file called propspec, look in it and see if you can find anything drawing names of players there.
The name isnt the problem... Its the floating dude above it
[QUOTE=nubskrub;45988274]Er. I phrased that pretty badly. I mean, let's say I have a website open in a DHTML panel, and it has to be in a DHTML panel, and it plays audio, and I want the audio it plays to be silenced.[/QUOTE] You could try modifying the sound-level, or: Before displaying the html, you could delete the part that plays the audio; you can use patterns ( unfortunately not Regular Expressions ) to grab the start and ending tag and delete that plus everything in between.
What hook should I use to stop render.DrawWireframeBox drawing through the skybox [t]http://cloud-4.steampowered.com/ugc/541878445461701224/718F1B05DF606FD9EBFD91FB08F668F3A8215C66/[/t] Keep in mind that box is at a valid position, but I want it hidden since it's in a different part of the map (behind a skybox texture).
Pre/Post Render hooks have arguments. Take a look at this: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/render_lasers_rendering_cubes.lua.html[/url] Don't let the hook run if it is the skybox call.
[QUOTE=Acecool;45992356]Pre/Post Render hooks have arguments. Take a look at this: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/render_lasers_rendering_cubes.lua.html[/url] Don't let the hook run if it is the skybox call.[/QUOTE] I hate your underscores, but I love your code. Well played. and thanks :3 [B]EDIT[/B] Actually, fucking rip in pepperinos it didnt work. [LUA] function _gm.cFunc.RenderScreenspaceEffects( bIsDepth, bIsSkybox) if !bIsSkybox then return end if GetGlobalVector("epp") != Vector(0,0,0) then local epp = GetGlobalVector("epp") local epr = GetGlobalInt("epr") local epa = GetGlobalInt("epa") local epw = GetGlobalInt("epw") local eph = GetGlobalInt("eph") local epl = GetGlobalInt("epl") render.DrawWireframeBox( epp + Vector(0,0,epa), Angle(0, epr, 0), Vector(-epw/2, -epl/2, -eph/2) , Vector(epw/2, epl/2, eph/2), Color(255,255,0), true ) end end hook.Add("PostDrawTranslucentRenderables", "gm_renderscreenspaceeffects", _gm.cFunc.RenderScreenspaceEffects) [/LUA] Doesnt draw at all now :'( (all I did was add the if !bIsSkybox then return end)
[QUOTE=Exho;45991321]The name isnt the problem... Its the floating dude above it[/QUOTE] Kill the player who is spectating. Make sure nowhere ply:DrawModel() is called.
I'm having trouble with logs. I log (a lot) of messages, and I want to be able to search such messages. So instead of going directly to a file, I use a table. I do this: [lua] function evolve.Log( message, category ) if( category == EV_LOG_ERROR ) then category = "Errors" elseif( category == EV_LOG_BANS ) then category = "Bans" elseif( category == EV_LOG_DAMAGE ) then category = "Damage" elseif( category == EV_LOG_ACTIVITY ) then category = "Players" else category = "General" end table.insert( evolve.logs, { logdate = os.date(), category = category, msg = message } ); end function evolve.SaveLogs() local logDb = {} local logFile = file.Read( "evolve/ev_log.txt", "DATA" ); if( logFile ) then local deserialized = von.deserialize( logFile ); if( deserialized ) then table.Add( logDb, deserialized ); end end if( #evolve.logs > 0 ) then table.Add( logDb, evolve.logs ) file.Write( "evolve/ev_log.txt", von.serialize( logDb ) ); end table.Empty( evolve.logs ); end [/lua] This works. I write the file every so often, since it becomes a fairly large file. So it only reads/re-writes the file when the server is idling, and I empty the table. I only ever populate the table again if I have to search from a log. Which isn't very often. Better suggestions? Should I just use SQLLite, or, MySQL?
Ok, wtf... I'm creating 'local Normal' and setting it with some vectors and some math. Right, except it keeps turning up nil or invalid now. [code] local TrRes = self.Owner:GetEyeTrace() local Unrelated local Normal if ( TrRes.Hit && TrRes.HitWorld ) || ( TrRes.Hit && !TrRes.Entity:IsPlayer() && !TrRes.Entity:IsNPC() ) then Unrelated = TrRes.HitPos Normal = ( TrRes.HitNormal + self.Owner:GetAimVector() * 0.5 ):Normalize() end[/code] In case your suggestion is to instantly set the local's value like so 'local Normal = Vector(0,0,0)' I've tried that, and it didn't work. This script worked perfectly yesterday when I was writing it, but today it just want's to be a bitch. Would anyone have an idea on how to correct this problem? The error report comes from the object made using the variable; [code][ERROR] lua/entities/c01e2_pmsgrenade.lua:92: attempt to perform arithmetic on field 'TeleportNormals' (a nil value) 1. Transition - lua/entities/c01e2_pmsgrenade.lua:92 2. unknown - lua/entities/c01e2_pmsgrenade.lua:58 Timer Failed! [Simple][@lua/entities/c01e2_pmsgrenade.lua (line 57)][/code] which is set with: [code] ent:SetDestination( Cesspit, Normal )[/code]
Is there a function similar to SetMaterial, however it supports multiple different textures (SetMaterials)? An example of what I mean would be like: [code]local listOfMaterials = Entity:GetMaterials( ) PrintTable( listOfMaterials ) Entity:SetMaterials( { "material/white", "material/glass", "material/metal", } )[/code]
[QUOTE=WalkingZombie - Please Click;45997985]Please click, or scroll up a post or two[/QUOTE] Seriously, it's so weird, I set the local 'Normal' to a vector, but all of the sudden it no longer exists. [editline]16th September 2014[/editline] Oh wow... changing Normalize to GetNormal did it. :suicide: Derp
[QUOTE=WalkingZombie;45998659]Seriously, it's so weird, I set the local 'Normal' to a vector, but all of the sudden it no longer exists. [editline]16th September 2014[/editline] Oh wow... changing Normalize to GetNormal did it. :suicide: Derp[/QUOTE] Normalize Changes the vector you have and does not return a value, while getnormal retuns the normalized value but does not change the original vector: [code] local vector1, vector2 = Vector(100, 200, 300), Vector(100, 200, 300) local x = vector1:Normalize() local y = vector2:GetNormal() --result: -- vector1, vector2, x, y -- Vector(1, 2, 3), Vector(100, 200, 300), nil, Vector(1, 2, 3) [/code] I'm trying to figure out a way to just not render the world. I want to "draw my own" world but I don't want to use a custom map, I just want to use Flatgrass. I don't want it to render at all though to try to save as much render time as possible.
How would I put animations on an entity, as my entity uses a playermodel for the model and I just want a default idle animation. EDIT: Nevermind, figured it out.
Sorry, you need to Log In to post a reply to this thread.