-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsh_arc9.lua
154 lines (145 loc) · 6.38 KB
/
sh_arc9.lua
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
PLUGIN.name = "ARC9 Compatibility"
PLUGIN.author = "FoxxoTrystan"
PLUGIN.description = "ARC9 Compatibility for the HELIX Gamemode."
if (ARC9) then
--// CONFIG
if (ix.plugin.Get("persistent_corpses")) then
ix.config.Add("DropWeaponsOnDeath", false, "Drop Weapons on death.", nil, {
category = PLUGIN.name
})
ix.config.Add("DropAttachementsOnDeath", false, "Drop Attachements on death.", nil, {
category = PLUGIN.name
})
end
--// CLIENT
if(CLIENT) then
GetConVar("arc9_hud_arc9"):SetInt(0)
GetConVar("arc9_cross_enable"):SetInt(0)
end
--// HOOKS
--// Attachements PostPlayerLoadout
function PLUGIN:PostPlayerLoadout(client)
client.ARC9_AttInv = {}
for i,v in pairs(client:GetCharacter():GetInventory():GetItems()) do
if v.category == "Attachements" then
ARC9:PlayerGiveAtt(client, v.att)
ARC9:PlayerSendAttInv(client)
end
end
end
--// ARC9RemoveGrenade
GrenadeClass = {}
hook.Add("EntityRemoved", "ARC9RemoveGrenade", function(entity)
if (GrenadeClass[entity:GetClass()]) then
local client = entity:GetOwner()
if (IsValid(client) and client:IsPlayer() and client:GetCharacter()) then
local ammoName = game.GetAmmoName(entity:GetPrimaryAmmoType())
if (isstring(ammoName) and client:GetAmmoCount(ammoName) < 1
and entity.ixItem and entity.ixItem.Unequip) then
entity.ixItem:Unequip(client, false, true)
end
end
end
end)
end
function PLUGIN:InitializedPlugins()
if (!ARC9) then
return print("// ARC9 Compatibility - Cant find ARC9 Addon! //")
else
if (SERVER) then
ARC9.NoHUD = true
GetConVar("arc9_free_atts"):SetInt(0)
GetConVar("arc9_atts_lock"):SetInt(0)
end
print("// ARC9 Compatibility - Loading Weapons... //")
for i,v in pairs(weapons.GetList()) do
if weapons.IsBasedOn(v.ClassName, "arc9_base") then
ALWAYS_RAISED[v.ClassName] = true
local ITEM = ix.item.Register(v.ClassName, "base_weapons", false, nil, true)
ITEM.name = v.PrintName
ITEM.description = v.Description or nil
ITEM.model = v.WorldModel
ITEM.class = v.ClassName
ITEM.width = 3
ITEM.height = 2
ITEM.category = "Weapons"
ITEM.weaponCategory = "Primary"
ITEM.bDropOnDeath = ix.config.Get("DropWeaponsOnDeath", false)
if (v.Throwable) then
ITEM.weaponCategory = "Throwable"
ITEM.width = 1
ITEM.height = 1
ITEM.isGrenade = true
GrenadeClass[v.ClassName] = true
elseif (v.NotAWeapon) then
ITEM.width = 1
ITEM.height = 1
elseif (v.PrimaryBash) then
ITEM.weaponCategory = "Melee"
ITEM.width = 1
ITEM.height = 2
elseif (v.HoldType == "pistol" or v.HoldType == "revolver") then
ITEM.weaponCategory = "Secondary"
ITEM.width = 2
ITEM.height = 1
end
function ITEM:GetDescription()
return self.description
end
--// TBD WEAPON REMOVED FROM INV NEED TO REMOVE ATTACHEMENT (Return attachement from removed weapons)
function ITEM:OnTransferred(oldInventory)
end
print("ARC9 Compatibility - "..v.ClassName.." Loaded!")
end
end
print("// ARC9 Compatibility - All Weapons Loaded! //")
print("// ARC9 Compatibility - Loading Attachments... //")
for i,v in pairs(ARC9.Attachments) do
if (!i.Free) then
local ITEM = ix.item.Register(i, nil, false, nil, true)
ITEM.name = v.PrintName
ITEM.description = "A weapon attachement."
ITEM.model = v.Model or "models/items/arc9/att_plastic_box.mdl"
ITEM.width = 1
ITEM.height = 1
ITEM.att = i
ITEM.category = "Attachements"
ITEM.bDropOnDeath = ix.config.Get("DropAttachementsOnDeath", false)
function ITEM:GetDescription()
return self.description
end
--// TBD CREATED IN INV
function ITEM:OnTransferred(oldInventory, newInventory)
if (oldInventory and isfunction(oldInventory.GetOwner)) then
if (IsValid(oldInventory:GetOwner())) then
for _,v in pairs(oldInventory:GetOwner():GetWeapons()) do
if(v.Attachments) then
for i,s in pairs(v.Attachments) do
if(s.Installed == ITEM.att) then
v:DetachAllFromSubSlot(i, false)
v:SendWeapon()
v:PostModify()
ARC9:PlayerGiveAtt(oldInventory:GetOwner(), ITEM.att)
end
end
end
end
ARC9:PlayerTakeAtt(oldInventory:GetOwner(), ITEM.att)
ARC9:PlayerSendAttInv(oldInventory:GetOwner())
end
end
if (newInventory and isfunction(newInventory.GetOwner)) then
if (IsValid(newInventory:GetOwner())) then
ARC9:PlayerGiveAtt(newInventory:GetOwner(), ITEM.att)
ARC9:PlayerSendAttInv(newInventory:GetOwner())
end
end
return true
end
print("// ARC9 Compatibility - "..i.." Loaded! //")
end
end
print("// ARC9 Compatibility - All Attachments Loaded! //")
end
print("// ARC9 Compatibility - Has finished loading! //")
end