0% acharam este documento útil (0 voto)
8 visualizações20 páginas

Atualização do HUD no VRP

codigo do bao em lua

Enviado por

vitinhoooprime
Direitos autorais
© All Rights Reserved
Levamos muito a sério os direitos de conteúdo. Se você suspeita que este conteúdo é seu, reivindique-o aqui.
Formatos disponíveis
Baixe no formato TXT, PDF, TXT ou leia on-line no Scribd
0% acharam este documento útil (0 voto)
8 visualizações20 páginas

Atualização do HUD no VRP

codigo do bao em lua

Enviado por

vitinhoooprime
Direitos autorais
© All Rights Reserved
Levamos muito a sério os direitos de conteúdo. Se você suspeita que este conteúdo é seu, reivindique-o aqui.
Formatos disponíveis
Baixe no formato TXT, PDF, TXT ou leia on-line no Scribd

-----------------------------------------------------------------------------------

------------------------------------------------------
-- VRP
-----------------------------------------------------------------------------------
------------------------------------------------------
local Tunnel = module("vrp","lib/Tunnel")
local Proxy = module("vrp","lib/Proxy")
vRP = [Link]("vRP")
-----------------------------------------------------------------------------------
------------------------------------------------------
-- CONNECTION
-----------------------------------------------------------------------------------
------------------------------------------------------
local Srr = {}
[Link]("hud", Srr)
vSERVER = [Link]("hud")
-----------------------------------------------------------------------------------
------------------------------------------------------
-- VARIABLES
-----------------------------------------------------------------------------------
------------------------------------------------------
local
health,armour,hunger,thirst,stamine,frequency,voiceLevel,voiceActive,gems,passport,
NitroFuel = 100,100,100,100,100,0,0,0,0,0,0
local hudVisibility,pausemenu,weaponVisibility,NitroFlame,PurgeActive =
true,false,false,false,false
local LightTrails,LightParticles,PurgeSprays,PurgeParticles = {},{},{},{}
local hungerTimer,thirstTimer = GetGameTimer(),GetGameTimer()

local weather = GlobalState["Weather"]


local hours = GlobalState["Hours"] or 0
local minutes = GlobalState["Minutes"] or 0

local NitroButton = GetGameTimer()


LocalPlayer["state"]["Nitro"] = false

local stress = 0
local lastUpdateTime = GetGameTimer()

local loggedStreets = {}

local currentStreetName = ""


local currentCrossingName = ""
local lastStreetUpdate = ""
local lastStreetPushTime = GetGameTimer()
-----------------------------------------------------------------------------------
------------------------------------------------------
-- STREET TRANSLATION FUNCTION
-----------------------------------------------------------------------------------
------------------------------------------------------
local function getTranslatedStreet(street)
if not street or street == "" then
return "Localização Desconhecida"
end

local translated = [Link][street]


if translated then
return translated
end
if [Link](street, " Street$") then
local abbreviatedStreet = [Link](street, " Street$", " St")
translated = [Link][abbreviatedStreet]
if translated then
return translated
end
end

-- Se não encontrou e termina com "St", tenta versão completa "Street"


if [Link](street, " St$") then
local fullStreet = [Link](street, " St$", " Street")
translated = [Link][fullStreet]
if translated then
return translated
end
end

-- Log para ruas sem tradução (apenas uma vez por rua para evitar spam)
if not loggedStreets[street] then
print("[HUD] Tradução não encontrada para: \"" .. street .. "\"")
loggedStreets[street] = true
end

-- Retorna o nome original se não encontrou tradução


return street
end

-----------------------------------------------------------------------------------
------------------------------------------------------
-- VISIBILITY
-----------------------------------------------------------------------------------
------------------------------------------------------
RegisterNetEvent("hud:Active")
AddEventHandler("hud:Active",function(status)
hudVisibility = status
SendNUIMessage({ action = "setVisibility", data = status })

-- Solicitar dados atualizados do servidor quando ativar o HUD


if status then
TriggerServerEvent("hud:RequestUpdate")

-- Enviar dados de rua e cruzamento imediatamente quando ativar o HUD


local coords = GetEntityCoords(PlayerPedId())
local streetHash, crossingHash = GetStreetNameAtCoord(coords.x, coords.y,
coords.z)
local streetName = GetStreetNameFromHashKey(streetHash)
local crossingName = (crossingHash and crossingHash ~= 0) and
GetStreetNameFromHashKey(crossingHash) or ""

-- Atualizar variáveis de controle


currentStreetName = streetName
currentCrossingName = crossingName
local translatedStreet = getTranslatedStreet(streetName)
local translatedCrossing = crossingName ~= "" and
getTranslatedStreet(crossingName) or ""
SendNUIMessage({action = "setStreet", data = translatedStreet})
SendNUIMessage({action = "setCrossing", data = translatedCrossing})
print("HUD Activated - Street: " .. tostring(streetName) .. " -> " ..
tostring(translatedStreet))

-- Enviar dados iniciais imediatamente quando ativar o HUD


local currentHours = hours or 0
local currentMinutes = minutes or 0
SendNUIMessage({action = "setInfos", data = {
time = {currentHours, currentMinutes},
frequency = frequency,
voiceLevel = voiceLevel,
voiceActive = voiceActive,
gems = gems,
userId = passport
}})

-- Enviar stats atuais (vida, colete, stamina) imediatamente


local ped = PlayerPedId()
local pedHealth = GetEntityHealth(ped) - 100
local healthPercentage = [Link]((pedHealth / 100) * 100)
if healthPercentage > 100 then healthPercentage = 100 end
if healthPercentage < 0 then healthPercentage = 0 end
local pedArmour = GetPedArmour(ped)
local pedStamina = GetPlayerStamina(PlayerId())
SendNUIMessage({action = "setStats", data = { health = healthPercentage,
armour = pedArmour, stamina = pedStamina }})
end
end)

