[ESX] STAFF Mode (FINAL VERSION)

This Script allows you to enter and leave a STAFF mode.
This staff mode gives you access to a god mode, coordinate checker (DEV) Health and armor display.
Allows the staff to teleport to a waypoint marker.
It also gives players a much needed /admins that shows them what STAFF is online, and if they are in Player mode or Staff mode.

COMMANDS:
/adminmode - Enter / Leave Admin Mode
/admins - Shows Online Admins
/admintp - Teleports to marker

Final Version - Added SQL logs - .sql file included.
Added Console Prints - and logs

DOWNLOAD: GitHub - Frkz/ESX_adminmode
FIXED AN ISSUE WHERE IT SAID THE ADMIN WAS INVALID
!chat

4 Likes

For me it says, Invalid for the name. How do I fix this?

same for me

Can you put a screenshot of how it appears to you?

When someone use /adminmode the chat show "Invalid, is in STAFF Mode but if you use /admins it show it well, just show it wrong when you activate or deactivate it

1 Like

Will take a look at it, and release the debugged version

@Freaklez do you allready see the problem?

Erro Fix.

Should be fixed now

Seems to be your servers problem i’d say.
Works fine on most guys i’ve seen

1 Like

compatible with es_admin2???

doesnt seem to let me come out of player mode

1 Like

Hy. How to can i fix this bug?

If you have error with mythic_notify only replace this [esx_adminmode/client/client.lua]

local Keys = {
    ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
    ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
    ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
    ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
    ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
    ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
    ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
    ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
    ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
}

local PID           			= 0
local GUI           			= {}
ESX 			    			= nil
GUI.Time            			= 0
local PlayerData                = {}
local IsInAdminMode = false
local CanShow = false
local ServerAdminMode = false
local LastAdminMode = false
local isGodMode = false
local LastUserGroup 
Citizen.CreateThread(function()
	while ESX == nil do
		TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
		Citizen.Wait(0)
	end
end)

RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer)
  PlayerData = xPlayer
  TriggerServerEvent('esx_adminmode:OnAdminLoad')
end)

RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob', function(job)
  PlayerData.job = job
end)

RegisterNetEvent('es_admin:setGroup')
AddEventHandler('es_admin:setGroup', function(g)
	print('Nível de admin: ' .. g)
	group = g
end)	


RegisterCommand('adminmode', function(source, args, rawCommand)

    ESX.TriggerServerCallback('esx_adminmode:GetGroup', function(UserGroup)
    LastUserGroup = UserGroup
    
    if LastUserGroup ~= 'user' then
        if not IsInAdminMode then
            IsInAdminMode = true
            AdminInMode = true
            SetGodMode(IsInAdminMode)
---            exports['mythic_notify']:SendAlert('success', 'You have entered STAFF mode!')
            local Name = GetPlayerName(source)
            TriggerEvent('esx_adminmode:AdminMode',IsInAdminMode)
            CheckAdminsOnline(AdminInMode)
            TriggerServerEvent('esx_adminmode:EnterStaffModeMSG',IsInAdminMode)
            TriggerServerEvent('esx_adminmode:StaffModeLogs', Name, IsInAdminMode)
        else
            IsInAdminMode = false
            AdminInMode = false
            SetGodMode(IsInAdminMode)
---            exports['mythic_notify']:SendAlert('error', 'You left STAFF mode!')
            TriggerEvent('esx_adminmode:AdminMode',IsInAdminMode)
            local Name = GetPlayerName(source)
            CheckAdminsOnline(AdminInMode)
            TriggerServerEvent('esx_adminmode:EnterStaffModeMSG',IsInAdminMode)

            TriggerServerEvent('esx_adminmode:StaffModeLogs', Name, IsInAdminMode)
        end
    else
---        exports['mythic_notify']:SendAlert('error', 'You have to be STAFF')
    end
end)
end)

function SetGodMode(isGodMode)
    if IsInAdminMode then
---            exports['mythic_notify']:SendAlert('success', 'God Mode Activated')
            SetEntityInvincible(GetPlayerPed(-1), true)
            SetPlayerInvincible(PlayerId(), true)
            SetPedCanRagdoll(GetPlayerPed(-1), false)
            ClearPedBloodDamage(GetPlayerPed(-1))
            ResetPedVisibleDamage(GetPlayerPed(-1))
            ClearPedLastWeaponDamage(GetPlayerPed(-1))
            SetEntityProofs(GetPlayerPed(-1), true, true, true, true, true, true, true, true)
            SetEntityOnlyDamagedByPlayer(GetPlayerPed(-1), false)
            SetEntityCanBeDamaged(GetPlayerPed(-1), false)
    else
 ---           exports['mythic_notify']:SendAlert('error', 'God Mode Desactivated')
            SetEntityInvincible(GetPlayerPed(-1), false)
			SetPlayerInvincible(PlayerId(), false)
			SetPedCanRagdoll(GetPlayerPed(-1), true)
			ClearPedLastWeaponDamage(GetPlayerPed(-1))
			SetEntityProofs(GetPlayerPed(-1), false, false, false, false, false, false, false, false)
			SetEntityOnlyDamagedByPlayer(GetPlayerPed(-1), true)
            SetEntityCanBeDamaged(GetPlayerPed(-1), true)
    end
