dobrograd-13-06-2022/garrysmod/addons/gmod-tools/lua/weapons/keypad_cracker/init.lua
Jonny_Bro (Nikita) e4d5311906 first commit
2023-11-16 15:01:19 +05:00

29 lines
809 B
Lua

AddCSLuaFile('shared.lua')
AddCSLuaFile('cl_init.lua')
include('shared.lua')
function SWEP:PrimaryAttack()
self:SetNextPrimaryFire(CurTime() + 0.4)
if not IsValid(self.Owner) or self.Owner.hacking then return end
local ent = self.Owner:GetEyeTrace().Entity
if not IsValid(ent) or not ent.IsKeypad then return end
if ent:GetPos():DistToSqr(self.Owner:GetShootPos()) > 2500 then return end
if ent:CPPIGetOwner() == self.Owner then return end
self:SetHoldType('pistol')
self.Owner:Hack(ent, function()
local vPoint = ent:GetPos()
local effect = EffectData()
effect:SetStart(vPoint)
effect:SetOrigin(vPoint)
effect:SetEntity(ent)
util.Effect('sparks_manhack', effect)
ent:EmitSound('buttons/combine_button7.wav', 70)
end, nil, function()
self:SetHoldType(self.IdleStance)
end)
end