-- Novo evento para receber dados do servidor


RegisterNetEvent("hud:UpdateData")
AddEventHandler("hud:UpdateData", function(data)
if data then
if [Link] then
hunger = [Link]
SendNUIMessage({action = "setStats", data = { hunger = hunger }})
end
if [Link] then
thirst = [Link]
SendNUIMessage({action = "setStats", data = { thirst = thirst }})
end
if [Link] then
stress = [Link]
SendNUIMessage({action = "setStats", data = { stress = stress }})
end
if [Link] then
gems = [Link]
SendNUIMessage({action = "setInfos", data = { gems = gems }})
end
if [Link] then
passport = [Link]
SendNUIMessage({action = "setInfos", data = { userId = passport }})
end
end
end)

-- Evento para stress


RegisterNetEvent("hud:Stress")
AddEventHandler("hud:Stress",function(number)
stress = number
SendNUIMessage({action = "setStats", data = { stress = stress }})
end)

-- Evento para gemas


RegisterNetEvent("hud:Gems")
AddEventHandler("hud:Gems",function(number)
gems = number
SendNUIMessage({action = "setInfos", data = { gems = gems }})
end)

-- Evento para adicionar gemas (quando usar itens)


RegisterNetEvent("hud:AddGemstone")
AddEventHandler("hud:AddGemstone",function(amount)
gems = gems + amount
SendNUIMessage({action = "setInfos", data = { gems = gems }})
end)

-- Evento para vida (health)


RegisterNetEvent("hud:Health")
AddEventHandler("hud:Health",function(number)
health = number
SendNUIMessage({action = "setStats", data = { health = health }})
end)

-----------------------------------------------------------------------------------
------------------------------------------------------
-- NOTIFY
-----------------------------------------------------------------------------------
------------------------------------------------------
local title = {
["fome"] = "Fome",
["sede"] = "Sede",
["amarelo"] = "Aviso",
["azul"] = "Notificação",
["vermelho"] = "Negado",
["verde"] = "Sucesso",
}