end

RegisterNetEvent('esx_adminmode:AdminMode')
AddEventHandler('esx_adminmode:AdminMode', function(IsInAdminMode)

    if IsInAdminMode then
    CanShow = true
    else
    CanShow = false
    end
end)

--ADMIN FUNCTIONS 
Citizen.CreateThread(function()
    while true do
    Citizen.Wait(1)
            if CanShow then
                local coordsMe = GetEntityCoords(GetPlayerPed(Ped), false)
                local coords = GetEntityCoords(PlayerPedId(), false)
                local Ped = GetPlayerPed(-1)
                local x, y, z = table.unpack(GetEntityCoords(Ped))
                local Health = GetEntityHealth(Ped)
                local Armor = GetPedArmour(Ped)
                roundx = tonumber(string.format("%.2f", x))
                roundy = tonumber(string.format("%.2f", y))
                roundz = tonumber(string.format("%.2f", z))
                local h = GetEntityHeading(Ped)
                roundh =  tonumber(string.format("%.2f", h))
                DrawText3D(coordsMe['x'], coordsMe['y'], coordsMe['z']," Coordinates | ~g~X: "..roundx.. "~s~ | ~o~ Y: "..roundy.." ~s~ | ~b~ Z: ".. roundz.." ~s~| ~p~h: ".. roundh.. " ~s~|")
                DrawText3D(coordsMe['x'], coordsMe['y'], coordsMe['z']-0.15," ❤️ ~r~Health | "..Health)
                DrawText3D(coordsMe['x'], coordsMe['y'], coordsMe['z']-0.295," 🛡️ ~b~Armor | "..Armor)
            else
                CanShow = false
                Citizen.Wait(1000)
            end
    end
end)

function CheckAdminsOnline(AdminInMode)

    if AdminInMode then
    ServerAdminMode = true
    else
    ServerAdminMode = false
    end
    TriggerServerEvent('esx_adminmode:AdminsInMode', ServerAdminMode)
end

--TELEPORT

RegisterCommand("AdminTP", function(source)
    ESX.TriggerServerCallback('esx_adminmode:GetGroup', function(UserGroup)
        LastUserGroup = UserGroup
        TriggerEvent('esx_adminmode:AdminMode',IsInAdminMode)
        if LastUserGroup ~= 'user'then
            if IsInAdminMode then
                local WaypointHandle = GetFirstBlipInfoId(8)
                if DoesBlipExist(WaypointHandle) then
                    for height = 1, 1000 do
                        local waypointCoords = GetBlipInfoIdCoord(WaypointHandle)
                        SetPedCoordsKeepVehicle(PlayerPedId(), waypointCoords, height + 0.0)
                    end
 -----                   exports['mythic_notify']:SendAlert('inform', 'Teleported!')  
                else
 ----                   exports['mythic_notify']:SendAlert('inform', 'Please Set a Waypoint!')
                end
            else
 ---               exports['mythic_notify']:SendAlert('error', 'You must be in STAFF mode to teleport!')        
            end
    else
 ---       exports['mythic_notify']:SendAlert('error', 'You must be STAFF to teleport!')
        end
    end)
end)



function DrawText3D(x,y,z, text)
    local onScreen,_x,_y = World3dToScreen2d(x,y,z)
    local px,py,pz = table.unpack(GetGameplayCamCoord())
    local dist = GetDistanceBetweenCoords(px,py,pz, x,y,z, 1)
 
    local scale = (1/dist)*2
    local fov = (1/GetGameplayCamFov())*100
    local scale = scale*fov

    if onScreen then
    SetTextScale(0.40, 0.40)
    SetTextFont(4)
    SetTextProportional(1)
    SetTextColour(255, 255, 255, 215)
    SetTextEntry("STRING")
    SetTextCentre(1)
    SetTextOutline()
    AddTextComponentString(text)
    DrawText(_x,_y)
    end
end


1 Like

Hello. Today I tried this system.
But I have a problem …
Although it is not called Dejf and I use the command: adminmode and is a friend of mine on the server: Now ten DEJF, so it writes his name.

I understand that it obviously depends on the player who has 1 and me 2.
And yours, it only writes ID 1 … How do I fix it?

Sorry, I can’t speak English very well!


Can you please make it so admins can see the id of a player?

1 Like

When i Duty in all the admins are in duty (in the list only) any fix? :smiley:

You don’t have mythic notify as asset in your server folder :slight_smile: OR not started yet

I have this error. What to do?