Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PlayerData = {}
- ESX = exports["es_extended"]:getSharedObject()
- local curvehicle = nil
- AddEventHandler('onResourceStart', function(resourceName)
- if (GetCurrentResourceName() ~= resourceName) then
- return
- end
- local localPlayerServerId = GetPlayerServerId(PlayerId())
- local voiceRange = exports.saltychat:GetVoiceRange(localPlayerServerId)
- Citizen.Wait(20)
- SendNUIMessage({
- voicerange = voiceRange,
- action = "setvoicerange"
- })
- SendNUIMessage({hideHUD = true,
- })
- end)
- AddEventHandler('esx:onPlayerDeath', function(data)
- Citizen.Wait(500)
- SendNUIMessage({hideHUD = true, updhealth = true})
- local ped = PlayerPedId()
- local health = GetEntityHealth(ped)
- end)
- AddEventHandler('esx:onPlayerSpawn', function(data)
- Citizen.Wait(50)
- SendNUIMessage({hideHUD = true})
- end)
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(2500)
- ispedinveh()
- armed()
- end
- end)
- local weapons = {
- ["WEAPON_ADVANCEDRIFLE"] = -1357824103,
- ["WEAPON_APPISTOL"] = 584646201,
- ["WEAPON_ASSAULTRIFLE"] = -1074790547,
- ["WEAPON_ASSAULTSHOTGUN"] = 1255410010,
- ["WEAPON_ASSAULTSMG"] = -270015777,
- ["WEAPON_AUTOSHOTGUN"] = -494615257,
- ["WEAPON_BALL"] = 126349499,
- ["WEAPON_BAT"] = -1786099057,
- ["WEAPON_BOTTLE"] = 419264365,
- ["WEAPON_BULLPUPRIFLE"] = 2132975508,
- ["WEAPON_BULLPUPSHOTGUN"] = -1654528753,
- ["WEAPON_BZGAS"] = -1600701090,
- ["WEAPON_CARBINERIFLE"] = -2084633992,
- ["WEAPON_COMBATMG"] = 2144741730,
- ["WEAPON_COMBATPDW"] = 171789620,
- ["WEAPON_COMBATPISTOL"] = 1593441988,
- ["WEAPON_COMPACTLAUNCHER"] = 125959754,
- ["WEAPON_COMPACTRIFLE"] = 1649403952,
- ["WEAPON_COUGAR"] = -2066352316,
- ["WEAPON_CROWBAR"] = -2067956739,
- ["WEAPON_DAGGER"] = -1834847097,
- ["WEAPON_DBSHOTGUN"] = 911657153,
- ["WEAPON_CARABINER"] = -1063057011,
- ["WEAPON_FIREEXTINGUISHER"] = 101631238,
- ["WEAPON_PISTOL"] = 453432689,
- ["WEAPON_FLARE"] = 1233104067,
- ["WEAPON_FLAREGUN"] = 1198879012,
- ["WEAPON_FLASHLIGHT"] = -1951375401,
- ["Unbewaffnet"] = -1569615261,
- ["WEAPON_GRENADE"] = -1813897027,
- ["WEAPON_GRENADELAUNCHER"] = -1568386805,
- ["WEAPON_GRENADELAUNCHER_SMOKE"] = 1305664598,
- ["WEAPON_GUSENBERG"] = 1627465347,
- ["WEAPON_HAMMER"] = 1317494643,
- ["WEAPON_HATCHET"] = -102973651,
- ["WEAPON_HEAVYPISTOL"] = -771403250,
- ["WEAPON_HEAVYSHOTGUN"] = 984333226,
- ["WEAPON_HEAVYSNIPER"] = -1204467880,
- ["WEAPON_HEAVYSNIPER_MK2"] = 177293209,
- ["WEAPON_HOMINGLAUNCHER"] = 1672152130,
- ["WEAPON_KNIFE"] = -1716189206,
- ["WEAPON_KNUCKLE"] = 3638508604,
- ["WEAPON_MACHETE"] = -581044007,
- ["WEAPON_MACHINEPISTOL"] = -619010992,
- ["WEAPON_MARKSMANPISTOL"] = -598887786,
- ["WEAPON_MARKSMANRIFLE"] = -2066285827,
- }
- local currentWeapon = nil
- function armed()
- local currentWeapon = GetSelectedPedWeapon(PlayerPedId())
- for weaponName, weaponHash in pairs(weapons) do
- if weaponHash == currentWeapon and weaponName ~= "Unbewaffnet" then
- break
- end
- end
- end
- local toggle = false
- function ispedinveh()
- local ped = PlayerPedId()
- local vehicle = GetVehiclePedIsIn(ped, false)
- local isInVehicle = IsPedInVehicle(ped, vehicle, false)
- if isInVehicle == 1 and not toggle then
- SendNUIMessage({inveh = true})
- toggle = true
- DisplayRadar(true)
- SetRadarZoom(1100)
- elseif not isInVehicle and toggle or not toggle then
- SendNUIMessage({hideHUD = true})
- toggle = false
- DisplayRadar(false)
- Citizen.Wait(2000)
- end
- end
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(5000)
- if ESX.PlayerData.job ~= nil then
- --print(ESX.PlayerData.job.label)
- local jobname = ESX.PlayerData.job.label
- local jobgrade = ESX.PlayerData.job.grade_label
- SendNUIMessage({
- jobname = jobname,
- jobgrade = jobgrade,
- action = "showJob"
- })
- end
- end
- end)
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(5000)
- local coords = GetEntityCoords(ped)
- local zone = GetNameOfZone(coords.x, coords.y, coords.z)
- local var1, var2 = GetStreetNameAtCoord(coords.x, coords.y, coords.z, Citizen.ResultAsInteger(), Citizen.ResultAsInteger())
- local hash1 = GetStreetNameFromHashKey(var1);
- SendNUIMessage({
- streetname = hash1,
- action = "showStreet"
- })
- end
- end)
- local showhud = false
- local showing = false
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(5000)
- local ped = PlayerPedId()
- local health = GetEntityHealth(ped)
- local armor = GetPedArmour(ped)
- -- Überprüfen, ob das HUD angezeigt wird
- if not showhud then
- showing = true
- end
- -- Wenn das HUD angezeigt wird, die Werte aktualisieren
- if showing then
- local id = GetPlayerServerId(PlayerId())
- -- Hunger aktualisieren
- TriggerEvent('esx_status:getStatus', 'hunger', function(status)
- SendNUIMessage({
- updhunger = status.val / 10000
- })
- end)
- -- Durst aktualisieren
- TriggerEvent('esx_status:getStatus', 'thirst', function(status)
- SendNUIMessage({
- updthirst = status.val / 10000
- })
- end)
- -- Gesundheit und Rüstung aktualisieren
- SendNUIMessage({
- showstat = true,
- updhealth = health,
- updarmor = armor
- })
- -- for k,v in pairs(ESX.PlayerData.accounts) do
- -- if v.name == 'bank' then
- -- local bank = v.money
- -- if bank ~= 0 then
- -- -- print("Bank: "..bank)
- -- else
- -- end
- -- elseif v.name == 'money' then
- -- local money = v.money
- -- if money ~= 0 then
- -- -- print("Gründgeld: "..money)
- -- else
- -- end
- -- elseif v.name == 'black_money' then
- -- local blackmoney = v.money
- --
- -- if blackmoney ~= 0 then
- -- --print("Schwarzgeld: "..blackmoney)
- -- else
- -- end
- -- end
- -- end
- end
- end
- end)
- local refresh = false
- RegisterNetEvent('getpostalhere')
- AddEventHandler('getpostalhere', function(postal)
- -- Code zum Ausführen, wenn das Ereignis ausgelöst wird
- SendNUIMessage({
- streetname2 = postal,
- action = "showStreet2"
- })
- end)
- AddEventHandler('SaltyChat_VoiceRangeChanged', function(range)
- SendNUIMessage({
- voicerange = range,
- action = "setvoicerange"
- })
- end)
- AddEventHandler('SaltyChat_TalkStateChanged', function(isTalking)
- if isTalking then
- SendNUIMessage({
- voicestatus = isTalking,
- action = "setvoicestatus"
- })
- elseif not isTalking then
- SendNUIMessage({
- voicestatus = isTalking,
- action = "setvoicestatus"
- })
- end
- end)
- AddEventHandler('SaltyChat_RadioChannelChanged', function(radioChannel,isPrimaryChannel)
- if radioChannel then
- SendNUIMessage({
- setradioactive = radioChannel,
- action = "setradioactive"
- })
- elseif not radioChannel then
- SendNUIMessage({
- setradioactive = radioChannel,
- action = "setradioactive"
- })
- end
- end)
- -- Initialisierung
- local REFRESH_DELAY = 70
- local REFRESH_DELAY_IN_VEHICLE = 5
- local refresh = true
- local toggle = true
- -- Hauptfunktion
- Citizen.CreateThread(function()
- while true do
- -- Aktualisierungsintervall anpassen, wenn Spieler in einem Fahrzeug ist
- local ped = PlayerPedId()
- local inVehicle = IsPedInAnyVehicle(ped)
- local refreshDelay = inVehicle and REFRESH_DELAY_IN_VEHICLE or REFRESH_DELAY
- if toggle and inVehicle and refresh then
- -- Fahrzeugdaten sammeln
- local veh = GetVehiclePedIsUsing(ped)
- local speed = GetEntitySpeed(veh)
- local kmh = speed * 3.6
- local model = GetEntityModel(veh)
- local maxSpeed = GetVehicleModelEstimatedMaxSpeed(model)
- local curFuel = ESX.Math.Round(GetVehicleFuelLevel(veh))
- local rpm = GetVehicleCurrentRpm(veh)
- local currentGear = GetVehicleCurrentGear(veh)
- local vehicleVal, vehicleLights, vehicleHighlights = GetVehicleLightsState(veh)
- local vehicleIsLightsOn
- -- Lichtstatus ermitteln
- if vehicleLights == 1 and vehicleHighlights == 0 and GetIsVehicleEngineRunning(veh) then
- vehicleIsLightsOn = 'normal'
- elseif vehicleLights == 1 and vehicleHighlights == 1 or vehicleLights == 0 and vehicleHighlights == 1 then
- vehicleIsLightsOn = 'high'
- else
- vehicleIsLightsOn = 'off'
- end
- -- Daten an UI senden
- if kmh < 1 then
- refresh = false
- refreshDelay = 350
- SendNUIMessage({
- speed = "0",
- currentFuel = "0",
- currpm = rpm,
- lightstate = vehicleIsLightsOn,
- motor = GetIsVehicleEngineRunning(veh),
- locked = GetVehicleDoorLockStatus(veh) == 1 or GetVehicleDoorLockStatus(veh) == 0
- })
- else
- Citizen.Wait(5)
- SendNUIMessage({
- curgear = currentGear,
- currpm = rpm,
- currentFuel = curFuel,
- lightstate = vehicleIsLightsOn,
- motor = GetIsVehicleEngineRunning(veh),
- speed = ESX.Math.Round(kmh),
- locked = GetVehicleDoorLockStatus(veh) == 1 or GetVehicleDoorLockStatus(veh) == 0
- })
- end
- else
- refresh = true
- end
- Wait(REFRESH_DELAY)
- end
- end)
- RegisterCommand('sh', function(source, args)
- local newHunger = tonumber(args[1])
- if newHunger then
- TriggerEvent('esx_status:set', 'hunger', newHunger * 10000, 100000)
- TriggerEvent('esx_status:set', 'thirst', newHunger * 10000, 100000)
- end
- end, false)
- RegisterCommand('st', function(source, args)
- if args ~= nil then
- local ped = PlayerPedId()
- local vehicle = GetVehiclePedIsUsing(ped)
- SetVehicleFixed(vehicle)
- end
- end, false)
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(0)
- HideHudComponentThisFrame(6)
- HideHudComponentThisFrame(7)
- HideHudComponentThisFrame(9)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement