Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ESX = nil
- TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
- local _source = source
- local xPlayer = ESX.GetPlayerFromId(source)
- local selling = false
- local success = false
- local paymentc = math.random (200,250)
- local paymentw = math.random (50,100)
- local paymentm = math.random (100,200)
- local paymento = math.random (300,400)
- local CopsConnected = 0
- function CountCops()
- local xPlayers = ESX.GetPlayers()
- CopsConnected = 0
- for i=1, #xPlayers, 1 do
- local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
- if xPlayer.job.name == 'police' then
- CopsConnected = CopsConnected + 1
- end
- end
- SetTimeout(1000, CountCops)
- end
- CountCops()
- RegisterNetEvent('drugs:trigger')
- AddEventHandler('drugs:trigger', function()
- TriggerEvent('currentlySelling')
- if selling == true and CopsConnected >= 1 then
- TriggerEvent('pass_or_fail')
- TriggerClientEvent("pNotify:SetQueueMax", source, "lmao", 1)
- TriggerClientEvent("pNotify:SendNotification", source, {
- text = "a tentar vender drogas",
- type = "error",
- queue = "lmao",
- timeout = 2500,
- layout = "Centerleft"
- })
- elseif CopsConnected < 1 then
- TriggerClientEvent("pNotify:SetQueueMax", source, "lmao", 1)
- TriggerClientEvent("pNotify:SendNotification", source, {
- text = "nao ha policias na cidade",
- type = "error",
- queue = "lmao",
- timeout = 2500,
- layout = "Centerleft"
- })
- end
- end)
- RegisterNetEvent('drugs:sell')
- AddEventHandler('drugs:sell', function()
- local xPlayer = ESX.GetPlayerFromId(source)
- local meth = xPlayer.getInventoryItem('meth_pooch').count
- local coke = xPlayer.getInventoryItem('coke_pooch').count
- local weed = xPlayer.getInventoryItem('weed_pooch').count
- local opium = xPlayer.getInventoryItem('opium_pooch').count
- if coke >= 1 and success == true then
- TriggerClientEvent("pNotify:SetQueueMax", source, "lmao", 5)
- TriggerClientEvent("pNotify:SendNotification", source, {
- text = "vendeste um saco de coca por $" .. paymentc ,
- type = "success",
- progressBar = false,
- queue = "lmao",
- timeout = 2000,
- layout = "CenterLeft"
- })
- xPlayer.removeInventoryItem('coke_pooch', 1)
- xPlayer.addAccountMoney('black_money', paymentc)
- selling = false
- elseif weed >= 1 and success == true then
- TriggerClientEvent("pNotify:SetQueueMax", source, "lmao", 5)
- TriggerClientEvent("pNotify:SendNotification", source, {
- text = "vendeste um saco de erva por $" .. paymentw ,
- type = "success",
- progressBar = false,
- queue = "lmao",
- timeout = 2000,
- layout = "CenterLeft"
- })
- xPlayer.removeInventoryItem('weed_pooch', 1)
- xPlayer.addAccountMoney('black_money', paymentw)
- selling = false
- elseif meth >= 1 and success == true then
- TriggerClientEvent("pNotify:SetQueueMax", source, "lmao", 5)
- TriggerClientEvent("pNotify:SendNotification", source, {
- text = "vendeste um saco de coca por $" .. paymentm ,
- type = "success",
- progressBar = false,
- queue = "lmao",
- timeout = 2000,
- layout = "CenterLeft"
- })
- xPlayer.removeInventoryItem('meth_pooch', 1)
- xPlayer.addAccountMoney('black_money', paymentm)
- selling = false
- elseif opium >= 1 and success == true then
- TriggerClientEvent("pNotify:SetQueueMax", source, "lmao", 5)
- TriggerClientEvent("pNotify:SendNotification", source, {
- text = "vendeste um saco de heroina por $" .. paymento ,
- type = "success",
- progressBar = false,
- queue = "lmao",
- timeout = 2000,
- layout = "CenterLeft"
- })
- xPlayer.removeInventoryItem('opium_pooch', 1)
- xPlayer.addAccountMoney('black_money', paymento)
- selling = false
- elseif selling == true and success == false then
- TriggerClientEvent("pNotify:SetQueueMax", source, "lmao", 5)
- TriggerClientEvent("pNotify:SendNotification", source, {
- text = "nao tem interesse em drogas",
- type = "error",
- progressBar = false,
- queue = "lmao",
- timeout = 2000,
- layout = "CenterLeft"
- })
- selling = false
- else
- TriggerClientEvent("pNotify:SetQueueMax", source, "lmao", 5)
- TriggerClientEvent("pNotify:SendNotification", source, {
- text = "nao tens drogas",
- type = "error",
- progressBar = false,
- queue = "lmao",
- timeout = 2000,
- layout = "CenterLeft"
- })
- end
- end)
- RegisterNetEvent('currentlySelling')
- AddEventHandler('currentlySelling', function()
- selling = true
- end)
- RegisterNetEvent('pass_or_fail')
- AddEventHandler('pass_or_fail', function()
- local percent = math.random(1, 10)
- 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
- success = false
- 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
- success = true
- end
- end)
- RegisterNetEvent('sell_dis')
- AddEventHandler('sell_dis', function()
- TriggerClientEvent("pNotify:SetQueueMax", source, "lmao", 5)
- TriggerClientEvent("pNotify:SendNotification", source, {
- text = "estas muito longe",
- type = "error",
- progressBar = false,
- queue = "lmao",
- timeout = 2000,
- layout = "CenterLeft"
- })
- end)
- RegisterServerEvent('drugs:police')
- AddEventHandler('drugs:police', function(text)
- local source = source
- local xPlayer = ESX.GetPlayerFromId(source)
- local xPlayers = ESX.GetPlayers()
- local cops = 0
- for i=1, #xPlayers, 1 do
- local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
- if xPlayer.job.name == 'police' then
- cops = cops + 1
- end
- end
- for i=1, #xPlayers, 1 do
- local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
- if xPlayer.job.name == 'police' then
- TriggerClientEvent('esx_phone:onMessage', xPlayer2.source, '', "Venda de droga nas ruas" , xPlayer.get('coords'), true, 'Alert Police', true)
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement