Garry's Mod

Garry's Mod

Half-Life Co-op: Infected
 This topic has been pinned, so it's probably important
upset  [developer] 8 Nov, 2020 @ 3:48am
Adding custom weapons to Weapon Shop
There is ability for server owners to use custom weapons that players can buy for score.

How to
Create a .lua file with any name (let it be inf_weapons.lua) in garrysmod/lua/autorun and add following code:
local weplist = { ["weapon_class_name"] = {cost = SCORE, name = "Your Weapon Name", ammocost = SCORE_AMMO}, ["weapon_class_name"] = {cost = SCORE, name = "Your Weapon Name", ammocost = SCORE_AMMO}, } hook.Add("HL1_WeaponShop_CustomWeapons", "InfectedWeapons", function() return weplist end)
Replace "weapon_class_name" with your weapon class name, e.g. "weapon_q2_bfg10k"
SCORE is how much score is needed to buy it, e.g. 1500
"Your Weapon Name" is weapon name to show in the shop
SCORE_AMMO is required score for buying ammo, e.g. 100

Example
local weplist = { ["weapon_cs16_deagle"] = {cost = 300, name = "Desert Eagle", ammocost = 50}, ["weapon_q2_bfg10k"] = {cost = 4000, name = "BFG10K", ammocost = 400}, ["weapon_q3_railgun"] = {cost = 3000, name = "Railgun", ammocost = 150}, } hook.Add("HL1_WeaponShop_CustomWeapons", "InfectedWeapons", function() return weplist end)
Last edited by upset; 10 Nov, 2020 @ 1:32pm
< >
Showing 1-6 of 6 comments
Eclipse 1 Apr, 2021 @ 6:48pm 
is there a way you could do this in console?
upset  [developer] 1 Apr, 2021 @ 11:51pm 
nope
rabbitfart39 31 Jan, 2023 @ 7:53pm 
will you make a tutorial to make a custom map?
mrkirill405 ✓ 1 Dec, 2024 @ 2:00pm 
A bug with getting ammo for custom
[Half-Life Co-op: Infected] gamemodes/hl1coop_infected/gamemode/cl_menus.lua:366: attempt to perform arithmetic on field 'MaxAmmo' (a nil value)
1. unknown - gamemodes/hl1coop_infected/gamemode/cl_menus.lua:366 (x102)
Please reply, issue still remains (
< >
Showing 1-6 of 6 comments
Per page: 1530 50