[QUOTE=ROFLBURGER;45933584]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.
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.[/QUOTE]
Don't use timers for it. Use some kind of think hook with CurTime() or something.
[QUOTE=HumbleTH;45921996]Are you hiding the chat via HUDShouldDraw?[/QUOTE]
So i figured out that the glitch is happening within this function but I don't know why.
[code]
function GM:HUDShouldDraw(vhud)
for k, v in pairs({"CHudHealth", "CHudBattery", "CHudAmmo", "CHudSecondaryAmmo", })do
if vhud == v then return false end
end
end
[/code]
[QUOTE=sacred1337;45936496]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.[/QUOTE]
Entity:GetMaterials( )
Returns a table of materials the model uses.
So wait, I looked at the wiki and it showed no support, is there no way to replace an entity's table of materials with a new table of materials?
For instance, I want to replace index 0 on the material table with whatintheworld/whatchamacallit.vmt, but I want to replace index 1 with whatwashername/whosamajigger.vmt, and replace index 2 with idonteven/whatthehellwasit.vmt. Is that possible?
use the render libarary.
[editline]9th September 2014[/editline]
nvm, that would replace materials for all instances of that model so rip.
[QUOTE=WalkingZombie;45937578]So wait, I looked at the wiki and it showed no support, is there no way to replace an entity's table of materials with a new table of materials?
For instance, I want to replace index 0 on the material table with whatintheworld/whatchamacallit.vmt, but I want to replace index 1 with whatwashername/whosamajigger.vmt, and replace index 2 with idonteven/whatthehellwasit.vmt. Is that possible?[/QUOTE]
Been looking for a way to do this, and the only thing I got was some half-thought answer by a crazy person spewing semicolons and underscores at me. (The idea didn't work either)
[QUOTE=BlackMadd;45937029]So i figured out that the glitch is happening within this function but I don't know why.
[code]
function GM:HUDShouldDraw(vhud)
for k, v in pairs({"CHudHealth", "CHudBattery", "CHudAmmo", "CHudSecondaryAmmo", })do
if vhud == v then return false end
end
end
[/code][/QUOTE]
It's returning nil for chat, if I'm not mistaken.
Add 'return true' after the for loop
[QUOTE=Revenge282;45938784]Been looking for a way to do this, and the only thing I got was some half-thought answer by a crazy person spewing semicolons and underscores at me. (The idea didn't work either)[/QUOTE]
[QUOTE=HumbleTH;45938787]It's returning nil for chat, if I'm not mistaken.
Add 'return true' after the for loop[/QUOTE]
It would be working fine you used hook.Add instead of overriding the GM function. Since you have overriden the whole thing you need to return true for things you still want to show.
Does anyone know why DS'es don't have the HL2 EP2 Jalopy but clients do? I'm thinking about making a gamemode using the jalopy but if it's not there and there's no way to get it there then i'm DOA.
[QUOTE=BFG9000;45939731]Does anyone know why DS'es don't have the HL2 EP2 Jalopy but clients do? I'm thinking about making a gamemode using the jalopy but if it's not there and there's no way to get it there then i'm DOA.[/QUOTE]
They do, but IsMounted returns false on srcds unless you make a proper [URL="http://wiki.garrysmod.com/page/Mounting_Content_on_a_DS"]cfg/mountdepots.txt[/URL] for it.
NP.
I'm trying to rerender my map to fix an issue specific to my gamemode.
I've tried doing:
[lua] Entity(0):DrawModel( ) [/lua]
However in result, the map comes out broken. It doesn't contain displacement brushes, some brush's vertexes get pushed to the origin of the map and development textures are returning back to their dev-texture (similar to how you see it inside hammer). If you want to see what I mean, just take a look at my screenshots below:
Without Entity(0):DrawModel( ) :
[t]https://dl.dropboxusercontent.com/u/17839069/C_154.png[/t]
Using it:
[t]https://dl.dropboxusercontent.com/u/17839069/C_153.png[/t]
I think someone already has tried something similar and I'm not sure if this has the capability of working the way I expect. Come to think of it, rerendering the map is pretty hacky D:
[QUOTE=Robotboy655;45939899]They do, but IsMounted returns false on srcds unless you make a proper cfg/mounteddepots.txt for it.[/QUOTE]
Is there any way I can add the jalopy without them having this file?
[editline]10th September 2014[/editline]
Nvm, I just remembered that i can look in base_vehicles.
Seems I just need to define the model, put the vehicle script in as a keyvalue, and then spawn the thing. Is it ok for me to include the vehicle.mdl model with my theoretical gamemode if I upload it to workshop? seeing as it's already vanilla at this point.
All you need to do is to remove IsMounted check on your server.
Hey, I read through this wiki page and thought it sounded neat, so I thought I'd try it out:
[url]https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index3319.html[/url]
bad argument 1 to SetMaterial, on 'render.SetMaterial(browser:GetHTMLMaterial())'. Does anyone know why? Not very familiar in this area.
Just use browser:PaintAt( x, y, w, h )
[QUOTE=NiandraLades;45942333]Hey, I read through this wiki page and thought it sounded neat, so I thought I'd try it out:
[url]https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index3319.html[/url]
bad argument 1 to SetMaterial, on 'render.SetMaterial(browser:GetHTMLMaterial())'. Does anyone know why? Not very familiar in this area.[/QUOTE]
GetHTMLMaterial will return nil sometimes, like when the page is loading, which makes it less useful.
[QUOTE=wh1t3rabbit;45938821]It would be working fine you used hook.Add instead of overriding the GM function. Since you have overriden the whole thing you need to return true for things you still want to show.[/QUOTE]
Was there a reason you quoted me? (Please have a solution, please... :suicide:)
[QUOTE=Revenge282;45945373]Was there a reason you quoted me? (Please have a solution, please... :suicide:)[/QUOTE]
Oops, I meant to reply to BlackMadd.
But as far as replacing the textures within the material, I don't have any experience with replacing them by 'index' but you can easily do material:SetTexture("$basetexture",newtexture) as long as you know the name ($basetexture, etc) of the texture slot you are replacing.
Some of these I can answer; I didn't see any real answer to these so... Also, one of the posts seems directed at me...
[QUOTE=BlackMadd;45937029]So i figured out that the glitch is happening within this function but I don't know why.
[code]
function GM:HUDShouldDraw(vhud)
for k, v in pairs({"CHudHealth", "CHudBattery", "CHudAmmo", "CHudSecondaryAmmo", })do
if vhud == v then return false end
end
end
[/code][/QUOTE]
Don't use a table to loop through for something like HUDShouldDraw. HUDShouldDraw is called n times already foreach of the panels that exist; by adding another loop it costs n^2 to execute. Lua is a language based around tables and there are some easy ways to directly access variables in tables. Over 100 million times, using that method costs 15.x seconds.. Using direct access over same number of executions = 0.08 seconds...
Benchmark: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/benchmarking_tips/benchmarking_hud_stuff.lua.html[/url]
Proper hud creation with the quick method of HUDShouldDraw ( also shown in benchmark, but this one contains all known elements: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/proper_hud_creation.lua.html[/url]
These next few are related:
[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]
I wrote something a while back to do this because I do it in V33X; replace all road textures and the end goal is to replace all of the maps textures. I wanted to do this so people didn't need HL2 to see the textures. ( the issue with that plan though, is when a user doesn't have a texture, it shows as an error and all error textures get grouped together... The only way to eliminate this is to provide blank vmt/vtfs so that something gets loaded for users that don't have it, and then switch it to the new texture... )
Here's how to do it: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/map_textures/replacing_textures_in_realtime.lua.html[/url]
[QUOTE=WalkingZombie;45937578]So wait, I looked at the wiki and it showed no support, is there no way to replace an entity's table of materials with a new table of materials?
For instance, I want to replace index 0 on the material table with whatintheworld/whatchamacallit.vmt, but I want to replace index 1 with whatwashername/whosamajigger.vmt, and replace index 2 with idonteven/whatthehellwasit.vmt. Is that possible?[/QUOTE]
It is possible, but it requires a little bit of work and a lot of memory management... Add me on Steam and I'll explain it.
[QUOTE=Revenge282;45938784]Been looking for a way to do this, and the only thing I got was some half-thought answer by a crazy person spewing semicolons and underscores at me. (The idea didn't work either)[/QUOTE]
Same with you. If you, or anyone else, is upset or don't understand something I explain, please ask me to clarify and I'll go over it with you again and simplify it if need be until it is understood. I'm very patient with those willing to learn.
But, in both cases if you choose to do it on your own.. look at how the map texture replacement is done. Replacing model textures is done in almost the exact the same way.
[QUOTE=Acecool;45946817]But, in both cases if you choose to do it on your own.. look at how the map texture replacement is done. Replacing model textures is done in almost the exact the same way.[/QUOTE]
Not when you want to replace a specific material on a specific entity that shares a model with another. Entity A and Entity B are the same model, but I want to replace a texture on Entity A only, leaving B the same as the default.
[QUOTE=Revenge282;45947963]Not when you want to replace a specific material on a specific entity that shares a model with another. Entity A and Entity B are the same model, but I want to replace a texture on Entity A only, leaving B the same as the default.[/QUOTE]
And I have a solution for you, feel free to contact me on Steam!
[QUOTE=Acecool;45948476]And I have a solution for you, feel free to contact me on Steam![/QUOTE]
If you have one, it would probably be best to post it here since there at least 3 of us looking to solve the same problem.
Alright; I seem to be having an issue accepting friends for some reason too, but here:
It is done the same way that map texture replacing works but with a little more work and a lot of memory management. Without memory management, this will run away on you. For entities / objects, you'll want to modify the texture before the model is rendered / drawn. You'll have to reset the materials back to original after you're finished drawing so the next person or object that you render won't share the new look.
The basic principle is simply: modify > draw / render > reset.
I'll be releasing some useful helper-functions that accomplish this in my dev base very soon. Hopefully this is clear enough, if it isn't then I'll try to work on getting the helpers out ASAP.
Is there an easy way to link a sound to a dermaframe? I'm looking to play a looping sound for as long as a certain dermaframe is open/exists.
[QUOTE=TripsLetash;45949516]Is there an easy way to link a sound to a dermaframe? I'm looking to play a looping sound for as long as a certain dermaframe is open/exists.[/QUOTE]Just add your sound code to example
[CODE]
local DermaPanel = vgui.Create( "DFrame" ) -- Creates the frame itself
DermaPanel:SetPos( 50,50 ) -- Position on the players screen
DermaPanel:SetSize( 1000, 900 ) -- Size of the frame
DermaPanel:SetTitle( "Testing Derma Stuff" ) -- Title of the frame
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true ) -- Draggable by mouse?
DermaPanel:ShowCloseButton( true ) -- Show the close button?
DermaPanel:MakePopup() -- Show the frame
surface.PlaySound( "items/ammo_pickup.wav" ) -- example sound code
[/CODE]
I have a small problem that's probably easy to fix but anyway I've been trying for a while to make a addon for zombie survival to where people can vote to blacklist a player from being able to nail props but sadly no matter what I can't figure out how to make it work but so far I believe that either my hooks aren't working or that a bool is not being set on the correct entity
Here is all the current stuff I have
autorun/server/sv_twistedzs.lua
[code]hook.Add( "PlayerInitialSpawn", "Spawn.Blacklist", function(ply)
//Debug
if ply.IsValid() and ply.IsPlayer() then
ply.bCantNail = true
end
if not file.Exists( "blacklisted_id.txt", "DATA" ) then
file.Write( "blacklisted_id.txt", "//Blacklisted players" )
end
local file = file.Read( "blacklisted_id.txt", "DATA" )
if string.find( file, ply:SteamID() ) then
ply.bCantNail = true
end
end )
function NailBlacklist(ply, time, callingply, reason)
if not file.Exists( "blacklisted_id.txt", "DATA" ) then
file.Write( "blacklisted_id.txt", "//Blacklisted Players/n" )
end
if ply:IsValid() and ply:IsPlayer() then
file.Append( "blacklisted_id.txt", "{Name="..ply:Nick()..",SteamID="..ply:SteamID()..",Time="..time..",Reason="..reason.."} blacklisted by "..callingply:Nick().."/n" )
end
end[/code]
autorun/sh_twistedzs.lua
[code]hook.Add( "CanRemoveNail", "CanRemoveNail.Blacklist", function(pl, nail)
if pl:IsValid() and pl:IsPlayer() and pl.bCantNail then
pl:PrintMessage( HUD_PRINTTALK, "Can't remove nail, you are blacklisted")
return false
end
end )
hook.Add( "CanPlaceNail", "CanPlaceNail.Blacklist", function(pl, tr)
if pl:IsValid() and pl:IsPlayer() and pl.bCantNail then
pl:PrintMessage( HUD_PRINTTALK, "Can't nail, you are blacklisted")
return false
end
end )[/code]
In your NailBlacklist function you are not setting bCantNail to true on the player.
[QUOTE=syl0r;45949885]In your NailBlacklist function you are not setting bCantNail to true on the player.[/QUOTE]
Yes I know this, bCantNail would be set from the vote function but currently as a debug I set it to true when the player spawns
NailBlacklist is currently unused until I can find out how to make a custom vote function for ULX and figure out how to call the function from it as I have no idea how to call functions that are within other lua files
[QUOTE=ForrestMarkX;45949929]Yes I know this, bCantNail would be set from the vote function but currently as a debug I set it to true when the player spawns[/QUOTE]
PlayerInitialSpawn is only called when the player spawns the first time. It should work after the blacklisted player rejoins.
Sorry, you need to Log In to post a reply to this thread.