Advertisement
CompCrafter

Untitled

Apr 26th, 2023
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.48 KB | None | 0 0
  1. PlayerData = {}
  2.  
  3. ESX = exports["es_extended"]:getSharedObject()
  4.  
  5.  
  6.  
  7. local curvehicle = nil
  8.  
  9. AddEventHandler('onResourceStart', function(resourceName)
  10. if (GetCurrentResourceName() ~= resourceName) then
  11.  
  12. return
  13. end
  14.  
  15. local localPlayerServerId = GetPlayerServerId(PlayerId())
  16. local voiceRange = exports.saltychat:GetVoiceRange(localPlayerServerId)
  17. Citizen.Wait(20)
  18. SendNUIMessage({
  19. voicerange = voiceRange,
  20. action = "setvoicerange"
  21. })
  22.  
  23.  
  24. SendNUIMessage({hideHUD = true,
  25. })
  26. end)
  27.  
  28. AddEventHandler('esx:onPlayerDeath', function(data)
  29. Citizen.Wait(500)
  30. SendNUIMessage({hideHUD = true, updhealth = true})
  31. local ped = PlayerPedId()
  32. local health = GetEntityHealth(ped)
  33. end)
  34.  
  35. AddEventHandler('esx:onPlayerSpawn', function(data)
  36. Citizen.Wait(50)
  37. SendNUIMessage({hideHUD = true})
  38.  
  39. end)
  40.  
  41. Citizen.CreateThread(function()
  42. while true do
  43. Citizen.Wait(2500)
  44. ispedinveh()
  45. armed()
  46. end
  47. end)
  48.  
  49. local weapons = {
  50. ["WEAPON_ADVANCEDRIFLE"] = -1357824103,
  51. ["WEAPON_APPISTOL"] = 584646201,
  52. ["WEAPON_ASSAULTRIFLE"] = -1074790547,
  53. ["WEAPON_ASSAULTSHOTGUN"] = 1255410010,
  54. ["WEAPON_ASSAULTSMG"] = -270015777,
  55. ["WEAPON_AUTOSHOTGUN"] = -494615257,
  56. ["WEAPON_BALL"] = 126349499,
  57. ["WEAPON_BAT"] = -1786099057,
  58. ["WEAPON_BOTTLE"] = 419264365,
  59. ["WEAPON_BULLPUPRIFLE"] = 2132975508,
  60. ["WEAPON_BULLPUPSHOTGUN"] = -1654528753,
  61. ["WEAPON_BZGAS"] = -1600701090,
  62. ["WEAPON_CARBINERIFLE"] = -2084633992,
  63. ["WEAPON_COMBATMG"] = 2144741730,
  64. ["WEAPON_COMBATPDW"] = 171789620,
  65. ["WEAPON_COMBATPISTOL"] = 1593441988,
  66. ["WEAPON_COMPACTLAUNCHER"] = 125959754,
  67. ["WEAPON_COMPACTRIFLE"] = 1649403952,
  68. ["WEAPON_COUGAR"] = -2066352316,
  69. ["WEAPON_CROWBAR"] = -2067956739,
  70. ["WEAPON_DAGGER"] = -1834847097,
  71. ["WEAPON_DBSHOTGUN"] = 911657153,
  72. ["WEAPON_CARABINER"] = -1063057011,
  73. ["WEAPON_FIREEXTINGUISHER"] = 101631238,
  74. ["WEAPON_PISTOL"] = 453432689,
  75. ["WEAPON_FLARE"] = 1233104067,
  76. ["WEAPON_FLAREGUN"] = 1198879012,
  77. ["WEAPON_FLASHLIGHT"] = -1951375401,
  78. ["Unbewaffnet"] = -1569615261,
  79. ["WEAPON_GRENADE"] = -1813897027,
  80. ["WEAPON_GRENADELAUNCHER"] = -1568386805,
  81. ["WEAPON_GRENADELAUNCHER_SMOKE"] = 1305664598,
  82. ["WEAPON_GUSENBERG"] = 1627465347,
  83. ["WEAPON_HAMMER"] = 1317494643,
  84. ["WEAPON_HATCHET"] = -102973651,
  85. ["WEAPON_HEAVYPISTOL"] = -771403250,
  86. ["WEAPON_HEAVYSHOTGUN"] = 984333226,
  87. ["WEAPON_HEAVYSNIPER"] = -1204467880,
  88. ["WEAPON_HEAVYSNIPER_MK2"] = 177293209,
  89. ["WEAPON_HOMINGLAUNCHER"] = 1672152130,
  90. ["WEAPON_KNIFE"] = -1716189206,
  91. ["WEAPON_KNUCKLE"] = 3638508604,
  92. ["WEAPON_MACHETE"] = -581044007,
  93. ["WEAPON_MACHINEPISTOL"] = -619010992,
  94. ["WEAPON_MARKSMANPISTOL"] = -598887786,
  95. ["WEAPON_MARKSMANRIFLE"] = -2066285827,
  96. }
  97.  
  98. local currentWeapon = nil
  99.  
  100. function armed()
  101. local currentWeapon = GetSelectedPedWeapon(PlayerPedId())
  102. for weaponName, weaponHash in pairs(weapons) do
  103. if weaponHash == currentWeapon and weaponName ~= "Unbewaffnet" then
  104.  
  105. break
  106. end
  107. end
  108. end
  109.  
  110.  
  111.  
  112.  
  113. local toggle = false
  114.  
  115. function ispedinveh()
  116. local ped = PlayerPedId()
  117. local vehicle = GetVehiclePedIsIn(ped, false)
  118. local isInVehicle = IsPedInVehicle(ped, vehicle, false)
  119. if isInVehicle == 1 and not toggle then
  120. SendNUIMessage({inveh = true})
  121. toggle = true
  122. DisplayRadar(true)
  123. SetRadarZoom(1100)
  124.  
  125.  
  126. elseif not isInVehicle and toggle or not toggle then
  127. SendNUIMessage({hideHUD = true})
  128. toggle = false
  129. DisplayRadar(false)
  130. Citizen.Wait(2000)
  131. end
  132. end
  133.  
  134.  
  135.  
  136. Citizen.CreateThread(function()
  137. while true do
  138. Citizen.Wait(5000)
  139. if ESX.PlayerData.job ~= nil then
  140. --print(ESX.PlayerData.job.label)
  141. local jobname = ESX.PlayerData.job.label
  142. local jobgrade = ESX.PlayerData.job.grade_label
  143.  
  144. SendNUIMessage({
  145. jobname = jobname,
  146. jobgrade = jobgrade,
  147. action = "showJob"
  148. })
  149. end
  150. end
  151. end)
  152.  
  153.  
  154. Citizen.CreateThread(function()
  155. while true do
  156. Citizen.Wait(5000)
  157. local coords = GetEntityCoords(ped)
  158. local zone = GetNameOfZone(coords.x, coords.y, coords.z)
  159.  
  160. local var1, var2 = GetStreetNameAtCoord(coords.x, coords.y, coords.z, Citizen.ResultAsInteger(), Citizen.ResultAsInteger())
  161. local hash1 = GetStreetNameFromHashKey(var1);
  162.  
  163. SendNUIMessage({
  164. streetname = hash1,
  165. action = "showStreet"
  166. })
  167. end
  168. end)
  169.  
  170.  
  171. local showhud = false
  172. local showing = false
  173.  
  174. Citizen.CreateThread(function()
  175. while true do
  176. Citizen.Wait(5000)
  177. local ped = PlayerPedId()
  178. local health = GetEntityHealth(ped)
  179. local armor = GetPedArmour(ped)
  180.  
  181. -- Überprüfen, ob das HUD angezeigt wird
  182. if not showhud then
  183. showing = true
  184. end
  185.  
  186.  
  187.  
  188. -- Wenn das HUD angezeigt wird, die Werte aktualisieren
  189. if showing then
  190. local id = GetPlayerServerId(PlayerId())
  191. -- Hunger aktualisieren
  192. TriggerEvent('esx_status:getStatus', 'hunger', function(status)
  193. SendNUIMessage({
  194. updhunger = status.val / 10000
  195. })
  196. end)
  197.  
  198. -- Durst aktualisieren
  199. TriggerEvent('esx_status:getStatus', 'thirst', function(status)
  200. SendNUIMessage({
  201. updthirst = status.val / 10000
  202. })
  203. end)
  204.  
  205. -- Gesundheit und Rüstung aktualisieren
  206. SendNUIMessage({
  207. showstat = true,
  208. updhealth = health,
  209. updarmor = armor
  210. })
  211.  
  212.  
  213.  
  214. -- for k,v in pairs(ESX.PlayerData.accounts) do
  215. -- if v.name == 'bank' then
  216. -- local bank = v.money
  217. -- if bank ~= 0 then
  218. -- -- print("Bank: "..bank)
  219. -- else
  220.  
  221. -- end
  222. -- elseif v.name == 'money' then
  223. -- local money = v.money
  224. -- if money ~= 0 then
  225. -- -- print("Gründgeld: "..money)
  226. -- else
  227.  
  228. -- end
  229. -- elseif v.name == 'black_money' then
  230. -- local blackmoney = v.money
  231. --
  232. -- if blackmoney ~= 0 then
  233. -- --print("Schwarzgeld: "..blackmoney)
  234. -- else
  235.  
  236. -- end
  237. -- end
  238. -- end
  239.  
  240.  
  241.  
  242.  
  243. end
  244. end
  245. end)
  246.  
  247. local refresh = false
  248.  
  249.  
  250. RegisterNetEvent('getpostalhere')
  251. AddEventHandler('getpostalhere', function(postal)
  252. -- Code zum Ausführen, wenn das Ereignis ausgelöst wird
  253. SendNUIMessage({
  254. streetname2 = postal,
  255. action = "showStreet2"
  256. })
  257. end)
  258.  
  259. AddEventHandler('SaltyChat_VoiceRangeChanged', function(range)
  260. SendNUIMessage({
  261. voicerange = range,
  262. action = "setvoicerange"
  263. })
  264. end)
  265.  
  266. AddEventHandler('SaltyChat_TalkStateChanged', function(isTalking)
  267. if isTalking then
  268. SendNUIMessage({
  269. voicestatus = isTalking,
  270. action = "setvoicestatus"
  271. })
  272.  
  273. elseif not isTalking then
  274. SendNUIMessage({
  275. voicestatus = isTalking,
  276. action = "setvoicestatus"
  277. })
  278. end
  279. end)
  280.  
  281. AddEventHandler('SaltyChat_RadioChannelChanged', function(radioChannel,isPrimaryChannel)
  282. if radioChannel then
  283. SendNUIMessage({
  284. setradioactive = radioChannel,
  285. action = "setradioactive"
  286. })
  287. elseif not radioChannel then
  288. SendNUIMessage({
  289. setradioactive = radioChannel,
  290. action = "setradioactive"
  291. })
  292. end
  293. end)
  294.  
  295. -- Initialisierung
  296. local REFRESH_DELAY = 70
  297. local REFRESH_DELAY_IN_VEHICLE = 5
  298. local refresh = true
  299. local toggle = true
  300.  
  301. -- Hauptfunktion
  302. Citizen.CreateThread(function()
  303. while true do
  304. -- Aktualisierungsintervall anpassen, wenn Spieler in einem Fahrzeug ist
  305. local ped = PlayerPedId()
  306. local inVehicle = IsPedInAnyVehicle(ped)
  307. local refreshDelay = inVehicle and REFRESH_DELAY_IN_VEHICLE or REFRESH_DELAY
  308.  
  309. if toggle and inVehicle and refresh then
  310. -- Fahrzeugdaten sammeln
  311. local veh = GetVehiclePedIsUsing(ped)
  312. local speed = GetEntitySpeed(veh)
  313. local kmh = speed * 3.6
  314. local model = GetEntityModel(veh)
  315. local maxSpeed = GetVehicleModelEstimatedMaxSpeed(model)
  316. local curFuel = ESX.Math.Round(GetVehicleFuelLevel(veh))
  317. local rpm = GetVehicleCurrentRpm(veh)
  318. local currentGear = GetVehicleCurrentGear(veh)
  319. local vehicleVal, vehicleLights, vehicleHighlights = GetVehicleLightsState(veh)
  320. local vehicleIsLightsOn
  321.  
  322.  
  323.  
  324.  
  325. -- Lichtstatus ermitteln
  326. if vehicleLights == 1 and vehicleHighlights == 0 and GetIsVehicleEngineRunning(veh) then
  327. vehicleIsLightsOn = 'normal'
  328. elseif vehicleLights == 1 and vehicleHighlights == 1 or vehicleLights == 0 and vehicleHighlights == 1 then
  329. vehicleIsLightsOn = 'high'
  330. else
  331. vehicleIsLightsOn = 'off'
  332. end
  333.  
  334. -- Daten an UI senden
  335. if kmh < 1 then
  336. refresh = false
  337. refreshDelay = 350
  338. SendNUIMessage({
  339. speed = "0",
  340. currentFuel = "0",
  341. currpm = rpm,
  342. lightstate = vehicleIsLightsOn,
  343. motor = GetIsVehicleEngineRunning(veh),
  344. locked = GetVehicleDoorLockStatus(veh) == 1 or GetVehicleDoorLockStatus(veh) == 0
  345. })
  346. else
  347. Citizen.Wait(5)
  348. SendNUIMessage({
  349. curgear = currentGear,
  350. currpm = rpm,
  351. currentFuel = curFuel,
  352. lightstate = vehicleIsLightsOn,
  353. motor = GetIsVehicleEngineRunning(veh),
  354. speed = ESX.Math.Round(kmh),
  355. locked = GetVehicleDoorLockStatus(veh) == 1 or GetVehicleDoorLockStatus(veh) == 0
  356. })
  357.  
  358. end
  359. else
  360. refresh = true
  361.  
  362. end
  363. Wait(REFRESH_DELAY)
  364. end
  365. end)
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376. RegisterCommand('sh', function(source, args)
  377. local newHunger = tonumber(args[1])
  378. if newHunger then
  379. TriggerEvent('esx_status:set', 'hunger', newHunger * 10000, 100000)
  380. TriggerEvent('esx_status:set', 'thirst', newHunger * 10000, 100000)
  381. end
  382. end, false)
  383.  
  384.  
  385. RegisterCommand('st', function(source, args)
  386.  
  387. if args ~= nil then
  388. local ped = PlayerPedId()
  389. local vehicle = GetVehiclePedIsUsing(ped)
  390. SetVehicleFixed(vehicle)
  391.  
  392. end
  393. end, false)
  394.  
  395.  
  396.  
  397.  
  398. Citizen.CreateThread(function()
  399. while true do
  400. Citizen.Wait(0)
  401. HideHudComponentThisFrame(6)
  402. HideHudComponentThisFrame(7)
  403. HideHudComponentThisFrame(9)
  404. end
  405. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement