mirror of
https://github.com/Aaron113/urs.git
synced 2025-03-04 03:13:11 -05:00
* Changed saving to only save one table at a time
(No point in saving every table every time)
This commit is contained in:
parent
988191cf0f
commit
487aa224cc
@ -47,7 +47,7 @@ function ulx.restrict( ply, type, what, ... )
|
||||
end
|
||||
end
|
||||
xgui.sendDataTable({}, "URSRestrictions")
|
||||
URS.Save()
|
||||
URS.Save(SAVE_RESTRICTIONS)
|
||||
table.sort(removers, function(a, b) return a > b end)
|
||||
if removers[1] then for num, nums in pairs(removers) do table.remove(groups, nums) end end
|
||||
if groups[1] then
|
||||
@ -94,7 +94,7 @@ function ulx.unrestrict( ply, type, what, ... )
|
||||
end
|
||||
table.sort( removers, function(a, b) return a > b end )
|
||||
for i=1,#removers do table.remove( URS.restrictions[type][what], removers[i] ) end
|
||||
URS.Save()
|
||||
URS.Save(SAVE_RESTRICTIONS)
|
||||
xgui.sendDataTable( {}, "URSRestrictions" )
|
||||
if groups[1] then
|
||||
table.sort( removers2, function(a, b) return a > b end )
|
||||
@ -116,7 +116,7 @@ unrestrict:help( "Remove a restrictions from a group." )
|
||||
function ulx.setlimit( ply, type, group, limit )
|
||||
if limit == -1 then URS.limits[type][group] = nil else URS.limits[type][group] = limit end
|
||||
xgui.sendDataTable( {}, "URSLimits" )
|
||||
URS.Save()
|
||||
URS.Save(SAVE_LIMITS)
|
||||
ulx.fancyLogAdmin( ply, URS.cfg.echoCommands:GetBool(), "#A set the #s limit for #s to #i", type, group, limit )
|
||||
end
|
||||
local limit = ulx.command( "URS", "ulx setlimit", ulx.setlimit, "!setlimit" )
|
||||
@ -142,7 +142,7 @@ function ulx.loadoutadd( ply, group, ... )
|
||||
if not URS.loadouts[group] then
|
||||
URS.loadouts[group] = weapons
|
||||
end
|
||||
URS.Save()
|
||||
URS.Save(SAVE_LOADOUTS)
|
||||
xgui.sendDataTable( {}, "URSLoadouts" )
|
||||
table.sort( removers, function(a, b) return a > b end )
|
||||
for i=1,#removers do table.remove( weapons, removers[i] ) end
|
||||
@ -164,7 +164,7 @@ function ulx.loadoutremove( ply, group, ... )
|
||||
if weapons[1] == "*" then
|
||||
URS.loadouts[group] = nil
|
||||
weapons = {}
|
||||
URS.Save()
|
||||
URS.Save(SAVE_LOADOUTS)
|
||||
xgui.sendDataTable( {}, "URSLoadouts" )
|
||||
ulx.fancyLogAdmin( ply, URS.cfg.echoCommands:GetBool(), "#A removed the loadout from #s", group )
|
||||
return
|
||||
@ -185,7 +185,7 @@ function ulx.loadoutremove( ply, group, ... )
|
||||
table.sort( removers, function(a, b) return a > b end )
|
||||
for i=1,#removers do table.remove( URS.loadouts[group], removers[i] ) end
|
||||
if not URS.loadouts[group][1] then URS.loadouts[group] = nil end
|
||||
URS.Save()
|
||||
URS.Save(SAVE_LOADOUTS)
|
||||
xgui.sendDataTable( {}, "URSLoadouts" )
|
||||
table.sort( removers2, function(a, b) return a > b end )
|
||||
for i=1,#removers2 do table.remove( weapons, removers2[i] ) end
|
||||
|
@ -1,5 +1,10 @@
|
||||
AddCSLuaFile( "ulx/modules/sh/urs_cmds.lua" )
|
||||
|
||||
SAVE_ALL = 0
|
||||
SAVE_RESTRICIONS = 1
|
||||
SAVE_LIMITS = 2
|
||||
SAVE_LOADOUTS = 3
|
||||
|
||||
if !URS then URS = {} end
|
||||
|
||||
function URS.Load()
|
||||
@ -18,10 +23,10 @@ function URS.Load()
|
||||
end
|
||||
end
|
||||
|
||||
function URS.Save()
|
||||
if URS.restrictions then file.Write("ulx/restrictions.txt", util.TableToJSON(URS.restrictions)) end
|
||||
if URS.limits then file.Write("ulx/limits.txt", util.TableToJSON(URS.limits)) end
|
||||
if URS.loadouts then file.Write("ulx/loadouts.txt", util.TableToJSON(URS.loadouts)) end
|
||||
function URS.Save(n)
|
||||
if (n == SAVE_ALL or n == SAVE_RESTRICTIONS) and URS.restrictions then file.Write("ulx/restrictions.txt", util.TableToJSON(URS.restrictions)) end
|
||||
if (n == SAVE_ALL or n == SAVE_LIMITS) and URS.limits then file.Write("ulx/limits.txt", util.TableToJSON(URS.limits)) end
|
||||
if (n == SAVE_ALL or n == SAVE_LOADOUTS) and URS.loadouts then file.Write("ulx/loadouts.txt", util.TableToJSON(URS.loadouts)) end
|
||||
end
|
||||
|
||||
function URS.PrintRestricted(ply, type, what)
|
||||
|
Loading…
Reference in New Issue
Block a user