Diff
checker
Texto
Texto
Imágenes
Documentos
Excel
Carpetas
Legal
Enterprise
Aplicación de escritorio
Precios
Iniciar sesión
Descargar Diffchecker Desktop
Comparar texto
Encuentra la diferencia entre dos archivos de texto
Herramientas
Historial
Editor live
Ocultar sin cambios
Sin ajuste de línea
Vista
Dividido
Unificado
Nivel de detalle
Inteligente
Palabra
Letra
Resaltado de sintaxis
Elegir sintaxis
Ignorar
Transformar texto
Ir al primer cambio
Editar entrada
Diffchecker Desktop
La forma más segura de usar Diffchecker. ¡Obtén la app de Diffchecker Desktop: tus diffs nunca salen de tu computadora!
Obtener Desktop
Lightbar
Creado
hace 5 años
El diff nunca expira
Borrar
Exportar
Compartir
Explicar
93 eliminaciones
Líneas
Total
Eliminado
Caracteres
Total
Eliminado
Para continuar usando esta función, actualice a
Diff
checker
Pro
Ver precios
493 líneas
Copiar todo
67 adiciones
Líneas
Total
Añadido
Caracteres
Total
Añadido
Para continuar usando esta función, actualice a
Diff
checker
Pro
Ver precios
447 líneas
Copiar todo
Copiar
Copiado
Copiar
Copiado
-- Version 0.1
ESX = nil
-- Devloped by Everett aka Mr. Yellow aka Munky aka De_verett
local PlayerData = {}
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
while PlayerData.job == nil do
PlayerData = ESX.GetPlayerData()
end
Citizen.Wait(0)
end
end)
local carSpawned = false
local carSpawned = false
local newVeh = nil
local newVeh = nil
local inLightbarMenu = false
local inLightbarMenu = false
local lightBool = false
local lightBool = false
local sirenBool = false
local sirenBool = false
local oldSirenBool = false
local oldSirenBool = false
local controlsDisabled = false
local controlsDisabled = false
local xCoord = 0
local xCoord = 0
local yCoord = 0
local yCoord = 0
local zCoord = 0
local zCoord = 0
local xrot = 0.0
local xrot = 0.0
local yrot = 0.0
local yrot = 0.0
local zrot = 0.0
local zrot = 0.0
local snd_pwrcall = {}
local snd_pwrcall = {}
local airHornSirenID = nil
local airHornSirenID = nil
local sirenTone = "VEHICLES_HORNS_SIREN_1"
local sirenTone = "VEHICLES_HORNS_SIREN_1"
local vehPlateBoolSavedData = nil
local vehPlateBoolSavedData = nil
local isPlateCar = false
local isPlateCar = false
local isAirhornKeyPressed = false
local isAirhornKeyPressed = false
local deleteVehicleLightbars = {}
local deleteVehicleLightbars = {}
Citizen.CreateThread(function()
Citizen.CreateThread(function()
while true do
while true do
Citizen.Wait(1)
Citizen.Wait(1)
if inLightbarMenu then
if inLightbarMenu then
printControlsText()
printControlsText()
end
end
local player = GetPlayerPed(-1)
local player = GetPlayerPed(-1)
if (IsControlJustReleased(1, 44)) then -- Q to turn on lights
if (IsControlJustReleased(1, 44)) then -- Q to turn on lights
toggleLights()
toggleLights()
end
end
Copiar
Copiado
Copiar
Copiado
if (IsControlJustReleased(1,
47
)) then --
G
to turn on siren
if (IsControlJustReleased(1,
246
)) then --
Y
to turn on siren
sirenTone = "VEHICLES_HORNS_SIREN_1" -- sets siren to default siren
sirenTone = "VEHICLES_HORNS_SIREN_1" -- sets siren to default siren
toggleSiren()
toggleSiren()
end
end
if (IsControlJustReleased(1, 210)) then -- Left control to change siren tone
if (IsControlJustReleased(1, 210)) then -- Left control to change siren tone
changeSirenTone()
changeSirenTone()
end
end
if IsControlJustPressed(1, 184) and not isAirhornKeyPressed then
if IsControlJustPressed(1, 184) and not isAirhornKeyPressed then
playAirHorn(true)
playAirHorn(true)
isAirhornKeyPressed = true
isAirhornKeyPressed = true
if sirenBool then
if sirenBool then
oldSirenBool = sirenBool
oldSirenBool = sirenBool
toggleSiren()
toggleSiren()
end
end
end
end
if IsControlJustReleased(1, 184) then
if IsControlJustReleased(1, 184) then
playAirHorn(false)
playAirHorn(false)
isAirhornKeyPressed = false
isAirhornKeyPressed = false
if oldSirenBool then
if oldSirenBool then
toggleSiren()
toggleSiren()
oldSirenBool = false
oldSirenBool = false
end
end
end
end
if isPlateCar then DisableControlAction(0,86,true) end -- Disables Veh horn
if isPlateCar then DisableControlAction(0,86,true) end -- Disables Veh horn
end
end
end)
end)
function printControlsText()
function printControlsText()
SetTextFont(0)
SetTextFont(0)
SetTextProportional(1)
SetTextProportional(1)
SetTextScale(0.0, 0.4)
SetTextScale(0.0, 0.4)
SetTextColour(128, 128, 255, 255)
SetTextColour(128, 128, 255, 255)
SetTextDropshadow(0, 0, 0, 0, 255)
SetTextDropshadow(0, 0, 0, 0, 255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextDropShadow()
SetTextDropShadow()
SetTextOutline()
SetTextOutline()
SetTextEntry("STRING")
SetTextEntry("STRING")
AddTextComponentString("Use your ↑ ↓ → ← Arrow Keys for Lateral Movements, Pg Up and Pg Down for Altitude Change")
AddTextComponentString("Use your ↑ ↓ → ← Arrow Keys for Lateral Movements, Pg Up and Pg Down for Altitude Change")
DrawText(0.25, 0.9)
DrawText(0.25, 0.9)
--
--
SetTextFont(0)
SetTextFont(0)
SetTextProportional(1)
SetTextProportional(1)
SetTextScale(0.0, 0.4)
SetTextScale(0.0, 0.4)
SetTextColour(128, 128, 255, 255)
SetTextColour(128, 128, 255, 255)
SetTextDropshadow(0, 0, 0, 0, 255)
SetTextDropshadow(0, 0, 0, 0, 255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextDropShadow()
SetTextDropShadow()
SetTextOutline()
SetTextOutline()
SetTextEntry("STRING")
SetTextEntry("STRING")
AddTextComponentString("and Insert and Delete for rotation. SPACE to save, DELETE to cancel")
AddTextComponentString("and Insert and Delete for rotation. SPACE to save, DELETE to cancel")
DrawText(0.25, 0.93)
DrawText(0.25, 0.93)
end
end
function toggleLights()
function toggleLights()
local player = GetPlayerPed(-1)
local player = GetPlayerPed(-1)
Copiar
Copiado
Copiar
Copiado
TriggerServerEvent("
toggleLights2", GetVehicleNumberPlateText(GetVehiclePedIsIn(player, false)))
TriggerServerEvent("
lightbar:
toggleLights2", GetVehicleNumberPlateText(GetVehiclePedIsIn(player, false)))
if sirenBool == true then
if sirenBool == true then
Copiar
Copiado
Copiar
Copiado
TriggerServerEvent("
ToggleSound1Server", GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false)))
TriggerServerEvent("
lightbar:
ToggleSound1Server", GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false)))
end
end
end
end
function changeSirenTone()
function changeSirenTone()
local currPlate = GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false))
local currPlate = GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false))
if not(vehPlateBoolSavedData == currPlate) then
if not(vehPlateBoolSavedData == currPlate) then
Copiar
Copiado
Copiar
Copiado
TriggerServerEvent("
returnLightBarVehiclePlates")
TriggerServerEvent("
lightbar:
returnLightBarVehiclePlates")
while true do
while true do
if(vehPlateBoolSavedData == GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false))) then
if(vehPlateBoolSavedData == GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false))) then
break
break
end
end
if not(currPlate == GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false))) then
if not(currPlate == GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false))) then
return
return
end
end
Citizen.Wait(10)
Citizen.Wait(10)
end
end
end
end
if isPlateCar then
if isPlateCar then
if sirenTone == "VEHICLES_HORNS_SIREN_1" then
if sirenTone == "VEHICLES_HORNS_SIREN_1" then
sirenTone = "VEHICLES_HORNS_SIREN_2"
sirenTone = "VEHICLES_HORNS_SIREN_2"
toggleSiren()
toggleSiren()
toggleSiren()
toggleSiren()
elseif sirenTone == "VEHICLES_HORNS_SIREN_2" then
elseif sirenTone == "VEHICLES_HORNS_SIREN_2" then
sirenTone = "VEHICLES_HORNS_POLICE_WARNING"
sirenTone = "VEHICLES_HORNS_POLICE_WARNING"
toggleSiren()
toggleSiren()
toggleSiren()
toggleSiren()
else
else
sirenTone = "VEHICLES_HORNS_SIREN_1"
sirenTone = "VEHICLES_HORNS_SIREN_1"
toggleSiren()
toggleSiren()
toggleSiren()
toggleSiren()
end
end
end
end
end
end
Copiar
Copiado
Copiar
Copiado
RegisterNetEvent('
openLightbarMenu')
RegisterNetEvent('
lightbar:
openLightbarMenu')
AddEventHandler('
openLightbarMenu', function(lightbarModel)
AddEventHandler('
lightbar:
openLightbarMenu', function(lightbarModel)
lightMenu(lightbarModel)
lightMenu(lightbarModel)
end)
end)
Copiar
Copiado
Copiar
Copiado
RegisterNetEvent('
clientToggleLights')
RegisterNetEvent('
lightbar:
clientToggleLights')
AddEventHandler('
clientToggleLights', function(lightsArray, lightsStatus, hostVehiclePointer)
AddEventHandler('
lightbar:
clientToggleLights', function(lightsArray, lightsStatus, hostVehiclePointer)
Citizen.CreateThread(function()
Citizen.CreateThread(function()
for k,v in pairs(lightsArray) do
for k,v in pairs(lightsArray) do
NetworkRequestControlOfNetworkId(v)
NetworkRequestControlOfNetworkId(v)
while not NetworkHasControlOfNetworkId(v) do
while not NetworkHasControlOfNetworkId(v) do
Citizen.Wait(0)
Citizen.Wait(0)
end
end
local test1 = NetToVeh(v)
local test1 = NetToVeh(v)
lightBool = lightsStatus
lightBool = lightsStatus
SetVehicleSiren(test1, not lightsStatus)
SetVehicleSiren(test1, not lightsStatus)
end
end
end)
end)
end)
end)
function toggleSiren()
function toggleSiren()
if lightBool == false then
if lightBool == false then
Copiar
Copiado
Copiar
Copiado
TriggerServerEvent("
ToggleSound1Server", GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false)))
TriggerServerEvent("
lightbar:
ToggleSound1Server", GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false)))
end
end
end
end
function spawnLightbar(lightbarModel)
function spawnLightbar(lightbarModel)
Copiar
Copiado
Copiar
Copiado
print("Got to spawn")
local player = GetPlayerPed(-1)
local player = GetPlayerPed(-1)
local vehiclehash1 = GetHashKey(lightbarModel)
local vehiclehash1 = GetHashKey(lightbarModel)
RequestModel(vehiclehash1)
RequestModel(vehiclehash1)
Citizen.CreateThread(function()
Citizen.CreateThread(function()
while not HasModelLoaded(vehiclehash1) do
while not HasModelLoaded(vehiclehash1) do
Citizen.Wait(100)
Citizen.Wait(100)
end
end
local coords = GetEntityCoords(player)
local coords = GetEntityCoords(player)
newVeh = CreateVehicle(vehiclehash1, coords.x, coords.y, coords.z, GetEntityHeading(PlayerPedId()), true, 0)
newVeh = CreateVehicle(vehiclehash1, coords.x, coords.y, coords.z, GetEntityHeading(PlayerPedId()), true, 0)
SetEntityCollision(newVeh, false, false)
SetEntityCollision(newVeh, false, false)
SetVehicleDoorsLocked(newVeh, 2)
SetVehicleDoorsLocked(newVeh, 2)
SetEntityAsMissionEntity(newVeh, true, true)
SetEntityAsMissionEntity(newVeh, true, true)
end)
end)
end
end
function lightMenu(lightbarModel)
function lightMenu(lightbarModel)
if not inLightbarMenu then
if not inLightbarMenu then
inLightbarMenu = true
inLightbarMenu = true
local player = GetPlayerPed(-1)
local player = GetPlayerPed(-1)
spawnLightbar(lightbarModel)
spawnLightbar(lightbarModel)
controlsDisabled = true
controlsDisabled = true
disableControls()
disableControls()
AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, 0, 0, 0, 0.0, 0.0, 0.0, true, true, true, true, 0, true)
AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, 0, 0, 0, 0.0, 0.0, 0.0, true, true, true, true, 0, true)
while true do
while true do
Citizen.Wait(10)
Citizen.Wait(10)
--resetOffSets()
--resetOffSets()
moveObj(newVeh)
moveObj(newVeh)
if (IsControlJustReleased(1, 22)) then -- attatch obj and close
if (IsControlJustReleased(1, 22)) then -- attatch obj and close
Copiar
Copiado
Copiar
Copiado
TriggerServerEvent("
addLightbar", GetVehicleNumberPlateText(GetVehiclePedIsIn(player, false)), VehToNet(newVeh), GetVehiclePedIsIn(player, false))
TriggerServerEvent("
lightbar:
addLightbar", GetVehicleNumberPlateText(GetVehiclePedIsIn(player, false)), VehToNet(newVeh), GetVehiclePedIsIn(player, false))
inLightbarMenu = false
inLightbarMenu = false
newVeh=nil
newVeh=nil
controlsDisabled = false
controlsDisabled = false
if(vehPlateBoolSavedData == GetVehicleNumberPlateText(GetVehiclePedIsIn(player, false))) then
if(vehPlateBoolSavedData == GetVehicleNumberPlateText(GetVehiclePedIsIn(player, false))) then
isPlateCar = true
isPlateCar = true
end
end
break
break
end
end
if (IsControlJustReleased(1, 177)) then -- close menu
if (IsControlJustReleased(1, 177)) then -- close menu
inLightbarMenu = false
inLightbarMenu = false
DeleteVehicle(newVeh)
DeleteVehicle(newVeh)
newVeh = nil
newVeh = nil
controlsDisabled = false
controlsDisabled = false
break
break
end
end
end
end
end
end
end
end
function moveObj(veh)
function moveObj(veh)
local player = GetPlayerPed(-1)
local player = GetPlayerPed(-1)
local MOVEMENT_CONSTANT = 0.01
local MOVEMENT_CONSTANT = 0.01
local vehOffset = GetOffsetFromEntityInWorldCoords(newVeh, 0.0, 1.3, 0.0)
local vehOffset = GetOffsetFromEntityInWorldCoords(newVeh, 0.0, 1.3, 0.0)
if (IsControlJustReleased(1, 121)) then -- rotate 180 upside down
if (IsControlJustReleased(1, 121)) then -- rotate 180 upside down
yrot = yrot + 180.0
yrot = yrot + 180.0
Copiar
Copiado
Copiar
Copiado
print("yrot = " .. yrot)
DetachEntity(newVeh, 0, 0)
DetachEntity(newVeh, 0, 0)
AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true)
AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true)
end
end
if (IsControlJustReleased(1, 178)) then -- rotate 180
if (IsControlJustReleased(1, 178)) then -- rotate 180
zrot = zrot + 180
zrot = zrot + 180
DetachEntity(newVeh, 0, 0)
DetachEntity(newVeh, 0, 0)
AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true)
AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true)
end
end
if (IsControlPressed(1, 190)) then -- move forward
if (IsControlPressed(1, 190)) then -- move forward
xCoord = xCoord + MOVEMENT_CONSTANT
xCoord = xCoord + MOVEMENT_CONSTANT
DetachEntity(newVeh, 0, 0)
DetachEntity(newVeh, 0, 0)
AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true)
AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true)
end
end
if (IsControlPressed(1, 189)) then -- move backwards
if (IsControlPressed(1, 189)) then -- move backwards
xCoord = xCoord - MOVEMENT_CONSTANT
xCoord = xCoord - MOVEMENT_CONSTANT
DetachEntity(newVeh, 0, 0)
DetachEntity(newVeh, 0, 0)
AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true)
AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true)
end
end
if (IsControlPressed(1, 27)) then -- move right
if (IsControlPressed(1, 27)) then -- move right
yCoord = yCoord + MOVEMENT_CONSTANT
yCoord = yCoord + MOVEMENT_CONSTANT
DetachEntity(newVeh, 0, 0)
DetachEntity(newVeh, 0, 0)
AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true)
AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true)
end
end
if (IsControlPressed(1, 187)) then -- move left
if (IsControlPressed(1, 187)) then -- move left
yCoord = yCoord - MOVEMENT_CONSTANT
yCoord = yCoord - MOVEMENT_CONSTANT
DetachEntity(newVeh, 0, 0)
DetachEntity(newVeh, 0, 0)
AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true)
AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true)
end
end
if (IsControlPressed(1, 208)) then -- move up
if (IsControlPressed(1, 208)) then -- move up
zCoord = zCoord + MOVEMENT_CONSTANT
zCoord = zCoord + MOVEMENT_CONSTANT
DetachEntity(newVeh, 0, 0)
DetachEntity(newVeh, 0, 0)
AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true)
AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true)
end
end
if (IsControlPressed(1, 207)) then -- move down
if (IsControlPressed(1, 207)) then -- move down
zCoord = zCoord - MOVEMENT_CONSTANT
zCoord = zCoord - MOVEMENT_CONSTANT
DetachEntity(newVeh, 0, 0)
DetachEntity(newVeh, 0, 0)
AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true)
AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true)
end
end
end
end
function resetOffSets()
function resetOffSets()
xCoord = 0
xCoord = 0
yCoord = 0
yCoord = 0
zCoord = 0
zCoord = 0
xrot = 0
xrot = 0
yrot = 0
yrot = 0
zrot = 0
zrot = 0
end
end
function disableControls()
function disableControls()
Citizen.CreateThread(function()
Citizen.CreateThread(function()
while controlsDisabled do
while controlsDisabled do
Citizen.Wait(0)
Citizen.Wait(0)
DisableControlAction(0,21,true) -- disable sprint
DisableControlAction(0,21,true) -- disable sprint
DisableControlAction(0,24,true) -- disable attack
DisableControlAction(0,24,true) -- disable attack
DisableControlAction(0,25,true) -- disable aim
DisableControlAction(0,25,true) -- disable aim
DisableControlAction(0,47,true) -- disable weapon
DisableControlAction(0,47,true) -- disable weapon
DisableControlAction(0,58,true) -- disable weapon
DisableControlAction(0,58,true) -- disable weapon
DisableControlAction(0,263,true) -- disable melee
DisableControlAction(0,263,true) -- disable melee
DisableControlAction(0,264,true) -- disable melee
DisableControlAction(0,264,true) -- disable melee
DisableControlAction(0,257,true) -- disable melee
DisableControlAction(0,257,true) -- disable melee
DisableControlAction(0,140,true) -- disable melee
DisableControlAction(0,140,true) -- disable melee
DisableControlAction(0,141,true) -- disable melee
DisableControlAction(0,141,true) -- disable melee
DisableControlAction(0,142,true) -- disable melee
DisableControlAction(0,142,true) -- disable melee
DisableControlAction(0,143,true) -- disable melee
DisableControlAction(0,143,true) -- disable melee
DisableControlAction(0,75,true) -- disable exit vehicle
DisableControlAction(0,75,true) -- disable exit vehicle
DisableControlAction(27,75,true) -- disable exit vehicle
DisableControlAction(27,75,true) -- disable exit vehicle
DisableControlAction(0,32,true) -- move (w)
DisableControlAction(0,32,true) -- move (w)
DisableControlAction(0,34,true) -- move (a)
DisableControlAction(0,34,true) -- move (a)
DisableControlAction(0,33,true) -- move (s)
DisableControlAction(0,33,true) -- move (s)
DisableControlAction(0,35,true) -- move (d)
DisableControlAction(0,35,true) -- move (d)
DisableControlAction(0,71,true) -- move (d)
DisableControlAction(0,71,true) -- move (d)
DisableControlAction(0,72,true) -- move (d)
DisableControlAction(0,72,true) -- move (d)
end
end
end)
end)
end
end
Copiar
Copiado
Copiar
Copiado
RegisterNetEvent("
sound1Client")
RegisterNetEvent("
lightbar:
sound1Client")
AddEventHandler("
sound1Client", function(sender, toggle)
AddEventHandler("
lightbar:
sound1Client", function(sender, toggle)
local player_s = GetPlayerFromServerId(sender)
local player_s = GetPlayerFromServerId(sender)
local ped_s = GetPlayerPed(player_s)
local ped_s = GetPlayerPed(player_s)
if DoesEntityExist(ped_s) and not IsEntityDead(ped_s) then
if DoesEntityExist(ped_s) and not IsEntityDead(ped_s) then
if IsPedInAnyVehicle(ped_s, false) then
if IsPedInAnyVehicle(ped_s, false) then
local veh = GetVehiclePedIsUsing(ped_s)
local veh = GetVehiclePedIsUsing(ped_s)
TogPowercallStateForVeh(veh, toggle)
TogPowercallStateForVeh(veh, toggle)
end
end
end
end
end)
end)
function TogPowercallStateForVeh(veh, toggle)
function TogPowercallStateForVeh(veh, toggle)
if DoesEntityExist(veh) and not IsEntityDead(veh) then
if DoesEntityExist(veh) and not IsEntityDead(veh) then
if toggle == true then
if toggle == true then
if snd_pwrcall[veh] == nil then
if snd_pwrcall[veh] == nil then
snd_pwrcall[veh] = GetSoundId()
snd_pwrcall[veh] = GetSoundId()
PlaySoundFromEntity(snd_pwrcall[veh], sirenTone, veh, 0, 0, 0)
PlaySoundFromEntity(snd_pwrcall[veh], sirenTone, veh, 0, 0, 0)
sirenBool = true
sirenBool = true
end
end
else
else
if snd_pwrcall[veh] ~= nil then
if snd_pwrcall[veh] ~= nil then
--sirenToneNumber = 1
--sirenToneNumber = 1
StopSound(snd_pwrcall[veh])
StopSound(snd_pwrcall[veh])
ReleaseSoundId(snd_pwrcall[veh])
ReleaseSoundId(snd_pwrcall[veh])
snd_pwrcall[veh] = nil
snd_pwrcall[veh] = nil
sirenBool = false
sirenBool = false
end
end
end
end
end
end
end
end
function playAirHorn(bool)
function playAirHorn(bool)
local tempVeh = GetVehiclePedIsIn(GetPlayerPed(-1), false)
local tempVeh = GetVehiclePedIsIn(GetPlayerPed(-1), false)
local currPlate = GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false))
local currPlate = GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false))
if not(vehPlateBoolSavedData == currPlate) then
if not(vehPlateBoolSavedData == currPlate) then
Copiar
Copiado
Copiar
Copiado
TriggerServerEvent("
returnLightBarVehiclePlates")
TriggerServerEvent("
lightbar:
returnLightBarVehiclePlates")
while true do
while true do
if(vehPlateBoolSavedData == GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false))) then
if(vehPlateBoolSavedData == GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false))) then
break
break
end
end
if not(currPlate == GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false))) then
if not(currPlate == GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false))) then
return
return
end
end
Citizen.Wait(10)
Citizen.Wait(10)
end
end
end
end
if not(tempVeh == nil) and isPlateCar and vehPlateBoolSavedData == currPlate then
if not(tempVeh == nil) and isPlateCar and vehPlateBoolSavedData == currPlate then
if bool then
if bool then
airHornSirenID = GetSoundId()
airHornSirenID = GetSoundId()
PlaySoundFromEntity(airHornSirenID, "SIRENS_AIRHORN", tempVeh, 0, 0, 0)
PlaySoundFromEntity(airHornSirenID, "SIRENS_AIRHORN", tempVeh, 0, 0, 0)
end
end
if not bool then
if not bool then
StopSound(airHornSirenID)
StopSound(airHornSirenID)
ReleaseSoundId(airHornSirenIDs)
ReleaseSoundId(airHornSirenIDs)
airHornSirenID = nil
airHornSirenID = nil
end
end
end
end
end
end
Copiar
Copiado
Copiar
Copiado
RegisterNetEvent("
sendLightBarVehiclePlates")
RegisterNetEvent("
lightbar:
sendLightBarVehiclePlates")
AddEventHandler("
sendLightBarVehiclePlates", function(platesArr)
AddEventHandler("
lightbar:
sendLightBarVehiclePlates", function(platesArr)
local player = GetPlayerPed(-1)
local player = GetPlayerPed(-1)
local currPlate = GetVehicleNumberPlateText(GetVehiclePedIsIn(player, false))
local currPlate = GetVehicleNumberPlateText(GetVehiclePedIsIn(player, false))
for k,v in pairs(platesArr) do
for k,v in pairs(platesArr) do
if currPlate == v then
if currPlate == v then
vehPlateBoolSavedData = currPlate
vehPlateBoolSavedData = currPlate
isPlateCar = true
isPlateCar = true
return
return
end
end
end
end
vehPlateBoolSavedData = currPlate
vehPlateBoolSavedData = currPlate
isPlateCar = false
isPlateCar = false
end)
end)
function deleteArray()
function deleteArray()
for k,v in pairs(deleteVehicleLightbars) do
for k,v in pairs(deleteVehicleLightbars) do
DeleteVehicle(NetToVeh(v))
DeleteVehicle(NetToVeh(v))
end
end
end
end
Copiar
Copiado
Copiar
Copiado
RegisterNetEvent("
deleteLightbarVehicle")
RegisterNetEvent("
lightbar:
deleteLightbarVehicle")
AddEventHandler("
deleteLightbarVehicle", function(mainVehPlate)
AddEventHandler("
lightbar:
deleteLightbarVehicle", function(mainVehPlate)
TriggerServerEvent("
returnLightbarsForMainVeh", mainVehPlate)
TriggerServerEvent("
lightbar:
returnLightbarsForMainVeh", mainVehPlate)
end)
end)
Copiar
Copiado
Copiar
Copiado
RegisterNetEvent("
updateLightbarArray")
RegisterNetEvent("
lightbar:
updateLightbarArray")
AddEventHandler("
updateLightbarArray", function(plates)
AddEventHandler("
lightbar:
updateLightbarArray", function(plates)
deleteVehicleLightbars = plates
deleteVehicleLightbars = plates
if sirenBool then
if sirenBool then
toggleLights()
toggleLights()
end
end
deleteArray()
deleteArray()
isPlateCar = false
isPlateCar = false
lightBool = false
lightBool = false
sirenBool = false
sirenBool = false
end)
end)
Copiar
Copiado
Copiar
Copiado
RegisterNetEvent("
centerLightbarMenu")
RegisterNetEvent("
lightbar:
centerLightbarMenu")
AddEventHandler("
centerLightbarMenu", function()
AddEventHandler("
lightbar:
centerLightbarMenu", function()
xCoord = 0
xCoord = 0
yCoord = 0
yCoord = 0
zCoord = 0
zCoord = 0
xrot = 0
xrot = 0
yrot = 0
yrot = 0
zrot = 0
zrot = 0
end)
end)
-------------------MENU-------------------------
-------------------MENU-------------------------
Copiar
Copiado
Copiar
Copiado
RegisterNetEvent("lightbar:lightbar:itemUse")
local stationGarage = {
AddEventHandler("lightbar:lightbar:itemUse", function(playerId)
{x=452.115966796875, y=-1018.10681152344, z=28.55, r=10}, -- Mission row PD
if PlayerData.job ~= nil and PlayerData.job.name == Config.Job and PlayerData.job.grade >= Config.Rank then
{x=1866.84, y=3697.15, z=33.65, r=20}, -- Sandy Shores PD
SetNuiFocus(true, true)
{x=-457.88, y=6024.79, z=31.4, r=20}, -- Paleto Bay PD
SendNUIMessage({
{x=-237.292, y=6332.39, z=32.8, r=20}, -- Paleto Medical
action = 'open'
{x=1842.364, y=3707.348, z=33.57, r=20}, -- Sandy Medical (x=1842.64, y=3667.10, z=33.9)
})
--{x=-657.582, y=293.92, z=81.9, r=10}, -- Eclipse Medical
end
--{x=-875.983, y=-294.837, z=39.9, r=10}, -- Portola Medical
{x=1169.01, y=-1509.82, z=34.9, r=20}, -- St Fiacre Medical
{x=303.086, y=-1439.04, z=29.84, r=20}, -- Central Medical
{x=289.94, y=-591.10, z=43.12, r=20}, -- Pillbox
{x=-1073.0, y=-856.19, z=4.87, r=20}, -- Vespucci PD
{x=2030.98, y=3002.75, z=-72.70, r=10}, -- Vinewood PD
{x=386.35, y=-1633.96, z=29.29, r=20}, -- Innocence
{x=-570.88, y=-143.93, z=37.54, r=20}, -- Rockford
{x=969.84, y=-3020.10, z=-39.65, r=20}, -- Rockford
{x=-468.105, y=-338.575, z=34.45, r=10}, -- Mount Zonah Medical
}
_menuPool = MenuPool.New()
mainMenu = NativeUI.CreateMenu("Lightbar Menu", "")
_menuPool:Add(mainMenu)
_menuPool:RefreshIndex()
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
_menuPool:ProcessMenus()
if IsControlJustPressed(1, 167) then -- F2
--if exports.policejob:getIsInService() then
for i = 1, #stationGarage do
ply = GetPlayerPed(-1)
plyCoords = GetEntityCoords(ply, 0)
local distance = GetDistanceBetweenCoords(stationGarage[i].x, stationGarage[i].y, stationGarage[i].z, plyCoords["x"], plyCoords["y"], plyCoords["z"], true)
if(distance < stationGarage[i].r) then
mainMenu:Clear()
lightbarMenu(mainMenu)
_menuPool:RefreshIndex()
mainMenu:Visible(not mainMenu:Visible())
end
end
--end
end
end
end)
end)
Copiar
Copiado
Copiar
Copiado
function lightbarMenu(menu)
RegisterNUICallback('close', function(data, cb)
lightbarIndex = 1
SetNuiFocus(false, false)
end)
local item1 = NativeUI.CreateItem("Small Stick Light ", "")
mainMenu:AddItem(item1)
local item2 = NativeUI.CreateItem("Blue Stick Light ", "")
mainMenu:AddItem(item2)
local item3 = NativeUI.CreateItem("Red Stick Light ", "")
mainMenu:AddItem(item3)
local item4 = NativeUI.CreateItem("Blue Dome Light ", "")
mainMenu:AddItem(item4)
local item5 = NativeUI.CreateItem("Remove All Lights ", "")
mainMenu:AddItem(item5)
local item6 = NativeUI.CreateItem("Center Lightbar ", "")
mainMenu:AddItem(item6)
Copiar
Copiado
Copiar
Copiado
mainMenu.OnIndexChange= function(menu, newindex)
RegisterNUICallback('use', function(data, cb)
print("Old index: " .. lightbarIndex)
SetNuiFocus(false, false)
lightbarIndex = newindex
if data.type == '1' then
print("New index: " .. lightbarIndex)
TriggerEvent("lightbar:openLightbarMenu", "lightbarTwoSticks")
end
elseif data.type == '2' then
TriggerEvent("lightbar:openLightbarMenu", "longLightbar")
elseif data.type == '3' then
TriggerEvent("lightbar:openLightbarMenu", "longLightbarRed")
elseif data.type == '4' then
TriggerEvent("lightbar:openLightbarMenu", "fbiold")
elseif data.type == '5' then
TriggerEvent("lightbar:deleteLightbarVehicle", GetVehicleNumberPlateText(GetVehiclePedIsIn(PlayerPedId(), false)))
end
end)
Copiar
Copiado
Copiar
Copiado
mainMenu.OnItemSelect = function (sender, item, index)
if
Config.Command
then
if
lightbarIndex == 1
then
RegisterCommand('lightbar', function(source, args)
TriggerEvent("openLightbarMenu", "lightbarTwoSticks")
TriggerEvent('lightbar:lightbar:itemUse')
elseif lightbarIndex == 2 then
end)
TriggerEvent("openLightbarMenu", "longLightbar")
elseif lightbarIndex == 3 then
TriggerEvent("openLightbarMenu", "longLightbarRed")
elseif lightbarIndex == 4 then
TriggerEvent("openLightbarMenu", "fbiold")
elseif lightbarIndex == 5 then
TriggerEvent("deleteLightbarVehicle", GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false)))
elseif lightbarIndex == 6 then
TriggerEvent("centerLightbarMenu")
end
end
end
end
Copiar
Copiado
Copiar
Copiado
lightbarMenu(mainMenu)
Diferencias guardadas
Texto original
Abrir archivo
-- Version 0.1 -- Devloped by Everett aka Mr. Yellow aka Munky aka De_verett local carSpawned = false local newVeh = nil local inLightbarMenu = false local lightBool = false local sirenBool = false local oldSirenBool = false local controlsDisabled = false local xCoord = 0 local yCoord = 0 local zCoord = 0 local xrot = 0.0 local yrot = 0.0 local zrot = 0.0 local snd_pwrcall = {} local airHornSirenID = nil local sirenTone = "VEHICLES_HORNS_SIREN_1" local vehPlateBoolSavedData = nil local isPlateCar = false local isAirhornKeyPressed = false local deleteVehicleLightbars = {} Citizen.CreateThread(function() while true do Citizen.Wait(1) if inLightbarMenu then printControlsText() end local player = GetPlayerPed(-1) if (IsControlJustReleased(1, 44)) then -- Q to turn on lights toggleLights() end if (IsControlJustReleased(1, 47)) then -- G to turn on siren sirenTone = "VEHICLES_HORNS_SIREN_1" -- sets siren to default siren toggleSiren() end if (IsControlJustReleased(1, 210)) then -- Left control to change siren tone changeSirenTone() end if IsControlJustPressed(1, 184) and not isAirhornKeyPressed then playAirHorn(true) isAirhornKeyPressed = true if sirenBool then oldSirenBool = sirenBool toggleSiren() end end if IsControlJustReleased(1, 184) then playAirHorn(false) isAirhornKeyPressed = false if oldSirenBool then toggleSiren() oldSirenBool = false end end if isPlateCar then DisableControlAction(0,86,true) end -- Disables Veh horn end end) function printControlsText() SetTextFont(0) SetTextProportional(1) SetTextScale(0.0, 0.4) SetTextColour(128, 128, 255, 255) SetTextDropshadow(0, 0, 0, 0, 255) SetTextEdge(1, 0, 0, 0, 255) SetTextDropShadow() SetTextOutline() SetTextEntry("STRING") AddTextComponentString("Use your ↑ ↓ → ← Arrow Keys for Lateral Movements, Pg Up and Pg Down for Altitude Change") DrawText(0.25, 0.9) -- SetTextFont(0) SetTextProportional(1) SetTextScale(0.0, 0.4) SetTextColour(128, 128, 255, 255) SetTextDropshadow(0, 0, 0, 0, 255) SetTextEdge(1, 0, 0, 0, 255) SetTextDropShadow() SetTextOutline() SetTextEntry("STRING") AddTextComponentString("and Insert and Delete for rotation. SPACE to save, DELETE to cancel") DrawText(0.25, 0.93) end function toggleLights() local player = GetPlayerPed(-1) TriggerServerEvent("toggleLights2", GetVehicleNumberPlateText(GetVehiclePedIsIn(player, false))) if sirenBool == true then TriggerServerEvent("ToggleSound1Server", GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false))) end end function changeSirenTone() local currPlate = GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false)) if not(vehPlateBoolSavedData == currPlate) then TriggerServerEvent("returnLightBarVehiclePlates") while true do if(vehPlateBoolSavedData == GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false))) then break end if not(currPlate == GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false))) then return end Citizen.Wait(10) end end if isPlateCar then if sirenTone == "VEHICLES_HORNS_SIREN_1" then sirenTone = "VEHICLES_HORNS_SIREN_2" toggleSiren() toggleSiren() elseif sirenTone == "VEHICLES_HORNS_SIREN_2" then sirenTone = "VEHICLES_HORNS_POLICE_WARNING" toggleSiren() toggleSiren() else sirenTone = "VEHICLES_HORNS_SIREN_1" toggleSiren() toggleSiren() end end end RegisterNetEvent('openLightbarMenu') AddEventHandler('openLightbarMenu', function(lightbarModel) lightMenu(lightbarModel) end) RegisterNetEvent('clientToggleLights') AddEventHandler('clientToggleLights', function(lightsArray, lightsStatus, hostVehiclePointer) Citizen.CreateThread(function() for k,v in pairs(lightsArray) do NetworkRequestControlOfNetworkId(v) while not NetworkHasControlOfNetworkId(v) do Citizen.Wait(0) end local test1 = NetToVeh(v) lightBool = lightsStatus SetVehicleSiren(test1, not lightsStatus) end end) end) function toggleSiren() if lightBool == false then TriggerServerEvent("ToggleSound1Server", GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false))) end end function spawnLightbar(lightbarModel) print("Got to spawn") local player = GetPlayerPed(-1) local vehiclehash1 = GetHashKey(lightbarModel) RequestModel(vehiclehash1) Citizen.CreateThread(function() while not HasModelLoaded(vehiclehash1) do Citizen.Wait(100) end local coords = GetEntityCoords(player) newVeh = CreateVehicle(vehiclehash1, coords.x, coords.y, coords.z, GetEntityHeading(PlayerPedId()), true, 0) SetEntityCollision(newVeh, false, false) SetVehicleDoorsLocked(newVeh, 2) SetEntityAsMissionEntity(newVeh, true, true) end) end function lightMenu(lightbarModel) if not inLightbarMenu then inLightbarMenu = true local player = GetPlayerPed(-1) spawnLightbar(lightbarModel) controlsDisabled = true disableControls() AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, 0, 0, 0, 0.0, 0.0, 0.0, true, true, true, true, 0, true) while true do Citizen.Wait(10) --resetOffSets() moveObj(newVeh) if (IsControlJustReleased(1, 22)) then -- attatch obj and close TriggerServerEvent("addLightbar", GetVehicleNumberPlateText(GetVehiclePedIsIn(player, false)), VehToNet(newVeh), GetVehiclePedIsIn(player, false)) inLightbarMenu = false newVeh=nil controlsDisabled = false if(vehPlateBoolSavedData == GetVehicleNumberPlateText(GetVehiclePedIsIn(player, false))) then isPlateCar = true end break end if (IsControlJustReleased(1, 177)) then -- close menu inLightbarMenu = false DeleteVehicle(newVeh) newVeh = nil controlsDisabled = false break end end end end function moveObj(veh) local player = GetPlayerPed(-1) local MOVEMENT_CONSTANT = 0.01 local vehOffset = GetOffsetFromEntityInWorldCoords(newVeh, 0.0, 1.3, 0.0) if (IsControlJustReleased(1, 121)) then -- rotate 180 upside down yrot = yrot + 180.0 print("yrot = " .. yrot) DetachEntity(newVeh, 0, 0) AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true) end if (IsControlJustReleased(1, 178)) then -- rotate 180 zrot = zrot + 180 DetachEntity(newVeh, 0, 0) AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true) end if (IsControlPressed(1, 190)) then -- move forward xCoord = xCoord + MOVEMENT_CONSTANT DetachEntity(newVeh, 0, 0) AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true) end if (IsControlPressed(1, 189)) then -- move backwards xCoord = xCoord - MOVEMENT_CONSTANT DetachEntity(newVeh, 0, 0) AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true) end if (IsControlPressed(1, 27)) then -- move right yCoord = yCoord + MOVEMENT_CONSTANT DetachEntity(newVeh, 0, 0) AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true) end if (IsControlPressed(1, 187)) then -- move left yCoord = yCoord - MOVEMENT_CONSTANT DetachEntity(newVeh, 0, 0) AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true) end if (IsControlPressed(1, 208)) then -- move up zCoord = zCoord + MOVEMENT_CONSTANT DetachEntity(newVeh, 0, 0) AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true) end if (IsControlPressed(1, 207)) then -- move down zCoord = zCoord - MOVEMENT_CONSTANT DetachEntity(newVeh, 0, 0) AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true) end end function resetOffSets() xCoord = 0 yCoord = 0 zCoord = 0 xrot = 0 yrot = 0 zrot = 0 end function disableControls() Citizen.CreateThread(function() while controlsDisabled do Citizen.Wait(0) DisableControlAction(0,21,true) -- disable sprint DisableControlAction(0,24,true) -- disable attack DisableControlAction(0,25,true) -- disable aim DisableControlAction(0,47,true) -- disable weapon DisableControlAction(0,58,true) -- disable weapon DisableControlAction(0,263,true) -- disable melee DisableControlAction(0,264,true) -- disable melee DisableControlAction(0,257,true) -- disable melee DisableControlAction(0,140,true) -- disable melee DisableControlAction(0,141,true) -- disable melee DisableControlAction(0,142,true) -- disable melee DisableControlAction(0,143,true) -- disable melee DisableControlAction(0,75,true) -- disable exit vehicle DisableControlAction(27,75,true) -- disable exit vehicle DisableControlAction(0,32,true) -- move (w) DisableControlAction(0,34,true) -- move (a) DisableControlAction(0,33,true) -- move (s) DisableControlAction(0,35,true) -- move (d) DisableControlAction(0,71,true) -- move (d) DisableControlAction(0,72,true) -- move (d) end end) end RegisterNetEvent("sound1Client") AddEventHandler("sound1Client", function(sender, toggle) local player_s = GetPlayerFromServerId(sender) local ped_s = GetPlayerPed(player_s) if DoesEntityExist(ped_s) and not IsEntityDead(ped_s) then if IsPedInAnyVehicle(ped_s, false) then local veh = GetVehiclePedIsUsing(ped_s) TogPowercallStateForVeh(veh, toggle) end end end) function TogPowercallStateForVeh(veh, toggle) if DoesEntityExist(veh) and not IsEntityDead(veh) then if toggle == true then if snd_pwrcall[veh] == nil then snd_pwrcall[veh] = GetSoundId() PlaySoundFromEntity(snd_pwrcall[veh], sirenTone, veh, 0, 0, 0) sirenBool = true end else if snd_pwrcall[veh] ~= nil then --sirenToneNumber = 1 StopSound(snd_pwrcall[veh]) ReleaseSoundId(snd_pwrcall[veh]) snd_pwrcall[veh] = nil sirenBool = false end end end end function playAirHorn(bool) local tempVeh = GetVehiclePedIsIn(GetPlayerPed(-1), false) local currPlate = GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false)) if not(vehPlateBoolSavedData == currPlate) then TriggerServerEvent("returnLightBarVehiclePlates") while true do if(vehPlateBoolSavedData == GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false))) then break end if not(currPlate == GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false))) then return end Citizen.Wait(10) end end if not(tempVeh == nil) and isPlateCar and vehPlateBoolSavedData == currPlate then if bool then airHornSirenID = GetSoundId() PlaySoundFromEntity(airHornSirenID, "SIRENS_AIRHORN", tempVeh, 0, 0, 0) end if not bool then StopSound(airHornSirenID) ReleaseSoundId(airHornSirenIDs) airHornSirenID = nil end end end RegisterNetEvent("sendLightBarVehiclePlates") AddEventHandler("sendLightBarVehiclePlates", function(platesArr) local player = GetPlayerPed(-1) local currPlate = GetVehicleNumberPlateText(GetVehiclePedIsIn(player, false)) for k,v in pairs(platesArr) do if currPlate == v then vehPlateBoolSavedData = currPlate isPlateCar = true return end end vehPlateBoolSavedData = currPlate isPlateCar = false end) function deleteArray() for k,v in pairs(deleteVehicleLightbars) do DeleteVehicle(NetToVeh(v)) end end RegisterNetEvent("deleteLightbarVehicle") AddEventHandler("deleteLightbarVehicle", function(mainVehPlate) TriggerServerEvent("returnLightbarsForMainVeh", mainVehPlate) end) RegisterNetEvent("updateLightbarArray") AddEventHandler("updateLightbarArray", function(plates) deleteVehicleLightbars = plates if sirenBool then toggleLights() end deleteArray() isPlateCar = false lightBool = false sirenBool = false end) RegisterNetEvent("centerLightbarMenu") AddEventHandler("centerLightbarMenu", function() xCoord = 0 yCoord = 0 zCoord = 0 xrot = 0 yrot = 0 zrot = 0 end) -------------------MENU------------------------- local stationGarage = { {x=452.115966796875, y=-1018.10681152344, z=28.55, r=10}, -- Mission row PD {x=1866.84, y=3697.15, z=33.65, r=20}, -- Sandy Shores PD {x=-457.88, y=6024.79, z=31.4, r=20}, -- Paleto Bay PD {x=-237.292, y=6332.39, z=32.8, r=20}, -- Paleto Medical {x=1842.364, y=3707.348, z=33.57, r=20}, -- Sandy Medical (x=1842.64, y=3667.10, z=33.9) --{x=-657.582, y=293.92, z=81.9, r=10}, -- Eclipse Medical --{x=-875.983, y=-294.837, z=39.9, r=10}, -- Portola Medical {x=1169.01, y=-1509.82, z=34.9, r=20}, -- St Fiacre Medical {x=303.086, y=-1439.04, z=29.84, r=20}, -- Central Medical {x=289.94, y=-591.10, z=43.12, r=20}, -- Pillbox {x=-1073.0, y=-856.19, z=4.87, r=20}, -- Vespucci PD {x=2030.98, y=3002.75, z=-72.70, r=10}, -- Vinewood PD {x=386.35, y=-1633.96, z=29.29, r=20}, -- Innocence {x=-570.88, y=-143.93, z=37.54, r=20}, -- Rockford {x=969.84, y=-3020.10, z=-39.65, r=20}, -- Rockford {x=-468.105, y=-338.575, z=34.45, r=10}, -- Mount Zonah Medical } _menuPool = MenuPool.New() mainMenu = NativeUI.CreateMenu("Lightbar Menu", "") _menuPool:Add(mainMenu) _menuPool:RefreshIndex() Citizen.CreateThread(function() while true do Citizen.Wait(0) _menuPool:ProcessMenus() if IsControlJustPressed(1, 167) then -- F2 --if exports.policejob:getIsInService() then for i = 1, #stationGarage do ply = GetPlayerPed(-1) plyCoords = GetEntityCoords(ply, 0) local distance = GetDistanceBetweenCoords(stationGarage[i].x, stationGarage[i].y, stationGarage[i].z, plyCoords["x"], plyCoords["y"], plyCoords["z"], true) if(distance < stationGarage[i].r) then mainMenu:Clear() lightbarMenu(mainMenu) _menuPool:RefreshIndex() mainMenu:Visible(not mainMenu:Visible()) end end --end end end end) function lightbarMenu(menu) lightbarIndex = 1 local item1 = NativeUI.CreateItem("Small Stick Light ", "") mainMenu:AddItem(item1) local item2 = NativeUI.CreateItem("Blue Stick Light ", "") mainMenu:AddItem(item2) local item3 = NativeUI.CreateItem("Red Stick Light ", "") mainMenu:AddItem(item3) local item4 = NativeUI.CreateItem("Blue Dome Light ", "") mainMenu:AddItem(item4) local item5 = NativeUI.CreateItem("Remove All Lights ", "") mainMenu:AddItem(item5) local item6 = NativeUI.CreateItem("Center Lightbar ", "") mainMenu:AddItem(item6) mainMenu.OnIndexChange= function(menu, newindex) print("Old index: " .. lightbarIndex) lightbarIndex = newindex print("New index: " .. lightbarIndex) end mainMenu.OnItemSelect = function (sender, item, index) if lightbarIndex == 1 then TriggerEvent("openLightbarMenu", "lightbarTwoSticks") elseif lightbarIndex == 2 then TriggerEvent("openLightbarMenu", "longLightbar") elseif lightbarIndex == 3 then TriggerEvent("openLightbarMenu", "longLightbarRed") elseif lightbarIndex == 4 then TriggerEvent("openLightbarMenu", "fbiold") elseif lightbarIndex == 5 then TriggerEvent("deleteLightbarVehicle", GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false))) elseif lightbarIndex == 6 then TriggerEvent("centerLightbarMenu") end end end lightbarMenu(mainMenu)
Texto modificado
Abrir archivo
ESX = nil local PlayerData = {} Citizen.CreateThread(function() while ESX == nil do TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) while PlayerData.job == nil do PlayerData = ESX.GetPlayerData() end Citizen.Wait(0) end end) local carSpawned = false local newVeh = nil local inLightbarMenu = false local lightBool = false local sirenBool = false local oldSirenBool = false local controlsDisabled = false local xCoord = 0 local yCoord = 0 local zCoord = 0 local xrot = 0.0 local yrot = 0.0 local zrot = 0.0 local snd_pwrcall = {} local airHornSirenID = nil local sirenTone = "VEHICLES_HORNS_SIREN_1" local vehPlateBoolSavedData = nil local isPlateCar = false local isAirhornKeyPressed = false local deleteVehicleLightbars = {} Citizen.CreateThread(function() while true do Citizen.Wait(1) if inLightbarMenu then printControlsText() end local player = GetPlayerPed(-1) if (IsControlJustReleased(1, 44)) then -- Q to turn on lights toggleLights() end if (IsControlJustReleased(1, 246)) then -- Y to turn on siren sirenTone = "VEHICLES_HORNS_SIREN_1" -- sets siren to default siren toggleSiren() end if (IsControlJustReleased(1, 210)) then -- Left control to change siren tone changeSirenTone() end if IsControlJustPressed(1, 184) and not isAirhornKeyPressed then playAirHorn(true) isAirhornKeyPressed = true if sirenBool then oldSirenBool = sirenBool toggleSiren() end end if IsControlJustReleased(1, 184) then playAirHorn(false) isAirhornKeyPressed = false if oldSirenBool then toggleSiren() oldSirenBool = false end end if isPlateCar then DisableControlAction(0,86,true) end -- Disables Veh horn end end) function printControlsText() SetTextFont(0) SetTextProportional(1) SetTextScale(0.0, 0.4) SetTextColour(128, 128, 255, 255) SetTextDropshadow(0, 0, 0, 0, 255) SetTextEdge(1, 0, 0, 0, 255) SetTextDropShadow() SetTextOutline() SetTextEntry("STRING") AddTextComponentString("Use your ↑ ↓ → ← Arrow Keys for Lateral Movements, Pg Up and Pg Down for Altitude Change") DrawText(0.25, 0.9) -- SetTextFont(0) SetTextProportional(1) SetTextScale(0.0, 0.4) SetTextColour(128, 128, 255, 255) SetTextDropshadow(0, 0, 0, 0, 255) SetTextEdge(1, 0, 0, 0, 255) SetTextDropShadow() SetTextOutline() SetTextEntry("STRING") AddTextComponentString("and Insert and Delete for rotation. SPACE to save, DELETE to cancel") DrawText(0.25, 0.93) end function toggleLights() local player = GetPlayerPed(-1) TriggerServerEvent("lightbar:toggleLights2", GetVehicleNumberPlateText(GetVehiclePedIsIn(player, false))) if sirenBool == true then TriggerServerEvent("lightbar:ToggleSound1Server", GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false))) end end function changeSirenTone() local currPlate = GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false)) if not(vehPlateBoolSavedData == currPlate) then TriggerServerEvent("lightbar:returnLightBarVehiclePlates") while true do if(vehPlateBoolSavedData == GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false))) then break end if not(currPlate == GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false))) then return end Citizen.Wait(10) end end if isPlateCar then if sirenTone == "VEHICLES_HORNS_SIREN_1" then sirenTone = "VEHICLES_HORNS_SIREN_2" toggleSiren() toggleSiren() elseif sirenTone == "VEHICLES_HORNS_SIREN_2" then sirenTone = "VEHICLES_HORNS_POLICE_WARNING" toggleSiren() toggleSiren() else sirenTone = "VEHICLES_HORNS_SIREN_1" toggleSiren() toggleSiren() end end end RegisterNetEvent('lightbar:openLightbarMenu') AddEventHandler('lightbar:openLightbarMenu', function(lightbarModel) lightMenu(lightbarModel) end) RegisterNetEvent('lightbar:clientToggleLights') AddEventHandler('lightbar:clientToggleLights', function(lightsArray, lightsStatus, hostVehiclePointer) Citizen.CreateThread(function() for k,v in pairs(lightsArray) do NetworkRequestControlOfNetworkId(v) while not NetworkHasControlOfNetworkId(v) do Citizen.Wait(0) end local test1 = NetToVeh(v) lightBool = lightsStatus SetVehicleSiren(test1, not lightsStatus) end end) end) function toggleSiren() if lightBool == false then TriggerServerEvent("lightbar:ToggleSound1Server", GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false))) end end function spawnLightbar(lightbarModel) local player = GetPlayerPed(-1) local vehiclehash1 = GetHashKey(lightbarModel) RequestModel(vehiclehash1) Citizen.CreateThread(function() while not HasModelLoaded(vehiclehash1) do Citizen.Wait(100) end local coords = GetEntityCoords(player) newVeh = CreateVehicle(vehiclehash1, coords.x, coords.y, coords.z, GetEntityHeading(PlayerPedId()), true, 0) SetEntityCollision(newVeh, false, false) SetVehicleDoorsLocked(newVeh, 2) SetEntityAsMissionEntity(newVeh, true, true) end) end function lightMenu(lightbarModel) if not inLightbarMenu then inLightbarMenu = true local player = GetPlayerPed(-1) spawnLightbar(lightbarModel) controlsDisabled = true disableControls() AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, 0, 0, 0, 0.0, 0.0, 0.0, true, true, true, true, 0, true) while true do Citizen.Wait(10) --resetOffSets() moveObj(newVeh) if (IsControlJustReleased(1, 22)) then -- attatch obj and close TriggerServerEvent("lightbar:addLightbar", GetVehicleNumberPlateText(GetVehiclePedIsIn(player, false)), VehToNet(newVeh), GetVehiclePedIsIn(player, false)) inLightbarMenu = false newVeh=nil controlsDisabled = false if(vehPlateBoolSavedData == GetVehicleNumberPlateText(GetVehiclePedIsIn(player, false))) then isPlateCar = true end break end if (IsControlJustReleased(1, 177)) then -- close menu inLightbarMenu = false DeleteVehicle(newVeh) newVeh = nil controlsDisabled = false break end end end end function moveObj(veh) local player = GetPlayerPed(-1) local MOVEMENT_CONSTANT = 0.01 local vehOffset = GetOffsetFromEntityInWorldCoords(newVeh, 0.0, 1.3, 0.0) if (IsControlJustReleased(1, 121)) then -- rotate 180 upside down yrot = yrot + 180.0 DetachEntity(newVeh, 0, 0) AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true) end if (IsControlJustReleased(1, 178)) then -- rotate 180 zrot = zrot + 180 DetachEntity(newVeh, 0, 0) AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true) end if (IsControlPressed(1, 190)) then -- move forward xCoord = xCoord + MOVEMENT_CONSTANT DetachEntity(newVeh, 0, 0) AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true) end if (IsControlPressed(1, 189)) then -- move backwards xCoord = xCoord - MOVEMENT_CONSTANT DetachEntity(newVeh, 0, 0) AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true) end if (IsControlPressed(1, 27)) then -- move right yCoord = yCoord + MOVEMENT_CONSTANT DetachEntity(newVeh, 0, 0) AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true) end if (IsControlPressed(1, 187)) then -- move left yCoord = yCoord - MOVEMENT_CONSTANT DetachEntity(newVeh, 0, 0) AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true) end if (IsControlPressed(1, 208)) then -- move up zCoord = zCoord + MOVEMENT_CONSTANT DetachEntity(newVeh, 0, 0) AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true) end if (IsControlPressed(1, 207)) then -- move down zCoord = zCoord - MOVEMENT_CONSTANT DetachEntity(newVeh, 0, 0) AttachEntityToEntity(newVeh, GetVehiclePedIsIn(player, false), 0, xCoord, yCoord, zCoord, xrot, yrot, zrot, true, true, true, true, 0, true) end end function resetOffSets() xCoord = 0 yCoord = 0 zCoord = 0 xrot = 0 yrot = 0 zrot = 0 end function disableControls() Citizen.CreateThread(function() while controlsDisabled do Citizen.Wait(0) DisableControlAction(0,21,true) -- disable sprint DisableControlAction(0,24,true) -- disable attack DisableControlAction(0,25,true) -- disable aim DisableControlAction(0,47,true) -- disable weapon DisableControlAction(0,58,true) -- disable weapon DisableControlAction(0,263,true) -- disable melee DisableControlAction(0,264,true) -- disable melee DisableControlAction(0,257,true) -- disable melee DisableControlAction(0,140,true) -- disable melee DisableControlAction(0,141,true) -- disable melee DisableControlAction(0,142,true) -- disable melee DisableControlAction(0,143,true) -- disable melee DisableControlAction(0,75,true) -- disable exit vehicle DisableControlAction(27,75,true) -- disable exit vehicle DisableControlAction(0,32,true) -- move (w) DisableControlAction(0,34,true) -- move (a) DisableControlAction(0,33,true) -- move (s) DisableControlAction(0,35,true) -- move (d) DisableControlAction(0,71,true) -- move (d) DisableControlAction(0,72,true) -- move (d) end end) end RegisterNetEvent("lightbar:sound1Client") AddEventHandler("lightbar:sound1Client", function(sender, toggle) local player_s = GetPlayerFromServerId(sender) local ped_s = GetPlayerPed(player_s) if DoesEntityExist(ped_s) and not IsEntityDead(ped_s) then if IsPedInAnyVehicle(ped_s, false) then local veh = GetVehiclePedIsUsing(ped_s) TogPowercallStateForVeh(veh, toggle) end end end) function TogPowercallStateForVeh(veh, toggle) if DoesEntityExist(veh) and not IsEntityDead(veh) then if toggle == true then if snd_pwrcall[veh] == nil then snd_pwrcall[veh] = GetSoundId() PlaySoundFromEntity(snd_pwrcall[veh], sirenTone, veh, 0, 0, 0) sirenBool = true end else if snd_pwrcall[veh] ~= nil then --sirenToneNumber = 1 StopSound(snd_pwrcall[veh]) ReleaseSoundId(snd_pwrcall[veh]) snd_pwrcall[veh] = nil sirenBool = false end end end end function playAirHorn(bool) local tempVeh = GetVehiclePedIsIn(GetPlayerPed(-1), false) local currPlate = GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false)) if not(vehPlateBoolSavedData == currPlate) then TriggerServerEvent("lightbar:returnLightBarVehiclePlates") while true do if(vehPlateBoolSavedData == GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false))) then break end if not(currPlate == GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false))) then return end Citizen.Wait(10) end end if not(tempVeh == nil) and isPlateCar and vehPlateBoolSavedData == currPlate then if bool then airHornSirenID = GetSoundId() PlaySoundFromEntity(airHornSirenID, "SIRENS_AIRHORN", tempVeh, 0, 0, 0) end if not bool then StopSound(airHornSirenID) ReleaseSoundId(airHornSirenIDs) airHornSirenID = nil end end end RegisterNetEvent("lightbar:sendLightBarVehiclePlates") AddEventHandler("lightbar:sendLightBarVehiclePlates", function(platesArr) local player = GetPlayerPed(-1) local currPlate = GetVehicleNumberPlateText(GetVehiclePedIsIn(player, false)) for k,v in pairs(platesArr) do if currPlate == v then vehPlateBoolSavedData = currPlate isPlateCar = true return end end vehPlateBoolSavedData = currPlate isPlateCar = false end) function deleteArray() for k,v in pairs(deleteVehicleLightbars) do DeleteVehicle(NetToVeh(v)) end end RegisterNetEvent("lightbar:deleteLightbarVehicle") AddEventHandler("lightbar:deleteLightbarVehicle", function(mainVehPlate) TriggerServerEvent("lightbar:returnLightbarsForMainVeh", mainVehPlate) end) RegisterNetEvent("lightbar:updateLightbarArray") AddEventHandler("lightbar:updateLightbarArray", function(plates) deleteVehicleLightbars = plates if sirenBool then toggleLights() end deleteArray() isPlateCar = false lightBool = false sirenBool = false end) RegisterNetEvent("lightbar:centerLightbarMenu") AddEventHandler("lightbar:centerLightbarMenu", function() xCoord = 0 yCoord = 0 zCoord = 0 xrot = 0 yrot = 0 zrot = 0 end) -------------------MENU------------------------- RegisterNetEvent("lightbar:lightbar:itemUse") AddEventHandler("lightbar:lightbar:itemUse", function(playerId) if PlayerData.job ~= nil and PlayerData.job.name == Config.Job and PlayerData.job.grade >= Config.Rank then SetNuiFocus(true, true) SendNUIMessage({ action = 'open' }) end end) RegisterNUICallback('close', function(data, cb) SetNuiFocus(false, false) end) RegisterNUICallback('use', function(data, cb) SetNuiFocus(false, false) if data.type == '1' then TriggerEvent("lightbar:openLightbarMenu", "lightbarTwoSticks") elseif data.type == '2' then TriggerEvent("lightbar:openLightbarMenu", "longLightbar") elseif data.type == '3' then TriggerEvent("lightbar:openLightbarMenu", "longLightbarRed") elseif data.type == '4' then TriggerEvent("lightbar:openLightbarMenu", "fbiold") elseif data.type == '5' then TriggerEvent("lightbar:deleteLightbarVehicle", GetVehicleNumberPlateText(GetVehiclePedIsIn(PlayerPedId(), false))) end end) if Config.Command then RegisterCommand('lightbar', function(source, args) TriggerEvent('lightbar:lightbar:itemUse') end) end
Encontrar la diferencia