Garry's Mod

Garry's Mod

149 ratings
[E2] WeaponCore
   
Award
Favorite
Favorited
Unfavorite
Content Type: Addon
Addon Type: Tool
Addon Tags: Build
File Size
Posted
Updated
12.309 KB
30 May, 2015 @ 12:45pm
13 Aug, 2023 @ 9:44am
6 Change Notes ( view )

Subscribe to download
[E2] WeaponCore

In 2 collections by Sir Papate
Marmottes.net
65 items
Expression 2 Core
5 items
Description
For more information, go to the GitHub Page[github.com]

WeaponCore

WeaponCore is an extension for the Expression 2[github.com] chip that allows you to manipulate weapons and ammo. It also allows you to run code when a player switches weapons or equips a weapon.

Workshop Installation

The WeaponCore is available on the Steam Workshop! Go to the WeaponCore Workshop Page and press
Subscribe
. For can go to the Expression 2 Core Collection for more extensions.

Manual Installation

Clone this repository into your
steamapps\common\GarrysMod\garrysmod\addons
folder using this command if you are using git:

Documentation

Console Commands

sbox_E2_WeaponCore_allow_all_users

If set to 1, all users will be able to use the WeaponCore on there prop protection friends or themselves. If set to 0, only admins will be able to use the WeaponCore.

default: 0

Events

Declaration
Replacing
event weaponSwitch(Player:entity, OldWeapon:entity, NewWeapon:entity)
runOnWeaponSwitch, weaponSwitchClk
Triggered when a player switches weapons.
event weaponEquip(Player:entity, Weapon:entity, OnSpawn:number)
runOnWeaponEquip, weaponEquipClk
Triggered when a player equips a weapon.
event weaponDrop(Player:entity, Weapon:entity)
Triggered when a player drops a weapon.

Tick Functions

Function
Return
Description
runOnWeaponSwitch(Activate:number)
void
If set to 1, the chip will be executed when the player switches weapons.
weaponSwitchClk()
number
Returns 1 if the player has switched weapons.
lastWeaponSwitchPlayer()
entity
Returns the player that switched weapons.
lastWeaponSwitchOld()
entity
Returns the weapon the player switched from.
lastWeaponSwitchNext()
entity
Returns the weapon the player switched to.
runOnWeaponEquip(Activate:number)
void
Is set to 1, E2 will run when a player equips a weapon.
weaponEquipClk()
number
Returns 1 if the E2 is run because of a weapon equip.
lastWeaponEquip()
entity
Returns the last equipped weapon.

Player Functions

Player functions are restricted to admins only.

Function
Return
Description
entity:plyGive(WeaponClass:string)
void
Give the player a weapon.
entity:plyGiveWeapon(WeaponClass:string)
void
Give the player a weapon.
entity:plyGiveAmmo(AmmoType:string, Amount:number)
void
Gives ammo to a player.
entity:plySetAmmo(AmmoType:string, Amount:number)
void
Sets the amount of of the specified ammo for the player.
entity:plySelectWeapon(WeaponClass:string)
void
Sets the player active weapon.
entity:plyDropWeapon(WeaponClass:string)
void
Drops the player's weapon of a specific class.
entity:plyDropWeapon(Weapon:entity)
void
Forces the player to drop the specified weapon.
entity:plyStripWeapon(WeaponClass:string)
void
Removes the specified weapon class from a certain player.
entity:plyStripWeapon(Weapon:entity)
void
Removes the specified weapon from a certain player
entity:plyStripWeapons()
void
Removes all weapons from a certain player
entity:plyStripAmmo()
void
Removes all ammo from the player.
entity:plySetClip1(Amount:number)
void
Lets you change the number of bullets in the given weapons primary clip.
entity:plySetClip2(Amount:number)
void
Lets you change the number of bullets in the given weapons secondary clip.

Getters

Function
Return
Description
entity:getWeapon(WeaponClass:string)
entity
Returns the weapon entity whit the class.
entity:getWeapons()
array
Returns a table of the player's weapons.
entity:hasWeapon(WeaponClass:string)
number
Returns if the player has the specified weapon.
Popular Discussions View All (4)
4
18 Oct, 2019 @ 9:04am
PINNED: Bug reports
Sir Papate
4
26 Apr, 2020 @ 5:09pm
PINNED: Documentation
Sir Papate
1
26 Jun, 2015 @ 10:20am
[E2 Code] Soap Guns
Sir Papate
9 Comments
Sanders 3 Mar @ 9:06am 
this doesnt work

@name
@inputs
@outputs
@persist
@trigger
@strict
interval(10)



E = owner()
TYPE = "Pulse Ammo"

E:plySetAmmo(TYPE,900)


i get the error sv: Expression 2 (generic): entities/gmod_wire_expression2/core/custom/weaponcore.lua:84: bad argument #2 to 'SetAmmo' (number expected, got function)


what am i doing wrong?
faɪkʰ 24 May, 2017 @ 1:12am 
Turns out I had to enable them in options....
Codingale 23 May, 2017 @ 4:56pm 
You have a few functions that are restricted for no reason and do not return empty arrays.

for example, ply:getWeapons() shouldn't be restricted to admins.. nor should hasWeapon
faɪkʰ 23 May, 2017 @ 1:15am 
I am having trouble getting any commands to work, E2 says they dont exist? tips?

GreyGhost 27 Jan, 2016 @ 7:44pm 
Thank you!!!!!
Link117 18 Nov, 2015 @ 1:04pm 
what does it do i am a bite confuse :squirtheh:
Jedimaster127 31 Oct, 2015 @ 3:34pm 
What does it do?
Rubicon 12 Oct, 2015 @ 12:37am 
YES!
X 1 Aug, 2015 @ 11:20pm 
what does it do?