|
| 1 | +PLUGIN.name = "ARC9 Compatibility" |
| 2 | +PLUGIN.author = "FoxxoTrystan" |
| 3 | +PLUGIN.description = "ARC9 Compatibility for the HELIX Gamemode." |
| 4 | + |
| 5 | +if (ARC9) then |
| 6 | + --// CONFIG |
| 7 | + if (ix.plugin.Get("persistent_corpses")) then |
| 8 | + ix.config.Add("DropWeaponsOnDeath", false, "Drop Weapons on death.", nil, { |
| 9 | + category = PLUGIN.name |
| 10 | + }) |
| 11 | + |
| 12 | + ix.config.Add("DropAttachementsOnDeath", false, "Drop Attachements on death.", nil, { |
| 13 | + category = PLUGIN.name |
| 14 | + }) |
| 15 | + end |
| 16 | + |
| 17 | + --// CLIENT |
| 18 | + if(CLIENT) then |
| 19 | + GetConVar("arc9_hud_arc9"):SetInt(0) |
| 20 | + GetConVar("arc9_cross_enable"):SetInt(0) |
| 21 | + end |
| 22 | + |
| 23 | + --// HOOKS |
| 24 | + --// Attachements PostPlayerLoadout |
| 25 | + function PLUGIN:PostPlayerLoadout(client) |
| 26 | + client.ARC9_AttInv = {} |
| 27 | + |
| 28 | + for i,v in pairs(client:GetCharacter():GetInventory():GetItems()) do |
| 29 | + if v.category == "Attachements" then |
| 30 | + ARC9:PlayerGiveAtt(client, v.att) |
| 31 | + ARC9:PlayerSendAttInv(client) |
| 32 | + end |
| 33 | + end |
| 34 | + end |
| 35 | + |
| 36 | + --// ARC9RemoveGrenade |
| 37 | + GrenadeClass = {} |
| 38 | + hook.Add("EntityRemoved", "ARC9RemoveGrenade", function(entity) |
| 39 | + if (GrenadeClass[entity:GetClass()]) then |
| 40 | + local client = entity:GetOwner() |
| 41 | + if (IsValid(client) and client:IsPlayer() and client:GetCharacter()) then |
| 42 | + local ammoName = game.GetAmmoName(entity:GetPrimaryAmmoType()) |
| 43 | + if (isstring(ammoName) and client:GetAmmoCount(ammoName) < 1 |
| 44 | + and entity.ixItem and entity.ixItem.Unequip) then |
| 45 | + entity.ixItem:Unequip(client, false, true) |
| 46 | + end |
| 47 | + end |
| 48 | + end |
| 49 | + end) |
| 50 | +end |
| 51 | + |
| 52 | +function PLUGIN:InitializedPlugins() |
| 53 | + if (!ARC9) then |
| 54 | + return print("// ARC9 Compatibility - Cant find ARC9 Addon! //") |
| 55 | + else |
| 56 | + if (SERVER) then |
| 57 | + ARC9.NoHUD = true |
| 58 | + GetConVar("arc9_free_atts"):SetInt(0) |
| 59 | + GetConVar("arc9_atts_lock"):SetInt(0) |
| 60 | + end |
| 61 | + print("// ARC9 Compatibility - Loading Weapons... //") |
| 62 | + for i,v in pairs(weapons.GetList()) do |
| 63 | + if weapons.IsBasedOn(v.ClassName, "arc9_base") then |
| 64 | + ALWAYS_RAISED[v.ClassName] = true |
| 65 | + local ITEM = ix.item.Register(v.ClassName, "base_weapons", false, nil, true) |
| 66 | + ITEM.name = v.PrintName |
| 67 | + ITEM.description = v.Description or nil |
| 68 | + ITEM.model = v.WorldModel |
| 69 | + ITEM.class = v.ClassName |
| 70 | + ITEM.width = 3 |
| 71 | + ITEM.height = 2 |
| 72 | + ITEM.category = "Weapons" |
| 73 | + ITEM.weaponCategory = "Primary" |
| 74 | + ITEM.bDropOnDeath = ix.config.Get("DropWeaponsOnDeath", false) |
| 75 | + if (v.Throwable) then |
| 76 | + ITEM.weaponCategory = "Throwable" |
| 77 | + ITEM.width = 1 |
| 78 | + ITEM.height = 1 |
| 79 | + ITEM.isGrenade = true |
| 80 | + GrenadeClass[v.ClassName] = true |
| 81 | + elseif (v.NotAWeapon) then |
| 82 | + ITEM.width = 1 |
| 83 | + ITEM.height = 1 |
| 84 | + elseif (v.PrimaryBash) then |
| 85 | + ITEM.weaponCategory = "Melee" |
| 86 | + ITEM.width = 1 |
| 87 | + ITEM.height = 2 |
| 88 | + elseif (v.HoldType == "pistol" or v.HoldType == "revolver") then |
| 89 | + ITEM.weaponCategory = "Secondary" |
| 90 | + ITEM.width = 2 |
| 91 | + ITEM.height = 1 |
| 92 | + end |
| 93 | + function ITEM:GetDescription() |
| 94 | + return self.description |
| 95 | + end |
| 96 | + --// TBD WEAPON REMOVED FROM INV NEED TO REMOVE ATTACHEMENT (Return attachement from removed weapons) |
| 97 | + function ITEM:OnTransferred(oldInventory) |
| 98 | + |
| 99 | + end |
| 100 | + print("ARC9 Compatibility - "..v.ClassName.." Loaded!") |
| 101 | + end |
| 102 | + end |
| 103 | + print("// ARC9 Compatibility - All Weapons Loaded! //") |
| 104 | + print("// ARC9 Compatibility - Loading Attachments... //") |
| 105 | + for i,v in pairs(ARC9.Attachments) do |
| 106 | + if (!i.Free) then |
| 107 | + local ITEM = ix.item.Register(i, nil, false, nil, true) |
| 108 | + ITEM.name = v.PrintName |
| 109 | + ITEM.description = "A weapon attachement." |
| 110 | + ITEM.model = v.Model or "models/items/arc9/att_plastic_box.mdl" |
| 111 | + ITEM.width = 1 |
| 112 | + ITEM.height = 1 |
| 113 | + ITEM.att = i |
| 114 | + ITEM.category = "Attachements" |
| 115 | + ITEM.bDropOnDeath = ix.config.Get("DropAttachementsOnDeath", false) |
| 116 | + function ITEM:GetDescription() |
| 117 | + return self.description |
| 118 | + end |
| 119 | + --// TBD CREATED IN INV |
| 120 | + function ITEM:OnTransferred(oldInventory, newInventory) |
| 121 | + if (oldInventory and isfunction(oldInventory.GetOwner)) then |
| 122 | + if (IsValid(oldInventory:GetOwner())) then |
| 123 | + for _,v in pairs(oldInventory:GetOwner():GetWeapons()) do |
| 124 | + if(v.Attachments) then |
| 125 | + for i,s in pairs(v.Attachments) do |
| 126 | + if(s.Installed == ITEM.att) then |
| 127 | + v:DetachAllFromSubSlot(i, false) |
| 128 | + v:SendWeapon() |
| 129 | + v:PostModify() |
| 130 | + ARC9:PlayerGiveAtt(oldInventory:GetOwner(), ITEM.att) |
| 131 | + end |
| 132 | + end |
| 133 | + end |
| 134 | + end |
| 135 | + ARC9:PlayerTakeAtt(oldInventory:GetOwner(), ITEM.att) |
| 136 | + ARC9:PlayerSendAttInv(oldInventory:GetOwner()) |
| 137 | + end |
| 138 | + end |
| 139 | + |
| 140 | + if (newInventory and isfunction(newInventory.GetOwner)) then |
| 141 | + if (IsValid(newInventory:GetOwner())) then |
| 142 | + ARC9:PlayerGiveAtt(newInventory:GetOwner(), ITEM.att) |
| 143 | + ARC9:PlayerSendAttInv(newInventory:GetOwner()) |
| 144 | + end |
| 145 | + end |
| 146 | + return true |
| 147 | + end |
| 148 | + print("// ARC9 Compatibility - "..i.." Loaded! //") |
| 149 | + end |
| 150 | + end |
| 151 | + print("// ARC9 Compatibility - All Attachments Loaded! //") |
| 152 | + end |
| 153 | + print("// ARC9 Compatibility - Has finished loading! //") |
| 154 | +end |
0 commit comments