[Resolute][HELP] Use Cursor for html UI

Hello

I’m looking for how to use the cursor for an interface in html as an example cursor.unlock ()

it’s ShowCursorThisFrame()

But the cursor and not visible for ui just visible for the games and player attack when clicked

DisableControlAction not working


Everything is working !!!

But I wonder if there is no better way to use CreateThread -> while

My code

--ultis

local function LocalPed()
    return GetPlayerPed(-1)
end

-- fin

local AtmActive = false

Citizen.CreateThread(function()
    while true do
        if AtmActive then
            DisableControlAction(0, 1, AtmActive) -- LookLeftRight
            DisableControlAction(0, 2, AtmActive) -- LookUpDown
            DisableControlAction(0, 142, AtmActive) -- MeleeAttackAlternate
            DisableControlAction(0, 106, AtmActive) -- VehicleMouseControlOverride
            if IsDisabledControlJustReleased(0, 142) then -- MeleeAttackAlternate
                -- SendNUIMessage({type = "click"})
            end
        end
        Citizen.Wait(0)
    end
end)

Citizen.CreateThread(function()
    while true do
        Wait(0)
        if IsControlPressed(1, 38) then
            Key()
            while true do
            Wait(0)
                if(IsControlPressed(0, 38) == false) then
                    break
                end
            end
        end
        Wait(0)
        if AtmActive then
            ShowCursorThisFrame()
        end
    end
end)

function Key()
    if(AtmActive == false) then
      Show()
      AtmActive = true
    else
      Hide()
      AtmActive = false
    end
end

RegisterNUICallback('Post', function(data, call)
    
    if data.type == "Close" then

    else
        
    end

    AtmActive = false
    Hide()
    call('ok')
end)

function Show()
    local ped = LocalPed()
    SendNUIMessage({NamePlayer = GetPlayerName(),Money = '100$', Bank = '100$'})
    FreezeEntityPosition(ped,true)
    SetNuiFocus(true)
end

function Hide()
    local ped = LocalPed()
    SendNUIMessage({meta = 'close'})
    FreezeEntityPosition(ped,false)
    SetNuiFocus(false)
end

JS

var account = $('.account');

$(document).ready(function(){
      $('body').mousemove(function(e){
            var y = e.pageY;
            var x = e.pageX;
            $('.moveAble').css('top', y-20).css('left', x-20);
      });
      
      $("body").on( "keydown", function( event ) {
          if(event.which == 69){
              $.post('http://atm/Post', JSON.stringify({type: "Close"}));
          }
      })
});

function Depose()
{
    $.post('http://atm/Post', JSON.stringify({type: "Depose",account: account.val()}));
    account.val(0)
}

function Retire()
{
    $.post('http://atm/Post', JSON.stringify({type: "Retire",account: account.val()}));
    account.val(0)
}

$(function()
{
    $('#atm').hide();
    $('.moveAble').hide();
    window.addEventListener('message', function(event)
    {
        var item = event.data;
        var NamePlayer = $('.NamePlayer');
        var Money = $('.Money');
        var Bank = $('.Bank');
    
        if (item.meta == 'close')
        {
            $('#atm').hide();
            $('.moveAble').hide();
            return;
        }
        else
        {
            NamePlayer.html(item.NamePlayer);
            Money.html(item.Money);
            Bank.html(item.Bank);
            $('#atm').show();
            $('.moveAble').show();
        }
    }, false);
});

The DisableControlAction are not needed.

Use:

SetPlayerControl(Player player, Bool toggle, int flags)

Flag 0, 4, 16 disable camera rotation as well; 256, 260 allow camera rotation.

Just make sure to set it back once the user closes the UI to get control back.

1 Like

can you show an example of this? Im trying to use it without luck