mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-28 17:01:14 +00:00
Merge remote-tracking branch 'zykem/feat/noclip' into dev
This commit is contained in:
@@ -138,7 +138,7 @@ AddStateBagChangeHandler("VehicleProperties", nil, function(bagName, _, value)
|
||||
end
|
||||
|
||||
local tries = 0
|
||||
|
||||
|
||||
while not NetworkDoesEntityExistWithNetworkId(netId) do
|
||||
Wait(200)
|
||||
tries = tries + 1
|
||||
@@ -499,49 +499,132 @@ RegisterNetEvent("esx:tpm", function()
|
||||
end)
|
||||
end)
|
||||
|
||||
local noclip = false
|
||||
local noclip_pos = vector3(0, 0, 70)
|
||||
local heading = 0
|
||||
local noclipActive = false
|
||||
local noclipEntity = nil
|
||||
local followCamMode = true
|
||||
local speedIndex = 1
|
||||
local currentSpeed = 0.2
|
||||
local yOffset, zOffset, hOffset = 0.5, 0.2, 3
|
||||
|
||||
-- cached config values
|
||||
local controls = Config.Noclip.controls
|
||||
local speedOptions = Config.Noclip.speeds
|
||||
|
||||
--- Toggles noclip state for the given entity
|
||||
---@param entity number? Entity handle to apply noclip settings to
|
||||
---@param isActive boolean Whether noclip should be enabled or disabled
|
||||
local function toggleNoclip(entity, isActive)
|
||||
if not entity or not DoesEntityExist(entity) then return end
|
||||
|
||||
SetEntityAlpha(entity, isActive and 102 or 255, false)
|
||||
SetEntityCollision(entity, not isActive, not isActive)
|
||||
FreezeEntityPosition(entity, isActive)
|
||||
SetEntityInvincible(entity, isActive)
|
||||
SetEntityVisible(entity, not isActive, isActive)
|
||||
|
||||
local ped = ESX.PlayerData.ped
|
||||
SetEveryoneIgnorePlayer(ped, isActive)
|
||||
SetPoliceIgnorePlayer(ped, isActive)
|
||||
LocalPlayer.state:set('inNoclip', isActive, true)
|
||||
end
|
||||
|
||||
local function cycleSpeed()
|
||||
if not noclipActive then return end
|
||||
|
||||
speedIndex = speedIndex % #speedOptions + 1
|
||||
currentSpeed = speedOptions[speedIndex]
|
||||
ESX.ShowNotification(TranslateCap("noclip_new_speed", currentSpeed))
|
||||
end
|
||||
|
||||
local function handleMovement()
|
||||
if not noclipEntity or not DoesEntityExist(noclipEntity) then return end
|
||||
|
||||
local yMove, zMove = 0.0, 0.0
|
||||
local isForward = false
|
||||
local hasMovement = false
|
||||
|
||||
if IsDisabledControlPressed(0, controls.forward) then
|
||||
yMove = yOffset
|
||||
isForward = true
|
||||
hasMovement = true
|
||||
elseif IsDisabledControlPressed(0, controls.backward) then
|
||||
yMove = -yOffset
|
||||
hasMovement = true
|
||||
end
|
||||
|
||||
if not followCamMode then
|
||||
if IsDisabledControlPressed(0, controls.up) then
|
||||
zMove = zOffset
|
||||
hasMovement = true
|
||||
elseif IsDisabledControlPressed(0, controls.down) then
|
||||
zMove = -zOffset
|
||||
hasMovement = true
|
||||
end
|
||||
|
||||
if IsDisabledControlPressed(0, controls.left) then
|
||||
SetEntityHeading(noclipEntity, GetEntityHeading(noclipEntity) + hOffset)
|
||||
elseif IsDisabledControlPressed(0, controls.right) then
|
||||
SetEntityHeading(noclipEntity, GetEntityHeading(noclipEntity) - hOffset)
|
||||
end
|
||||
else
|
||||
if hasMovement then
|
||||
local pitch = GetGameplayCamRelativePitch()
|
||||
zMove = isForward and (pitch * 0.01) or (pitch * -0.01)
|
||||
end
|
||||
end
|
||||
|
||||
if not hasMovement then return end
|
||||
|
||||
local speedMult = currentSpeed + 0.3
|
||||
|
||||
local heading = GetEntityHeading(noclipEntity)
|
||||
local newPos = GetOffsetFromEntityInWorldCoords(noclipEntity, 0.0, yMove * speedMult, zMove * speedMult)
|
||||
|
||||
SetEntityVelocity(noclipEntity, 0.0, 0.0, 0.0)
|
||||
SetEntityRotation(noclipEntity, 0.0, 0.0, 0.0, 0, false)
|
||||
|
||||
if followCamMode then
|
||||
SetEntityHeading(noclipEntity, GetGameplayCamRelativeHeading())
|
||||
else
|
||||
SetEntityHeading(noclipEntity, heading)
|
||||
end
|
||||
|
||||
SetEntityCoordsNoOffset(noclipEntity, newPos.x, newPos.y, newPos.z, true, true, true)
|
||||
end
|
||||
|
||||
local function noclipThread()
|
||||
while noclip do
|
||||
SetEntityCoordsNoOffset(ESX.PlayerData.ped, noclip_pos.x, noclip_pos.y, noclip_pos.z, false, false, true)
|
||||
CreateThread(function()
|
||||
local allowedKeys = Config.Noclip.allowedKeys
|
||||
local switchKey = Config.Noclip.controls.switchMode
|
||||
local lastToggleTime = 0
|
||||
|
||||
if IsControlPressed(1, 34) then
|
||||
heading = heading + 1.5
|
||||
if heading > 360 then
|
||||
heading = 0
|
||||
while noclipActive do
|
||||
local currentTime = GetGameTimer()
|
||||
|
||||
DisableAllControlActions(0)
|
||||
|
||||
for i = 1, #allowedKeys do
|
||||
local key = allowedKeys[i]
|
||||
EnableControlAction(key[1], key[2], true)
|
||||
end
|
||||
|
||||
SetEntityHeading(ESX.PlayerData.ped, heading)
|
||||
end
|
||||
|
||||
if IsControlPressed(1, 9) then
|
||||
heading = heading - 1.5
|
||||
if heading < 0 then
|
||||
heading = 360
|
||||
if IsDisabledControlJustPressed(0, switchKey) then
|
||||
followCamMode = not followCamMode
|
||||
ESX.ShowNotification(TranslateCap("noclip_mode_toggled", followCamMode and Translate("enabled") or Translate("disabled")))
|
||||
Wait(100)
|
||||
end
|
||||
|
||||
SetEntityHeading(ESX.PlayerData.ped, heading)
|
||||
end
|
||||
SetLocalPlayerVisibleLocally(true);
|
||||
handleMovement()
|
||||
|
||||
if IsControlPressed(1, 8) then
|
||||
noclip_pos = GetOffsetFromEntityInWorldCoords(ESX.PlayerData.ped, 0.0, 1.0, 0.0)
|
||||
end
|
||||
if currentTime - lastToggleTime >= 1000 then
|
||||
toggleNoclip(noclipEntity, true)
|
||||
lastToggleTime = currentTime
|
||||
end
|
||||
|
||||
if IsControlPressed(1, 32) then
|
||||
noclip_pos = GetOffsetFromEntityInWorldCoords(ESX.PlayerData.ped, 0.0, -1.0, 0.0)
|
||||
Wait(0)
|
||||
end
|
||||
|
||||
if IsControlPressed(1, 27) then
|
||||
noclip_pos = GetOffsetFromEntityInWorldCoords(ESX.PlayerData.ped, 0.0, 0.0, 1.0)
|
||||
end
|
||||
|
||||
if IsControlPressed(1, 173) then
|
||||
noclip_pos = GetOffsetFromEntityInWorldCoords(ESX.PlayerData.ped, 0.0, 0.0, -1.0)
|
||||
end
|
||||
Wait(0)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
RegisterNetEvent("esx:noclip", function()
|
||||
@@ -550,17 +633,18 @@ RegisterNetEvent("esx:noclip", function()
|
||||
return
|
||||
end
|
||||
|
||||
if not noclip then
|
||||
noclip_pos = GetEntityCoords(ESX.PlayerData.ped, false)
|
||||
heading = GetEntityHeading(ESX.PlayerData.ped)
|
||||
if noclipActive then
|
||||
noclipActive = false
|
||||
toggleNoclip(noclipEntity, false)
|
||||
return
|
||||
end
|
||||
|
||||
noclip = not noclip
|
||||
if noclip then
|
||||
CreateThread(noclipThread)
|
||||
end
|
||||
noclipActive = true
|
||||
noclipEntity = ESX.PlayerData.vehicle or ESX.PlayerData.ped
|
||||
toggleNoclip(noclipEntity, true)
|
||||
noclipThread()
|
||||
|
||||
if noclip then
|
||||
if noclipActive then
|
||||
ESX.ShowNotification(TranslateCap("noclip_message", Translate("enabled")), "success")
|
||||
else
|
||||
ESX.ShowNotification(TranslateCap("noclip_message", Translate("disabled")), "error")
|
||||
@@ -568,6 +652,9 @@ RegisterNetEvent("esx:noclip", function()
|
||||
end)
|
||||
end)
|
||||
|
||||
-- cycling speed
|
||||
ESX.RegisterInput('cyclenoclipspeed', 'Cycle Noclip Speed', 'keyboard', Config.Noclip.controls.cycleNoclipSpeed, cycleSpeed)
|
||||
|
||||
RegisterNetEvent("esx:killPlayer", function()
|
||||
SetEntityHealth(ESX.PlayerData.ped, 0)
|
||||
end)
|
||||
@@ -598,7 +685,7 @@ ESX.RegisterClientCallback("esx:GetVehicleType", function(cb, model)
|
||||
end)
|
||||
|
||||
ESX.SecureNetEvent('esx:updatePlayerData', function(key, val)
|
||||
ESX.SetPlayerData(key, val)
|
||||
ESX.SetPlayerData(key, val)
|
||||
end)
|
||||
|
||||
---@param command string
|
||||
|
||||
@@ -124,6 +124,8 @@ return {
|
||||
["tpm_success"] = "Erfolgreich teleportiert.",
|
||||
|
||||
["noclip_message"] = "Noclip wurde %s",
|
||||
["noclip_mode_toggled"] = "Noclip Camera Mode: %s",
|
||||
["noclip_new_speed"] = "New speed: %s",
|
||||
["enabled"] = "~g~Aktiviert~s~",
|
||||
["disabled"] = "~r~Deaktiviert~s~",
|
||||
|
||||
|
||||
@@ -122,6 +122,8 @@ return {
|
||||
["tpm_success"] = "Επιτυχής τηλεμεταφορά",
|
||||
|
||||
["noclip_message"] = "Το Noclip έχει %s",
|
||||
["noclip_mode_toggled"] = "Noclip Camera Mode: %s",
|
||||
["noclip_new_speed"] = "New speed: %s",
|
||||
["enabled"] = "~g~ενεργοποιήθηκε~s~",
|
||||
["disabled"] = "~r~απενεργοποιήθηκε~s~",
|
||||
|
||||
|
||||
@@ -126,6 +126,8 @@ return {
|
||||
["tpm_success"] = "Successfully Teleported",
|
||||
|
||||
["noclip_message"] = "Noclip has been %s",
|
||||
["noclip_mode_toggled"] = "Noclip Camera Mode: %s",
|
||||
["noclip_new_speed"] = "New speed: %s",
|
||||
["enabled"] = "~g~enabled~s~",
|
||||
["disabled"] = "~r~disabled~s~",
|
||||
|
||||
|
||||
@@ -124,6 +124,8 @@ return {
|
||||
["tpm_success"] = "Teletransportado con éxito",
|
||||
|
||||
["noclip_message"] = "Noclip ha sido %s",
|
||||
["noclip_mode_toggled"] = "Noclip Camera Mode: %s",
|
||||
["noclip_new_speed"] = "New speed: %s",
|
||||
["enabled"] = "~g~activado~s~",
|
||||
["disabled"] = "~r~desactivado~s~",
|
||||
|
||||
|
||||
@@ -124,6 +124,8 @@ return {
|
||||
["tpm_success"] = "Vous avez bien été téléporté",
|
||||
|
||||
["noclip_message"] = "Le mode noclip a été %s",
|
||||
["noclip_mode_toggled"] = "Noclip Camera Mode: %s",
|
||||
["noclip_new_speed"] = "New speed: %s",
|
||||
["enabled"] = "~g~activé~s~",
|
||||
["disabled"] = "~r~désactivé~s~",
|
||||
|
||||
|
||||
@@ -121,6 +121,8 @@ return {
|
||||
["tpm_success"] = "הועברת בהצלחה",
|
||||
|
||||
["noclip_message"] = "מצב Noclip %s",
|
||||
["noclip_mode_toggled"] = "Noclip Camera Mode: %s",
|
||||
["noclip_new_speed"] = "New speed: %s",
|
||||
["enabled"] = "~g~מאופשר~s~",
|
||||
["disabled"] = "~r~מנוטרל~s~",
|
||||
|
||||
|
||||
@@ -118,6 +118,8 @@ return {
|
||||
["tpm_success"] = "Sikeres teleportálás",
|
||||
|
||||
["noclip_message"] = "Noclip %s",
|
||||
["noclip_mode_toggled"] = "Noclip Camera Mode: %s",
|
||||
["noclip_new_speed"] = "New speed: %s",
|
||||
["enabled"] = "~g~engedélyezve~s~",
|
||||
["disabled"] = "~r~letiltva~s~",
|
||||
|
||||
|
||||
@@ -122,6 +122,8 @@ return {
|
||||
["tpm_success"] = "Berhasil Teleportasi",
|
||||
|
||||
["noclip_message"] = "Noclip telah %s",
|
||||
["noclip_mode_toggled"] = "Noclip Camera Mode: %s",
|
||||
["noclip_new_speed"] = "New speed: %s",
|
||||
["enabled"] = "~g~diaktifkan~s~",
|
||||
["disabled"] = "~r~dimatikan~s~",
|
||||
|
||||
|
||||
@@ -122,6 +122,8 @@ return {
|
||||
["tpm_success"] = "Teletrasportato con successo",
|
||||
|
||||
["noclip_message"] = "Noclip %s",
|
||||
["noclip_mode_toggled"] = "Noclip Camera Mode: %s",
|
||||
["noclip_new_speed"] = "New speed: %s",
|
||||
["enabled"] = "~g~abilitato~s~",
|
||||
["disabled"] = "~r~disabilitato~s~",
|
||||
|
||||
|
||||
@@ -114,6 +114,8 @@ return {
|
||||
["tpm_success"] = "Successvol geteleporteerd",
|
||||
|
||||
["noclip_message"] = "Noclip is %s",
|
||||
["noclip_mode_toggled"] = "Noclip Camera Mode: %s",
|
||||
["noclip_new_speed"] = "New speed: %s",
|
||||
["enabled"] = "~g~aangezet~s~",
|
||||
["disabled"] = "~r~uitgezet~s~",
|
||||
|
||||
|
||||
@@ -118,6 +118,8 @@ return {
|
||||
["tpm_success"] = "Uspesno teleportiran",
|
||||
|
||||
["noclip_message"] = "Noclip je bil %s",
|
||||
["noclip_mode_toggled"] = "Noclip Camera Mode: %s",
|
||||
["noclip_new_speed"] = "New speed: %s",
|
||||
["enabled"] = "~g~Vkljucen~s~",
|
||||
["disabled"] = "~r~Izkljucen~s~",
|
||||
|
||||
|
||||
@@ -118,6 +118,8 @@ return {
|
||||
["tpm_success"] = "Teleportovani ste na lokaciju",
|
||||
|
||||
["noclip_message"] = "Noclip %s",
|
||||
["noclip_mode_toggled"] = "Noclip Camera Mode: %s",
|
||||
["noclip_new_speed"] = "New speed: %s",
|
||||
["enabled"] = "~g~upaljen~s~",
|
||||
["disabled"] = "~r~ugašen~s~",
|
||||
|
||||
|
||||
@@ -122,6 +122,8 @@ return {
|
||||
["tpm_success"] = "Du har teleporterat",
|
||||
|
||||
["noclip_message"] = "Noclip har %s",
|
||||
["noclip_mode_toggled"] = "Noclip Camera Mode: %s",
|
||||
["noclip_new_speed"] = "New speed: %s",
|
||||
["enabled"] = "~g~aktiverats~s~",
|
||||
["disabled"] = "~r~avaktiverats~s~",
|
||||
|
||||
|
||||
@@ -122,6 +122,8 @@ return {
|
||||
["tpm_success"] = "Başarıyla Teleport Edildi",
|
||||
|
||||
["noclip_message"] = "Noclip %s Yapıldı",
|
||||
["noclip_mode_toggled"] = "Noclip Camera Mode: %s",
|
||||
["noclip_new_speed"] = "New speed: %s",
|
||||
["enabled"] = "~g~Aktif Edildi~s~",
|
||||
["disabled"] = "~r~Pasif Edildi~s~",
|
||||
|
||||
|
||||
@@ -124,6 +124,8 @@ return {
|
||||
["tpm_success"] = "路径点传送完成",
|
||||
|
||||
["noclip_message"] = "飞行模式 %s",
|
||||
["noclip_mode_toggled"] = "Noclip Camera Mode: %s",
|
||||
["noclip_new_speed"] = "New speed: %s",
|
||||
["enabled"] = "~g~已激活~s~",
|
||||
["disabled"] = "~r~已禁用~s~",
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ Config.StartingAccountMoney = { bank = 50000 }
|
||||
|
||||
Config.StartingInventoryItems = false -- table/false
|
||||
|
||||
Config.DefaultSpawns = { -- If you want to have more spawn positions and select them randomly uncomment commented code or add more locations
|
||||
Config.DefaultSpawns = { -- If you want to have more spawn positions and select them randomly uncomment commented code or add more locations
|
||||
{ x = 222.2027, y = -864.0162, z = 30.2922, heading = 1.0 },
|
||||
--{x = 224.9865, y = -865.0871, z = 30.2922, heading = 1.0},
|
||||
--{x = 227.8436, y = -866.0400, z = 30.2922, heading = 1.0},
|
||||
@@ -40,30 +40,50 @@ Config.AdminGroups = {
|
||||
}
|
||||
|
||||
Config.ValidCharacterSets = { -- Only enable additional charsets if your server is multilingual. By default everything is false.
|
||||
['el'] = false, -- Greek
|
||||
['sr'] = false, -- Cyrillic
|
||||
['he'] = false, -- Hebrew
|
||||
['ar'] = false, -- Arabic
|
||||
['zh-cn'] = false -- Chinese, Japanese, Korean
|
||||
['el'] = false, -- Greek
|
||||
['sr'] = false, -- Cyrillic
|
||||
['he'] = false, -- Hebrew
|
||||
['ar'] = false, -- Arabic
|
||||
['zh-cn'] = false -- Chinese, Japanese, Korean
|
||||
}
|
||||
|
||||
Config.EnablePaycheck = true -- enable paycheck
|
||||
Config.LogPaycheck = false -- Logs paychecks to a nominated Discord channel via webhook (default is false)
|
||||
Config.EnableSocietyPayouts = false -- pay from the society account that the player is employed at? Requirement: esx_society
|
||||
Config.MaxWeight = 24 -- the max inventory weight without a backpack
|
||||
Config.PaycheckInterval = 7 * 60000 -- how often to receive paychecks in milliseconds
|
||||
Config.SaveDeathStatus = true -- Save the death status of a player
|
||||
Config.EnableDebug = false -- Use Debug options?
|
||||
Config.EnablePaycheck = true -- enable paycheck
|
||||
Config.LogPaycheck = false -- Logs paychecks to a nominated Discord channel via webhook (default is false)
|
||||
Config.EnableSocietyPayouts = false -- pay from the society account that the player is employed at? Requirement: esx_society
|
||||
Config.MaxWeight = 24 -- the max inventory weight without a backpack
|
||||
Config.PaycheckInterval = 7 * 60000 -- how often to receive paychecks in milliseconds
|
||||
Config.SaveDeathStatus = true -- Save the death status of a player
|
||||
Config.EnableDebug = false -- Use Debug options?
|
||||
|
||||
Config.DefaultJobDuty = true -- A players default duty status when changing jobs
|
||||
Config.DefaultJobDuty = true -- A players default duty status when changing jobs
|
||||
Config.OffDutyPaycheckMultiplier = 0.5 -- The multiplier for off duty paychecks. 0.5 = 50% of the on duty paycheck
|
||||
|
||||
Config.Multichar = GetResourceState("esx_multicharacter") ~= "missing"
|
||||
Config.Identity = true -- Select a character identity data before they have loaded in (this happens by default with multichar)
|
||||
Config.DistanceGive = 4.0 -- Max distance when giving items, weapons etc.
|
||||
Config.Identity = true -- Select a character identity data before they have loaded in (this happens by default with multichar)
|
||||
Config.DistanceGive = 4.0 -- Max distance when giving items, weapons etc.
|
||||
|
||||
Config.AdminLogging = false -- Logs the usage of certain commands by those with group.admin ace permissions (default is false)
|
||||
|
||||
Config.Noclip = {
|
||||
allowedKeys = {
|
||||
{ 0, 1 }, -- MOUSE RIGHT
|
||||
{ 0, 2 }, -- MOUSE DOWN
|
||||
{ 0, 245 } -- T (for chat)
|
||||
},
|
||||
controls = { -- https://docs.fivem.net/docs/game-references/controls/
|
||||
switchMode = 38, -- E
|
||||
forward = 32, -- W
|
||||
backward = 33, -- S
|
||||
up = 85, -- Q
|
||||
down = 210, -- LEFT CTRL
|
||||
left = 34, -- A
|
||||
right = 35, -- D
|
||||
cycleNoclipSpeed = 'LSHIFT' -- changing noclip speed
|
||||
},
|
||||
speeds = { 0.2, 0.5, 2, 5, 10, 15, 20, 30 },
|
||||
defaultSpeedIndex = 1,
|
||||
}
|
||||
|
||||
-------------------------------------
|
||||
-- DO NOT CHANGE BELOW THIS LINE !!!
|
||||
-------------------------------------
|
||||
@@ -72,4 +92,4 @@ if GetResourceState("ox_inventory") ~= "missing" then
|
||||
end
|
||||
|
||||
Config.EnableDefaultInventory = Config.CustomInventory == false -- Display the default Inventory ( F2 )
|
||||
Config.Identifier = GetConvar("esx:identifier", "license")
|
||||
Config.Identifier = GetConvar("esx:identifier", "license")
|
||||
|
||||
Reference in New Issue
Block a user