diff --git a/lua/weapons/glide_instant_repair.lua b/lua/weapons/glide_instant_repair.lua deleted file mode 100644 index 811852b7..00000000 --- a/lua/weapons/glide_instant_repair.lua +++ /dev/null @@ -1,54 +0,0 @@ -SWEP.Base = "glide_repair" - -SWEP.PrintName = "#glide.swep.instant_repair" -SWEP.Instructions = "#glide.swep.repair.desc" -SWEP.Author = "StyledStrike" -SWEP.Category = "Glide" - -SWEP.Slot = 0 -SWEP.Spawnable = true -SWEP.AdminOnly = true - -if CLIENT then - SWEP.WepSelectIcon = surface.GetTextureID( "glide/vgui/glide_repair_wrench_icon" ) - SWEP.IconOverride = "glide/vgui/glide_repair_wrench_admin.png" -end - -function SWEP:PrimaryAttack() - local user = self:GetOwner() - if not IsValid( user ) then return end - - self:SetNextPrimaryFire( CurTime() + 0.1 ) - - if not SERVER then return end - - local ent = self.repairTarget - if not ent then return end - - local wasHealthIncreased, hasFinished = Glide.PartialRepair( ent, 99999, 1.0 ) - - if wasHealthIncreased then - if user.ViewPunch then - user:ViewPunch( Angle( -5, 0, 0 ) ) - end - - self:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) - user:SetAnimation( PLAYER_ATTACK1 ) - - local trace = self.repairTrace - - if trace then - local data = EffectData() - data:SetOrigin( trace.HitPos + trace.HitNormal * 5 ) - data:SetNormal( trace.HitNormal ) - data:SetScale( 1 ) - data:SetMagnitude( 1 ) - data:SetRadius( 10 ) - util.Effect( "cball_bounce", data, false, true ) - end - end - - if hasFinished then - user:EmitSound( "buttons/lever6.wav", 75, math.random( 70, 80 ), 0.5 ) - end -end diff --git a/lua/weapons/glide_repair.lua b/lua/weapons/glide_repair.lua index 94937faa..422e51dd 100644 --- a/lua/weapons/glide_repair.lua +++ b/lua/weapons/glide_repair.lua @@ -125,6 +125,76 @@ end function SWEP:SecondaryAttack() end +hook.Add( "InitPostEntity", "GLide_RepairSWEP::CAMI", function() + if not CAMI or not CAMI.RegisterPrivilege then return end + + CAMI.RegisterPrivilege( { + Name = "GLide::RepairSWEP", + MinAccess = "admin" + } ) +end ) + +local IS_SINGLEPLAYER = game.SinglePlayer() +local function IsAccess( ply, veh ) + if IS_SINGLEPLAYER then + return true + end + + if not CAMI or not CAMI.PlayerHasAccess then + return ply:IsAdmin() + elseif CAMI.PlayerHasAccess( ply, "GLide::RepairSWEP" ) then + return true + end + + local Access = hook.Run( "GLide_RepairSWEP::CanAccess", ply, veh ) + if Access == nil then + return false + end + + return false +end + +function SWEP:Reload() + local user = self:GetOwner() + if not IsValid( user ) then return end + + self:SetNextPrimaryFire( CurTime() + 0.1 ) + + if not SERVER then return end + + local ent = self.repairTarget + if not ent then return end + + if not IsAccess( user, ent ) then return end + + local wasHealthIncreased, hasFinished = Glide.PartialRepair( ent, 99999, 1.0 ) + + if wasHealthIncreased then + if user.ViewPunch then + user:ViewPunch( Angle( -5, 0, 0 ) ) + end + + self:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) + user:SetAnimation( PLAYER_ATTACK1 ) + + local trace = self.repairTrace + + if trace then + local data = EffectData() + data:SetOrigin( trace.HitPos + trace.HitNormal * 5 ) + data:SetNormal( trace.HitNormal ) + data:SetScale( 1 ) + data:SetMagnitude( 1 ) + data:SetRadius( 10 ) + util.Effect( "cball_bounce", data, false, true ) + end + end + + if hasFinished then + user:EmitSound( "buttons/lever6.wav", 75, math.random( 70, 80 ), 0.5 ) + end +end + if not CLIENT then return end function SWEP:DrawHUD() diff --git a/materials/glide/vgui/glide_repair_wrench_admin.png b/materials/glide/vgui/glide_repair_wrench_admin.png deleted file mode 100644 index 8d803b1c..00000000 Binary files a/materials/glide/vgui/glide_repair_wrench_admin.png and /dev/null differ