Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- --------------------------------------------
- -- Variables
- -- --------------------------------------------
- local fields
- local process
- local sellers
- local blanchi
- local sellingPnj
- local sellings
- local NbrCops = 0
- local HappyHour = 20
- local Hour = 1
- local hasDrugs = false
- local drugs = {
- [14] = 0,
- [231] = 0,
- [28] = 0,
- [259] = 0,
- [258] = 0,
- [232] = 0,
- [8] = 0,
- }
- local closePed = false
- local pedCloseTo
- local pedSold = {}
- local IsInAppart = false
- function mapBlipsDebug()
- if fields ~= nil then
- for k, v in pairs(fields) do
- for _, point in pairs(fields[k].loc) do
- AddBlip("Champs " .. k, 1, 1, point.x, point.y, point.z, 0.7)
- end
- end
- end
- if sellers.settings ~= nil then
- for k, v in pairs(sellers.settings) do
- AddBlip("Sale", 1, 1, sellers.loc[v.id].x, sellers.loc[v.id].y, sellers.loc[v.id].z, 0.7)
- end
- end
- if blanchi.loc ~= nil then
- for k, v in pairs(blanchi.loc) do
- AddBlip("Blanchiment", 1, 1, v.x, v.y, v.z, 0.7)
- end
- end
- end
- -- --------------------------------------------
- -- Evènements pour l'utilisation du matériel
- -- --------------------------------------------
- local Particles = {}
- local Props = {}
- function beginProcess(type)
- local playerPed = PlayerPedId()
- local propCoords = GetOffsetFromEntityInWorldCoords(playerPed, 0.0, 2.0, 0.0)
- TriggerServerEvent('drugs:addProcess', type, { x = propCoords['x'], y = propCoords['y'], z = propCoords['z'] })
- end
- function addProcessObjects(_type, _coords)
- -- Table
- table.insert(process[_type].loc, _coords)
- -- Particules
- if process[_type].settings.particle ~= '' then
- RequestNamedPtfxAsset('core')
- SetPtfxAssetNextCall('core')
- local effet = StartParticleFxLoopedAtCoord(process[_type].settings.particle, _coords.x, _coords.y, _coords.z + 5.0, 0.0, 0.0, 0.0, 1.0, 1, 1, 1, 0)
- Particles[math.floor(_coords.x * 100)] = effet
- end
- -- Prop
- if Props[math.floor(_coords.x * 100)] == nil then
- local object = CreateObject(GetHashKey(process[_type].settings.prop), _coords.x, _coords.y, _coords.z - 1.0, false, false, false)
- PlaceObjectOnGroundProperly(object)
- Props[math.floor(_coords.x * 100)] = object
- end
- end
- RegisterNetEvent('drugs:shareAddProcess')
- AddEventHandler('drugs:shareAddProcess', function(type, coords)
- addProcessObjects(type, coords)
- end)
- RegisterNetEvent('drugs:shareRemoveProcess')
- AddEventHandler('drugs:shareRemoveProcess', function(type, coords)
- -- Table
- if process ~= nil then
- RemoveSpec(process[type].loc, coords)
- end
- -- Particules
- if Particles[math.floor(coords.x * 100)] ~= nil then
- StopParticleFxLooped(Particles[math.floor(coords.x * 100)], 0)
- end
- -- Prop
- if Props[math.floor(coords.x * 100)] ~= nil then
- DeleteObject(Props[math.floor(coords.x * 100)])
- end
- end)
- AddEventHandler('apart:enteredAppart', function(_status)
- IsInAppart = _status
- end)
- AddEventHandler('drugs:materiel-joints', function()
- if not IsInAppart and sellers.settings['Joints'] ~= nil then
- beginProcess('Joints')
- TriggerServerEvent('pinventory:looseItem', sellers.settings['Joints'].item, 1)
- else
- SendNotification('Vous ne pouvez pas placer ça ici...', 'error')
- end
- end)
- AddEventHandler('drugs:materiel-shit', function()
- if not IsInAppart and sellers.settings['Shit'] ~= nil then
- beginProcess('Shit')
- TriggerServerEvent('pinventory:looseItem', sellers.settings['Shit'].item, 1)
- else
- SendNotification('Vous ne pouvez pas placer ça ici...', 'error')
- end
- end)
- AddEventHandler('drugs:materiel-skuff', function()
- if not IsInAppart and sellers.settings['Skuff'] ~= nil then
- beginProcess('Skuff')
- TriggerServerEvent('pinventory:looseItem', sellers.settings['Skuff'].item, 1)
- else
- SendNotification('Vous ne pouvez pas placer ça ici...', 'error')
- end
- end)
- AddEventHandler('drugs:materiel-bho', function()
- if not IsInAppart and sellers.settings['BHO'] ~= nil then
- beginProcess('BHO')
- TriggerServerEvent('pinventory:looseItem', sellers.settings['BHO'].item, 1)
- else
- SendNotification('Vous ne pouvez pas placer ça ici...', 'error')
- end
- end)
- AddEventHandler('drugs:materiel-cocaine', function()
- if not IsInAppart and sellers.settings['Cocaine'] ~= nil then
- beginProcess('Cocaine')
- TriggerServerEvent('pinventory:looseItem', sellers.settings['Cocaine'].item, 1)
- else
- SendNotification('Vous ne pouvez pas placer ça ici...', 'error')
- end
- end)
- AddEventHandler('drugs:materiel-crack', function()
- if not IsInAppart and sellers.settings['Crack'] ~= nil then
- beginProcess('Crack')
- TriggerServerEvent('pinventory:looseItem', sellers.settings['Crack'].item, 1)
- else
- SendNotification('Vous ne pouvez pas placer ça ici...', 'error')
- end
- end)
- AddEventHandler('drugs:materiel-ecsta', function()
- if not IsInAppart and sellers.settings['Ecstasy'] ~= nil then
- beginProcess('Ecstasy')
- TriggerServerEvent('pinventory:looseItem', sellers.settings['Ecstasy'].item, 1)
- else
- SendNotification('Vous ne pouvez pas placer ça ici...', 'error')
- end
- end)
- -- --------------------------------------------
- -- Gestions des données
- -- --------------------------------------------
- AddEventHandler('jointransition:ended', function()
- TriggerServerEvent('drugs:getData')
- end)
- RegisterNetEvent('drugs:setData')
- AddEventHandler('drugs:setData', function(_fields, _process, _sellers, _blanchi, _sellingPnj, _sellings)
- fields = _fields
- process = _process
- sellers = _sellers
- blanchi = _blanchi
- sellingPnj = _sellingPnj
- sellings = _sellings
- -- mapBlipsDebug() -- Laisser désactivé si production
- TriggerEvent('drugs:initSpawnedData', process)
- end)
- -- Charge les objets au spawn
- AddEventHandler('drugs:initSpawnedData', function(_process)
- for drugtype, processdata in pairs(_process) do
- for idx, coords in ipairs(processdata.loc) do
- addProcessObjects(drugtype, processdata.loc[idx])
- Citizen.Wait(250)
- end
- end
- end)
- RegisterNetEvent('drugs:shareUpdateRecolte')
- AddEventHandler('drugs:shareUpdateRecolte', function(type, id, amount)
- if fields ~= nil then
- fields[type].loc[id].qty = fields[type].loc[id].qty + amount
- end
- end)
- RegisterNetEvent('drugs:returnInfo')
- AddEventHandler('drugs:returnInfo', function(_Policiers, _Hour)
- NbrCops = _Policiers
- Hour = _Hour
- end)
- -- A COMMENTER
- -- RegisterCommand('debug', function(source, args)
- -- TriggerServerEvent("drugs:getData")
- -- end)
- -- RegisterCommand('pol', function(source, args)
- -- NbrCops = tonumber(args[1])
- -- end)
- -- --------------------------------------------
- -- Calculs des distances et autres infos
- -- --------------------------------------------
- Citizen.CreateThread(function()
- while true do
- Wait(750)
- if fields ~= nil then
- for k,v in pairs(fields) do
- v.settings.close.yes, v.settings.close.id = CloseTo(v.loc, v.settings.close.dist)
- end
- for k,v in pairs(process) do
- v.settings.close.int, v.settings.close.id = CloseTo(v.loc, v.settings.close.distInt)
- end
- for k,v in pairs(sellers.settings) do
- v.close.int, v.close.id = CloseTo({sellers.loc[v.id]}, v.close.distInt)
- end
- blanchi.settings.close.yes,_ = CloseTo(blanchi.loc, blanchi.settings.close.dist)
- sellingPnj.settings.close.yes,_ = CloseTo(sellingPnj.loc, sellingPnj.settings.close.dist)
- sellings.settings.close.yes,_ = CloseTo({sellings.loc[sellings.settings.id]}, sellings.settings.close.dist)
- drugs = GetDrugs(drugs)
- hasDrugs = HasDrugs(drugs)
- if hasDrugs and sellingPnj.settings.close.yes then
- closePed, pedCloseTo = CloseToPed()
- end
- end
- end
- end)
- Citizen.CreateThread(function()
- while true do
- TriggerServerEvent('drugs:getInfo')
- Wait(480000)
- end
- end)
- -- --------------------------------------------
- -- Interactions avec les points
- -- --------------------------------------------
- Citizen.CreateThread(function()
- while true do
- Wait(0)
- if sellingPnj ~= nil then
- if hasDrugs then
- if closePed then
- if NbrCops >= sellingPnj.settings.cops or Hour >= HappyHour then
- DisplayHelpText("Appuyez sur ~INPUT_CONTEXT~ pour ~y~proposer ton tosma.")
- if IsControlJustReleased(1, 51) then
- if not IsInTable(pedCloseTo, pedSold) then
- if math.random(1, 100) == 1 then
- SendNotification(sellings.phrase[sellings.settings.id] .. '<b><span style="color:#CC2D2D;">' .. sellings.settings.mdp .. '</span></b>' .. '.', "success", 15000)
- end
- if math.random(1, 2) == 1 then
- TriggerServerEvent("drugs:sellPnj", drugs)
- MissionText("~y~Client :~w~ Je vais te prendre ça.", 2500)
- PlayAnimation(sellingPnj.settings.anim)
- Wait(2000)
- ClearPedTasks(PlayerPedId())
- table.insert(pedSold, pedCloseTo)
- else
- MissionText("~y~Client :~w~ Non merci.", 2500)
- table.insert(pedSold, pedCloseTo)
- end
- else
- MissionText("~y~Client :~w~ Encore ? Casse toi.", 2500)
- if math.random(1, 10) == 1 then
- TaskPlayAnim(pedCloseTo, 'amb@code_human_wander_texting@male@enter', 'enter', 8.0, 1.0, -1, 50)
- Wait(8000)
- if not IsPedInjured(pedCloseTo) then
- TriggerEvent('orgCallLSPD:call', {
- type = "Quelqu'un me propose de la drogue !",
- hide = false,
- expire = 60,
- noplayer = true,
- })
- end
- ClearPedTasks(pedCloseTo)
- end
- end
- end
- else
- DisplayHelpText("~r~Aucun client ne sera intéressé pour le moment ...")
- end
- end
- end
- end
- if fields ~= nil then
- for k,v in pairs(fields) do
- if v.settings.close.yes then
- if NbrCops >= v.settings.cops or Hour >= HappyHour then
- if v.loc[v.settings.close.id].qty > 0 then
- DisplayHelpText('Appuyez sur ~INPUT_CONTEXT~ pour ~g~ramasser ' .. v.settings.text .. '.')
- if IsControlJustReleased(1, 51) then
- TriggerServerEvent('drugs:updateRecolte', k, v.settings.close.id)
- TriggerServerEvent('pinventory:receiveItem', v.settings.item.id, v.settings.item.qty, 0, true)
- PlayAnimation(v.settings.anim)
- Wait(v.settings.timers.harvest/2)
- ClearPedTasks(PlayerPedId())
- Wait(v.settings.timers.harvest/2)
- end
- else
- DisplayHelpText('~r~Il n\'y a plus rien ici ...')
- end
- else
- DisplayHelpText('~r~Repasse plus tard, ça craint là ...')
- end
- end
- end
- end
- if process ~= nil then
- for k,v in pairs(process) do
- if v.settings.close.int then
- DisplayHelpText('Restez appuyé sur ~INPUT_CONTEXT~ pour ~b~ramasser le matériel.')
- if NbrCops >= v.settings.cops or Hour >= HappyHour then
- TriggerServerEvent('pinventory:craft', v.settings.item.from, v.settings.item.to)
- PlayAnimation(v.settings.anim)
- Wait(v.settings.timers.process)
- ClearPedTasks(PlayerPedId())
- else
- MissionText('~r~Repasse plus tard, ça craint là ...')
- end
- if IsControlPressed(1, 51) then
- TriggerServerEvent('drugs:removeProcess', k, v.loc[v.settings.close.id])
- while IsControlPressed(1, 51) do
- Wait(100)
- end
- Wait(5000)
- end
- end
- end
- end
- if sellers ~= nil then
- for k,v in pairs(sellers.settings) do
- if v.close.int then
- DisplayHelpText('Appuyez sur ~INPUT_CONTEXT~ pour ~r~acheter ' .. v.text .. '. ~w~(' .. v.price .. ' $)')
- if IsControlJustReleased(1, 51) then
- TriggerServerEvent('drugs:buyMateriel', k)
- end
- end
- end
- end
- if blanchi ~= nil then
- if blanchi.settings.close.yes then
- if NbrCops >= blanchi.settings.cops then
- DisplayHelpText("Appuyez sur ~INPUT_CONTEXT~ pour ~y~blanchir votre argent.")
- if IsControlJustReleased(1, 51) then
- while blanchi.settings.close.yes do
- TriggerServerEvent('drugs:blanchi')
- Wait(blanchi.settings.time)
- end
- end
- else
- DisplayHelpText("~r~Repasse plus tard, ça craint là ...")
- end
- end
- end
- if sellings ~= nil then
- if sellings.settings.close.yes and hasDrugs then
- if NbrCops >= sellings.settings.cops or Hour >= HappyHour then
- DisplayHelpText("Appuyez sur ~INPUT_CONTEXT~ pour ~y~pour vendre votre tosma.")
- if IsControlJustReleased(1, 51) then
- local try = OpenTextInput("Mot de passe :", "")
- print(try)
- print(sellings.settings.mdp)
- if try == sellings.settings.mdp then
- while sellings.settings.close.yes do
- TriggerServerEvent('drugs:sell', drugs)
- Wait(sellings.settings.time)
- end
- else
- SendNotification('C\'est pas le bon mot de passe.', 'error')
- end
- end
- else
- DisplayHelpText("~r~Repasse plus tard, ça craint là ...")
- end
- end
- end
- -- if IsControlJustReleased(1, 182) then
- -- local coords = GetEntityCoords(PlayerPedId())
- -- local heading = GetEntityHeading(PlayerPedId())
- -- print('{ x = ' ..coords['x']..', y = '..coords['y']..', z = '..coords['z']..', h = '..heading..' }')
- -- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement