aboutsummaryrefslogtreecommitdiff
path: root/entities/weapons/hands.lua
blob: 1354941a31bdf5d43e0c3c2d6013ae5c37de72bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
AddCSLuaFile("hands.lua")

SWEP.ViewModel				= ""--"models/error.mdl"
SWEP.WorldModel				= ""--"models/error.mdl"

SWEP.HoldType 				= "normal"

SWEP.Primary.ClipSize       = -1
SWEP.Primary.DefaultClip    = -1
SWEP.Primary.Automatic      = true
SWEP.Primary.Ammo           = "none"

SWEP.Secondary.Clipsize    	= -1
SWEP.Secondary.DefaultClip  = -1
SWEP.Secondary.Automatic   	= false
SWEP.Secondary.Ammo         = "none"

SWEP.DrawAmmo				= false
SWEP.DrawCrosshair			= false

function SWEP:Initialize()
	self:SetWeaponHoldType(self.HoldType)
	self:DrawShadow(false)
	self:SetNoDraw(true)

	--[[
	if (CLIENT) then
		self.MOB = ClientsideModel("error.mdl")
		self.MOB:SetNoDraw(true)
		self.MOB:DrawShadow(false)
	end
	]]
end

function SWEP:ShouldDropOnDie()
	return false
end

function SWEP:PrimaryAttack()
	if CLIENT then return end
	
	--Make sure we have an equipment inventory
	if not self.Owner then return end
	if not self.Owner.data then return end
	if not self.Owner.data.inventories then return end
	if not self.Owner.data.inventories[1] then return end
	local eqpd = self.Owner.data.inventories[1]
	
	--Get the weapon we want to fire, and fire it!
	local weapon = eqpd:Get({"Left Hand"}) or eqpd:Get({"Dual"})
	if not weapon then return end --Make sure we have a weapon
	if weapon.onClick ~= nil then
		weapon:onClick(self.Owner)
	end
end

function SWEP:SecondaryAttack()
	if CLIENT then return end
	
	--Make sure we have an equipment inventory
	if not self.Owner then return end
	if not self.Owner.data then return end
	if not self.Owner.data.inventories then return end
	if not self.Owner.data.inventories[1] then return end
	local eqpd = self.Owner.data.inventories[1]
	
	--Get the weapon we want to fire, and fire it!
	local weapon = eqpd:Get({"Right Hand"}) or eqpd:Get({"Dual"})
	if not weapon then return end --Make sure we have a weapon
	if weapon.onClick ~= nil then
		weapon:onClick(self.Owner)
	end
end