RegisterNetEvent("Notify")
AddEventHandler("Notify",function(type,message,time)
if not time then time = 5000 end
SendNUIMessage({ action = "addNotify", data = { theme = type, title =
title[type] or "Notificação", message = message, delay = time } })
end)
-----------------------------------------------------------------------------------
------------------------------------------------------
-- PROGRESS
-----------------------------------------------------------------------------------
------------------------------------------------------
RegisterNetEvent("Progress")
AddEventHandler("Progress",function(message,delay)
if not delay or not message then return end
SendNUIMessage({action = "addProgress",data = { title = "Progresso", message =
message, delay = delay }})
end)
-----------------------------------------------------------------------------------
------------------------------------------------------
-- ALERTS
-----------------------------------------------------------------------------------
------------------------------------------------------
RegisterNetEvent("Alerts")
AddEventHandler("Alerts",function(data)
SendNUIMessage({ action = "addAlert", data = { icon = [Link], color =
[Link], time = [Link], title = [Link], author = [Link], message =
[Link], delay = [Link] }})
end)
-----------------------------------------------------------------------------------
------------------------------------------------------
-- HEALTH
-----------------------------------------------------------------------------------
------------------------------------------------------
AddEventHandler('gameEventTriggered', function (name, args)
if name == "CEventNetworkEntityDamage" then
if PlayerPedId() ~= args[1] then return end
-- Atualizar vida mesmo quando HUD estiver invisível
local newHealth = GetEntityHealth(args[1]) - 100
-- Calcular vida como porcentagem de 200 (vida máxima)
local healthPercentage = [Link]((newHealth / 100) * 100)
if healthPercentage > 100 then healthPercentage = 100 end
if healthPercentage < 0 then healthPercentage = 0 end

health = healthPercentage
SendNUIMessage({action = "setStats", data = { health = health }})
end
end)
-----------------------------------------------------------------------------------
------------------------------------------------------
-- THREAD
-----------------------------------------------------------------------------------
------------------------------------------------------
CreateThread(function()
LoadPtfxAsset("veh_xs_vehicle_mods")
DisplayRadar(false)

RequestStreamedTextureDict("circlemap", false)
while not HasStreamedTextureDictLoaded("circlemap") do
Wait(500)
end
AddReplaceTexture("platform:/textures/graphics", "radarmasksm", "circlemap",
"radarmasksm")

SetNuiFocus(false)

-- Ativar a HUD por padrão


hudVisibility = true
SendNUIMessage({ action = "setVisibility", data = true })

-- Solicitar dados iniciais do servidor


TriggerServerEvent("hud:RequestUpdate")

-- Enviar horário inicial para a NUI


local currentHours = hours or 0
local currentMinutes = minutes or 0
SendNUIMessage({action = "setInfos", data = { time = {currentHours,
currentMinutes}} })

-- Enviar nome da rua inicial e cruzamento


local coords = GetEntityCoords(PlayerPedId())
local streetHash, crossingHash = GetStreetNameAtCoord(coords.x, coords.y,
coords.z)
local streetName = GetStreetNameFromHashKey(streetHash)
local crossingName = (crossingHash and crossingHash ~= 0) and
GetStreetNameFromHashKey(crossingHash) or ""

-- Atualizar variáveis de controle


currentStreetName = streetName
currentCrossingName = crossingName
local translatedStreet = getTranslatedStreet(streetName)
local translatedCrossing = crossingName ~= "" and
getTranslatedStreet(crossingName) or ""
SendNUIMessage({action = "setStreet", data = translatedStreet})
SendNUIMessage({action = "setCrossing", data = translatedCrossing})

print("HUD Initialized - Initial Street: " .. tostring(streetName) .. " -> " ..


tostring(translatedStreet))

while true do
-- Atualizações de vida/colete/stamina SEM depender da visibilidade
local ped = PlayerPedId()
local newHealthVal = GetEntityHealth(ped) - 100
local newArmour = GetPedArmour(ped)
local newStamine = GetPlayerStamina(PlayerId())

-- Calcular vida como porcentagem de 200 (vida máxima)


local healthPercentage = [Link]((newHealthVal / 100) * 100)
if healthPercentage > 100 then healthPercentage = 100 end
if healthPercentage < 0 then healthPercentage = 0 end

if healthPercentage ~= health then


health = healthPercentage
SendNUIMessage({action = "setStats", data = { health = health }})
end
if newArmour ~= armour then
armour = newArmour
SendNUIMessage({action = "setStats", data = { armour = armour }})
end
if newStamine ~= stamine then
stamine = newStamine
SendNUIMessage({action = "setStats", data = { stamina = stamine }})
end

-- Pausa: esconder HUD quando menu estiver aberto


if hudVisibility then
if IsPauseMenuActive() and not pausemenu then
pausemenu = true
SendNUIMessage({ action = "setVisibility", data = false })
elseif not IsPauseMenuActive() and pausemenu then
pausemenu = false
SendNUIMessage({ action = "setVisibility", data = true })
end

-- Solicitar atualização do servidor periodicamente


if GetGameTimer() - lastUpdateTime > 10000 then -- A cada 10 segundos
TriggerServerEvent("hud:RequestUpdate")
lastUpdateTime = GetGameTimer()
end
if hungerTimer <= GetGameTimer() then
hungerTimer = GetGameTimer() + 50000

if hunger < 5 and GetEntityHealth(ped) > 100 then


DoScreenFadeOut(0)

if not IsPedInAnyVehicle(ped) then


SetPedToRagdoll(ped,2500,2500,0,0,0,0)
end

SetTimeout(500,function()
DoScreenFadeIn(0)
end)

ApplyDamageToPed(ped,[Link](2),false)
TriggerEvent("Notify","fome","Sofrendo com a
fome.",2500)
end
end

if thirstTimer <= GetGameTimer() then


thirstTimer = GetGameTimer() + 10000

if thirst < 5 and GetEntityHealth(ped) > 100 then


ApplyDamageToPed(ped,[Link](1),false)
TriggerEvent("Notify","sede","Sofrendo com a
sede.",2500)
end
end

end
Wait(250) -- Intervalo ajustado para bom equilíbrio entre performance e
responsividade
end
end)

-- Evento do servidor para solicitar atualização


RegisterNetEvent("hud:RequestUpdate")
AddEventHandler("hud:RequestUpdate", function()
TriggerServerEvent("hud:RequestUpdate")
end)

RegisterNetEvent("hud:Weapon")
AddEventHandler("hud:Weapon",function(Status,Hash)
weaponVisibility = Status
if not Status then
SendNUIMessage({ action = "setWeapon", data = false })
return
end
CreateThread(function()
while weaponVisibility do
local ped = PlayerPedId()
if IsPedArmed(ped,6) then
local weapon = GetSelectedPedWeapon(ped)
local __, ammoClip = GetAmmoInClip(ped, weapon)
local maxAmmo = GetAmmoInPedWeapon(ped, weapon)
local Ammo = maxAmmo - ammoClip
if Config["Weapon"][weapon] then
SendNUIMessage({ action = "setWeapon", data = { image
= Config["Weapon"][weapon].image or "", name = Config["Weapon"][weapon].name or
"", ammo = ammoClip.."/"..Ammo }})
else
SendNUIMessage({ action = "setWeapon", data = { image
= "Arma Indefinida", name = "", ammo = ammoClip.."/"..Ammo }})
end
else
if weaponVisibility then
SendNUIMessage({ action = "setWeapon", data = false })
weaponVisibility = false
end
end
Wait(100)
end
end)
end)
-----------------------------------------------------------------------------------
------------------------------------------------------
-- VEHICLE
-----------------------------------------------------------------------------------
------------------------------------------------------
local seatbeltSpeed = 0
local seatbeltLock = false
local seatbeltVelocity = vec3(0,0,0)

AddEventHandler('gameEventTriggered', function (name, args)


if name == "CEventNetworkPlayerEnteredVehicle" then
if args[1] ~= PlayerId() then return end
SendNUIMessage({ action = "setVehicleHud", data = true })
DisplayRadar(true)
while IsPedInAnyVehicle(PlayerPedId()) do
local ped = PlayerPedId()
local vehicle = GetVehiclePedIsIn(ped)
local speed = [Link](GetEntitySpeed(vehicle) * 3.6)
local gear = tostring(GetVehicleCurrentGear(vehicle))
if (speed == 0 and gear == "0") or (speed == 0 and gear == "1") then
gear = "N"
elseif (speed > 0 and gear == "0") then
gear = "R"
end
if not IsPedOnAnyBike(ped) and not IsPedInAnyHeli(ped) and not
IsPedInAnyPlane(ped) then

if GetVehicleDoorLockStatus(vehicle) == 2 or seatbeltLock
then
DisableControlAction(1,75,true)
end

if speed ~= seatbeltSpeed then


if (seatbeltSpeed - speed) >= 60 and not seatbeltLock
then
SmashVehicleWindow(vehicle,6)
SetEntityNoCollisionEntity(ped,vehicle,false)
SetEntityNoCollisionEntity(vehicle,ped,false)

TriggerServerEvent("hud:VehicleEject",seatbeltVelocity)

Wait(500)
SetEntityNoCollisionEntity(ped,vehicle,true)
SetEntityNoCollisionEntity(vehicle,ped,true)
end

seatbeltVelocity = GetEntityVelocity(vehicle)
seatbeltSpeed = speed
end
end

local Nitro = false


if Entity(vehicle).[Link] and Entity(vehicle).[Link] >
0 then
Nitro = Entity(vehicle).[Link] / 20
end

SendNUIMessage({ action = "setVehicleData", data =


{
nitro = Nitro,
rpm = GetVehicleCurrentRpm(vehicle),
gear = gear,
speed = speed,
fuel = GetVehicleFuelLevel(vehicle),
engine = (GetVehicleEngineHealth(vehicle) / 10),
locked = (GetVehicleDoorLockStatus(vehicle) == 1)
}})
Wait(50)
end
SendNUIMessage({ action = "setVehicleHud", data = false })
DisplayRadar(false)

if seatbeltSpeed ~= 0 then
seatbeltSpeed = 0
end
if seatbeltLock then
seatbeltLock = false
end

if NitroFlame then
NitroDisable()
end

end
end)

RegisterCommand("Beltz",function(source)
local ped = PlayerPedId()
if IsPedInAnyVehicle(ped) then
if not IsPedOnAnyBike(ped) and not IsPedInAnyHeli(ped) and not
IsPedInAnyPlane(ped) then
if seatbeltLock then
TriggerEvent("sounds:Private","unbelt",0.5)
seatbeltLock = false
SendNUIMessage({ action = "setVehicleData", data =
{seatbelt = seatbeltLock}})
else
TriggerEvent("sounds:Private","belt",0.5)
seatbeltLock = true
SendNUIMessage({ action = "setVehicleData", data =
{seatbelt = seatbeltLock}})
end
end
end
end)

RegisterKeyMapping("Beltz","Colocar/Retirar o cinto.","keyboard","G")
-----------------------------------------------------------------------------------
------------------------------------------------------
-- UPDATEINFOS
-----------------------------------------------------------------------------------
------------------------------------------------------
AddStateBagChangeHandler("Weather", nil, function(_, __, value)
weather = value
end)

AddStateBagChangeHandler("Hours", nil, function(_, __, value)


hours = value
local currentHours = hours or 0
local currentMinutes = minutes or 0
SendNUIMessage({action = "setInfos", data = { time = {currentHours,
currentMinutes}} })
end)

AddStateBagChangeHandler("Minutes", nil, function(_, __, value)


minutes = value
local currentHours = hours or 0
local currentMinutes = minutes or 0
SendNUIMessage({action = "setInfos", data = { time = {currentHours,
currentMinutes}} })
end)

RegisterNetEvent("cda_hud:updateKm")
AddEventHandler("cda_hud:updateKm",function(km)
SendNUIMessage({ action = "setVehicleData", data = { mileage = km }})
end)

RegisterNetEvent("hud:Voice")
AddEventHandler("hud:Voice",function(status)
voiceActive = status
SendNUIMessage({action = "setInfos", data = { voiceActive = voiceActive }})
end)

RegisterNetEvent("hud:Voip")
AddEventHandler("hud:Voip",function(mode)
voiceLevel = mode
SendNUIMessage({action = "setInfos", data = { voiceLevel = voiceLevel }})
end)

RegisterNetEvent("hud:Radio")
AddEventHandler("hud:Radio",function(number)
frequency = number
SendNUIMessage({action = "setInfos", data = { frequency = frequency }})
end)

RegisterNetEvent("hud:Passport")
AddEventHandler("hud:Passport",function(id)
passport = id
SendNUIMessage({action = "setInfos", data = { userId = passport }})
SendNUIMessage({action = "setInfos", data = { voiceLevel = 2 }})
end)

RegisterNetEvent("hud:AddGems")
AddEventHandler("hud:AddGems",function(amount)
gems = amount + gems
SendNUIMessage({action = "setInfos", data = { gems = gems }})
end)
RegisterNetEvent("hud:RemoveGems")
AddEventHandler("hud:RemoveGems",function(amount)
gems = gems - amount
SendNUIMessage({action = "setInfos", data = { gems = gems }})
end)

RegisterNetEvent("hud:Thirst")
AddEventHandler("hud:Thirst",function(number)
thirst = number
SendNUIMessage({action = "setStats", data = { thirst = thirst }})
end)

RegisterNetEvent("hud:Hunger")
AddEventHandler("hud:Hunger",function(number)
hunger = number
SendNUIMessage({action = "setStats", data = { hunger = hunger }})
end)
-----------------------------------------------------------------------------------
------------------------------------------------------
-- EXPORTS
-----------------------------------------------------------------------------------
------------------------------------------------------
exports("Wanted",function()
return false
end)

exports("Reposed",function()
return false
end)
-----------------------------------------------------------------------------------
------------------------------------------------------
-- TIME
-----------------------------------------------------------------------------------
------------------------------------------------------
[Link](function()
while true do
SetWeatherTypeNow(weather)
SetWeatherTypePersist(weather)
SetWeatherTypeNowPersist(weather)
NetworkOverrideClockTime(hours, minutes, 00)
[Link](1000)
end
end)
-----------------------------------------------------------------------------------
------------------------------------------------------
-- REQUEST
-----------------------------------------------------------------------------------
------------------------------------------------------
local activeRequest = false
local resultRequest = false
local timeRequest = GetGameTimer()
local idRequest = 0
function [Link](Message)
if activeRequest then
return false
end

idRequest = idRequest + 1
SendNUIMessage({ action = "addRequest", data = { id = idRequest, title =
"Pergunta", description = Message, author = "Sistema", delay = 15000 } })
timeRequest = GetGameTimer() + 15000
activeRequest = true

while activeRequest do
if GetGameTimer() >= timeRequest then
SendNUIMessage({ action = "remRequest", data = idRequest })
resultRequest = false
activeRequest = false
end

Wait(0)
end

return resultRequest
end

RegisterCommand("cda:acceptRequest",function()
if activeRequest then
resultRequest = true
activeRequest = false
SendNUIMessage({ action = "remRequest", data = idRequest })
end
end)

RegisterCommand("cda:declineRequest",function()
if activeRequest then
resultRequest = false
activeRequest = false
SendNUIMessage({ action = "remRequest", data = idRequest })
end
end)

RegisterKeyMapping("cda:acceptRequest","Aceitar requisições.","keyboard","Y")
RegisterKeyMapping("cda:declineRequest","Rejeitar requisições.","keyboard","U")
-----------------------------------------------------------------------------------
------------------------------------------------------
-- PROMPT
-----------------------------------------------------------------------------------
------------------------------------------------------
local promptStatus = ""
local promptActive = false

function [Link](Text,DefaultText)
if not DefaultText then DefaultText = "" end
if promptActive then
return false
end

promptStatus = ""
promptActive = true
SendNUIMessage({ action = "showPrompt", data = { title = Text, defaultValue =
DefaultText } })
SetNuiFocus(true,true)

while promptStatus == "" do


Wait(100)
end
local actualStats = promptStatus
promptStatus = false
return actualStats
end

RegisterNUICallback("removeFocus",function(Data,Callback)
if promptActive then
promptStatus = false
promptActive = false
SetNuiFocus(false,false)
end
-- if chatStatus then
-- TriggerEvent("cda:ChatVisible",false)
-- end
end)

RegisterNUICallback("submitPrompt",function(Data,Callback)
promptActive = false
promptStatus = [Link]
SetNuiFocus(false,false)
end)
-----------------------------------------------------------------------------------
------------------------------------------------------
-- SHORTCUTS
-----------------------------------------------------------------------------------
------------------------------------------------------
function ShowShortcuts()
local Shortcuts = [Link]()
SendNUIMessage({ action = "setHotbar", data = Shortcuts })
end

function HideShortcuts()
SendNUIMessage({ action = "setHotbar", data = false })
end

RegisterCommand("+shortcuts",ShowShortcuts)
RegisterCommand("-shortcuts",HideShortcuts)
RegisterKeyMapping("+shortcuts","Visualizar atalhos.","keyboard","TAB")
-----------------------------------------------------------------------------------
------------------------------------------------------
-- NOTIFYPUSH
-----------------------------------------------------------------------------------
------------------------------------------------------
-- RegisterNetEvent("NotifyPush")
-- AddEventHandler("NotifyPush",function(Data)
-- local streetName =
GetStreetNameFromHashKey(GetStreetNameAtCoord(Data["x"],Data["y"],Data["z"]))

-- SendNUIMessage({ action = "addNotifyPush", data = {


-- code = Data["code"],
-- title = Data["title"],
-- description = Data["criminal"] or Data["text"] or "",
-- street = [Link][streetName],
-- time = {hours, minutes},
-- cds = {Data["x"], Data["y"], Data["z"]},
-- phone = Data["phone"] or false,
-- userId = Data["Passport"] or 0 }
-- })

-- local Blip = AddBlipForCoord(Data["x"],Data["y"],Data["z"])

-- if parseInt(Data["code"]) == 13 then
-- TriggerEvent("sounds:Private","deathcop",0.5)
-- end

-- SetBlipSprite(Blip,270)
-- SetBlipDisplay(Blip,4)
-- SetBlipAsShortRange(Blip,true)
-- SetBlipColour(Blip,Data["blipColor"])
-- SetBlipScale(Blip,0.9)
-- BeginTextCommandSetBlipName("STRING")
-- AddTextComponentString(Data["title"])
-- EndTextCommandSetBlipName(Blip)

-- SetTimeout(60000,function()
-- if DoesBlipExist(Blip) then
-- RemoveBlip(Blip)
-- end
-- end)
-- end)

-- RegisterNUICallback("NotifyPush:pingGps",function(Data,Callback)
-- SetNewWaypoint(Data["x"] + 0.0001,Data["y"] + 0.0001)
-- end)

-- RegisterNUICallback("NotifyPush:call",function(Data,Callback)
-- exports["smartphone"]:callPlayer(Data["phone"])
-- end)

-- RegisterCommand("NotifyCall",function()
-- if not LocalPlayer["state"]["Commands"] and not LocalPlayer["state"]
["Handcuff"] and not IsPauseMenuActive() then
-- SendNUIMessage({ action = "NotifyPush:history", data = true })
-- end
-- end)

-- RegisterKeyMapping("NotifyCall","Consultar as notificações.","keyboard","F2")
-----------------------------------------------------------------------------------
------------------------------------------------------
-- CHAT
-----------------------------------------------------------------------------------
------------------------------------------------------
-- local chatStatus = false
-- RegisterCommand("cda:chat", function()
-- TriggerEvent("cda:ChatVisible",true)
-- SetNuiFocus(true, true)
-- end)

-- RegisterKeyMapping("cda:chat", "Abrir Chat", "keyboard", "T")


-- RegisterNetEvent("cda:ChatVisible")
-- AddEventHandler("cda:ChatVisible",function(Status)
-- SetNuiFocus(Status, Status)
-- SendNUIMessage({ action = "Chat:showInput", data = Status })
-- chatStatus = Status
-- end)

RegisterNUICallback("getChatChannels",function(data,cb)
cb({})
end)

-- RegisterNUICallback("submitCommand",function(data,cb)
-- if not data then return end
-- local command = [Link][1]
-- ExecuteCommand(command:sub(2))
-- chatStatus = false
-- SetNuiFocus(chatStatus, chatStatus)
-- cb(true)
-- end)

-- RegisterNUICallback("submitChatMessage",function(data,cb)
-- if not data then return end
-- TriggerServerEvent("cda_hud:serverMessage",[Link],[Link])
-- chatStatus = false
-- SetNuiFocus(chatStatus, chatStatus)
-- cb(true)
-- end)

-- RegisterNetEvent("cda_hud:clientMessage")
-- AddEventHandler("cda_hud:clientMessage",function(text,author)
-- SendNUIMessage( {
-- action = "Chat:addMessage",
-- data = {
-- label = author,
-- author = "",
-- color = "#ff5050",
-- time = {hours, minutes},
-- content = text,
-- },
-- })
-- Wait(500)
-- SendNUIMessage({ action = "Chat:showMessages", data = true })
-- SetTimeout(4000, function()
-- SendNUIMessage({ action = "Chat:showMessages", data = false })
-- end)
-- end)
-----------------------------------------------------------------------------------
------------------------------------------------------
-- NITRO
-----------------------------------------------------------------------------------
------------------------------------------------------
function NitroEnable()
if GetGameTimer() >= NitroButton and not IsPauseMenuActive() then
local ped = PlayerPedId()
if IsPedInAnyVehicle(ped) then
NitroButton = GetGameTimer() + 1000

local Vehicle = GetVehiclePedIsUsing(ped)


if GetPedInVehicleSeat(Vehicle,-1) == ped then
if GetVehicleTopSpeedModifier(Vehicle) < 50.0 then
local Plate = GetVehicleNumberPlateText(Vehicle)
NitroFuel = Entity(Vehicle).[Link] or 0

if NitroFuel >= 1 then


if GetIsVehicleEngineRunning(Vehicle) then
local Speed = GetEntitySpeed(Vehicle) *
3.6
if Speed > 10 then
LocalPlayer["state"]["Nitro"] =
true

while LocalPlayer["state"]["Nitro"]
do
if NitroFuel >= 1 then
NitroFuel = NitroFuel -
1

if not NitroFlame then

SetVehicleRocketBoostActive(Vehicle,true)

SetVehicleNitroEnabled(Vehicle,true)

SetVehicleBoostActive(Vehicle,true)

ModifyVehicleTopSpeed(Vehicle,50.0)

SetLightTrail(Vehicle,true)
NitroFlame = Plate
end
else
if NitroFlame then

SetVehicleRocketBoostActive(Vehicle,false)

Entity(Vehicle).state:set('Nitro', NitroFuel)

SetVehicleNitroEnabled(Vehicle,false)

SetVehicleBoostActive(Vehicle,false)

ModifyVehicleTopSpeed(Vehicle,0.0)

SetLightTrail(Vehicle,false)
NitroFlame = false

LocalPlayer["state"]["Nitro"] = false
end
end

Wait(1)
end
else
SetPurgeSprays(Vehicle,true)
PurgeActive = true
end
else
SetPurgeSprays(Vehicle,true)
PurgeActive = true
end
end
end
end
end
end
end

function NitroDisable()
local Vehicle = GetLastDrivenVehicle()

if NitroFlame then
SetVehicleRocketBoostActive(Vehicle,false)
Entity(Vehicle).state:set('Nitro', NitroFuel)
SetVehicleNitroEnabled(Vehicle,false)
SetVehicleBoostActive(Vehicle,false)
ModifyVehicleTopSpeed(Vehicle,0.0)
SetLightTrail(Vehicle,false)
NitroFlame = false

LocalPlayer["state"]["Nitro"] = false
end

if PurgeActive then
SetPurgeSprays(Vehicle,false)
PurgeActive = false
end
end

RegisterCommand("+activeNitro",NitroEnable)
RegisterCommand("-activeNitro",NitroDisable)
RegisterKeyMapping("+activeNitro","Ativação do nitro.","keyboard","LMENU")

function SetLightTrail(Vehicle,Enable)
if LightTrails[Vehicle] == Enable then
return
end

if Enable then
local Particles = {}
local LeftTrail =
CreateLightTrail(Vehicle,GetEntityBoneIndexByName(Vehicle,"taillight_l"))
local RightTrail =
CreateLightTrail(Vehicle,GetEntityBoneIndexByName(Vehicle,"taillight_r"))

Particles[#Particles + 1] = LeftTrail
Particles[#Particles + 1] = RightTrail

LightTrails[Vehicle] = true
LightParticles[Vehicle] = Particles
else
if LightParticles[Vehicle] and #LightParticles[Vehicle] > 0 then
for _,v in ipairs(LightParticles[Vehicle]) do
StopLightTrail(v)
end
end
LightTrails[Vehicle] = nil
LightParticles[Vehicle] = nil
end
end

function CreateLightTrail(Vehicle,Bone)
UseParticleFxAssetNextCall("core")
local Particle =
StartParticleFxLoopedOnEntityBone("veh_light_red_trail",Vehicle,0.0,0.0,0.0,0.0,0.0
,0.0,Bone,1.0,false,false,false)
SetParticleFxLoopedEvolution(Particle,"speed",1.0,false)

return Particle
end

function StopLightTrail(Particle)
CreateThread(function()
local endTime = GetGameTimer() + 500
while GetGameTimer() < endTime do
Wait(0)
local now = GetGameTimer()
local Scale = (endTime - now) / 500
SetParticleFxLoopedScale(Particle,Scale)
SetParticleFxLoopedAlpha(Particle,Scale)
end

StopParticleFxLooped(Particle)
end)
end

function SetPurgeSprays(Vehicle,Enable)
if PurgeSprays[Vehicle] == Enable then
return
end

if Enable then
local Particles = {}
local Bone = GetEntityBoneIndexByName(Vehicle,"bonnet")
local Position = GetWorldPositionOfEntityBone(Vehicle,Bone)
local Offset =
GetOffsetFromEntityGivenWorldCoords(Vehicle,Position["x"],Position["y"],Position["z
"])

for i = 0,3 do
local LeftPurge = CreatePurgeSprays(Vehicle,Offset["x"] -
0.5,Offset["y"] + 0.05,Offset["z"],40.0,-20.0,0.0,0.5)
local RightPurge = CreatePurgeSprays(Vehicle,Offset["x"] +
0.5,Offset["y"] + 0.05,Offset["z"],40.0,20.0,0.0,0.5)

Particles[#Particles + 1] = LeftPurge
Particles[#Particles + 1] = RightPurge
end

PurgeSprays[Vehicle] = true
PurgeParticles[Vehicle] = Particles
else
if PurgeParticles[Vehicle] then
RemoveParticleFxFromEntity(Vehicle)
end
PurgeSprays[Vehicle] = nil
PurgeParticles[Vehicle] = nil
end
end

function CreatePurgeSprays(Vehicle,xOffset,yOffset,zOffset,xRot,yRot)
UseParticleFxAssetNextCall("core")
return
StartNetworkedParticleFxNonLoopedOnEntity("ent_sht_steam",Vehicle,xOffset,yOffset,z
Offset,xRot,yRot,0.0,0.5,false,false,false)
end
-----------------------------------------------------------------------------------
------------------------------------------------------
-- COMMANDS
-----------------------------------------------------------------------------------
------------------------------------------------------
RegisterCommand("hud",function()
TriggerEvent("hud:Active",not hudVisibility)
end)

-- Thread dedicada para rua e cruzamento


CreateThread(function()
local lastCoords = vec3(0,0,0)
local lastCheck = GetGameTimer()
while true do
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)

-- Checagem rápida: se moveu mais que 1.0m ou a cada 1000ms


local moved = #(coords - lastCoords) > 1.0
local timePassed = GetGameTimer() - lastCheck > 1000

if moved or timePassed then


lastCoords = coords
lastCheck = GetGameTimer()

local streetHash, crossingHash = GetStreetNameAtCoord(coords.x,


coords.y, coords.z)
local newStreetName = GetStreetNameFromHashKey(streetHash)
local newCrossingName = (crossingHash and crossingHash ~= 0) and
GetStreetNameFromHashKey(crossingHash) or ""

if newStreetName ~= currentStreetName then


currentStreetName = newStreetName
local translatedStreet = getTranslatedStreet(currentStreetName)
SendNUIMessage({action = "setStreet", data = translatedStreet})
end

if newCrossingName ~= currentCrossingName then


currentCrossingName = newCrossingName
local translatedCrossing = currentCrossingName ~= "" and
getTranslatedStreet(currentCrossingName) or ""
SendNUIMessage({action = "setCrossing", data = translatedCrossing})
end
end

-- Keepalive: reenviar rua/cruzamento periodicamente para garantir


atualização
if GetGameTimer() - lastStreetPushTime > 1500 then
local translatedStreetKeep = getTranslatedStreet(currentStreetName)
local translatedCrossingKeep = currentCrossingName ~= "" and
getTranslatedStreet(currentCrossingName) or ""
SendNUIMessage({action = "setStreet", data = translatedStreetKeep})
SendNUIMessage({action = "setCrossing", data = translatedCrossingKeep})
lastStreetPushTime = GetGameTimer()
end

Wait(200)
end
end)

Você também pode gostar