mirror of
https://github.com/kythre/Buildmode-ULX.git
synced 2025-03-04 03:03:04 -05:00
Restriction tables now allow for "*" wildcard
This commit is contained in:
parent
b13486c3a4
commit
210ae378e2
@ -387,11 +387,25 @@ local function _kyle_Buildmode_Disable(z)
|
||||
end
|
||||
end
|
||||
|
||||
local function hasValue (tbl, value)
|
||||
if table.HasValue(tbl, value) then return true end
|
||||
|
||||
for k,v in pairs(tbl) do
|
||||
if string.find(v, "*") then
|
||||
if string.match(value, "^(" .. string.sub(v, 1, -2) .. ")" ) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
local function _kyle_builder_spawn_weapon(y, z)
|
||||
local restrictweapons = _Kyle_Buildmode["restrictweapons"]=="1" and y.buildmode
|
||||
|
||||
if restrictweapons then
|
||||
local restrictionmet = (_Kyle_Buildmode["weaponlistmode"]=="0") == table.HasValue(_Kyle_Buildmode["buildloadout"], z)
|
||||
local restrictionmet = (_Kyle_Buildmode["weaponlistmode"]=="0") == hasValue(_Kyle_Buildmode["buildloadout"], z)
|
||||
local adminbypass = y:IsAdmin() and _Kyle_Buildmode["adminsbypassrestrictions"]=="1"
|
||||
return restrictionmet or adminbypass
|
||||
else
|
||||
@ -403,7 +417,7 @@ local function _kyle_builder_spawn_entity(y, z)
|
||||
local restrictsents = _Kyle_Buildmode["restrictsents"]=="1" and y.buildmode
|
||||
|
||||
if restrictsents then
|
||||
local restrictionmet = (_Kyle_Buildmode["entitylistmode"]=="0") == table.HasValue(_Kyle_Buildmode["builderentitylist"], z)
|
||||
local restrictionmet = (_Kyle_Buildmode["entitylistmode"]=="0") == hasValue(_Kyle_Buildmode["builderentitylist"], z)
|
||||
local adminbypass = y:IsAdmin() and _Kyle_Buildmode["adminsbypassrestrictions"]=="1"
|
||||
return restrictionmet or adminbypass
|
||||
else
|
||||
|
@ -97,11 +97,7 @@ concommand.Add("kylebuildmode", function( x, y, z )
|
||||
|
||||
if (x:IsValid() and x:query( "kylebuildmodesettings" )) then
|
||||
if z[1]=="addweapon" then
|
||||
if weapons.Get(z[2]) then
|
||||
table.insert(_Kyle_Buildmode["buildloadout"], z[2])
|
||||
else
|
||||
x:SendLua("GAMEMODE:AddNotify(\"Invalid SWEP. Could not add to list.\",NOTIFY_ERROR, 5)")
|
||||
end
|
||||
table.insert(_Kyle_Buildmode["buildloadout"], z[2])
|
||||
elseif z[1]=="removeweapon" then
|
||||
table.RemoveByValue( _Kyle_Buildmode["buildloadout"], z[2] )
|
||||
elseif z[1]=="addentity" then
|
||||
|
Loading…
Reference in New Issue
Block a user