Advertisement
Stivicx

Pooljob [Lalife]

Jun 11th, 2017
451
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 19.64 KB | None | 0 0
  1. local clientjobID = 0
  2.  
  3. job = {
  4.     plate = 0,
  5. }
  6.  
  7. local pool_locations = {
  8.     {enteringpool = {722.0145,-909.5587,24.43356}, innutile2 = {722.0145,-909.5587,24.43356}, outsidepool= {717.3234,-894.7209,24.0391}},
  9. }
  10.  
  11. local pool_blips ={}
  12. local inrangeofpool= false
  13. local inrangeofpool3 = false
  14. local currentlocation = nil
  15. local boughtcar = false
  16.  
  17. local function LocalPed()
  18.     return GetPlayerPed(-1)
  19. end
  20.  
  21. function drawTxtpool(text,font,centre,x,y,scale,r,g,b,a)
  22.     SetTextFont(font)
  23.     SetTextProportional(0)
  24.     SetTextScale(scale, scale)
  25.     SetTextColour(r, g, b, a)
  26.     SetTextDropShadow(0, 0, 0, 0,255)
  27.     SetTextEdge(1, 0, 0, 0, 255)
  28.     SetTextDropShadow()
  29.     SetTextOutline()
  30.     SetTextCentre(centre)
  31.     SetTextEntry("STRING")
  32.     AddTextComponentString(text)
  33.     DrawText(x , y)
  34. end
  35.  
  36. function IsPlayerInRangeOfpool()
  37.     return inrangeofpool
  38. end
  39.  
  40. function IsPlayerInRangeOfpool3()
  41.     return inrangeofpool3
  42. end
  43.  
  44. function ShowpoolBlips(bool)
  45.     if bool and #pool_blips == 0 then
  46.         for station,pos in pairs(pool_locations) do
  47.             local loc = pos
  48.             pos = pos.outsidepool
  49.             local blip = AddBlipForCoord(pos[1],pos[2],pos[3])
  50.             -- 60 58 137
  51.             SetBlipSprite(blip,399)
  52.             SetBlipColour(blip, 2)
  53.             SetBlipScale(blip, 0.65)
  54.             BeginTextCommandSetBlipName("STRING")
  55.             AddTextComponentString('Piscine')
  56.             EndTextCommandSetBlipName(blip)
  57.             SetBlipAsShortRange(blip,true)
  58.             SetBlipAsMissionCreatorBlip(blip,true)
  59.             table.insert(pool_blips, {blip = blip, pos = loc})
  60.         end
  61.         Citizen.CreateThread(function()
  62.             while #pool_blips > 0 do
  63.                 Citizen.Wait(0)
  64.                 local inrange = false
  65.                 local inrange3 = false
  66.                 for i,b in ipairs(pool_blips) do
  67.                     if IsPedInAnyVehicle(LocalPed(), true) == false and GetDistanceBetweenCoords(b.pos.enteringpool[1],b.pos.enteringpool[2],b.pos.enteringpool[3],GetEntityCoords(LocalPed()),true) > 0 then
  68.                         DrawMarker(0,711.4304,-893.3711,23.05157,0,0,0,0,0,0,2.001,2.0001,0.5001,0,155,255,200,0,0,0,0)
  69.                         currentlocation = b
  70.                         if GetDistanceBetweenCoords(711.4304,-893.3711,23.05157,GetEntityCoords(LocalPed()),true) < 3 then
  71.                             ShowInfoJobPool("Appuyez sur ~INPUT_CONTEXT~ pour sortir votre ~b~Camion~w~.", 0)
  72.                             inrange3 = true
  73.                         end
  74.                     end
  75.                 end
  76.                 inrangeofpool = inrange
  77.                 inrangeofpool3 = inrange3
  78.             end
  79.         end)
  80.     elseif bool == false and #pool_blips > 0 then
  81.         for i,b in ipairs(pool_blips) do
  82.             if DoesBlipExist(b.blip) then
  83.                 SetBlipAsMissionCreatorBlip(b.blip,false)
  84.                 Citizen.InvokeNative(0x86A652570E5F25DD, Citizen.PointerValueIntInitialized(b.blip))
  85.             end
  86.         end
  87.         pool_blips = {}
  88.     end
  89. end
  90.  
  91. RegisterNetEvent("job:f_GetIdentifier")
  92. AddEventHandler("job:f_GetIdentifier", function(plate)
  93.     job.plate = plate
  94. end)
  95.  
  96. AddEventHandler("playerSpawned", function()
  97.     TriggerServerEvent("job:GetIdentifier")
  98. end)
  99.  
  100. local ShowMsgtime = { msg = "", time = 0 }
  101. local myjob = 0
  102.  
  103. RegisterNetEvent("mine:getJobs")
  104. AddEventHandler("mine:getJobs", function(job)
  105.     myjob = job
  106. end)
  107.  
  108. Citizen.CreateThread(function()
  109.   while true do
  110.     Citizen.Wait(0)
  111.     if ShowMsgtime.time ~= 0 then
  112.       drawTxtpool(ShowMsgtime.msg, 0, 1, 0.5, 0.8, 0.6, 255, 255, 255, 255)
  113.       ShowMsgtime.time = ShowMsgtime.time - 1
  114.     end
  115.   end
  116. end)
  117.  
  118. Citizen.CreateThread(function()
  119.     while true do
  120.         Citizen.Wait(0)
  121.         if IsControlJustPressed(1,38) and inrangeofpool3 then
  122.             TriggerServerEvent("poleemploi:getjobs")
  123.             Wait(100)
  124.             if myjob == 2 then
  125.                 SetPedComponentVariation(GetPlayerPed(-1), 11, 123, 1, 0)
  126.                 SetPedComponentVariation(GetPlayerPed(-1), 8, 15, 0, 0)
  127.                 SetPedComponentVariation(GetPlayerPed(-1), 4, 17, 6, 0)
  128.                 SetPedComponentVariation(GetPlayerPed(-1), 6, 8, 0, 0)
  129.                 SetPedComponentVariation(GetPlayerPed(-1), 3, 0, 0, 0)
  130.                 --TriggerServerEvent('CheckPoolVehi')
  131.                 --TriggerServerEvent('SetPlateJob')
  132.                 --local car = 0xC703DB5F
  133.                 Wait(100)
  134.                 --local car = GetHashKey("pony2")
  135.                 local car = 0x58B3979C
  136.                 -- VOITURE PAR DÉFAUT
  137.                 local cplate = job.plate
  138.                 Citizen.CreateThread(function()
  139.                     Citizen.Wait(10)
  140.  
  141.  
  142.                     RequestModel(car)
  143.                     while not HasModelLoaded(car) do
  144.                         Citizen.Wait(0)
  145.                     end
  146.                     veh = CreateVehicle(car, 729.268, -878.351, 24.95, 0.0, true, false)
  147.                     SetEntityVelocity(veh, 2000)
  148.                     SetVehicleNumberPlateText(veh, cplate)
  149.                     SetVehicleOnGroundProperly(veh)
  150.                     SetVehicleHasBeenOwnedByPlayer(veh,true)
  151.                     local id = NetworkGetNetworkIdFromEntity(veh)
  152.                     SetNetworkIdCanMigrate(id, true)
  153.                     SetVehRadioStation(veh, "OFF")
  154.                     SetVehicleColours(veh, 64,64)
  155.                     SetVehicleLivery(veh, 3)
  156.                     SetPedIntoVehicle(GetPlayerPed(-1),  veh,  -1)
  157.                     DrawNotif("Véhicule sorti, bonne route")
  158.                 end)
  159.                 clientjobID = 45 -- Piscine
  160.                 inrangeofpool3 = false
  161.                 inrange3 = false
  162.             else
  163.                 ShowMsgtime.msg = '~r~ Vous devez être nettoyeur de piscine !'
  164.                 ShowMsgtime.time = 150
  165.             end
  166.         end
  167.     end
  168. end)
  169.  
  170. onJobPool = 0
  171.  
  172. daily = {flag = {}, blip = {}, veh = {}, coords = {cx={}, cy={}, cz={}}}
  173.  
  174. function StartJobPool()
  175.     showLoadingPromtpool("Chargement du métier.""Conduisez et allez nettoyer les ~h~~y~Piscines~w~.", 10000)
  176.     onJobPool = 1
  177. end
  178.  
  179. function DrawMissionTextpool(m_text, showtime)
  180.     ClearPrints()
  181.     SetTextEntry_2("STRING")
  182.     AddTextComponentString(m_text)
  183.     DrawSubtitleTimed(showtime, 1)
  184. end
  185.  
  186. function showLoadingPromtpool(showText, showTime, showType)
  187.     Citizen.CreateThread(function()
  188.         Citizen.Wait(0)
  189.         N_0xaba17d7ce615adbf("STRING") -- set type
  190.         AddTextComponentString(showText) -- sets the text
  191.         N_0xbd12f8228410d9b4(showType) -- show promt (types = 3)
  192.         Citizen.Wait(showTime) -- show time
  193.         N_0x10d373323e5b9c0d() -- remove promt
  194.     end)
  195. end
  196.  
  197. function DrawNotif(text)
  198.     SetNotificationTextEntry("STRING")
  199.     AddTextComponentString(text)
  200.     DrawNotification(false, false)
  201. end
  202.  
  203. function ShowInfoJobPool(text, state)
  204.     SetTextComponentFormat("STRING")
  205.     AddTextComponentString(text)
  206.     DisplayHelpTextFromStringLabel(0, state, 0, -1)
  207. end
  208.  
  209. function StopJobPool()
  210.     if daily.blip[1] ~= nil and DoesBlipExist(daily.blip[1]) then
  211.         Citizen.InvokeNative(0x86A652570E5F25DD,Citizen.PointerValueIntInitialized(daily.blip[1]))
  212.         daily.blip[1] = nil
  213.     end
  214.     onJobPool = 0
  215.     clientjobID = 0
  216.     daily.veh[1] = nil
  217.     daily.flag[1] = nil
  218.     daily.flag[2] = nil
  219. end
  220.  
  221. Citizen.CreateThread(function()
  222.     while true do
  223.         Wait(0)
  224.         if onJobPool == 0 then
  225.             if (clientjobID == 45) then -- JOB pool
  226.                 if IsPedSittingInAnyVehicle(GetPlayerPed(-1)) then
  227.                     --if IsVehicleModel(GetVehiclePedIsUsing(GetPlayerPed(-1)), GetHashKey("pony2", _r)) then
  228.                     if IsVehicleModel(GetVehiclePedIsUsing(GetPlayerPed(-1)), 0x58B3979C) then
  229.                         TriggerServerEvent("poleemploi:getjobs")
  230.                         Wait(100)
  231.                         if myjob == 2 then
  232.                             StartJobPool(1)
  233.                         else
  234.                             ShowMsgtime.msg = '~r~ Vous devez être nettoyeur de piscine !'
  235.                             ShowMsgtime.time = 150
  236.                         end
  237.                     end
  238.                 end
  239.             end
  240.         elseif onJobPool == 1 then
  241.             if DoesEntityExist(daily.veh[1]) and IsVehicleDriveable(daily.veh[1], 0) then
  242.  
  243.                 if daily.flag[1] == 1 then
  244.                     daily.flag[2] = GetRandomIntInRange(1, 88)
  245.                     daily.blip[1] = AddBlipForCoord(daily.coords.cx[daily.flag[2]],daily.coords.cy[daily.flag[2]],daily.coords.cz[daily.flag[2]])
  246.                     N_0x80ead8e2e1d5d52e(daily.blip[1])
  247.                     SetBlipRoute(daily.blip[1], 1)
  248.                     distance = GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)), daily.coords.cx[daily.flag[2]],daily.coords.cy[daily.flag[2]],daily.coords.cz[daily.flag[2]], true)
  249.                     daily.flag[1] = 2
  250.                 end
  251.                 if daily.flag[1] == 2 then
  252.                     if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)), daily.coords.cx[daily.flag[2]],daily.coords.cy[daily.flag[2]],daily.coords.cz[daily.flag[2]], true) > 5.0001 then
  253.                         --DrawMarker(1, daily.coords.cx[daily.flag[2]],daily.coords.cy[daily.flag[2]],daily.coords.cz[daily.flag[2]]-1.0001, 0, 0, 0, 0, 0, 0, 2.0, 2.0, 2.0, 178, 236, 93, 155, 0, 0, 2, 0, 0, 0, 0)
  254.                     else
  255.                         if daily.blip[1] ~= nil and DoesBlipExist(daily.blip[1]) then
  256.                             Citizen.InvokeNative(0x86A652570E5F25DD,Citizen.PointerValueIntInitialized(daily.blip[1]))
  257.                             daily.blip[1] = nil
  258.                         end
  259.                         if IsPedInAnyVehicle(LocalPed(), true) == false then
  260.                             ShowInfoJobPool("Appuyez sur ~INPUT_CONTEXT~ pour ~b~nettoyer~w~ la piscine.", 0)
  261.                             if IsControlJustPressed(1,38) then
  262.                                 local dict = "pickup_object"
  263.                                 local anim = "pickup_low"
  264.                                 RequestAnimDict(dict)
  265.  
  266.                                 while not HasAnimDictLoaded(dict) do
  267.                                     Citizen.Wait(0)
  268.                                 end
  269.  
  270.                                 local myPed = PlayerPedId()
  271.                                 local animation = anim
  272.                                 local flags = 16 -- only play the animation on the upper body
  273.  
  274.                                 TaskPlayAnim(myPed, dict, animation, 8.0, -8, -1, flags, 0, 0, 0, 0)
  275.                                 Wait(2000)
  276.                                 DrawMissionTextpool("~h~Vous avez ~g~nettoyé~w~ une piscine !", 5000)
  277.                                 TriggerServerEvent('job:success', distance)
  278.                                 --TriggerServerEvent('CheckPool')
  279.                                 Wait(1000)
  280.                                 daily.flag[1] = 1
  281.                                 daily.flag[2] = GetRandomIntInRange(1, 88)
  282.                             end
  283.                         end
  284.                     end
  285.                 end
  286.  
  287.                 if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)), GetEntityCoords(daily.veh[1]), true) > 350.0001 then
  288.                     StopJobPool(1)
  289.                     DrawNotif("~r~Retournez dans votre véhicule pour reprendre votre travail")
  290.                 else
  291.  
  292.                 end
  293.  
  294.             else
  295.                 StopJobPool(1)
  296.                 DrawMissionTextpool("Votre camion est ~h~~r~hors-service~w~.", 5000)
  297.             end
  298.         end
  299.     end
  300.  
  301. end)
  302.  
  303. AddEventHandler('playerSpawned', function(spawn)
  304.     ShowpoolBlips(true)
  305. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement