mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 16:23:21 +00:00
use new esx carry limit code
This commit is contained in:
+1
-14
@@ -1,15 +1,3 @@
|
|||||||
Keys = {
|
|
||||||
["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
|
|
||||||
["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
|
|
||||||
["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
|
|
||||||
["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
|
|
||||||
["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
|
|
||||||
["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
|
|
||||||
["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
|
|
||||||
["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
|
|
||||||
["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
|
|
||||||
}
|
|
||||||
|
|
||||||
ESX = nil
|
ESX = nil
|
||||||
local menuOpen = false
|
local menuOpen = false
|
||||||
local wasOpen = false
|
local wasOpen = false
|
||||||
@@ -37,7 +25,7 @@ Citizen.CreateThread(function()
|
|||||||
if not menuOpen then
|
if not menuOpen then
|
||||||
ESX.ShowHelpNotification(_U('dealer_prompt'))
|
ESX.ShowHelpNotification(_U('dealer_prompt'))
|
||||||
|
|
||||||
if IsControlJustReleased(0, Keys['E']) then
|
if IsControlJustReleased(0, 38) then
|
||||||
wasOpen = true
|
wasOpen = true
|
||||||
OpenDrugShop()
|
OpenDrugShop()
|
||||||
end
|
end
|
||||||
@@ -163,7 +151,6 @@ end
|
|||||||
|
|
||||||
Citizen.CreateThread(function()
|
Citizen.CreateThread(function()
|
||||||
for k,zone in pairs(Config.CircleZones) do
|
for k,zone in pairs(Config.CircleZones) do
|
||||||
|
|
||||||
CreateBlipCircle(zone.coords, zone.name, zone.radius, zone.color, zone.sprite)
|
CreateBlipCircle(zone.coords, zone.name, zone.radius, zone.color, zone.sprite)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
+5
-16
@@ -2,17 +2,13 @@ local spawnedWeeds = 0
|
|||||||
local weedPlants = {}
|
local weedPlants = {}
|
||||||
local isPickingUp, isProcessing = false, false
|
local isPickingUp, isProcessing = false, false
|
||||||
|
|
||||||
|
|
||||||
Citizen.CreateThread(function()
|
Citizen.CreateThread(function()
|
||||||
while true do
|
while true do
|
||||||
Citizen.Wait(10)
|
Citizen.Wait(500)
|
||||||
local coords = GetEntityCoords(PlayerPedId())
|
local coords = GetEntityCoords(PlayerPedId())
|
||||||
|
|
||||||
if GetDistanceBetweenCoords(coords, Config.CircleZones.WeedField.coords, true) < 50 then
|
if GetDistanceBetweenCoords(coords, Config.CircleZones.WeedField.coords, true) < 50 then
|
||||||
SpawnWeedPlants()
|
SpawnWeedPlants()
|
||||||
Citizen.Wait(500)
|
|
||||||
else
|
|
||||||
Citizen.Wait(500)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@@ -28,8 +24,7 @@ Citizen.CreateThread(function()
|
|||||||
ESX.ShowHelpNotification(_U('weed_processprompt'))
|
ESX.ShowHelpNotification(_U('weed_processprompt'))
|
||||||
end
|
end
|
||||||
|
|
||||||
if IsControlJustReleased(0, Keys['E']) and not isProcessing then
|
if IsControlJustReleased(0, 38) and not isProcessing then
|
||||||
|
|
||||||
if Config.LicenseEnable then
|
if Config.LicenseEnable then
|
||||||
ESX.TriggerServerCallback('esx_license:checkLicense', function(hasProcessingLicense)
|
ESX.TriggerServerCallback('esx_license:checkLicense', function(hasProcessingLicense)
|
||||||
if hasProcessingLicense then
|
if hasProcessingLicense then
|
||||||
@@ -41,7 +36,6 @@ Citizen.CreateThread(function()
|
|||||||
else
|
else
|
||||||
ProcessWeed()
|
ProcessWeed()
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Citizen.Wait(500)
|
Citizen.Wait(500)
|
||||||
@@ -74,6 +68,7 @@ end
|
|||||||
Citizen.CreateThread(function()
|
Citizen.CreateThread(function()
|
||||||
while true do
|
while true do
|
||||||
Citizen.Wait(0)
|
Citizen.Wait(0)
|
||||||
|
|
||||||
local playerPed = PlayerPedId()
|
local playerPed = PlayerPedId()
|
||||||
local coords = GetEntityCoords(playerPed)
|
local coords = GetEntityCoords(playerPed)
|
||||||
local nearbyObject, nearbyID
|
local nearbyObject, nearbyID
|
||||||
@@ -85,16 +80,14 @@ Citizen.CreateThread(function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if nearbyObject and IsPedOnFoot(playerPed) then
|
if nearbyObject and IsPedOnFoot(playerPed) then
|
||||||
|
|
||||||
if not isPickingUp then
|
if not isPickingUp then
|
||||||
ESX.ShowHelpNotification(_U('weed_pickupprompt'))
|
ESX.ShowHelpNotification(_U('weed_pickupprompt'))
|
||||||
end
|
end
|
||||||
|
|
||||||
if IsControlJustReleased(0, Keys['E']) and not isPickingUp then
|
if IsControlJustReleased(0, 38) and not isPickingUp then
|
||||||
isPickingUp = true
|
isPickingUp = true
|
||||||
|
|
||||||
ESX.TriggerServerCallback('esx_drugs:canPickUp', function(canPickUp)
|
ESX.TriggerServerCallback('esx_drugs:canPickUp', function(canPickUp)
|
||||||
|
|
||||||
if canPickUp then
|
if canPickUp then
|
||||||
TaskStartScenarioInPlace(playerPed, 'world_human_gardener_plant', 0, false)
|
TaskStartScenarioInPlace(playerPed, 'world_human_gardener_plant', 0, false)
|
||||||
|
|
||||||
@@ -113,16 +106,12 @@ Citizen.CreateThread(function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
isPickingUp = false
|
isPickingUp = false
|
||||||
|
|
||||||
end, 'cannabis')
|
end, 'cannabis')
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
Citizen.Wait(500)
|
Citizen.Wait(500)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
AddEventHandler('onResourceStop', function(resource)
|
AddEventHandler('onResourceStop', function(resource)
|
||||||
@@ -206,4 +195,4 @@ function GetCoordZ(x, y)
|
|||||||
end
|
end
|
||||||
|
|
||||||
return 43.0
|
return 43.0
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
USE `essentialmode`;
|
USE `essentialmode`;
|
||||||
|
|
||||||
INSERT INTO `items` (`name`, `label`, `limit`, `rare`, `can_remove`) VALUES
|
INSERT INTO `items` (`name`, `label`, `weight`, `rare`, `can_remove`) VALUES
|
||||||
('cannabis', 'Cannabis', 40, 0, 1),
|
('cannabis', 'Cannabis', 3, 0, 1),
|
||||||
('marijuana', 'Marijuana', 14, 0, 1)
|
('marijuana', 'Marijuana', 2, 0, 1)
|
||||||
;
|
;
|
||||||
|
|
||||||
INSERT INTO `licenses` (`type`, `label`) VALUES
|
INSERT INTO `licenses` (`type`, `label`) VALUES
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
USE `essentialmode`;
|
USE `essentialmode`;
|
||||||
|
|
||||||
INSERT INTO `items` (`name`, `label`, `limit`, `rare`, `can_remove`) VALUES
|
INSERT INTO `items` (`name`, `label`, `weight`, `rare`, `can_remove`) VALUES
|
||||||
('cannabis', 'Marijuana húmeda', 40, 0, 1),
|
('cannabis', 'Marijuana húmeda', 3, 0, 1),
|
||||||
('marijuana', 'Marijuana', 14, 0, 1)
|
('marijuana', 'Marijuana', 2, 0, 1)
|
||||||
;
|
;
|
||||||
|
|
||||||
INSERT INTO `licenses` (`type`, `label`) VALUES
|
INSERT INTO `licenses` (`type`, `label`) VALUES
|
||||||
|
|||||||
+22
-30
@@ -15,7 +15,7 @@ AddEventHandler('esx_drugs:sellDrug', function(itemName, amount)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if xItem.count < amount then
|
if xItem.count < amount then
|
||||||
TriggerClientEvent('esx:showNotification', source, _U('dealer_notenough'))
|
xPlayer.showNotification(_U('dealer_notenough'))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -28,26 +28,25 @@ AddEventHandler('esx_drugs:sellDrug', function(itemName, amount)
|
|||||||
end
|
end
|
||||||
|
|
||||||
xPlayer.removeInventoryItem(xItem.name, amount)
|
xPlayer.removeInventoryItem(xItem.name, amount)
|
||||||
|
xPlayer.showNotification(_U('dealer_sold', amount, xItem.label, ESX.Math.GroupDigits(price)))
|
||||||
TriggerClientEvent('esx:showNotification', source, _U('dealer_sold', amount, xItem.label, ESX.Math.GroupDigits(price)))
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
ESX.RegisterServerCallback('esx_drugs:buyLicense', function(source, cb, licenseName)
|
ESX.RegisterServerCallback('esx_drugs:buyLicense', function(source, cb, licenseName)
|
||||||
local xPlayer = ESX.GetPlayerFromId(source)
|
local xPlayer = ESX.GetPlayerFromId(source)
|
||||||
local license = Config.LicensePrices[licenseName]
|
local license = Config.LicensePrices[licenseName]
|
||||||
|
|
||||||
if license == nil then
|
if license then
|
||||||
print(('esx_drugs: %s attempted to buy an invalid license!'):format(xPlayer.identifier))
|
if xPlayer.getMoney() >= license.price then
|
||||||
cb(false)
|
xPlayer.removeMoney(license.price)
|
||||||
end
|
|
||||||
|
TriggerEvent('esx_license:addLicense', source, licenseName, function()
|
||||||
if xPlayer.getMoney() >= license.price then
|
cb(true)
|
||||||
xPlayer.removeMoney(license.price)
|
end)
|
||||||
|
else
|
||||||
TriggerEvent('esx_license:addLicense', source, licenseName, function()
|
cb(false)
|
||||||
cb(true)
|
end
|
||||||
end)
|
|
||||||
else
|
else
|
||||||
|
print(('esx_drugs: %s attempted to buy an invalid license!'):format(xPlayer.identifier))
|
||||||
cb(false)
|
cb(false)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@@ -55,24 +54,17 @@ end)
|
|||||||
RegisterServerEvent('esx_drugs:pickedUpCannabis')
|
RegisterServerEvent('esx_drugs:pickedUpCannabis')
|
||||||
AddEventHandler('esx_drugs:pickedUpCannabis', function()
|
AddEventHandler('esx_drugs:pickedUpCannabis', function()
|
||||||
local xPlayer = ESX.GetPlayerFromId(source)
|
local xPlayer = ESX.GetPlayerFromId(source)
|
||||||
local xItem = xPlayer.getInventoryItem('cannabis')
|
|
||||||
|
|
||||||
if xItem.limit ~= -1 and (xItem.count + 1) > xItem.limit then
|
if xPlayer.canCarryItem('cannabis', 1) then
|
||||||
TriggerClientEvent('esx:showNotification', _source, _U('weed_inventoryfull'))
|
xPlayer.showNotification(_U('weed_inventoryfull'))
|
||||||
else
|
else
|
||||||
xPlayer.addInventoryItem(xItem.name, 1)
|
xPlayer.addInventoryItem('cannabis', 1)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
ESX.RegisterServerCallback('esx_drugs:canPickUp', function(source, cb, item)
|
ESX.RegisterServerCallback('esx_drugs:canPickUp', function(source, cb, item)
|
||||||
local xPlayer = ESX.GetPlayerFromId(source)
|
local xPlayer = ESX.GetPlayerFromId(source)
|
||||||
local xItem = xPlayer.getInventoryItem(item)
|
cb(xPlayer.canCarryItem(item, 1))
|
||||||
|
|
||||||
if xItem.limit ~= -1 and xItem.count >= xItem.limit then
|
|
||||||
cb(false)
|
|
||||||
else
|
|
||||||
cb(true)
|
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterServerEvent('esx_drugs:processCannabis')
|
RegisterServerEvent('esx_drugs:processCannabis')
|
||||||
@@ -82,17 +74,17 @@ AddEventHandler('esx_drugs:processCannabis', function()
|
|||||||
|
|
||||||
playersProcessingCannabis[_source] = ESX.SetTimeout(Config.Delays.WeedProcessing, function()
|
playersProcessingCannabis[_source] = ESX.SetTimeout(Config.Delays.WeedProcessing, function()
|
||||||
local xPlayer = ESX.GetPlayerFromId(_source)
|
local xPlayer = ESX.GetPlayerFromId(_source)
|
||||||
local xCannabis, xMarijuana = xPlayer.getInventoryItem('cannabis'), xPlayer.getInventoryItem('marijuana')
|
local xCannabis = xPlayer.getInventoryItem('cannabis')
|
||||||
|
|
||||||
if xMarijuana.limit ~= -1 and (xMarijuana.count + 1) >= xMarijuana.limit then
|
if not xPlayer.canCarryItem('marijuana', 1) then
|
||||||
TriggerClientEvent('esx:showNotification', _source, _U('weed_processingfull'))
|
xPlayer.showNotification(_U('weed_processingfull'))
|
||||||
elseif xCannabis.count < 3 then
|
elseif xCannabis.count < 3 then
|
||||||
TriggerClientEvent('esx:showNotification', _source, _U('weed_processingenough'))
|
xPlayer.showNotification(_U('weed_processingenough'))
|
||||||
else
|
else
|
||||||
xPlayer.removeInventoryItem('cannabis', 3)
|
xPlayer.removeInventoryItem('cannabis', 3)
|
||||||
xPlayer.addInventoryItem('marijuana', 1)
|
xPlayer.addInventoryItem('marijuana', 1)
|
||||||
|
|
||||||
TriggerClientEvent('esx:showNotification', _source, _U('weed_processed'))
|
xPlayer.showNotification(_U('weed_processed'))
|
||||||
end
|
end
|
||||||
|
|
||||||
playersProcessingCannabis[_source] = nil
|
playersProcessingCannabis[_source] = nil
|
||||||
|
|||||||
Reference in New Issue
Block a user