added opium

This commit is contained in:
TanguyOrtegat
2017-08-25 18:51:12 +02:00
committed by GitHub
parent 27992b06fe
commit 93a8db19a0
8 changed files with 293 additions and 27 deletions
+11 -1
View File
@@ -5,7 +5,17 @@ FXserver ESX Drugs
* esx_policejob => https://github.com/FXServer-ESX/fxserver-esx_policejob
[INSTALLATION]
[UPDATE]
to install opium :
```
INSERT INTO `items` (name, label) VALUES
('opium', 'Opium'),
('opium_pooch', 'Pochon de opium')
;
```
[INSTALLATION]
1) CD in your resources/[esx] folder
2) Clone the repository
+53 -5
View File
@@ -20,6 +20,8 @@ local weedQTE = 0
local weed_poochQTE = 0
local methQTE = 0
local meth_poochQTE = 0
local opiumQTE = 0
local opium_poochQTE = 0
local myJob = nil
local PlayerData = {}
local GUI = {}
@@ -39,7 +41,8 @@ end)
AddEventHandler('esx_drugs:hasEnteredMarker', function(zone)
ESX.UI.Menu.CloseAll()
--coke
if zone == 'CokeFarm' then
if myJob ~= "police" then
CurrentAction = 'coke_harvest'
@@ -67,7 +70,8 @@ AddEventHandler('esx_drugs:hasEnteredMarker', function(zone)
end
end
end
--meth
if zone == 'MethFarm' then
if myJob ~= "police" then
CurrentAction = 'meth_harvest'
@@ -95,7 +99,8 @@ AddEventHandler('esx_drugs:hasEnteredMarker', function(zone)
end
end
end
--weed
if zone == 'WeedFarm' then
if myJob ~= "police" then
CurrentAction = 'weed_harvest'
@@ -123,6 +128,35 @@ AddEventHandler('esx_drugs:hasEnteredMarker', function(zone)
end
end
end
--opium
if zone == 'OpiumFarm' then
if myJob ~= "police" then
CurrentAction = 'opium_harvest'
CurrentActionMsg = _U('press_collect_opium')
CurrentActionData = {}
end
end
if zone == 'OpiumTreatment' then
if myJob ~= "police" then
if opiumQTE >= 5 then
CurrentAction = 'opium_treatment'
CurrentActionMsg = _U('press_process_opium')
CurrentActionData = {}
end
end
end
if zone == 'OpiumResell' then
if myJob ~= "police" then
if opium_poochQTE >= 1 then
CurrentAction = 'opium_resell'
CurrentActionMsg = _U('press_sell_opium')
CurrentActionData = {}
end
end
end
end)
AddEventHandler('esx_drugs:hasExitedMarker', function(zone)
@@ -139,6 +173,9 @@ AddEventHandler('esx_drugs:hasExitedMarker', function(zone)
TriggerServerEvent('esx_drugs:stopHarvestWeed')
TriggerServerEvent('esx_drugs:stopTransformWeed')
TriggerServerEvent('esx_drugs:stopSellWeed')
TriggerServerEvent('esx_drugs:stopHarvestOpium')
TriggerServerEvent('esx_drugs:stopTransformOpium')
TriggerServerEvent('esx_drugs:stopSellOpium')
end)
-- Weed Effect
@@ -188,13 +225,15 @@ end)
-- RETURN NUMBER OF ITEMS FROM SERVER
RegisterNetEvent('esx_drugs:ReturnInventory')
AddEventHandler('esx_drugs:ReturnInventory', function(cokeNbr, cokepNbr, methNbr, methpNbr, weedNbr, weedpNbr, jobName, currentZone)
AddEventHandler('esx_drugs:ReturnInventory', function(cokeNbr, cokepNbr, methNbr, methpNbr, weedNbr, weedpNbr,opiumNbr, opiumpNbr, jobName, currentZone)
cokeQTE = cokeNbr
coke_poochQTE = cokepNbr
methQTE = methNbr
meth_poochQTE = methpNbr
weedQTE = weedNbr
weed_poochQTE = weedpNbr
weed_poochQTE = weedpNbr
opiumQTE = opiumbr
opium_poochQTE = opiumpNbr
myJob = jobName
TriggerEvent('esx_drugs:hasEnteredMarker', currentZone)
end)
@@ -266,6 +305,15 @@ Citizen.CreateThread(function()
if CurrentAction == 'weed_resell' then
TriggerServerEvent('esx_drugs:startSellWeed')
end
if CurrentAction == 'opium_harvest' then
TriggerServerEvent('esx_drugs:startHarvestOpium')
end
if CurrentAction == 'opium_treatment' then
TriggerServerEvent('esx_drugs:startTransformOpium')
end
if CurrentAction == 'opium_resell' then
TriggerServerEvent('esx_drugs:startSellOpium')
end
CurrentAction = nil
end
end
+13 -9
View File
@@ -6,16 +6,20 @@ Config.ZoneSize = {x = 5.0, y = 5.0, z = 3.0}
Config.RequiredCopsCoke = 2
Config.RequiredCopsMeth = 2
Config.RequiredCopsWeed = 0
Config.RequiredCopsOpium = 3
Config.Locale = 'fr'
Config.Zones = {
CokeFarm = {x=2448.9228515625, y=-1836.8076171875, z=51.953701019287},
CokeTreatment = {x=-458.13967895508, y=-2278.6174316406, z=7.5158290863037},
CokeResell = {x=-1756.1984863281, y=427.31674194336, z=126.68292999268},
MethFarm = {x=1525.298828125, y=1710.0217285156, z=109.00956726074},
MethTreatment = {x=-1001.4151611328, y=4848.0087890625, z=274.00686645508},
MethResell = {x=-63.592178344727, y=-1224.0709228516, z=27.768648147583},
WeedFarm = {x=1609.125, y=6663.5942382813, z=20.961572647095},
WeedTreatment = {x=91.061386108398, y=3750.0380859375, z=39.77326965332},
WeedResell = {x=-54.249694824219, y=-1443.3666992188, z=31.068626403809}
CokeFarm = {x=2448.9228515625, y=-1836.8076171875, z=51.953701019287},
CokeTreatment = {x=-458.13967895508, y=-2278.6174316406, z=7.5158290863037},
CokeResell = {x=-1756.1984863281, y=427.31674194336, z=126.68292999268},
MethFarm = {x=1525.298828125, y=1710.0217285156, z=109.00956726074},
MethTreatment = {x=-1001.4151611328, y=4848.0087890625, z=274.00686645508},
MethResell = {x=-63.592178344727, y=-1224.0709228516, z=27.768648147583},
WeedFarm = {x=1609.125, y=6663.5942382813, z=20.961572647095},
WeedTreatment = {x=91.061386108398, y=3750.0380859375, z=39.77326965332},
WeedResell = {x=-54.249694824219, y=-1443.3666992188, z=31.068626403809},
OpiumFarm = {x=1972.784790039, y=3819.3999023438, z=33.428722381592},
OpiumTreatment = {x=971.86499023438,y=-2157.61328125, z=28.475107192994},
OpiumResell = {x=2331.0881347656,y=2570.2250976562,z=46.681819915772}
}
+3 -1
View File
@@ -4,5 +4,7 @@ INSERT INTO `items` (name, label) VALUES
('coke', 'Coke'),
('coke_pooch', 'Pochon de coke'),
('meth', 'Meth'),
('meth_pooch', 'Pochon de meth')
('meth_pooch', 'Pochon de meth'),
('opium', 'Opium'),
('opium_pooch', 'Pochon de opium')
;
+7
View File
@@ -8,6 +8,9 @@ Locales['br'] = {
['press_sell_meth'] = 'Pressione ~INPUT_CONTEXT~ para vender metanfetamina',
['press_collect_weed'] = 'Pressione ~INPUT_CONTEXT~ para coletar erva',
['press_process_weed'] = 'Pressione ~INPUT_CONTEXT~ para processar erva',
['press_sell_opium'] = 'Pressione ~INPUT_CONTEXT~ para vender ópio',
['press_collect_opium'] = 'Pressione ~INPUT_CONTEXT~ para coletar ópio',
['press_process_opium'] = 'Pressione ~INPUT_CONTEXT~ para processar ópio',
['press_sell_weed'] = 'Pressione ~INPUT_CONTEXT~ para vender erva',
['act_imp_police'] = 'Ação ~r~impossivel~s~, ~b~polícia~s~: ',
['inv_full_coke'] = 'Você não pode mais coletar a Cocaína, seu estoque está ~r~cheio~s~',
@@ -25,5 +28,9 @@ Locales['br'] = {
['not_enough_weed'] = 'Você não tem erva suficiente para ~r~embalar~s~',
['sold_one_weed'] = 'Você vendeu ~g~x1 Trouxinha de erva~s~',
['used_one_weed'] = 'Você usou 1 trouxinha de ~b~erva',
['inv_full_opium'] = 'Você não pode mais coletar ópio, seu inventário está ~r~cheio~s~',
['not_enough_opium'] = 'Você não tem ópio suficiente para ~r~embalar~s~',
['sold_one_opium'] = 'Você vendeu ~g~x1 Trouxinha de ópio~s~',
['used_one_opium'] = 'Você usou 1 trouxinha de ~b~ópio',
}
+7
View File
@@ -9,6 +9,9 @@ Locales['en'] = {
['press_collect_weed'] = 'press ~INPUT_CONTEXT~ to collect weed',
['press_process_weed'] = 'press ~INPUT_CONTEXT~ to process weed',
['press_sell_weed'] = 'press ~INPUT_CONTEXT~ to sell weed',
['press_collect_opium'] = 'press ~INPUT_CONTEXT~ to collect opium',
['press_process_opium'] = 'press ~INPUT_CONTEXT~ to process opium',
['press_sell_opium'] = 'press ~INPUT_CONTEXT~ to sell opium',
['act_imp_police'] = 'action ~r~impossible~s~, ~b~police~s~: ',
['inv_full_coke'] = 'you can no longer collect Cocaine, your inventory is ~r~full~s~',
['pickup_in_prog'] = '~y~Pickup in progress~s~...',
@@ -25,5 +28,9 @@ Locales['en'] = {
['not_enough_weed'] = 'you do not have enough Weed to ~r~pack~s~',
['sold_one_weed'] = 'you\'ve sold ~g~x1 Weed Pouch~s~',
['used_one_weed'] = 'you used 1 pouch of ~b~weed',
['inv_full_opium'] = 'you can no longer collect opium, your inventory is ~r~full~s~',
['not_enough_opium'] = 'you do not have enough opium to ~r~pack~s~',
['sold_one_opium'] = 'you\'ve sold ~g~x1 opium Pouch~s~',
['used_one_opium'] = 'you used 1 pouch of ~b~opium',
}
+7
View File
@@ -9,6 +9,9 @@ Locales['fr'] = {
['press_collect_weed'] = 'appuyez sur ~INPUT_CONTEXT~ pour récolter la weed',
['press_process_weed'] = 'appuyez sur ~INPUT_CONTEXT~ pour traiter la weed',
['press_sell_weed'] = 'appuyez sur ~INPUT_CONTEXT~ pour vendre la weed',
['press_collect_opium'] = "appuyez sur ~INPUT_CONTEXT~ pour récolter l'opium",
['press_process_opium'] = "appuyez sur ~INPUT_CONTEXT~ pour traiter l'opium",
['press_sell_opium'] = "appuyez sur ~INPUT_CONTEXT~ pour vendre l'opium",
['act_imp_police'] = 'action ~r~impossible~s~, ~b~policiers~s~: ',
['inv_full_coke'] = 'vous ne pouvez plus ramasser de Cocaine, votre inventaire est ~r~plein~s~',
['pickup_in_prog'] = '~y~Ramassage en cours~s~...',
@@ -25,5 +28,9 @@ Locales['fr'] = {
['not_enough_weed'] = 'vous n\'avez pas assez de weed à ~r~conditionner~s~',
['sold_one_weed'] = 'vous avez vendu ~g~x1 Pochon de weed~s~',
['used_one_weed'] = 'Vous avez utilisé 1 Pochon de ~b~weed',
['inv_full_opium'] = 'vous ne pouvez plus ramasser de weed, votre inventaire est ~r~plein~s~',
['not_enough_opium'] = 'vous n\'avez pas assez de opium à ~r~conditionner~s~',
['sold_one_opium'] = 'vous avez vendu ~g~x1 Pochon de opium~s~',
['used_one_opium'] = 'Vous avez utilisé 1 Pochon de ~b~opium',
}
+192 -11
View File
@@ -1,14 +1,17 @@
ESX = nil
local CopsConnected = 0
local PlayersHarvestingCoke = {}
local PlayersTransformingCoke = {}
local PlayersSellingCoke = {}
local PlayersHarvestingMeth = {}
local PlayersTransformingMeth = {}
local PlayersSellingMeth = {}
local PlayersHarvestingWeed = {}
local PlayersTransformingWeed = {}
local PlayersSellingWeed = {}
ESX = nil
local CopsConnected = 0
local PlayersHarvestingCoke = {}
local PlayersTransformingCoke = {}
local PlayersSellingCoke = {}
local PlayersHarvestingMeth = {}
local PlayersTransformingMeth = {}
local PlayersSellingMeth = {}
local PlayersHarvestingWeed = {}
local PlayersTransformingWeed = {}
local PlayersSellingWeed = {}
local PlayersHarvestingOpium = {}
local PlayersTransformingOpium = {}
local PlayersSellingOpium = {}
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
@@ -31,6 +34,7 @@ end
CountCops()
--coke
local function HarvestCoke(source)
if CopsConnected < Config.RequiredCopsCoke then
@@ -200,6 +204,7 @@ AddEventHandler('esx_drugs:stopSellCoke', function()
end)
--meth
local function HarvestMeth(source)
if CopsConnected < Config.RequiredCopsMeth then
@@ -372,6 +377,7 @@ AddEventHandler('esx_drugs:stopSellMeth', function()
end)
--weed
local function HarvestWeed(source)
if CopsConnected < Config.RequiredCopsWeed then
@@ -538,6 +544,179 @@ AddEventHandler('esx_drugs:stopSellWeed', function()
end)
--opium
local function HarvestOpium(source)
if CopsConnected < Config.RequiredCopsOpium then
TriggerClientEvent('esx:showNotification', source, _U('act_imp_police') .. CopsConnected .. '/' .. Config.RequiredCopsOpium)
return
end
SetTimeout(5000, function()
if PlayersHarvestingOpium[source] == true then
local xPlayer = ESX.GetPlayerFromId(source)
local opium = xPlayer.getInventoryItem('opium')
if opium.limit ~= -1 and opium.count >= opium.limit then
TriggerClientEvent('esx:showNotification', source, _U('inv_full_opium'))
else
xPlayer.addInventoryItem('opium', 1)
HarvestOpium(source)
end
end
end)
end
RegisterServerEvent('esx_drugs:startHarvestOpium')
AddEventHandler('esx_drugs:startHarvestOpium', function()
local _source = source
PlayersHarvestingOpium[_source] = true
TriggerClientEvent('esx:showNotification', _source, _U('pickup_in_prog'))
HarvestOpium(_source)
end)
RegisterServerEvent('esx_drugs:stopHarvestOpium')
AddEventHandler('esx_drugs:stopHarvestOpium', function()
local _source = source
PlayersHarvestingOpium[_source] = false
end)
local function TransformOpium(source)
if CopsConnected < Config.RequiredCopsOpium then
TriggerClientEvent('esx:showNotification', source, _U('act_imp_police') .. CopsConnected .. '/' .. Config.RequiredCopsOpium)
return
end
SetTimeout(10000, function()
if PlayersTransformingOpium[source] == true then
local xPlayer = ESX.GetPlayerFromId(source)
local opiumQuantity = xPlayer.getInventoryItem('opium').count
local poochQuantity = xPlayer.getInventoryItem('opium_pooch').count
if poochQuantity > 35 then
TriggerClientEvent('esx:showNotification', source, _U('too_many_pouches'))
elseif opiumQuantity < 5 then
TriggerClientEvent('esx:showNotification', source, _U('not_enough_opium'))
else
xPlayer.removeInventoryItem('opium', 5)
xPlayer.addInventoryItem('opium_pooch', 1)
TransformOpium(source)
end
end
end)
end
RegisterServerEvent('esx_drugs:startTransformOpium')
AddEventHandler('esx_drugs:startTransformOpium', function()
local _source = source
PlayersTransformingOpium[_source] = true
TriggerClientEvent('esx:showNotification', _source, _U('packing_in_prog'))
TransformOpium(_source)
end)
RegisterServerEvent('esx_drugs:stopTransformOpium')
AddEventHandler('esx_drugs:stopTransformOpium', function()
local _source = source
PlayersTransformingOpium[_source] = false
end)
local function SellOpium(source)
if CopsConnected < Config.RequiredCopsOpium then
TriggerClientEvent('esx:showNotification', source, _U('act_imp_police') .. CopsConnected .. '/' .. Config.RequiredCopsOpium)
return
end
SetTimeout(7500, function()
if PlayersSellingOpium[source] == true then
local xPlayer = ESX.GetPlayerFromId(source)
local poochQuantity = xPlayer.getInventoryItem('opium_pooch').count
if poochQuantity == 0 then
TriggerClientEvent('esx:showNotification', source, _U('no_pouches_sale'))
else
xPlayer.removeInventoryItem('opium_pooch', 1)
if CopsConnected == 0 then
xPlayer.addAccountMoney('black_money', 300)
TriggerClientEvent('esx:showNotification', source, _U('sold_one_opium'))
elseif CopsConnected == 1 then
xPlayer.addAccountMoney('black_money', 500)
TriggerClientEvent('esx:showNotification', source, _U('sold_one_opium'))
elseif CopsConnected == 2 then
xPlayer.addAccountMoney('black_money', 700)
TriggerClientEvent('esx:showNotification', source, _U('sold_one_opium'))
elseif CopsConnected == 3 then
xPlayer.addAccountMoney('black_money', 800)
TriggerClientEvent('esx:showNotification', source, _U('sold_one_opium'))
elseif CopsConnected == 4 then
xPlayer.addAccountMoney('black_money', 900)
TriggerClientEvent('esx:showNotification', source, _U('sold_one_opium'))
elseif CopsConnected >= 5 then
xPlayer.addAccountMoney('black_money', 1000)
TriggerClientEvent('esx:showNotification', source, _U('sold_one_opium'))
end
SellOpium(source)
end
end
end)
end
RegisterServerEvent('esx_drugs:startSellOpium')
AddEventHandler('esx_drugs:startSellOpium', function()
local _source = source
PlayersSellingOpium[_source] = true
TriggerClientEvent('esx:showNotification', _source, _U('sale_in_prog'))
SellOpium(_source)
end)
RegisterServerEvent('esx_drugs:stopSellOpium')
AddEventHandler('esx_drugs:stopSellOpium', function()
local _source = source
PlayersSellingOpium[_source] = false
end)
-- RETURN INVENTORY TO CLIENT
RegisterServerEvent('esx_drugs:GetUserInventory')
AddEventHandler('esx_drugs:GetUserInventory', function(currentZone)
@@ -551,6 +730,8 @@ AddEventHandler('esx_drugs:GetUserInventory', function(currentZone)
xPlayer.getInventoryItem('meth_pooch').count,
xPlayer.getInventoryItem('weed').count,
xPlayer.getInventoryItem('weed_pooch').count,
xPlayer.getInventoryItem('opium').count,
xPlayer.getInventoryItem('opium_pooch').count,
xPlayer.job.name,
currentZone
)