Skip to content

Instantly share code, notes, and snippets.

@nullvariable
Created April 23, 2022 17:28

Revisions

  1. nullvariable created this gist Apr 23, 2022.
    94 changes: 94 additions & 0 deletions debug.lua
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,94 @@

    function DrawText3Ds(x, y, z, text)
    SetTextScale(0.35, 0.35)
    SetTextFont(4)
    SetTextProportional(1)
    SetTextColour(255, 255, 255, 215)
    SetTextEntry("STRING")
    SetTextCentre(true)
    AddTextComponentString(text)
    SetDrawOrigin(x,y,z, 0)
    DrawText(0.0, 0.0)
    local factor = (string.len(text)) / 370
    DrawRect(0.0, 0.0+0.0125, 0.017+ factor, 0.03, 0, 0, 0, 75)
    ClearDrawOrigin()
    end

    function DrawHudText(text,colour,coordsx,coordsy,scalex,scaley)
    SetTextFont(4)
    SetTextProportional(7)
    SetTextScale(scalex, scaley)
    local colourr,colourg,colourb,coloura = table.unpack(colour)
    SetTextColour(colourr,colourg,colourb, coloura)
    SetTextDropshadow(0, 0, 0, 0, coloura)
    SetTextEdge(1, 0, 0, 0, coloura)
    SetTextDropShadow()
    SetTextOutline()
    SetTextEntry("STRING")
    AddTextComponentString(text)
    DrawText(coordsx,coordsy)
    end

    Citizen.CreateThread(function()
    while true do
    Wait(0)
    local x, y, z = table.unpack(GetEntityCoords(PlayerPedId()))
    -- DrawText3Ds(x, y, z+1.0, json.encode({GetFollowVehicleCamViewMode(), GetFollowPedCamViewMode()}))
    local context = GetCamActiveViewModeContext()
    -- local text = json.encode({GetCamViewModeForContext(context), GetFollowVehicleCamViewMode(), debugX, debugY})
    local text = GetEntityHeightAboveGround(PlayerPedId())
    DrawHudText(text, {255,255,255, 255}, 0.015, 0.3, 0.5, 0.5)
    end
    end)





    function DrawText3Ds(x, y, z, text)
    SetTextScale(0.35, 0.35)
    SetTextFont(4)
    SetTextProportional(1)
    SetTextColour(255, 255, 255, 215)
    SetTextEntry("STRING")
    SetTextCentre(true)
    AddTextComponentString(text)
    SetDrawOrigin(x,y,z, 0)
    DrawText(0.0, 0.0)
    local factor = (string.len(text)) / 370
    DrawRect(0.0, 0.0+0.0125, 0.017+ factor, 0.03, 0, 0, 0, 75)
    ClearDrawOrigin()
    end

    function DrawHudText(text,colour,coordsx,coordsy,scalex,scaley)
    SetTextFont(4)
    SetTextProportional(7)
    SetTextScale(scalex, scaley)
    local colourr,colourg,colourb,coloura = table.unpack(colour)
    SetTextColour(colourr,colourg,colourb, coloura)
    SetTextDropshadow(0, 0, 0, 0, coloura)
    SetTextEdge(1, 0, 0, 0, coloura)
    SetTextDropShadow()
    SetTextOutline()
    SetTextEntry("STRING")
    AddTextComponentString(text)
    DrawText(coordsx,coordsy)
    end

    local max = 0
    local debugX = 0
    Citizen.CreateThread(function()
    while true do
    Wait(0)
    -- local x, y, z = table.unpack(GetEntityCoords(PlayerPedId()))
    -- DrawText3Ds(x, y, z+1.0, json.encode({GetFollowVehicleCamViewMode(), GetFollowPedCamViewMode()}))
    -- local context = GetCamActiveViewModeContext()
    -- local text = json.encode({GetCamViewModeForContext(context), GetFollowVehicleCamViewMode(), debugX, debugY})
    local text = GetEntityHeightAboveGround(GetVehiclePedIsUsing(PlayerPedId()))
    -- local text = tostring(debugX)
    DrawHudText(text, {255,255,255, 255}, 0.015, 0.3, 0.5, 0.5)
    if text > max then max = text end
    DrawHudText(tostring(max), {255,0,0, 255}, 0.015, 0.325, 0.5, 0.5)
    if IsControlJustReleased(0, 178) then max = 0 end
    end
    end)