Skip to content

Commit

Permalink
Merge Master branch updates into Experimental Branch (#84)
Browse files Browse the repository at this point in the history
* Update CHANGELOG.md

* Fix Weapon SetClipErrors (#76)

* fix: result isn't used in this context.

* fix: the docs say ply, we use ply.

* perf: we don't need to call that twice.

* fix: printname isn't a name, it's class. localise class.

* fix: fix weapon error if not given.

replace printname with class.
only call getweapon if we can't get it through give.

* fix: Make sure SetClip1 and SetClip2 actually exist before we call them.

* WTF (#63)

* Update CHANGELOG.md

* Update ulib.build

* Update addon.txt

* Update defines.lua

Co-authored-by: Joshua Piper <[email protected]>
Co-authored-by: Deyvan <[email protected]>
  • Loading branch information
3 people authored Aug 5, 2022
1 parent d325fc7 commit 8f86a5a
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 27 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# ULib Changelog

## v2.71 - *(00/00/0000)*
* [FIX] Fixed some issues in player.lua with SetClip errors. (Thanks, JoshPiper)
* [FIX] Cleaned up some code in player.lua to be more aligned with our docs. (Thanks, JoshPiper)
* [FIX] Added returns to some fallback functions in sh_ucl.lua (Thanks, Deyvan)

## v2.70 - *(08/04/2022)*
* [ADD] Hook when a new, previously unknown access is registered. UCLChanged is now called as well.
* [CHANGE] Moved bans to SQLite.
Expand Down
2 changes: 1 addition & 1 deletion addon.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"AddonInfo"
{
"name" "ULib"
"version" "2.63d"
"version" "2.71"
"up_date" "00/00/00"
"author_name" "Team Ulysses"
"author_email" "[email protected]"
Expand Down
56 changes: 34 additions & 22 deletions lua/ulib/server/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -207,26 +207,27 @@ end
Updates player object to store health and armor. Has no effect unless ULib.Spawn is used later.
]]
function ULib.getSpawnInfo( player )
local result = {}

function ULib.getSpawnInfo( ply )
local t = {}
player.ULibSpawnInfo = t
t.health = player:Health()
t.armor = player:Armor()
if player:GetActiveWeapon():IsValid() then
t.curweapon = player:GetActiveWeapon():GetClass()
ply.ULibSpawnInfo = t

t.health = ply:Health()
t.armor = ply:Armor()

local wep = ply:GetActiveWeapon()
if IsValid( wep ) then
t.curweapon = wep:GetClass()
end

local weapons = player:GetWeapons()
local data = {}
local weapons = ply:GetWeapons()
for _, weapon in ipairs( weapons ) do
printname = weapon:GetClass()
data[ printname ] = {}
data[ printname ].clip1 = weapon:Clip1()
data[ printname ].clip2 = weapon:Clip2()
data[ printname ].ammo1 = player:GetAmmoCount( weapon:GetPrimaryAmmoType() )
data[ printname ].ammo2 = player:GetAmmoCount( weapon:GetSecondaryAmmoType() )
local class = weapon:GetClass()
data[ class ] = {}
data[ class ].clip1 = weapon:Clip1()
data[ class ].clip2 = weapon:Clip2()
data[ class ].ammo1 = ply:GetAmmoCount( weapon:GetPrimaryAmmoType() )
data[ class ].ammo2 = ply:GetAmmoCount( weapon:GetSecondaryAmmoType() )
end
t.data = data
end
Expand All @@ -238,13 +239,24 @@ local function doWeapons( player, t )
player:StripAmmo()
player:StripWeapons()

for printname, data in pairs( t.data ) do
player:Give( printname )
local weapon = player:GetWeapon( printname )
weapon:SetClip1( data.clip1 )
weapon:SetClip2( data.clip2 )
player:SetAmmo( data.ammo1, weapon:GetPrimaryAmmoType() )
player:SetAmmo( data.ammo2, weapon:GetSecondaryAmmoType() )
for class, data in pairs( t.data ) do
local weapon = player:Give( class )
if not IsValid( weapon ) then
weapon = player:GetWeapon( class )
end

if IsValid( weapon ) then
if weapon.SetClip1 then
weapon:SetClip1( data.clip1 )
end

if weapon.SetClip2 then
weapon:SetClip2( data.clip2 )
end

player:SetAmmo( data.ammo1, weapon:GetPrimaryAmmoType() )
player:SetAmmo( data.ammo2, weapon:GetSecondaryAmmoType() )
end
end

if t.curweapon then
Expand Down
2 changes: 1 addition & 1 deletion lua/ulib/shared/defines.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
ULib = ULib or {}

ULib.RELEASE = false -- Don't access these two directly, use ULib.pluginVersionStr("ULib")
ULib.VERSION = 2.70
ULib.VERSION = 2.71
ULib.AUTOMATIC_UPDATE_CHECKS = true

ULib.ACCESS_ALL = "user"
Expand Down
4 changes: 2 additions & 2 deletions lua/ulib/shared/sh_ucl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ function meta:IsAdmin()
if ucl.groups[ ULib.ACCESS_ADMIN ] then
return self:CheckGroup( ULib.ACCESS_ADMIN )
else -- Group doesn't exist, fall back on garry's method
origIsAdmin( self )
return origIsAdmin( self )
end
end

Expand All @@ -248,7 +248,7 @@ function meta:IsSuperAdmin()
if ucl.groups[ ULib.ACCESS_SUPERADMIN ] then
return self:CheckGroup( ULib.ACCESS_SUPERADMIN )
else -- Group doesn't exist, fall back on garry's method
origIsSuperAdmin( self )
return origIsSuperAdmin( self )
end
end

Expand Down
2 changes: 1 addition & 1 deletion ulib.build
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1644541484
1659669671

0 comments on commit 8f86a5a

Please sign in to comment.