Advertisement
Guest User

Untitled

a guest
Mar 17th, 2018
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.14 KB | None | 0 0
  1. ESX = nil
  2. TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  3.     local _source = source
  4.     local xPlayer = ESX.GetPlayerFromId(source)
  5.     local selling = false
  6.     local success = false
  7.     local paymentc = math.random (200,250)
  8.     local paymentw = math.random (50,100)
  9.     local paymentm = math.random (100,200)
  10.     local paymento = math.random (300,400)
  11.     local CopsConnected           = 0
  12.  
  13.   function CountCops()
  14.  
  15.     local xPlayers = ESX.GetPlayers()
  16.  
  17.     CopsConnected = 0
  18.  
  19.     for i=1, #xPlayers, 1 do
  20.         local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
  21.         if xPlayer.job.name == 'police' then
  22.             CopsConnected = CopsConnected + 1
  23.         end
  24.     end
  25.  
  26.     SetTimeout(1000, CountCops)
  27.  
  28. end
  29. CountCops()
  30.  
  31.   RegisterNetEvent('drugs:trigger')
  32.   AddEventHandler('drugs:trigger', function()
  33.     TriggerEvent('currentlySelling')
  34.         if selling == true and CopsConnected >= 1 then
  35.             TriggerEvent('pass_or_fail')
  36.             TriggerClientEvent("pNotify:SetQueueMax", source, "lmao", 1)
  37.             TriggerClientEvent("pNotify:SendNotification", source, {
  38.             text = "a tentar vender drogas",
  39.             type = "error",
  40.             queue = "lmao",
  41.             timeout = 2500,
  42.             layout = "Centerleft"
  43.             })
  44.         elseif CopsConnected < 1 then
  45.             TriggerClientEvent("pNotify:SetQueueMax", source, "lmao", 1)
  46.             TriggerClientEvent("pNotify:SendNotification", source, {
  47.             text = "nao ha policias na cidade",
  48.             type = "error",
  49.             queue = "lmao",
  50.             timeout = 2500,
  51.             layout = "Centerleft"
  52.             })
  53.         end
  54.  end)
  55.  
  56.   RegisterNetEvent('drugs:sell')
  57.   AddEventHandler('drugs:sell', function()
  58.     local xPlayer = ESX.GetPlayerFromId(source)
  59.     local meth = xPlayer.getInventoryItem('meth_pooch').count
  60.     local coke    = xPlayer.getInventoryItem('coke_pooch').count
  61.     local weed = xPlayer.getInventoryItem('weed_pooch').count
  62.     local opium = xPlayer.getInventoryItem('opium_pooch').count
  63.  
  64.         if coke >= 1 and success == true then
  65.                 TriggerClientEvent("pNotify:SetQueueMax", source, "lmao", 5)
  66.                 TriggerClientEvent("pNotify:SendNotification", source, {
  67.                     text = "vendeste um saco de coca por $" .. paymentc ,
  68.                     type = "success",
  69.                     progressBar = false,
  70.                     queue = "lmao",
  71.                     timeout = 2000,
  72.                     layout = "CenterLeft"
  73.             })
  74.             xPlayer.removeInventoryItem('coke_pooch', 1)
  75.             xPlayer.addAccountMoney('black_money', paymentc)
  76.             selling = false
  77.         elseif weed >= 1 and success == true then
  78.                 TriggerClientEvent("pNotify:SetQueueMax", source, "lmao", 5)
  79.                 TriggerClientEvent("pNotify:SendNotification", source, {
  80.                     text = "vendeste um saco de erva por $" .. paymentw ,
  81.                     type = "success",
  82.                     progressBar = false,
  83.                     queue = "lmao",
  84.                     timeout = 2000,
  85.                     layout = "CenterLeft"
  86.                 })
  87.             xPlayer.removeInventoryItem('weed_pooch', 1)
  88.             xPlayer.addAccountMoney('black_money', paymentw)
  89.             selling = false
  90.           elseif meth >= 1 and success == true then
  91.                 TriggerClientEvent("pNotify:SetQueueMax", source, "lmao", 5)
  92.                 TriggerClientEvent("pNotify:SendNotification", source, {
  93.                     text = "vendeste um saco de coca por $" .. paymentm ,
  94.                     type = "success",
  95.                     progressBar = false,
  96.                     queue = "lmao",
  97.                     timeout = 2000,
  98.                     layout = "CenterLeft"
  99.             })
  100.             xPlayer.removeInventoryItem('meth_pooch', 1)
  101.             xPlayer.addAccountMoney('black_money', paymentm)
  102.             selling = false
  103.             elseif opium >= 1 and success == true then
  104.                 TriggerClientEvent("pNotify:SetQueueMax", source, "lmao", 5)
  105.                 TriggerClientEvent("pNotify:SendNotification", source, {
  106.                     text = "vendeste um saco de heroina por $" .. paymento ,
  107.                     type = "success",
  108.                     progressBar = false,
  109.                     queue = "lmao",
  110.                     timeout = 2000,
  111.                     layout = "CenterLeft"
  112.             })
  113.             xPlayer.removeInventoryItem('opium_pooch', 1)
  114.             xPlayer.addAccountMoney('black_money', paymento)
  115.             selling = false
  116.             elseif selling == true and success == false then
  117.                 TriggerClientEvent("pNotify:SetQueueMax", source, "lmao", 5)
  118.                 TriggerClientEvent("pNotify:SendNotification", source, {
  119.                     text = "nao tem interesse em drogas",
  120.                     type = "error",
  121.                     progressBar = false,
  122.                     queue = "lmao",
  123.                     timeout = 2000,
  124.                     layout = "CenterLeft"
  125.             })
  126.             selling = false
  127.             else
  128.                 TriggerClientEvent("pNotify:SetQueueMax", source, "lmao", 5)
  129.                 TriggerClientEvent("pNotify:SendNotification", source, {
  130.                 text = "nao tens drogas",
  131.                 type = "error",
  132.                 progressBar = false,
  133.                 queue = "lmao",
  134.                 timeout = 2000,
  135.                 layout = "CenterLeft"
  136.             })
  137.         end
  138. end)
  139.  
  140. RegisterNetEvent('currentlySelling')
  141. AddEventHandler('currentlySelling', function()
  142.     selling = true
  143. end)
  144.  
  145. RegisterNetEvent('pass_or_fail')
  146. AddEventHandler('pass_or_fail', function()
  147.        
  148.         local percent = math.random(1, 10)
  149.  
  150.         if percent == 3 or percent == 4 or percent == 5 or percent == 6 or percent == 7 or percent == 8 or percent == 9 or percent == 10 then
  151.             success = false
  152.         elseif percent ~= 3 or percent ~= 4 or percent ~= 5 or percent ~= 6 or percent ~= 7 or percent ~= 8 or percent ~= 9 or percent ~= 10 then
  153.             success = true
  154.         end
  155.   end)
  156.  
  157. RegisterNetEvent('sell_dis')
  158. AddEventHandler('sell_dis', function()
  159.         TriggerClientEvent("pNotify:SetQueueMax", source, "lmao", 5)
  160.         TriggerClientEvent("pNotify:SendNotification", source, {
  161.         text = "estas muito longe",
  162.         type = "error",
  163.         progressBar = false,
  164.         queue = "lmao",
  165.         timeout = 2000,
  166.         layout = "CenterLeft"
  167.     })
  168. end)
  169.  
  170.  
  171. RegisterServerEvent('drugs:police')
  172. AddEventHandler('drugs:police', function(text)
  173.  
  174.     local source = source
  175.     local xPlayer = ESX.GetPlayerFromId(source)
  176.     local xPlayers = ESX.GetPlayers()
  177.     local cops = 0
  178.     for i=1, #xPlayers, 1 do
  179.         local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
  180.         if xPlayer.job.name == 'police' then
  181.             cops = cops + 1
  182.         end
  183.     end
  184.     for i=1, #xPlayers, 1 do
  185.         local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
  186.         if xPlayer.job.name == 'police' then
  187.             TriggerClientEvent('esx_phone:onMessage', xPlayer2.source, '', "Venda de droga nas ruas" , xPlayer.get('coords'), true, 'Alert Police', true)  
  188.         end
  189.     end
  190. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement