Skip to content

Conversation

@aske02
Copy link
Contributor

@aske02 aske02 commented Jul 16, 2023

This implements some new features for the weapon extension.

It has some features mentioned in #2677 and some extra ones.

New Functions

entity:hasWeapon(string classname)

entity:clip1Size()

entity:setClip1(number amount)

entity:clip2Size()

entity:setClip2(number amount)

entity:giveWeapon(string classname)

entity:giveWeapon(string classname, number noAmmo)

entity:selectWeapon(string classname)

entity:giveAmmo(number amount, string type)

entity:giveAmmo(number amount, string type, number hidePopUp)

entity:setAmmo(number ammoCount, string type)

entity:removeAmmo(number ammoCount, string type)

entity:removeAllAmmo()

entity:stripWeapon(string classname)

entity:stripWeapons()

New Events

event weaponPickup(Weapon:entity, Owner:entity) {
    
}

event weaponSwitched(Player:entity, OldWeapon:entity, NewWeapon:entity) {
    
}

New Convars
wire_expression2_weapon_ammo_set_enable
wire_expression2_weapon_ammo_give_enable
wire_expression2_weapon_give_enable

@vurvdev
Copy link

vurvdev commented Jul 16, 2023

Feel like weaponEquipped should be weaponPickup instead, to not be confused with weaponSwitched.

As for permissions:

There definitely needs to be a convar for these functions, probably a separate one for each type of function:

  1. Ammo giving/setting, removing shouldn't need anything.
  2. Giving weapon

Also need to check if you WireLib.CanTool or E2Lib.isFriend with the target player for all of these functions.

For giving weapon also need to check https://wiki.facepunch.com/gmod/SANDBOX:PlayerGiveSWEP

Will do a more in depth review later

@aske02
Copy link
Contributor Author

aske02 commented Jul 16, 2023

My bad hadn't really thought about permissions.
They should be added now.

Copy link

@vurvdev vurvdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just need to fix the lints, check E2Lib.isFriend before CanTool and add convars to the functions I previously thought were fine to leave without any convars.

@aske02 aske02 requested a review from vurvdev July 26, 2023 22:10
Added check to stripWeapon to throw a runtime error in case the weapon class is invalid.

Changed logic for permissions to AND, so you could be either a friend or have cppi perms rather than needing both to access the functions.

Added check to the ammo functions to ensure the ammo type is valid, or else throw a runtime error

self.entity.player -> self.player

Changed invalid weapon error message for giveWeapon functions

Fix checkGive using incorrect variable (this) instead of (target)
@vurvdev vurvdev merged commit e92d489 into wiremod:master Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants