Convert RegisterCommand to IsControlJustPressed

I basically want this coding to change to a IsControlJustPressed but cant seem to get it to work

RegisterCommand(“drag”, function(source, args, fullCommand)
local Player, Distance = Drag:GetClosestPlayer()

if Distance ~= -1 and Distance < Drag.Distance then
TriggerServerEvent(“Drag”, GetPlayerServerId(Player))
else
ESX.ShowNotification(‘No Player Nearby’)
end
end, false)

I am not 100% sure this will work. Change 19 to the button you want.

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)
        if IsControlJustPressed(0, 19) then
            local Player, Distance = Drag:GetClosestPlayer()
            if Distance ~= -1 and Distance < Drag.Distance then
                TriggerServerEvent(“Drag”, GetPlayerServerId(Player))
            else
                ESX.ShowNotification(‘No Player Nearby’)
            end
        end
    end
end)
Citizen.CreateThread(function ()
  while true do
    Wait(0)
    if IsControlJustPressed(1, 246) then
local Player, Distance = Drag:GetClosestPlayer()
   if Distance ~= -1 and Distance < Drag.Distance then
TriggerServerEvent(“Drag”, GetPlayerServerId(Player))
else
ESX.ShowNotification(‘No Player Nearby’)
end
    end
  end
end)

Thanks, it worked.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.