• Door charges but doors doesnt respawn
    6 replies, posted
Hello, i have the mad cow door charges on my server but when i try to blow up a door it works but the door doesnt respawn after a few minutes. is it only me or are there more and how do i fix that? Code below: this is the shared.lua but i deleted the first part of it that is not important for this case [CODE] /*--------------------------------------------------------- Name: SWEP:Precache() Desc: Use this function to precache stuff. ---------------------------------------------------------*/ function SWEP:Precache() util.PrecacheSound("weapons/c4/c4_disarm.wav") util.PrecacheSound("weapons/c4/c4_explode1.wav") util.PrecacheSound("weapons/c4/c4_click.wav") util.PrecacheSound("weapons/c4/c4_plant.wav") util.PrecacheSound("weapons/c4/c4_beep1.wav") end /*--------------------------------------------------------- Name: SWEP:PrimaryAttack() Desc: +attack1 has been pressed. ---------------------------------------------------------*/ function SWEP:PrimaryAttack() // Holst/Deploy your fucking weapon if (not self.Owner:IsNPC() and self.Owner:KeyDown(IN_USE)) then bHolsted = !self.Weapon:GetDTBool(0) self:SetHolsted(bHolsted) self.Weapon:SetNextPrimaryFire(CurTime() + 0.3) self.Weapon:SetNextSecondaryFire(CurTime() + 0.3) self:SetIronsights(false) return end /* if self.Weapon:GetNWBool("Planted") then self.Weapon:SendWeaponAnim(ACT_SLAM_DETONATOR_DETONATE) self.Weapon:EmitSound("Streetwar.d3_c17_10b_mine_mode") for k, ent in pairs(ents.GetAll()) do if ent:GetClass() == "ent_mad_charge" and ent.Owner == self.Owner then timer.Simple(1, function() ent:Explosion() ent:Remove() end) self.Weapon:SendWeaponAnim(ACT_SLAM_DETONATOR_DETONATE) end end self.Weapon:SetNextPrimaryFire(CurTime() + 2) self.Weapon:SetNextSecondaryFire(CurTime() + 2) self.Weapon:SetNWBool("Planted", false) timer.Simple(0.5, function() self.Weapon:SendWeaponAnim(ACT_SLAM_DETONATOR_HOLSTER) end) timer.Simple(1, function() if self.Owner:GetAmmoCount(self.Primary.Ammo) > 0 then self:Deploy() else self.Weapon:Remove() self.Owner:ConCommand("lastinv") end end) return end */ if (not self:CanPrimaryAttack()) then return end local tr = {} tr.start = self.Owner:GetShootPos() tr.endpos = self.Owner:GetShootPos() + 100 * self.Owner:GetAimVector() tr.filter = {self.Owner} local trace = util.TraceLine(tr) self.Weapon:SetNextPrimaryFire(CurTime() + 0.5) self.Weapon:SetNextSecondaryFire(CurTime() + 0.5) if not trace.Hit or trace.Entity:GetClass() ~= "prop_door_rotating" or trace.HitWorld then if (SERVER) then self.Owner:PrintMessage(HUD_PRINTTALK, "Explosive charge can only be installed on doors!") end return end self.Weapon:SetNextPrimaryFire(CurTime() + self.Primary.Delay) self.Weapon:SetNextSecondaryFire(CurTime() + self.Primary.Delay) self.Weapon:SendWeaponAnim(ACT_SLAM_TRIPMINE_ATTACH) timer.Simple(0.5, function() if (not self.Owner:Alive() or self.Weapon:GetOwner():GetActiveWeapon():GetClass() ~= "weapon_mad_charge" or not IsFirstTimePredicted()) then return end self.Weapon:SendWeaponAnim(ACT_SLAM_TRIPMINE_ATTACH2) local tr = {} tr.start = self.Owner:GetShootPos() tr.endpos = self.Owner:GetShootPos() + 100 * self.Owner:GetAimVector() tr.filter = {self.Owner} local trace = util.TraceLine(tr) if not trace.Hit or trace.Entity:GetClass() ~= "prop_door_rotating" or trace.HitWorld then timer.Simple(0.6, function() if self.Owner:GetAmmoCount(self.Primary.Ammo) > 0 then self:Deploy() else self.Weapon:Remove() self.Owner:ConCommand("lastinv") end end) return end self.Owner:SetAnimation(PLAYER_ATTACK1) self:TakePrimaryAmmo(1) if (CLIENT) then return end Charge = ents.Create("ent_mad_charge") Charge:SetPos(trace.HitPos + trace.HitNormal) trace.HitNormal.z = -trace.HitNormal.z Charge:SetAngles(trace.HitNormal:Angle() - Angle(270, 180, 180)) Charge.Owner = self.Owner Charge:Spawn() if trace.Entity and trace.Entity:IsValid() and trace.Entity:GetClass() == "prop_door_rotating" then if not trace.Entity:IsNPC() and not trace.Entity:IsPlayer() and trace.Entity:GetPhysicsObject():IsValid() then constraint.Weld(Charge, trace.Entity) end else Charge:SetMoveType(MOVETYPE_NONE) end timer.Simple(0.6, function() if (not self.Owner:Alive() or self.Weapon:GetOwner():GetActiveWeapon():GetClass() ~= "weapon_mad_charge") or not IsFirstTimePredicted() then return end // self.Weapon:SetNWBool("Planted", true) self:Deploy() end) end) end /*--------------------------------------------------------- Name: SWEP:SecondaryAttack() Desc: +attack2 has been pressed. ---------------------------------------------------------*/ function SWEP:SecondaryAttack() end /*--------------------------------------------------------- Name: SWEP:CanPrimaryAttack() Desc: Helper function for checking for no ammo. ---------------------------------------------------------*/ function SWEP:CanPrimaryAttack() if (self.Owner:GetAmmoCount(self.Primary.Ammo) <= 0) or (self.Owner:WaterLevel() > 2) then self.Weapon:SetNextPrimaryFire(CurTime() + 0.5) return false end if (not self.Owner:IsNPC()) and (self.Owner:KeyDown(IN_SPEED)) then self.Weapon:SetNextPrimaryFire(CurTime() + 0.5) return false end return true end /*--------------------------------------------------------- Name: SWEP:Deploy() Desc: Whip it out. ---------------------------------------------------------*/ function SWEP:Deploy() // if self.Weapon:GetNWBool("Planted") then // self.Weapon:SendWeaponAnim(ACT_SLAM_DETONATOR_DRAW) // else self.Weapon:SendWeaponAnim(ACT_SLAM_TRIPMINE_DRAW) // end self.Weapon:SetNextPrimaryFire(CurTime() + self.DeployDelay) self.Weapon:SetNextSecondaryFire(CurTime() + self.DeployDelay) self.ActionDelay = (CurTime() + self.DeployDelay) return true end /*--------------------------------------------------------- Name: SWEP:Holster() ---------------------------------------------------------*/ function SWEP:Holster() if (CLIENT) and self.Ghost:IsValid() then self.Ghost:SetColor(255, 255, 255, 0) end return true end /*--------------------------------------------------------- Name: SWEP:OnRemove() Desc: Called just before entity is deleted. ---------------------------------------------------------*/ function SWEP:OnRemove() if (CLIENT) and self.Ghost:IsValid() then self.Ghost:SetColor(255, 255, 255, 0) end return true end[/CODE] Iam sorry for the huge code but i dont know what part i need :/ I hope someone can help me with this. Rickyboy12367
The SWEP isn't supposed to spawn a door back after a while...
but is it possible to make it that the doors respawn after 2 minutes or something?
[QUOTE=The Android1;39914691]The SWEP isn't supposed to spawn a door back after a while...[/QUOTE] I've played with Mad Cows before and in both singleplayer and multiplayer (pre-gmod13) the doors respawned after being shot off or breached. As of now, though, they don't respawn and the door stays off.
This is late but the problem code actually exists in ent_mad_charge/init.lua Here is the section we are talking about at line 59 of the file. [LUA] for k, v in pairs(doorentities) do if IsValid(v) and v:GetClass() == "prop_door_rotating" then v:Fire("open", "", 0.1) v:Fire("unlock", "", 0.1) local pos = v:GetPos() local ang = v:GetAngles() local model = v:GetModel() local skin = v:GetSkin() v:SetNotSolid(true) v:SetNoDraw(true) //local function ResetDoor(door, fakedoor) // door:SetNotSolid(false) // door:SetNoDraw(false) // fakedoor:Remove() //end local norm = pos - (self.Entity:GetPos() + self.Entity:GetRight() * 100 + self.Entity:GetUp() * 400) if norm.z < 0 then norm.z = 0 end norm:Normalize() local push = 40000 * norm local ent = ents.Create("prop_physics") ent:SetPos(pos) ent:SetAngles(ang) ent:SetModel(model) if(skin) then ent:SetSkin(skin) end ent:Spawn() //timer.Simple(0.01, ent.SetVelocity, ent, push) //timer.Simple(0.01, ent:GetPhysicsObject().ApplyForceCenter, ent:GetPhysicsObject(), push) //timer.Simple(25, ResetDoor, v, ent) end end [/LUA] Now dont get me wrong. I'm not offering a fix, I'm just pointing out I have the same issue, and I know where its coming from, but I cant fix it. I figured that the last timer and its matching function are responsible for "Respawning" the door, so given it looked alright to me, I just uncommented it... ... to get something like this... [code] Lua Error: [ERROR] addons/mad cows weapons/lua/entities/ent_mad_charge/init.lua:73: attempt to index local 'door' (a nil value) 1. unknown - addons/mad cows weapons/lua/entities/ent_mad_charge/init.lua:73 [/code] So i tried storing the value of V for later use, I even tried moving the function etc but nothing worked. My only other idea is to have a seperate entity that does a map wide search for doors, ensures all are set to visible, and drawn... however every possible implementation of this that i can think of results in an infinite loop, a half job (respawn doors but the fake doors remain) or just doesnt work at all.
change [code]timer.Simple(25, ResetDoor, v, ent)[/code] to [code]timer.Simple(25, function() ResetDoor(v,ent) end)[/code] then try. dunno if it will do much but it may help.
Thank you sir, that has fixed my issue and probably the same issue thousands of servers using this pack have been having. Applause.
Sorry, you need to Log In to post a reply to this thread.