Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if SERVER then
- util.AddNetworkString( "adminhub_playerlist" )
- util.AddNetworkString( "adminhub_openmenu" )
- hook.Add( "PlayerInitialSpawn", "playerfilecreating", function(ply)
- if not file.Exists( "adminhub", "DATA" ) then
- file.CreateDir( "adminhub" )
- end
- local plyinfo = {
- name = ply:Nick(),
- steamid = ply:SteamID(),
- steamid64 = ply:SteamID64(),
- ip = ply:IPAddress(),
- lastjoin = os.time(),
- lastjoinstr = os.date( "%X - %d/%m/%Y" , os.time() ),
- }
- if ( file.Exists( "adminhub/"..ply:SteamID64()..".txt", "DATA" ) ) then
- print( "[AH]: User profile exists for "..ply:Nick()..", updating....." )
- file.Write( "adminhub/"..ply:SteamID64()..".txt", util.TableToJSON(plyinfo) )
- print( "[AH]: User profile for "..ply:Nick().." updated successfully!" )
- else
- print( "[AH]: User profile doesn't exist for "..ply:Nick()..", creating new." )
- file.Write( "adminhub/"..ply:SteamID64()..".txt", util.TableToJSON(plyinfo) )
- print( "[AH]: User profile for "..ply:Nick().." has been created!" )
- end
- net.Start( "adminhub_playerlist" )
- net.WriteTable( adminhub_getTextData() )
- net.Broadcast()
- end )
- local ULXranks = {
- "superadmin",
- "admin"
- }
- local function hasRank( ply )
- local hasULXRank = false
- for k, v in pairs( ULXranks ) do
- if ply:IsUserGroup( v ) then
- hasULXRank = true
- end
- end
- return hasULXRank
- end
- hook.Add( "PlayerSay", "adminhub_chatCommand", function( ply, message )
- if message == "!users" then
- if hasRank( ply ) then
- net.Start( "adminhub_openmenu" )
- net.Send( ply )
- return false
- end
- end
- end )
- function adminhub_getTextData()
- local allPlayers = {}
- local files, directories = file.Find( "adminhub/*", "DATA" )
- for _, f in pairs(files) do
- local TableFromJSON = util.JSONToTable( file.Read( "adminhub/"..f, "DATA" ) )
- table.insert( allPlayers, TableFromJSON )
- end
- return allPlayers
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement