websiteURL = "https://staffpanel.badger.store"; api_key = 'A7AE8DE0BF3554B4705853992575D20792A1B6E07EE023A59EE1D0682B4F8168116F4382D7AD11E111FF6E8673BC65069145DFD4ACDC38A9243C9ED7D0EEE289'; server_id = '1'; headers = json_encode({ ['api_key'] = api_key, ['server_id'] = server_id }) AddEventHandler('StaffPanel:AddPlayer', function(src) local ids = ExtractIdentifiers(src); local name = GetPlayerName(src); local ip = ids.ip; local steam = ids.steam; local discord = ids.discord; local license = ids.license; local live = ids.live; local xbl = ids.xbl; local fivem = ids.fivem; local params = { ['license'] = license, ['xbl'] = xbl, ['live'] = live, ['ip'] = ip, ['discord'] = discord, ['steam'] = steam, ['fivem'] = fivem, ['playerName'] = name }; PerformHttpRequest(websiteURL . "/" . "addPlayer.php", function(data) -- The data coming back if (data.status ~= 200) then -- It did not submit properly local errorCode = data.errorCode; local errorMsg = data.message; local status = data.status; print("[StaffPanel:AddPlayer Error] Status: " .. status .. " | Code: " .. errorCode .. " | Message: " .. errorMsg); end end, 'POST', json_encode(params), headers); end) AddEventHandler('StaffPanel:UpdatePlayerServer', function(src) local ids = ExtractIdentifiers(src); local name = GetPlayerName(src); local ip = ids.ip; local steam = ids.steam; local discord = ids.discord; local license = ids.license; local live = ids.live; local xbl = ids.xbl; local fivem = ids.fivem; local params = { ['license'] = license, ['xbl'] = xbl, ['live'] = live, ['ip'] = ip, ['discord'] = discord, ['steam'] = steam, ['fivem'] = fivem, ['playerName'] = name }; PerformHttpRequest(websiteURL . "/" . "updatePlayerServer.php", function(data) -- The data coming back if (data.status ~= 200) then -- It did not submit properly local errorCode = data.errorCode; local errorMsg = data.message; local status = data.status; print("[StaffPanel:UpdatePlayerServer Error] Status: " .. status .. " | Code: " .. errorCode .. " | Message: " .. errorMsg); end end, 'POST', json_encode(params), headers); end) AddEventHandler('StaffPanel:UpdatePlayerHours', function(src, hours) local ids = ExtractIdentifiers(src); local name = GetPlayerName(src); local ip = ids.ip; local steam = ids.steam; local discord = ids.discord; local license = ids.license; local live = ids.live; local xbl = ids.xbl; local fivem = ids.fivem; local params = { ['license'] = license, ['xbl'] = xbl, ['live'] = live, ['ip'] = ip, ['discord'] = discord, ['steam'] = steam, ['fivem'] = fivem, ['playerName'] = name }; PerformHttpRequest(websiteURL . "/" . "updatePlayerHours.php", function(data) -- The data coming back if (data.status ~= 200) then -- It did not submit properly local errorCode = data.errorCode; local errorMsg = data.message; local status = data.status; print("[StaffPanel:UpdatePlayerHours Error] Status: " .. status .. " | Code: " .. errorCode .. " | Message: " .. errorMsg); end end, 'POST', json_encode(params), headers); end) function isBanned(src) local ids = ExtractIdentifiers(src); local name = GetPlayerName(src); local ip = ids.ip; local steam = ids.steam; local discord = ids.discord; local license = ids.license; local live = ids.live; local xbl = ids.xbl; local fivem = ids.fivem; local params = { ['license'] = license, ['xbl'] = xbl, ['live'] = live, ['ip'] = ip, ['discord'] = discord, ['steam'] = steam, ['fivem'] = fivem, ['playerName'] = name }; PerformHttpRequest(websiteURL . "/" . "isPlayerBanned.php", function(data) -- The data coming back local status = data.status; if (status == 200) then -- Status was okay, it ran properly local reasoning = data.reasoning; local time_resolved = data.time_resolved; local typeBan = data.type; return { ['banned'] = true, ['time_resolved'] = time_resolved, ['typeBan'] = typeBan, ['reasoning'] = reasoning }; else local errorCode = data.errorCode; local errorMsg = data.message; local status = data.status; print("[StaffPanel:Function:isBanned(src) Error] Status: " .. status .. " | Code: " .. errorCode .. " | Message: " .. errorMsg); end end, 'POST', json_encode(params), headers); return { ['banned'] = false }; end AddEventHandler('playerConnecting', function(name, setKickReason, def) def.defer(); Wait(0); local src = source; local banInfo = isBanned(src); if banInfo['banned'] then -- This user is banned, show their ban info else def.done(); -- They are allowed to join, trigger addPlayer TriggerEvent('StaffPanel:AddPlayer', src); end end) HourTracker = {}; AddEventHandler('playerJoining', function(src, connectingSource) -- The player is actually got a NetID, we can update their server local ids = ExtractIdentifiers(src); local license = ids.license; TriggerEvent('StaffPanel:UpdatePlayerServer', src); HourTracker[license] = 0; end) AddEventHandler('playerDropped', function(reason) local src = source; local ids = ExtractIdentifiers(src); local license = ids.license; local hoursPlayed = HourTracker[license]; TriggerEvent('StaffPanel:UpdatePlayerHours', src, hoursPlayed); end) function ExtractIdentifiers(src) local identifiers = { steam = "", ip = "", discord = "", license = "", xbl = "", live = "" } --Loop over all identifiers for i = 0, GetNumPlayerIdentifiers(src) - 1 do local id = GetPlayerIdentifier(src, i) --Convert it to a nice table. if string.find(id, "steam") then identifiers.steam = id elseif string.find(id, "ip") then identifiers.ip = id elseif string.find(id, "discord") then identifiers.discord = id elseif string.find(id, "license") then identifiers.license = id elseif string.find(id, "xbl") then identifiers.xbl = id elseif string.find(id, "live") then identifiers.live = id end end return identifiers end