-- =============================================
-- ADVANCED ADMIN SCRIPT (Lua)
-- With Temporary Rank System
-- Compatible with: FiveM, Garry's Mod, Roblox (Luau)
-- =============================================
local Config = {
Prefix = "^1[ADMIN]^7 ",
UsePermissionSystem = true, -- Set to false for simple mode
}
-- ==================== TEMPORARY RANK SYSTEM ====================
local ActiveTempRanks = {}
function GiveTempRank(playerId, rankName, durationMinutes, reason)
local identifier = GetPlayerIdentifier(playerId, 0) or "unknown"
local endTime = os.time() + (durationMinutes * 60)
ActiveTempRanks[identifier] = {
rank = rankName,
expires = endTime,
reason = reason or "No reason given"
}
print(Config.Prefix .. GetPlayerName(playerId) .. " received temporary rank: " .. rankName .. " for " .. durationMinutes .. " minutes.")
TriggerClientEvent('chat:addMessage', -1, {
color = {255, 100, 100},
args = {"[ADMIN]", GetPlayerName(playerId) .. " received temp rank ^3" .. rankName .. "^7 for ^2" .. durationMinutes .. "^7 minutes."}
})
end
function RemoveTempRank(playerId)
local identifier = GetPlayerIdentifier(playerId, 0)
if ActiveTempRanks[identifier] then
ActiveTempRanks[identifier] = nil
print(Config.Prefix .. "Temporary rank removed from " .. GetPlayerName(playerId))
end
end
-- Check temp ranks every minute
Citizen.CreateThread(function()
while true do
Citizen.Wait(60000) -- 1 minute
local currentTime = os.time()
for identifier, data in pairs(ActiveTempRanks) do
if currentTime > data.expires then
-- Find player by identifier and remove rank
for _, playerId in ipairs(GetPlayers()) do
if GetPlayerIdentifier(playerId, 0) == identifier then
RemoveTempRank(playerId)
break
end
end
end
end
end
end)
-- ==================== COMMAND FRAMEWORK ====================
local Commands = {}
function RegisterAdminCommand(name, callback, help, minRank)
Commands[string.lower(name)] = {
callback = callback,
help = help or "No description",
minRank = minRank or "admin"
}
end
-- Command Handler
AddEventHandler('chatMessage', function(source, name, message)
if string.sub(message, 1, 1) \~= "/" then return end
local args = {}
for arg in string.gmatch(message, "%S+") do
table.insert(args, arg)
end
local cmd = string.lower(table.remove(args, 1))
if Commands[cmd] then
local cmdData = Commands[cmd]
-- TODO: Add permission check here (LuckPerms, Ace Perms, etc.)
cmdData.callback(source, args)
CancelEvent()
end
end)
-- ==================== COMMANDS (Examples - Expand to 100+) ====================
RegisterAdminCommand("temprank", function(source, args)
if #args < 3 then
TriggerClientEvent('chat:addMessage', source, {args = {"^1Usage: /temprank [id] [rank] [minutes] [reason]"}})
return
end
local target = tonumber(args[1])
local rank = args[2]
local minutes = tonumber(args[3])
local reason = table.concat(args, " ", 4) or "No reason"
if not target or not GetPlayerName(target) then
TriggerClientEvent('chat:addMessage', source, {args = {"^1Player not found!"}})
return
end
GiveTempRank(target, rank, minutes, reason)
end, "Give temporary rank", "admin")
RegisterAdminCommand("removetemp", function(source, args)
if #args < 1 then return end
local target = tonumber(args[1])
if target then
RemoveTempRank(target)
end
end, "Remove temporary rank")
-- Basic Commands
RegisterAdminCommand("gm", function(source, args)
local mode = args[1] or "1"
TriggerClientEvent('admin:setGamemode', source, mode)
end, "Change gamemode")
RegisterAdminCommand("fly", function(source, args)
TriggerClientEvent('admin:toggleFly', source)
end, "Toggle flying")
RegisterAdminCommand("ban", function(source, args)
-- Add your ban logic here
print(Config.Prefix .. "Player banned by " .. GetPlayerName(source))
end, "Ban a player")
RegisterAdminCommand("kick", function(source, args)
-- Add kick logic
end, "Kick a player")
RegisterAdminCommand("tp", function(source, args)
local target = tonumber(args[1])
if target then
TriggerClientEvent('admin:teleportToPlayer', source, target)
end
end, "Teleport to player")
-- Add more commands easily:
-- RegisterAdminCommand("god", function... end)
-- RegisterAdminCommand("noclip", ...)
-- RegisterAdminCommand("money", ...)
-- etc.
print("^2[Admin Script] Loaded with " .. #Commands .. " commands and Temp Rank System")
Comments
No comments yet
Be the first to share your thoughts!