es_extended: noclip

# add missing locales
# refactor noclip methods (thread only if noclip enabled)
# format code
This commit is contained in:
Csoki
2022-11-27 21:58:04 +01:00
parent b98de6c2c4
commit bedefd7b5c
3 changed files with 138 additions and 139 deletions
+39 -50
View File
@@ -537,10 +537,12 @@ AddEventHandler("esx:tpm", function()
local GetVehiclePedIsIn = GetVehiclePedIsIn local GetVehiclePedIsIn = GetVehiclePedIsIn
ESX.TriggerServerCallback("esx:isUserAdmin", function(admin) ESX.TriggerServerCallback("esx:isUserAdmin", function(admin)
if admin then if not admin then
return
end
local blipMarker = GetFirstBlipInfoId(8) local blipMarker = GetFirstBlipInfoId(8)
if not DoesBlipExist(blipMarker) then if not DoesBlipExist(blipMarker) then
ESX.ShowNotification('No Waypoint Set.', true, false, 140) ESX.ShowNotification(TranslateCap('tpm_nowaypoint'), true, false, 140)
return 'marker' return 'marker'
end end
@@ -558,11 +560,7 @@ AddEventHandler("esx:tpm", function()
-- 825.0 seems to be the max a player can reach while 0.0 being the lowest. -- 825.0 seems to be the max a player can reach while 0.0 being the lowest.
local x, y, groundZ, Z_START = coords['x'], coords['y'], 850.0, 950.0 local x, y, groundZ, Z_START = coords['x'], coords['y'], 850.0, 950.0
local found = false local found = false
if vehicle > 0 then FreezeEntityPosition(vehicle > 0 and vehicle or ped, true)
FreezeEntityPosition(vehicle, true)
else
FreezeEntityPosition(ped, true)
end
for i = Z_START, 0, -25.0 do for i = Z_START, 0, -25.0 do
local z = i local z = i
@@ -601,11 +599,7 @@ AddEventHandler("esx:tpm", function()
-- Remove black screen once the loop has ended. -- Remove black screen once the loop has ended.
DoScreenFadeIn(650) DoScreenFadeIn(650)
if vehicle > 0 then FreezeEntityPosition(vehicle > 0 and vehicle or ped, false)
FreezeEntityPosition(vehicle, false)
else
FreezeEntityPosition(ped, false)
end
if not found then if not found then
-- If we can't find the coords, set the coords to the old ones. -- If we can't find the coords, set the coords to the old ones.
@@ -617,78 +611,73 @@ AddEventHandler("esx:tpm", function()
-- If Z coord was found, set coords in found coords. -- If Z coord was found, set coords in found coords.
SetPedCoordsKeepVehicle(ped, x, y, groundZ) SetPedCoordsKeepVehicle(ped, x, y, groundZ)
ESX.ShowNotification(TranslateCap('tpm_success'), true, false, 140) ESX.ShowNotification(TranslateCap('tpm_success'), true, false, 140)
end
end) end)
end) end)
local noclip = false local noclip = false
RegisterNetEvent("esx:noclip") local noclip_pos = vector3(0, 0, 70)
AddEventHandler("esx:noclip", function(input) local heading = 0
ESX.TriggerServerCallback("esx:isUserAdmin", function(admin)
if admin then
local player = PlayerId()
local msg = "disabled" local function noclipThread()
if(noclip == false)then while noclip do
noclip_pos = GetEntityCoords(ESX.PlayerData.ped, false)
end
noclip = not noclip
if(noclip)then
msg = "enabled"
end
TriggerEvent("chatMessage", "Noclip has been ^2^*" .. msg)
end
end)
end)
local heading = 0
CreateThread(function()
while true do
local Sleep = 1500
if(noclip)then
Sleep = 0
SetEntityCoordsNoOffset(ESX.PlayerData.ped, noclip_pos.x, noclip_pos.y, noclip_pos.z, 0, 0, 0) SetEntityCoordsNoOffset(ESX.PlayerData.ped, noclip_pos.x, noclip_pos.y, noclip_pos.z, 0, 0, 0)
if(IsControlPressed(1, 34))then if IsControlPressed(1, 34) then
heading = heading + 1.5 heading = heading + 1.5
if(heading > 360)then if heading > 360 then
heading = 0 heading = 0
end end
SetEntityHeading(ESX.PlayerData.ped, heading) SetEntityHeading(ESX.PlayerData.ped, heading)
end end
if(IsControlPressed(1, 9))then if IsControlPressed(1, 9) then
heading = heading - 1.5 heading = heading - 1.5
if(heading < 0)then if heading < 0 then
heading = 360 heading = 360
end end
SetEntityHeading(ESX.PlayerData.ped, heading) SetEntityHeading(ESX.PlayerData.ped, heading)
end end
if(IsControlPressed(1, 8))then if IsControlPressed(1, 8) then
noclip_pos = GetOffsetFromEntityInWorldCoords(ESX.PlayerData.ped, 0.0, 1.0, 0.0) noclip_pos = GetOffsetFromEntityInWorldCoords(ESX.PlayerData.ped, 0.0, 1.0, 0.0)
end end
if(IsControlPressed(1, 32))then if IsControlPressed(1, 32) then
noclip_pos = GetOffsetFromEntityInWorldCoords(ESX.PlayerData.ped, 0.0, -1.0, 0.0) noclip_pos = GetOffsetFromEntityInWorldCoords(ESX.PlayerData.ped, 0.0, -1.0, 0.0)
end end
if(IsControlPressed(1, 27))then if IsControlPressed(1, 27) then
noclip_pos = GetOffsetFromEntityInWorldCoords(ESX.PlayerData.ped, 0.0, 0.0, 1.0) noclip_pos = GetOffsetFromEntityInWorldCoords(ESX.PlayerData.ped, 0.0, 0.0, 1.0)
end end
if(IsControlPressed(1, 173))then if IsControlPressed(1, 173) then
noclip_pos = GetOffsetFromEntityInWorldCoords(ESX.PlayerData.ped, 0.0, 0.0, -1.0) noclip_pos = GetOffsetFromEntityInWorldCoords(ESX.PlayerData.ped, 0.0, 0.0, -1.0)
end end
Wait(0)
end end
Wait(Sleep) end
RegisterNetEvent("esx:noclip")
AddEventHandler("esx:noclip", function(input)
ESX.TriggerServerCallback("esx:isUserAdmin", function(admin)
if not admin then
return
end end
if not noclip then
noclip_pos = GetEntityCoords(ESX.PlayerData.ped, false)
heading = GetEntityHeading(ESX.PlayerData.ped)
end
noclip = not noclip
if noclip then
CreateThread(noclipThread)
end
ESX.ShowNotification(TranslateCap('noclip_message', noclip and "enabled" or "disabled"), true, false, 140)
end)
end) end)
RegisterNetEvent("esx:killPlayer") RegisterNetEvent("esx:killPlayer")
+5
View File
@@ -108,8 +108,13 @@ Locales['en'] = {
['command_giveammo_noweapon_found'] = '%s does not have that weapon', ['command_giveammo_noweapon_found'] = '%s does not have that weapon',
['command_giveammo_weapon'] = 'Weapon name', ['command_giveammo_weapon'] = 'Weapon name',
['command_giveammo_ammo'] = 'Ammo Quantity', ['command_giveammo_ammo'] = 'Ammo Quantity',
['tpm_nowaypoint'] = 'No Waypoint Set.',
['tpm_success'] = 'Successfully Teleported', ['tpm_success'] = 'Successfully Teleported',
['noclip_message'] = 'Noclip has been %s',
['enabled'] = '~g~enabled~s~',
['disabled'] = '~r~disabled~s~',
-- Locale settings -- Locale settings
['locale_digit_grouping_symbol'] = ',', ['locale_digit_grouping_symbol'] = ',',
['locale_currency'] = '£%s', ['locale_currency'] = '£%s',
+5
View File
@@ -108,8 +108,13 @@ Locales["hu"] = {
['command_giveammo_noweapon_found'] = 'Nincs ilyen fegyvered: %s', ['command_giveammo_noweapon_found'] = 'Nincs ilyen fegyvered: %s',
['command_giveammo_weapon'] = 'Fegyver név', ['command_giveammo_weapon'] = 'Fegyver név',
['command_giveammo_ammo'] = 'Lőszer mennyiség', ['command_giveammo_ammo'] = 'Lőszer mennyiség',
['tpm_nowaypoint'] = 'Nincs kijelölve pozíció!',
['tpm_success'] = 'Sikeres teleportálás', ['tpm_success'] = 'Sikeres teleportálás',
['noclip_message'] = 'Noclip %s',
['enabled'] = '~g~engedélyezve~s~',
['disabled'] = '~r~letiltva~s~',
-- Locale settings -- Locale settings
["locale_digit_grouping_symbol"] = ",", ["locale_digit_grouping_symbol"] = ",",
["locale_currency"] = "$%s", ["locale_currency"] = "$%s",