[HELP] Draw Script

I used the script below to make an — Admin On Duty — script but i need help with the second command /adminoff to remove the text drawn on screen

https://forum.cfx.re/t/release-me-but-the-text-is-3d-printed/149691

client.lua

local color = {r = 255, g = 0, b = 0, alpha = 205} -- Color of the text 
local font = 8 -- Font of the text
local time = 384615384615 -- Duration of the display of the text : 500 ~= 13sec

RegisterCommand('admin', function(source, args)
    local text = '>> Admin On Duty'
    for i = 1,#args do
        text = ' '
    end
    text = text .. ' <<'
    TriggerServerEvent('3dadmin:shareDisplay', text)
end)
RegisterCommand('adminoff', function(source, args)

--something here

end)

RegisterNetEvent('3dadmin:triggerDisplay')
AddEventHandler('3dadmin:triggerDisplay', function(text, source)
    Display(GetPlayerFromServerId(source), text)
end)

function Display(mePlayer, text)
    local timer = 0
    while timer < time do
        Wait(0)
        timer = timer + 1
        local coords = GetEntityCoords(GetPlayerPed(mePlayer), false)
        DrawText3D(coords['x'], coords['y'], coords['z']+1, text)
    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.10*scale, 0.60*scale)
        SetTextFont(font)
        SetTextProportional(1)
        SetTextColour(color.r, color.g, color.b, color.alpha)
        SetTextDropshadow(0, 0, 0, 0, 255)
        SetTextEdge(4, 0, 0, 0, 150)
        SetTextDropShadow()
        SetTextOutline()
        SetTextEntry("STRING")
        SetTextCentre(true)
        AddTextComponentString(text)
        EndTextCommandDisplayText(_x, _y)
    end
end

server.lua

local logEnabled = true

RegisterServerEvent('3dadmin:shareDisplay')
AddEventHandler('3dadmin:shareDisplay', function(text)
	TriggerClientEvent('3dadmin:triggerDisplay', -1, text, source)
	if logEnabled then
		setLog(text, source)
	end
end)

function setLog(text, source)
	local time = os.date("%d/%m/%Y %X")
	local name = GetPlayerName(source)
	local identifier = GetPlayerIdentifiers(source)
	local data = time .. ' : ' .. name .. ' - ' .. identifier[1] .. ' : ' .. text

	local content = LoadResourceFile(GetCurrentResourceName(), "admin.txt")
	local newContent = content .. '\r\n' .. data
	SaveResourceFile(GetCurrentResourceName(), "admin.txt", newContent, -1)
end

any help would be amazing

you know there is one out there right?? mine.

thank you is there like a thing where you can set a vehicle to an admin vehicle and then when people get in it they die

i can try.

not sure how it will turn out though.

Also your script just shows a pursuit nearby I want it to show he Admin above there head and have this now like you do /admin with the perms and above you head it will say admin and if you hit a keybind you get the admin pursuit (like Q) and then when you hit it again it goes away but keeping he admin above your head and when you type admin again or like /adminoff the thing above your head goes away

It’s hard to explain over text but I hope you get what I’m saying

For future reference it’s best if you don’t paste whole scripts, only the specific piece(s) you need help with.

1 Like