Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.21 KB | None | 0 0
  1. ESX = nil
  2. Citizen.CreateThread(function()
  3. while true do
  4. Wait(5)
  5. if ESX ~= nil then
  6.  
  7. else
  8. ESX = nil
  9. TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  10. end
  11. end
  12. end)
  13.  
  14. local Keys = {
  15. ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
  16. ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
  17. ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
  18. ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
  19. ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
  20. ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
  21. ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
  22. ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
  23. ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
  24. }
  25.  
  26. local fishing = false
  27. local lastInput = 0
  28. local pause = false
  29. local pausetimer = 0
  30. local correct = 0
  31.  
  32. local bait = "none"
  33.  
  34. local blip = AddBlipForCoord(Config.SellFish.x, Config.SellFish.y, Config.SellFish.z)
  35.  
  36. SetBlipSprite (blip, 356)
  37. SetBlipDisplay(blip, 4)
  38. SetBlipScale (blip, 1.1)
  39. SetBlipColour (blip, 17)
  40. SetBlipAsShortRange(blip, true)
  41. BeginTextCommandSetBlipName("STRING")
  42. AddTextComponentString("Fish selling")
  43. EndTextCommandSetBlipName(blip)
  44.  
  45. local blip2 = AddBlipForCoord(Config.SellTurtle.x, Config.SellTurtle.y, Config.SellTurtle.z)
  46.  
  47. SetBlipSprite (blip2, 68)
  48. SetBlipDisplay(blip2, 4)
  49. SetBlipScale (blip2, 0.9)
  50. SetBlipColour (blip2, 49)
  51. SetBlipAsShortRange(blip2, true)
  52. BeginTextCommandSetBlipName("STRING")
  53. AddTextComponentString("Sea Turtle dealer")
  54. EndTextCommandSetBlipName(blip2)
  55.  
  56. local blip3 = AddBlipForCoord(Config.SellShark.x, Config.SellShark.y, Config.SellShark.z)
  57.  
  58. SetBlipSprite (blip3, 68)
  59. SetBlipDisplay(blip3, 4)
  60. SetBlipScale (blip3, 0.9)
  61. SetBlipColour (blip3, 49)
  62. SetBlipAsShortRange(blip3, true)
  63. BeginTextCommandSetBlipName("STRING")
  64. AddTextComponentString("Shark meat dealer")
  65. EndTextCommandSetBlipName(blip3)
  66.  
  67. for _, info in pairs(Config.MarkerZones) do
  68. info.blip = AddBlipForCoord(info.x, info.y, info.z)
  69. SetBlipSprite(info.blip, 455)
  70. SetBlipDisplay(info.blip, 4)
  71. SetBlipScale(info.blip, 1.0)
  72. SetBlipColour(info.blip, 20)
  73. SetBlipAsShortRange(info.blip, true)
  74. BeginTextCommandSetBlipName("STRING")
  75. AddTextComponentString("Boat rental")
  76. EndTextCommandSetBlipName(info.blip)
  77. end
  78.  
  79. Citizen.CreateThread(function()
  80. while true do
  81. Citizen.Wait(0)
  82. for k in pairs(Config.MarkerZones) do
  83.  
  84. DrawMarker(1, Config.MarkerZones[k].x, Config.MarkerZones[k].y, Config.MarkerZones[k].z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.0, 3.0, 1.0, 0, 150, 150, 100, 0, 0, 0, 0)
  85. end
  86. end
  87. end)
  88.  
  89. function DisplayHelpText(str)
  90. SetTextComponentFormat("STRING")
  91. AddTextComponentString(str)
  92. DisplayHelpTextFromStringLabel(0, 0, 1, -1)
  93. end
  94. Citizen.CreateThread(function()
  95. while true do
  96. Wait(600)
  97. if pause and fishing then
  98. pausetimer = pausetimer + 1
  99. end
  100. end
  101. end)
  102. Citizen.CreateThread(function()
  103. while true do
  104. Wait(5)
  105. if fishing then
  106. if IsControlJustReleased(0, Keys['1']) then
  107. input = 1
  108. end
  109. if IsControlJustReleased(0, Keys['2']) then
  110. input = 2
  111. end
  112. if IsControlJustReleased(0, Keys['3']) then
  113. input = 3
  114. end
  115. if IsControlJustReleased(0, Keys['4']) then
  116. input = 4
  117. end
  118. if IsControlJustReleased(0, Keys['5']) then
  119. input = 5
  120. end
  121. if IsControlJustReleased(0, Keys['6']) then
  122. input = 6
  123. end
  124. if IsControlJustReleased(0, Keys['7']) then
  125. input = 7
  126. end
  127. if IsControlJustReleased(0, Keys['8']) then
  128. input = 8
  129. end
  130.  
  131.  
  132. if IsControlJustReleased(0, Keys['X']) then
  133. fishing = false
  134. ESX.ShowNotification("~r~Stopped fishing")
  135. end
  136. if fishing then
  137.  
  138. playerPed = GetPlayerPed(-1)
  139. local pos = GetEntityCoords(GetPlayerPed(-1))
  140. if pos.y >= 7700 or pos.y <= -4000 or pos.x <= -3700 or pos.x >= 4300 or IsPedInAnyVehicle(GetPlayerPed(-1)) then
  141.  
  142. else
  143. fishing = false
  144. ESX.ShowNotification("~r~Stopped fishing")
  145. end
  146. if IsEntityDead(playerPed) or IsEntityInWater(playerPed) then
  147. ESX.ShowNotification("~r~Stopped fishing")
  148. end
  149. end
  150.  
  151.  
  152.  
  153. if pausetimer > 3 then
  154. input = 99
  155. end
  156.  
  157. if pause and input ~= 0 then
  158. pause = false
  159. if input == correct then
  160. TriggerServerEvent('fishing:catch', bait)
  161. else
  162. ESX.ShowNotification("~r~Fish got free")
  163. end
  164. end
  165. end
  166.  
  167.  
  168.  
  169. if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)), Config.SellFish.x, Config.SellFish.y, Config.SellFish.z, true) <= 3 then
  170. TriggerServerEvent('fishing:startSelling', "fish")
  171. Citizen.Wait(4000)
  172. end
  173. if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)), Config.SellShark.x, Config.SellShark.y, Config.SellShark.z, true) <= 3 then
  174. TriggerServerEvent('fishing:startSelling', "shark")
  175. Citizen.Wait(4000)
  176. end
  177. if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)), Config.SellTurtle.x, Config.SellTurtle.y, Config.SellTurtle.z, true) <= 3 then
  178. TriggerServerEvent('fishing:startSelling', "turtle")
  179. Citizen.Wait(4000)
  180. end
  181.  
  182. end
  183. end)
  184.  
  185.  
  186.  
  187. Citizen.CreateThread(function()
  188. while true do
  189. Wait(1)
  190.  
  191. DrawMarker(1, Config.SellFish.x, Config.SellFish.y, Config.SellFish.z , 0.0, 0.0, 0.0, 0, 0.0, 0.0, 3.0, 3.0, 2.0, 0, 70, 250, 30, false, true, 2, false, false, false, false)
  192. DrawMarker(1, Config.SellTurtle.x, Config.SellTurtle.y, Config.SellTurtle.z , 0.0, 0.0, 0.0, 0, 0.0, 0.0, 3.0, 3.0, 2.0, 0, 70, 250, 30, false, true, 2, false, false, false, false)
  193. DrawMarker(1, Config.SellShark.x, Config.SellShark.y, Config.SellShark.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 3.0, 3.0, 2.0, 0, 70, 250, 30, false, true, 2, false, false, false, false)
  194. end
  195. end)
  196.  
  197. Citizen.CreateThread(function()
  198. while true do
  199. local wait = math.random(Config.FishTime.a , Config.FishTime.b)
  200. Wait(wait)
  201. if fishing then
  202. pause = true
  203. correct = math.random(1,8)
  204. ESX.ShowNotification("~g~Fish is taking the bait \n ~h~Press " .. correct .. " to catch it")
  205. input = 0
  206. pausetimer = 0
  207. end
  208.  
  209. end
  210. end)
  211.  
  212. RegisterNetEvent('fishing:message')
  213. AddEventHandler('fishing:message', function(message)
  214. ESX.ShowNotification(message)
  215. end)
  216. RegisterNetEvent('fishing:break')
  217. AddEventHandler('fishing:break', function()
  218. fishing = false
  219. ClearPedTasks(GetPlayerPed(-1))
  220. end)
  221.  
  222. RegisterNetEvent('fishing:spawnPed')
  223. AddEventHandler('fishing:spawnPed', function()
  224.  
  225. RequestModel( GetHashKey( "A_C_SharkTiger" ) )
  226. while ( not HasModelLoaded( GetHashKey( "A_C_SharkTiger" ) ) ) do
  227. Citizen.Wait( 1 )
  228. end
  229. local pos = GetEntityCoords(GetPlayerPed(-1))
  230.  
  231. local ped = CreatePed(29, 0x06C3F072, pos.x, pos.y, pos.z, 90.0, true, false)
  232. SetEntityHealth(ped, 0)
  233. end)
  234.  
  235. RegisterNetEvent('fishing:setbait')
  236. AddEventHandler('fishing:setbait', function(bool)
  237. bait = bool
  238. print(bait)
  239. end)
  240.  
  241. RegisterNetEvent('fishing:fishstart')
  242. AddEventHandler('fishing:fishstart', function()
  243.  
  244.  
  245.  
  246. playerPed = GetPlayerPed(-1)
  247. local pos = GetEntityCoords(GetPlayerPed(-1))
  248. print('started fishing' .. pos)
  249. if IsPedInAnyVehicle(playerPed) then
  250. ESX.ShowNotification("~y~You can not fish from a vehicle")
  251. else
  252. if pos.y >= 7700 or pos.y <= -4000 or pos.x <= -3700 or pos.x >= 4300 then
  253. ESX.ShowNotification("~g~Fishing started")
  254. TaskStartScenarioInPlace(GetPlayerPed(-1), "WORLD_HUMAN_STAND_FISHING", 0, true)
  255. fishing = true
  256. else
  257. ESX.ShowNotification("~y~You need to go further away from the shore")
  258. end
  259. end
  260.  
  261. end, false)
  262.  
  263. Citizen.CreateThread(function()
  264. while true do
  265. Citizen.Wait(0)
  266.  
  267. for k in pairs(Config.MarkerZones) do
  268. local ped = PlayerPedId()
  269. local pedcoords = GetEntityCoords(ped, false)
  270. local distance = Vdist(pedcoords.x, pedcoords.y, pedcoords.z, Config.MarkerZones[k].x, Config.MarkerZones[k].y, Config.MarkerZones[k].z)
  271. if distance <= 1.40 then
  272.  
  273. DisplayHelpText('Press E to rent a boat')
  274.  
  275. if IsControlJustPressed(0, Keys['E']) and IsPedOnFoot(ped) then
  276. OpenBoatsMenu(Config.MarkerZones[k].xs, Config.MarkerZones[k].ys, Config.MarkerZones[k].zs)
  277. end
  278. elseif distance < 1.45 then
  279. ESX.UI.Menu.CloseAll()
  280. end
  281. end
  282. end
  283. end)
  284.  
  285. function OpenBoatsMenu(x, y , z)
  286. local ped = PlayerPedId()
  287. PlayerData = ESX.GetPlayerData()
  288. local elements = {}
  289.  
  290.  
  291. table.insert(elements, {label = '<span style="color:green;">Dinghy</span> <span style="color:red;">2500$</span>', value = 'boat'})
  292. table.insert(elements, {label = '<span style="color:green;">Suntrap</span> <span style="color:red;">3500$</span>', value = 'boat6'})
  293. table.insert(elements, {label = '<span style="color:green;">Jetmax</span> <span style="color:red;">4500$</span>', value = 'boat5'})
  294. table.insert(elements, {label = '<span style="color:green;">Toro</span> <span style="color:red;">5500$</span>', value = 'boat2'})
  295. table.insert(elements, {label = '<span style="color:green;">Marquis</span> <span style="color:red;">6000$</span>', value = 'boat3'})
  296. table.insert(elements, {label = '<span style="color:green;">Tug boat</span> <span style="color:red;">7500$</span>', value = 'boat4'})
  297.  
  298. --If user has police job they will be able to get free Police Predator boat
  299. if PlayerData.job.name == "police" then
  300. table.insert(elements, {label = '<span style="color:green;">Police Predator</span>', value = 'police'})
  301. end
  302.  
  303. ESX.UI.Menu.CloseAll()
  304.  
  305. ESX.UI.Menu.Open(
  306. 'default', GetCurrentResourceName(), 'client',
  307. {
  308. title = 'Rent a boat',
  309. align = 'bottom-right',
  310. elements = elements,
  311. },
  312.  
  313.  
  314. function(data, menu)
  315.  
  316. if data.current.value == 'boat' then
  317. ESX.UI.Menu.CloseAll()
  318.  
  319. TriggerServerEvent("fishing:lowmoney", 2500)
  320. TriggerEvent("chatMessage", 'You rented a boat for', {255,0,255}, '$' .. 2500)
  321. SetPedCoordsKeepVehicle(ped, x, y , z)
  322. TriggerEvent('esx:spawnVehicle', "dinghy4")
  323. end
  324.  
  325. if data.current.value == 'boat2' then
  326. ESX.UI.Menu.CloseAll()
  327.  
  328. TriggerServerEvent("fishing:lowmoney", 5500)
  329. TriggerEvent("chatMessage", 'You rented a boat for', {255,0,255}, '$' .. 5500)
  330. SetPedCoordsKeepVehicle(ped, x, y , z)
  331. TriggerEvent('esx:spawnVehicle', "TORO")
  332. end
  333.  
  334. if data.current.value == 'boat3' then
  335. ESX.UI.Menu.CloseAll()
  336.  
  337. TriggerServerEvent("fishing:lowmoney", 6000)
  338. TriggerEvent("chatMessage", 'You rented a boat for', {255,0,255}, '$' .. 6000)
  339. SetPedCoordsKeepVehicle(ped, x, y , z)
  340. TriggerEvent('esx:spawnVehicle', "MARQUIS")
  341. end
  342.  
  343. if data.current.value == 'boat4' then
  344. ESX.UI.Menu.CloseAll()
  345.  
  346. TriggerServerEvent("fishing:lowmoney", 7500)
  347. TriggerEvent("chatMessage", 'You rented a boat for', {255,0,255}, '$' .. 7500)
  348. SetPedCoordsKeepVehicle(ped, x, y , z)
  349. TriggerEvent('esx:spawnVehicle', "tug")
  350. end
  351.  
  352. if data.current.value == 'boat5' then
  353. ESX.UI.Menu.CloseAll()
  354.  
  355. TriggerServerEvent("fishing:lowmoney", 4500)
  356. TriggerEvent("chatMessage", 'You rented a boat for', {255,0,255}, '$' .. 4500)
  357. SetPedCoordsKeepVehicle(ped, x, y , z)
  358. TriggerEvent('esx:spawnVehicle', "jetmax")
  359. end
  360.  
  361. if data.current.value == 'boat6' then
  362. ESX.UI.Menu.CloseAll()
  363.  
  364. TriggerServerEvent("fishing:lowmoney", 3500)
  365. TriggerEvent("chatMessage", 'You rented a boat for', {255,0,255}, '$' .. 3500)
  366. SetPedCoordsKeepVehicle(ped, x, y , z)
  367. TriggerEvent('esx:spawnVehicle', "suntrap")
  368. end
  369.  
  370.  
  371. if data.current.value == 'police' then
  372. ESX.UI.Menu.CloseAll()
  373.  
  374. TriggerEvent("chatMessage", 'You took out a boat')
  375. SetPedCoordsKeepVehicle(ped, x, y , z)
  376. TriggerEvent('esx:spawnVehicle', "predator")
  377. end
  378. ESX.UI.Menu.CloseAll()
  379.  
  380.  
  381. end,
  382. function(data, menu)
  383. menu.close()
  384. end
  385. )
  386. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement