Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function omgcleanupomg()
- cleanup.CC_AdminCleanup()
- LoadMapKCS()
- end
- function LoadMapKCS()
- MsgN( "Chargement de la configuration de la map..." )
- local read = file.Read( string.lower( KCS.SavePath ) .. "/" .. string.lower( game.GetMap() ) .. "_json.txt", "DATA" )
- if not read then
- MsgN( "Aucune configuration de map trouver" .. game.GetMap() .. "." )
- return
- end
- local config = util.JSONToTable( read )
- MsgN( "Chargement de la configuration de la map avec succés" )
- for k,v in pairs( config ) do
- if v[1] then
- for c,d in pairs( ents.FindByClass( k ) ) do
- d:Remove()
- end
- for c,d in pairs( v ) do
- if k == "keycard_register" then
- local id = d[1]
- local level = d[2]
- for _, ent in pairs( ents.GetAll() ) do
- if ent:EntIndex() == id then
- ent.Restricted = true
- ent.Level = level
- end
- end
- end
- end
- end
- end
- end
- hook.Add( "InitPostEntity", "LoadTheStops", LoadMapKCS )
- function SaveMapKCS()
- if not file.Exists( KCS.SavePath, "DATA" ) then file.CreateDir( KCS.SavePath ) end
- MsgN( "Sauvegarde de la configuration DATA de vos cartes" )
- local enttbl = {
- keycard_register = {}
- }
- for k,v in pairs( enttbl ) do
- for c,d in pairs( ents.GetAll() ) do
- if d.Restricted then
- table.insert( enttbl[k], { d:EntIndex(), d.Level } )
- end
- end
- end
- file.Write( string.lower( KCS.SavePath ) .. "/" .. string.lower( game.GetMap() ) .. "_json.txt", util.TableToJSON( enttbl ) )
- end
- function SaveKCS( ply, cmd, args )
- if ( !ply:IsAdmin() or !ply:IsSuperAdmin() ) then return end
- ply:StripWeapon( "admin_multitool" )
- SaveMapKCS()
- end
- concommand.Add( "kcs_end", SaveKCS )
- function KCSSetupMode( ply, cmd, args )
- if not IsValid( ply ) then
- for k, ply in pairs( player.GetAll() ) do
- if ply:IsAdmin() or ply:IsSuperAdmin() then
- ply:Give( "admin_multitool" )
- end
- end
- return
- end
- if ply:IsAdmin() or ply:IsSuperAdmin() then
- ply:Give( "admin_multitool" )
- end
- end
- concommand.Add( "kcs_start", KCSSetupMode )
- hook.Add( "InitPostEntity", "jesusfuckingchrist", function()
- timer.Simple( 10, function()
- hook.Add( "PlayerUse", "CheckThePrivlege", function( ply, ent )
- if not ent.Restricted then return end
- local weapon = ply:GetActiveWeapon()
- if not IsValid( weapon ) then return false end
- if not weapon:GetClass():find( "keycard" ) then return false end
- local level = ent.Level
- local access = weapon.Level
- if level <= access then return true end
- ent:EmitSound( "buttons/combine_button_locked.wav", 100, math.random(90,100) )
- return false
- end )
- end )
- end )
- hook.Add( "PlayerInitialSpawn", "NetworkTheButtons", function( ply )
- timer.Simple( 5, function()
- local butts = {}
- for _,butt in pairs( ents.GetAll() ) do
- if butt.Restricted then
- butts[ butt:EntIndex() ] = butt.Level
- end
- end
- net.Start( "SyncButtons" )
- net.WriteTable( butts )
- net.Send( ply )
- end )
- end )
- concommand.Add( "reset", omgcleanupomg )
Advertisement
Add Comment
Please, Sign In to add comment