• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
Is there a way to find the TextureID of something from icon16/? I.E. [code] surface.GetTextureID("icon16/cross") [/code]
I know it's not an accurate answer, but why do you need the TextureID? Can't Material do just fine?
The end result is to do [code] surface.SetTexture(surface.GetTextureID("icon16/cross")) [/code] I've tried finding everything I could, changing the path to everything I could think of, it says the path exists as materials/icon16/cross.png. It just refuses to recognize it in TextureID.
[QUOTE=Lolcats;45919066]The end result is to do [code] surface.SetTexture(surface.GetTextureID("icon16/cross")) [/code] I've tried finding everything I could, changing the path to everything I could think of, it says the path exists as materials/icon16/cross.png. It just refuses to recognize it in TextureID.[/QUOTE] If you're using surface.* functions, you can just forget about surface.GetTextureID / surface.SetTexture altogether - as far as I know, the Material system supports all old textures and offers a lot of new stuff in addition (such as PNG materials or options): [lua] local mat = Material("icon16/cross.png") -- you only need to initialize the material once, try not to do it 24/7 like in a HUDPaint hook or in panel paint, it rapes everything for no reason surface.SetMaterial(mat) surface.DrawTexturedRect(0, 0, 16, 16) [/lua]
Ah, thanks man, that worked. Still think it's silly how surface.GetTextureID doesn't recognize it, but this seems easier.
How would you go about saving Leaderboard content without SQL?
file.Write? Find a website that hosts leaderboards and use their webapi to manage it?
[QUOTE=Lolcats;45919028]Is there a way to find the TextureID of something from icon16/? I.E. [code] surface.GetTextureID("icon16/cross") [/code][/QUOTE] No. Use surface.SetMaterial( Material("icon16/cross.png") ) But you better cache the output of Material() though. EDIT: I am ninjad again. Better go sleep :v:
Does net.Recieve handle players differently? I would've done this clientside but the function is only serverside so I send the data over.. [code] [ERROR] addons/eeg shop/lua/sv_player_extension.lua:136: attempt to index local 'self' (a number value) 1. PS_TakePoints - addons/eeg shop/lua/sv_player_extension.lua:136 2. func - addons/exhos ttt weps/lua/autorun/psbetting.lua:95 3. unknown - lua/includes/modules/net.lua:32 [/code] [code] net.Receive( "ReceiveBet", function( len, ply ) -- if LotteryIsOpen then local tab = net.ReadTable() --PrintTable(tab) ply.PS_TakePoints(tab.Amount) Pot = Pot + tab.Amount local datatab = { ply:SteamID( ), tab.Amount, tab.Role } local dat = table.concat(datatab,", ") table.insert(SubmittedBets, dat) PrintTable(SubmittedBets) end) [/code]
[code]ply.PS_TakePoints(tab.Amount)[/code] This is wrong
[QUOTE=Willox;45919694][code]ply.PS_TakePoints(tab.Amount)[/code] This is wrong[/QUOTE] Its a method isnt it... Yuuuppp
How to get if a table has a specific value that a different table contains? This is the first table code [code] CopMenuWeapons = {} CopMenuWeapons[1] = "weapon_smg1" [/code] This is the code that I currently try to use but doesn't work. Note, I am make sure that the player in question HAS the weapon. [code] local searchB = vgui.Create("cButton", frame) searchB:SetSize(frame:GetWide() - 24, 24) searchB:SetPos(12, YPos) YPos = YPos + 32 searchB:SetText("SEARCH PLAYER") searchB:SetClick(function() closeMenu() for k,v in pairs(eyeEntity:GetWeapons()) do if(v:GetClass() == CopMenuWeapons[k]) then print("has weapon!") return true else print("has no weapon!") end end end) [/code] It just keeps on printing 'has no weapon!' Anyone knows how to do this?
Is there a way to give a player a weapon silently / without the equip noise?
I'm confused with converting angles to normalized vectors. Basically what I'm trying to do is adding a specific angle to the bullet direction of a bullet table. bullet.Dir = self.Owner:GetAimVector() [editline]7th September 2014[/editline] nvm got it. tried it a different way. Hopefully my solution isn't laggy [code] local angle = (self.Owner:GetPunchAngle() + self.Owner:EyeAngles()):Forward() local bullet = {} bullet.Num = numbul bullet.Src = self.Owner:GetShootPos() bullet.Dir = angle bullet.Spread = Vector(cone, cone, 0) + Vector(self.extraspread,self.extraspread,0) bullet.Tracer = 3 bullet.Force = dmg/10 bullet.Damage = dmg self.Owner:FireBullets(bullet)[/code]
[lua] ent:DrawShadow( true ) function ENT:Draw( ) self:MarkShadowAsDirty( true ) // OR self:MarkShadowAsDirty( ) self:DrawModel( ) end [/lua] Why is MarkShadowAsDirty not working as it did before? D:
[QUOTE=BlackMadd;45917894]I have a weird glitch in my custom WIP gamemode where if a player pushes Y to talk with chat nothing happens. Instead your view angles are pushed up (so you are looking at the sky) and garrysmod refuses any keyboard input ;3; im lost here.[/QUOTE] Are you hiding the chat via HUDShouldDraw?
-snip-
[QUOTE=Teddi Orange;45920815]Is there a way to give a player a weapon silently / without the equip noise?[/QUOTE] [code]hook.Add("EntityEmitSound", "adsa", function(data) if data.SoundName == "items/ammo_pickup.wav" then return false end end)[/code] ?
[QUOTE=HumbleTH;45921996]Are you hiding the chat via HUDShouldDraw?[/QUOTE] The only elements hidden via that function are: "CHudHealth", "CHudBattery", "CHudAmmo", "CHudSecondaryAmmo" I haven't tested it yet but a friend pointed out that because I am not working off the BASE Game mode I need to go in and add the following functions myself *derp* [url]http://wiki.garrysmod.com/page/GM/ChatText[/url] [url]http://wiki.garrysmod.com/page/GM/ChatTextChanged[/url] [url]http://wiki.garrysmod.com/page/GM/FinishChat[/url] [url]http://wiki.garrysmod.com/page/GM/OnPlayerChat[/url] [url]http://wiki.garrysmod.com/page/GM/PlayerCanSeePlayersChat[/url] [url]http://wiki.garrysmod.com/page/GM/OnChatTab[/url] [url]http://wiki.garrysmod.com/page/GM/StartChat[/url] Example in BASE Game mode cl_init.lua [url]https://github.com/garrynewman/garrysmod/blob/4eb9bb19dcfac06007691376ecaf2dbc56efa6b2/garrysmod/gamemodes/base/gamemode/cl_init.lua[/url]
I need help with this class I made [code]if TableSearcher(ply.ClassNumber,"Shatter") == true then if not ply.Immunity then ply.Immunity = false end if not ply.BulletHitCount then ply.BulletHitCount = 1 end --print(dmginfo:GetDamageType()) --print(ply.Immunity) if ply:Armor() > 0 then if ply.Immunity == false then if ply.BulletHitCount >= 1 then ply.Immunity = true --ply.BulletHitCount = 0 ply.Stun = 1 ply:SetMaterial("brick/brick_model.vmf") ply:EmitSound("weapons/demo_charge_hit_world"..math.random(1,3)..".wav") timer.Simple(1,function() ply.Immunity = false ply:SetMaterial("") ply.BulletHitCount = 0 end) end ply.BulletHitCount = ply.BulletHitCount + 1 end end if ply.Immunity == true then DamageScale = DamageScale*0 else DamageScale = DamageScale*1.5 end end [/code] Basically what it does is grant immunity for 1 second if hit, but the original hit still does damage. I'm just trying to hard counter shotguns and rapid fire weapons in my class mod. It's not working as intended. It's basically blocking the original hit every second hit.
Can you scale the particles from a PCF (ParticleEffect/ParticleEffectAttach)? Or, is this something that needs to be done as a Lua particle?
[QUOTE=ROFLBURGER;45927121]I need help with this class I made Basically what it does is grant immunity for 1 second if hit, but the original hit still does damage. I'm just trying to hard counter shotguns and rapid fire weapons in my class mod. It's not working as intended. It's basically blocking the original hit every second hit.[/QUOTE] I'm not sure I understand... You want the original shot to damage every-time; but you want immunity from all hits for 1 second after the original hit?? You can shorten some of the code; you don't need to use == true for the comparisons; just if ( ply.Immunity ) then... and if ( TableSearcher(ply.ClassNumber,"Shatter") ) then .... And to check if a value is false / nil ( you don't want to specifically check for false, except certain cases... Basically, if the value is not set or set to nil you'll have some issues with that )... if ( !ply.Immunity ) then ... or if ( not ply.Immunity ) then .... which will return true if it is false, or nil / not-set... If you're searching a table each time someone is shot ( or hit with a bullet / pellet ), it may get laggy with large firefights. I'd recommend using a technique like this: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_gm_specific_darkrp/darkrp_customcheck_isvip_via_list_or_group_or_admin_check.lua.html[/url] -- The group table. or [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/proper_hud_creation.lua.html[/url] -- The HUDShouldDraw table. For debugging, if you want to print out damage just by using print( dmginfo ), here: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_utilities/metatables_tostring_damageinfo.lua[/url] Next. Are you hooking into PlayerScaleDamage? It seems that way because of the scaling you're doing.. The issue is, if you shoot a shotgun that fires 8 pellets, for example, each pellet will call PlayerScaleDamage / PlayerTakeDamage if I recall correctly. You may need to look into a re-direct to accomplish the goal by counting how many times FireBullets by adding 1 to the entity that called FireBullets, and removing 1 in the bullet-callback. But; if you could be more specific in how it should behave, I'm sure we can help. Do you want full immunity from 7 pellets out of 8 fired? Or do you want full immunity from all attacks for one second from everyone after being hit once? Or do you want full immunity from only the player that hit you for one second? 1 second is a LONG time in a gun-fight, by removing multi-hit capabilities / wasting all ammo fired in 1 second, people may not like that. If a gun shoots 600 rounds per minute, that is 10 per second. The M4 shoots at 825 RPM with is ~14 rounds per second. You may want to consider ( if you want full immunity for 1 second from all, or from one ) to scale the damage downwards for each successive hit so gunfights can last longer, but isn't totally negating damage.
Has anyone been able to apply custom lighting to a mesh without using SetModelLighting, more specifically I want to use SetLightingOrigin
[QUOTE=BlackMadd;45923874]The only elements hidden via that function are: "CHudHealth", "CHudBattery", "CHudAmmo", "CHudSecondaryAmmo" I haven't tested it yet but a friend pointed out that because I am not working off the BASE Game mode I need to go in and add the following functions myself *derp* [url]http://wiki.garrysmod.com/page/GM/ChatText[/url] [url]http://wiki.garrysmod.com/page/GM/ChatTextChanged[/url] [url]http://wiki.garrysmod.com/page/GM/FinishChat[/url] [url]http://wiki.garrysmod.com/page/GM/OnPlayerChat[/url] [url]http://wiki.garrysmod.com/page/GM/PlayerCanSeePlayersChat[/url] [url]http://wiki.garrysmod.com/page/GM/OnChatTab[/url] [url]http://wiki.garrysmod.com/page/GM/StartChat[/url] Example in BASE Game mode cl_init.lua [url]https://github.com/garrynewman/garrysmod/blob/4eb9bb19dcfac06007691376ecaf2dbc56efa6b2/garrysmod/gamemodes/base/gamemode/cl_init.lua[/url][/QUOTE] Well adding that didn't work :/ I'm lost her as to what to do.
I'm trying to make a little fun item that replace's all the textures in the map, I'm wanting to change the map, viewmodel, and all such to this other texture. I did a little test and it semi worked, but it didn't change map stuff, or viewmodels. [lua] for _,ent in pairs( ents.GetAll() ) do ent:SetMaterial("Models/effects/splodearc_sheet" ) end [/lua] Apparently garry's done something like this but I wasn't able to find it. [QUOTE=Kogitsune;38851374]It was something garry showed a while back - all textures in the world were replaced by a single ( in this case, scrolling ) texture.[/QUOTE] Does anyone know how to achieve this?
This should be what you're looking for. [url]http://wiki.garrysmod.com/page/IMaterial/SetTexture[/url]
I need help with predictions. Well I'm predicting that's what I need help with. [code]function SWEP:PrimaryAttack() if !self:CanPrimaryAttack() then return end if self.FireMode == 1 then self.Primary.RecoilMul = 1 self.Primary.Cone = .02 self:Attack() self:IdleStuff() self:SetNextPrimaryFire(CurTime() + self.Primary.Delay) elseif self.FireDelay < CurTime() then self.Primary.Cone = .01 self.Primary.RecoilMul = 0.5 self:SetNextPrimaryFire(CurTime() + self.Primary.Delay*2) self:Attack() timer.Simple(self.Primary.Delay*0.5, function() if (!IsValid(self) or !IsValid(self.Owner) or !self.Owner:GetActiveWeapon() or self.Owner:GetActiveWeapon() != self) then return end self:Attack() end) timer.Simple(self.Primary.Delay*1, function() if (!IsValid(self) or !IsValid(self.Owner) or !self.Owner:GetActiveWeapon() or self.Owner:GetActiveWeapon() != self) then return end self:Attack() end) self.FireDelay = CurTime() + self.Primary.Delay*4 end end function SWEP:SecondaryAttack() self:EmitSound("weapons/elite/elite_sliderelease.wav") if self.FireMode == 1 then self.Owner:PrintMessage( HUD_PRINTCENTER, "Switched to Burst Fire Mode" ) self.FireMode = 2 else self.FireMode = 1 self.Owner:PrintMessage( HUD_PRINTCENTER, "Switched to Semi-Automatic" ) end end function SWEP:Attack() if !self:CanPrimaryAttack() then return end self:SendWeaponAnim(ACT_VM_PRIMARYATTACK) self:SeriousFlash() self.Owner:SetAnimation(PLAYER_ATTACK1) self:WeaponSound(self.Primary.Sound) self:ShootBullet(self.Primary.Damage, self.Primary.NumShots, self.Primary.Cone) if !self.Owner:IsNPC() then self:TakePrimaryAmmo(1) end self.NextReload = CurTime() +self.Primary.Delay + 0.1 self:HolsterDelay() end[/code] Basically it works fine on singleplayer and for the person hosting the server. Everyone else reports lag with the burstfire mode and it's probably because of my simple coding. I'm just wondering if there's a way to improve this. [QUOTE=Acecool;45927939]I'm not sure I understand... You want the original shot to damage every-time; but you want immunity from all hits for 1 second after the original hit?? You can shorten some of the code; you don't need to use == true for the comparisons; just if ( ply.Immunity ) then... and if ( TableSearcher(ply.ClassNumber,"Shatter") ) then .... And to check if a value is false / nil ( you don't want to specifically check for false, except certain cases... Basically, if the value is not set or set to nil you'll have some issues with that )... if ( !ply.Immunity ) then ... or if ( not ply.Immunity ) then .... which will return true if it is false, or nil / not-set... If you're searching a table each time someone is shot ( or hit with a bullet / pellet ), it may get laggy with large firefights. I'd recommend using a technique like this: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_gm_specific_darkrp/darkrp_customcheck_isvip_via_list_or_group_or_admin_check.lua.html[/url] -- The group table. or [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/proper_hud_creation.lua.html[/url] -- The HUDShouldDraw table. For debugging, if you want to print out damage just by using print( dmginfo ), here: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_utilities/metatables_tostring_damageinfo.lua[/url] Next. Are you hooking into PlayerScaleDamage? It seems that way because of the scaling you're doing.. The issue is, if you shoot a shotgun that fires 8 pellets, for example, each pellet will call PlayerScaleDamage / PlayerTakeDamage if I recall correctly. You may need to look into a re-direct to accomplish the goal by counting how many times FireBullets by adding 1 to the entity that called FireBullets, and removing 1 in the bullet-callback. But; if you could be more specific in how it should behave, I'm sure we can help. Do you want full immunity from 7 pellets out of 8 fired? Or do you want full immunity from all attacks for one second from everyone after being hit once? Or do you want full immunity from only the player that hit you for one second? 1 second is a LONG time in a gun-fight, by removing multi-hit capabilities / wasting all ammo fired in 1 second, people may not like that. If a gun shoots 600 rounds per minute, that is 10 per second. The M4 shoots at 825 RPM with is ~14 rounds per second. You may want to consider ( if you want full immunity for 1 second from all, or from one ) to scale the damage downwards for each successive hit so gunfights can last longer, but isn't totally negating damage.[/QUOTE] I managed to get it working using DamageInfo(). And don't worry about the balancing, I know what I'm doing. Basically the starting class gets low hp (50) and the person is stunned (frozen, cannot move, cannot shoot, cannot look) for that second. The original hit does 50% extra damage.
Trying to re-create a similar effect to Dead Space's inventory system but I can't get why my 3D2D keeps doing this: If I offset it to the left, it doesn't seem to maintain the offset when the angles are changed, if that makes sense. [vid]http://a.pomf.se/ykuvrm.webm[/vid] [code] if ( !vgui.Start3D2D ) then include( "3d2dvgui.lua" ) end local frame = vgui.Create( "DFrame" ) frame:SetPos( 0, 0 ) frame:SetSize( 300, 60 ) frame:SetTitle( "Test" ) frame:SetKeyboardInputEnabled( true ) frame:SetMouseInputEnabled( true ) hook.Add( "PostDrawOpaqueRenderables", "DrawSample3D2DFrame" .. math.random(), function() vgui.Start3D2D( LocalPlayer():GetPos() + Vector( -100, 0, 30 ), Angle( LocalPlayer():EyeAngles().p, LocalPlayer():EyeAngles().y, 0 ), 1 ) frame:Paint3D2D() vgui.End3D2D() end ) [/code] ( also using Overv/Matt's 3D2D VGUI library [url]https://github.com/HandsomeMatt/3d2d-vgui[/url] )
[QUOTE=Adzter;45936085]Trying to re-create a similar effect to Dead Space's inventory system but I can't get why my 3D2D keeps doing this: If I offset it to the left, it doesn't seem to maintain the offset when the angles are changed, if that makes sense. [vid]http://a.pomf.se/ykuvrm.webm[/vid] [code] if ( !vgui.Start3D2D ) then include( "3d2dvgui.lua" ) end local frame = vgui.Create( "DFrame" ) frame:SetPos( 0, 0 ) frame:SetSize( 300, 60 ) frame:SetTitle( "Test" ) frame:SetKeyboardInputEnabled( true ) frame:SetMouseInputEnabled( true ) hook.Add( "PostDrawOpaqueRenderables", "DrawSample3D2DFrame" .. math.random(), function() vgui.Start3D2D( LocalPlayer():GetPos() + Vector( -100, 0, 30 ), Angle( LocalPlayer():EyeAngles().p, LocalPlayer():EyeAngles().y, 0 ), 1 ) frame:Paint3D2D() vgui.End3D2D() end ) [/code] ( also using Overv/Matt's 3D2D VGUI library [url]https://github.com/HandsomeMatt/3d2d-vgui[/url] )[/QUOTE] Do [code] if ( !vgui.Start3D2D ) then include( "3d2dvgui.lua" ) end local frame = vgui.Create( "DFrame" ) frame:SetPos( 0, 0 ) frame:SetSize( 300, 60 ) frame:SetTitle( "Test" ) frame:SetKeyboardInputEnabled( true ) frame:SetMouseInputEnabled( true ) hook.Add( "PostDrawOpaqueRenderables", "DrawSample3D2DFrame" .. math.random(), function() vgui.Start3D2D( ( LocalPlayer():GetPos() + LocalPlayer( ):EyeAngles( ):Forward( ) * 99 + LocalPlayer( ):EyeAngles( ):Up( ) * 10 + LocalPlayer( ):EyeAngles( ):Right( ) * 50 ), Angle( LocalPlayer():EyeAngles().p, LocalPlayer():EyeAngles().y, 0 ), 1 ) frame:Paint3D2D() vgui.End3D2D() end ) [/code]
[QUOTE=sacred1337;45931038]I'm trying to make a little fun item that replace's all the textures in the map, I'm wanting to change the map, viewmodel, and all such to this other texture. I did a little test and it semi worked, but it didn't change map stuff, or viewmodels. [lua] for _,ent in pairs( ents.GetAll() ) do ent:SetMaterial("Models/effects/splodearc_sheet" ) end [/lua] Apparently garry's done something like this but I wasn't able to find it. Does anyone know how to achieve this?[/QUOTE] [QUOTE=scottd564;45933475]This should be what you're looking for. [url]http://wiki.garrysmod.com/page/IMaterial/SetTexture[/url][/QUOTE] Yes I realise that can be done, but is there a way to get a table containing all textures easily? As I'd thing that gmod has it saved somewhere. I guess otherwise I could search for vmt's to create a table, but that would be something I'd rather not do, and would cause it to overwrite hud stuff too, I'm just wanting to change ALL entitiys, ingame.
Sorry, you need to Log In to post a reply to this thread.