function URS.Check(ply, type, what, noecho, ... )
-- MTZ
if ply:IsSuperAdmin() then return end
what = string.lower(what)
local group = ply:GetUserGroup()
local restriction = false
-- if we passed a description, use that for messages instead MTZ
local whatdesc = what
local arg={...}
if arg[1] != nil then
whatdesc = arg[1]
end
local passedRestrictionTest = false
if URS.restrictions[type] and URS.restrictions[type][what] then
restriction = URS.restrictions[type][what]
end
if restriction then
if table.HasValue(restriction, "*") then
if !(table.HasValue(restriction, group) or table.HasValue(restriction, ply:SteamID())) then
if !noecho then URS.PrintRestricted(ply, type, whatdesc) end
return false
end
elseif table.HasValue(restriction, group) or table.HasValue(restriction, ply:SteamID()) then
if !noecho then URS.PrintRestricted(ply, type, whatdesc) end
return false
end
passedRestrictionTest = true -- we overtly passed the restriction test. Don't bother looking at wildcards later on MTZ
end
if URS.restrictions["all"] and URS.restrictions["all"][type] and table.HasValue(URS.restrictions["all"][type], group) then
if !noecho then ULib.tsayError(ply, "Your rank is restricted from all ".. type .."s") end
return false
end
if table.HasValue(URS.types.limits, type) and URS.limits[type] and (URS.limits[type][ply:SteamID()] or URS.limits[type][group]) then
if URS.limits[type][ply:SteamID()] then
if ply:GetCount(type.."s") >= URS.limits[type][ply:SteamID()] then
ply:LimitHit( type .."s" )
return false
end
elseif URS.limits[type][group] then
if ply:GetCount(type.."s") >= URS.limits[type][group] then
ply:LimitHit( type .."s" )
return false
end
end
if URS.cfg.overwriteSbox:GetBool() then
return true -- Overwrite sbox limit (ours is greater)
end
end
-- find wildcard entires and recurse against it MTZ
if !string.ends(what,"*") and passedRestrictionTest == false then
local whatwild = converttowildcard(what)
if whatwild != what then
local res = URS.Check( ply, type, whatwild, noecho, what )
if (res == false) then
return false
end
end
end
end
-- MTZ
function string.starts(String,Start)
return string.sub(String,1,string.len(Start))==Start
end
function string.ends(String,End)
return End=='' or string.sub(String,-string.len(End))==End
end
function converttowildcard(what)
local what2 = ""
if string.starts(what, "weapon_doom3_") then what2 = "weapon_doom3_*"
elseif string.starts(what, "npcg_") then what2 = "npcg_*"
elseif string.starts(what, "gb5_light_") then what2 = "gb5_light_*"
elseif string.starts(what, "gb5_") then what2 = "gb5_*"
elseif string.starts(what, "halo_swep_") then what2 = "halo_swep_*"
elseif string.starts(what, "weapon_sky_") then what2 = "weapon_sky_*"
elseif string.starts(what, "m9k_") then what2 = "m9k_*"
elseif string.starts(what, "crysis_wep_") then what2 = "crysis_wep_*"
elseif string.starts(what, "weapon_752_") then what2 = "weapon_752_*"
elseif string.starts(what, "fas2_") then what2 = "fas2_*"
end
return what2
end
-- END MTZ