mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-30 17:58:54 +00:00
Add files via upload
This commit is contained in:
+112
-15
@@ -430,7 +430,7 @@ ESX.Game.SpawnLocalVehicle = function(modelName, coords, heading, cb)
|
||||
RequestCollisionAtCoord(coords.x, coords.y, coords.z)
|
||||
|
||||
while not HasCollisionLoadedAroundEntity(vehicle) do
|
||||
RequestCollisionAtCoord(coords.x, coords.y, coords.z)
|
||||
RequestCollisionAtCoord(coords.x, coords.x, coords.x)
|
||||
Citizen.Wait(0)
|
||||
end
|
||||
|
||||
@@ -1057,6 +1057,7 @@ ESX.Game.Utils.DrawText3D = function(coords, text, size)
|
||||
|
||||
end
|
||||
|
||||
|
||||
ESX.ShowInventory = function()
|
||||
|
||||
local playerPed = GetPlayerPed(-1)
|
||||
@@ -1145,6 +1146,10 @@ ESX.ShowInventory = function()
|
||||
table.insert(elements, {label = _U('remove'), action = 'remove', type = data.current.type, value = data.current.value})
|
||||
end
|
||||
|
||||
if data.current.type == "item_weapon" then
|
||||
table.insert(elements, {label = --[[_U('giveammo')]]"Give ammo", action = 'giveammo', type = data.current.type, value = data.current.value})
|
||||
end
|
||||
|
||||
table.insert(elements, {label = _U('return'), action = 'return'})
|
||||
|
||||
ESX.UI.Menu.Open(
|
||||
@@ -1158,29 +1163,54 @@ ESX.ShowInventory = function()
|
||||
|
||||
local item = data.current.value
|
||||
local type = data.current.type
|
||||
local playerPed = GetPlayerPed(-1)
|
||||
|
||||
if data.current.action == 'give' then
|
||||
|
||||
if type == 'item_weapon' then
|
||||
|
||||
local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
|
||||
local closestPed = GetPlayerPed(closestPlayer)
|
||||
local pedammo = GetAmmoInPedWeapon(GetPlayerPed(-1),GetHashKey(item))
|
||||
if not IsPedSittingInAnyVehicle(closestPed) then
|
||||
if closestPlayer ~= -1 and closestDistance < 3.0 then
|
||||
if pedammo > 0 then
|
||||
ESX.UI.Menu.Open(
|
||||
'dialog', GetCurrentResourceName(), 'inventory_item_count_give',
|
||||
{
|
||||
title = _U('amountammo')
|
||||
},
|
||||
function(data2, menu2)
|
||||
local quantity = tonumber(data2.value)
|
||||
if quantity <= pedammo and quantity >= 0 and quantity ~= nil then
|
||||
local ammobefore = GetAmmoInPedWeapon(playerPed, item)
|
||||
TriggerServerEvent('esx:giveInventoryItem', GetPlayerServerId(closestPlayer), type, item, quantity)
|
||||
local finalammo = math.floor(ammobefore - quantity)
|
||||
SetPedAmmo(playerPed, item, finalammo)
|
||||
menu2.close()
|
||||
menu.close()
|
||||
else
|
||||
ESX.ShowNotification(_U("noammo"))
|
||||
end
|
||||
|
||||
if closestPlayer ~= -1 or closestDistance > 3.0 then
|
||||
-- PERSONNE
|
||||
if not IsPedSittingInAnyVehicle(closestPed) then
|
||||
TriggerServerEvent('esx:giveInventoryItem', GetPlayerServerId(closestPlayer), type, item, 1)
|
||||
else
|
||||
ESX.ShowNotification(_U("in_vehicle"))
|
||||
end
|
||||
end,
|
||||
function(data2, menu2)
|
||||
menu2.close()
|
||||
end
|
||||
)
|
||||
else
|
||||
TriggerServerEvent('esx:giveInventoryItem', GetPlayerServerId(closestPlayer), type, item, 0)
|
||||
menu.close()
|
||||
end
|
||||
else
|
||||
ESX.ShowNotification(_U('players_nearby'))
|
||||
end
|
||||
else
|
||||
ESX.ShowNotification(_U('players_nearby'))
|
||||
ESX.ShowNotification(_U("in_vehicle"))
|
||||
end
|
||||
menu.close()
|
||||
|
||||
else
|
||||
|
||||
ESX.UI.Menu.Open(
|
||||
ESX.UI.Menu.Open(
|
||||
'dialog', GetCurrentResourceName(), 'inventory_item_count_give',
|
||||
{
|
||||
title = _U('amount')
|
||||
@@ -1191,7 +1221,7 @@ ESX.ShowInventory = function()
|
||||
local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
|
||||
local closestPed = GetPlayerPed(closestPlayer)
|
||||
if not IsPedSittingInAnyVehicle(closestPed) then
|
||||
if closestPlayer ~= -1 or closestDistance < 3.0 then
|
||||
if closestPlayer ~= -1 and closestDistance < 3.0 then
|
||||
TriggerServerEvent('esx:giveInventoryItem', GetPlayerServerId(closestPlayer), type, item, quantity)
|
||||
else
|
||||
ESX.ShowNotification(_U('players_nearby'))
|
||||
@@ -1214,9 +1244,33 @@ ESX.ShowInventory = function()
|
||||
elseif data.current.action == 'remove' then
|
||||
|
||||
if type == 'item_weapon' then
|
||||
local pedammo = GetAmmoInPedWeapon(GetPlayerPed(-1),GetHashKey(item))
|
||||
ESX.UI.Menu.Open(
|
||||
'dialog', GetCurrentResourceName(), 'inventory_item_count_remove',
|
||||
{
|
||||
title = _U('amount')
|
||||
},
|
||||
function(data2, menu2)
|
||||
|
||||
TriggerServerEvent('esx:removeInventoryItem', type, item, 1)
|
||||
menu.close()
|
||||
local quantity = tonumber(data2.value)
|
||||
|
||||
if quantity <= pedammo and quantity >= 0 and quantity ~= nil then
|
||||
local ammobefore = GetAmmoInPedWeapon(playerPed, item)
|
||||
TriggerServerEvent('esx:removeInventoryItem', type, item, quantity)
|
||||
local finalammo = math.floor(ammobefore - quantity)
|
||||
SetPedAmmo(playerPed, item, finalammo)
|
||||
else
|
||||
ESX.ShowNotification(_U("noammo"))
|
||||
end
|
||||
|
||||
menu2.close()
|
||||
menu.close()
|
||||
|
||||
end,
|
||||
function(data2, menu2)
|
||||
menu2.close()
|
||||
end
|
||||
)
|
||||
|
||||
else
|
||||
|
||||
@@ -1255,6 +1309,49 @@ ESX.ShowInventory = function()
|
||||
ESX.UI.Menu.CloseAll()
|
||||
ESX.ShowInventory()
|
||||
|
||||
elseif data.current.action == 'giveammo' then
|
||||
local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
|
||||
local closestPed = GetPlayerPed(closestPlayer)
|
||||
local pedammo = GetAmmoInPedWeapon(playerPed,GetHashKey(item))
|
||||
if not IsPedSittingInAnyVehicle(closestPed) then
|
||||
if closestPlayer ~= -1 and closestDistance < 3.0 then
|
||||
if pedammo > 0 then
|
||||
ESX.UI.Menu.Open(
|
||||
'dialog', GetCurrentResourceName(), 'inventory_item_count_give',
|
||||
{
|
||||
title = _U('amountammo')
|
||||
},
|
||||
function(data2, menu2)
|
||||
local quantity = tonumber(data2.value)
|
||||
if quantity <= pedammo and quantity >= 0 and quantity ~= nil then
|
||||
local ammobefore2 = GetAmmoInPedWeapon(closestPed, item)
|
||||
local finalammo = math.floor(pedammo - quantity)
|
||||
local finalammo2 = math.floor(ammobefore2 + quantity)
|
||||
SetPedAmmo(playerPed, item, finalammo)
|
||||
Citizen.invokeNative(0x78F0424C34306220,closestPed, item, finalammo2)
|
||||
--SetPedAmmo(closestPed, item, finalammo2)
|
||||
ESX.ShowNotification(_U('yougave') .. "x~r~ " .. quantity .. _U('ammogiven') )
|
||||
menu2.close()
|
||||
menu.close()
|
||||
else
|
||||
ESX.ShowNotification(_U("noammo"))
|
||||
end
|
||||
|
||||
end,
|
||||
function(data2, menu2)
|
||||
menu2.close()
|
||||
end
|
||||
)
|
||||
else
|
||||
TriggerServerEvent('esx:giveInventoryItem', GetPlayerServerId(closestPlayer), type, item, 0)
|
||||
menu.close()
|
||||
end
|
||||
else
|
||||
ESX.ShowNotification(_U('players_nearby'))
|
||||
end
|
||||
else
|
||||
ESX.ShowNotification(_U("in_vehicle"))
|
||||
end
|
||||
end
|
||||
|
||||
end,
|
||||
|
||||
+4
-4
@@ -333,13 +333,13 @@ AddEventHandler('esx:removePickup', function(id)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:pickupWeapon')
|
||||
AddEventHandler('esx:pickupWeapon', function(weaponPickup, weaponName)
|
||||
AddEventHandler('esx:pickupWeapon', function(weaponPickup, weaponName,ammo)
|
||||
|
||||
local ped = GetPlayerPed(-1)
|
||||
local playerPedPos = GetEntityCoords(ped, true)
|
||||
|
||||
CreateAmbientPickup(GetHashKey(weaponPickup), playerPedPos.x + 2.0, playerPedPos.y, playerPedPos.z + 0.5, 0, 1000, 1, false, true)
|
||||
|
||||
print(ammo)
|
||||
CreateAmbientPickup(GetHashKey(weaponPickup), playerPedPos.x + 2.0, playerPedPos.y, playerPedPos.z + 0.5, 0, ammo, 1, false, true)
|
||||
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:spawnPed')
|
||||
|
||||
+5
-5
@@ -1,13 +1,13 @@
|
||||
Config = {}
|
||||
Config.MaxPlayers = 32
|
||||
Config.MaxPlayers = 4
|
||||
Config.Accounts = { 'bank', 'black_money' }
|
||||
Config.AccountLabels = { bank = 'Banque', black_money = 'Argent Sale' } -- French
|
||||
-- Config.AccountLabels = { bank = 'Bank', black_money = 'Dirty Money' } -- English
|
||||
Config.PaycheckInterval = 7 * 60000
|
||||
Config.ShowDotAbovePlayer = false
|
||||
Config.PaycheckInterval = 2 * 60000
|
||||
Config.ShowDotAbovePlayer = true
|
||||
Config.DisableWantedLevel = true
|
||||
Config.RemoveInventoryItemDelay = 5 * 60000
|
||||
Config.RemoveInventoryItemDelay = 1000
|
||||
Config.EnableWeaponPickup = true
|
||||
Config.Locale = 'fr'
|
||||
Config.EnableDebug = false
|
||||
Config.EnableDebug = true
|
||||
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
Locales['de'] = {
|
||||
['amountammo'] = 'anzahl der Munition',
|
||||
['noammo'] = 'Du hast keine Munition !',
|
||||
['withammo'] = '~s~ mit x',
|
||||
['ammogiven'] = '~s~ Kugeln',
|
||||
['giveammo'] = 'Munition geben',
|
||||
['inventory'] = 'Inventar',
|
||||
['use'] = 'benutzen',
|
||||
['give'] = 'geben',
|
||||
|
||||
+6
-1
@@ -5,6 +5,11 @@ Locales['en'] = {
|
||||
['remove'] = 'remove',
|
||||
['return'] = 'return',
|
||||
['amount'] = 'amount',
|
||||
['amountammo'] = 'amount of ammo',
|
||||
['noammo'] = 'You dont have all these ammo !',
|
||||
['withammo'] = '~s~ with x',
|
||||
['ammogiven'] = '~s~ bullets',
|
||||
['giveammo'] = 'Give ammo',
|
||||
['amount_invalid'] = 'invalid amount',
|
||||
['players_nearby'] = 'no players nearby',
|
||||
['ex_inv_lim'] = 'action not possible, exceeding invetory limit for ~b~',
|
||||
@@ -128,4 +133,4 @@ Locales['en'] = {
|
||||
['weapon_flashlight'] = 'flashlight',
|
||||
['gadget_nightvision'] = 'night vision',
|
||||
['gadget_parachute'] = 'parachute',
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,11 @@ Locales['fr'] = {
|
||||
['remove'] = 'jeter',
|
||||
['return'] = 'retour',
|
||||
['amount'] = 'quantité',
|
||||
['amountammo'] = 'nombre de munitions',
|
||||
['noammo'] = 'Tu n\'as pas toutes ces munitions !',
|
||||
['withammo'] = '~s~ avec x ',
|
||||
['ammogiven'] = '~s~ balles',
|
||||
['giveammo'] = 'Donner munitions',
|
||||
['amount_invalid'] = 'montant invalide',
|
||||
['players_nearby'] = 'aucun joueur à proximité',
|
||||
['ex_inv_lim'] = 'action impossible, depassement de la limite d\'inventaire pour ~b~',
|
||||
|
||||
@@ -388,11 +388,10 @@ function CreateExtendedPlayer(player, accounts, inventory, job, loadout, name, l
|
||||
if not foundWeapon then
|
||||
table.insert(self.loadout, {
|
||||
name = weaponName,
|
||||
ammo = ammon,
|
||||
ammo = ammo,
|
||||
label = weaponLabel
|
||||
})
|
||||
end
|
||||
|
||||
TriggerClientEvent('esx:addWeapon', self.source, weaponName, ammo)
|
||||
TriggerClientEvent("esx:addInventoryItem", self.source, {label = weaponLabel}, 1)
|
||||
end
|
||||
|
||||
+5
-5
@@ -309,7 +309,7 @@ end)
|
||||
|
||||
|
||||
RegisterServerEvent('esx:giveInventoryItem')
|
||||
AddEventHandler('esx:giveInventoryItem', function(target, type, itemName, itemCount)
|
||||
AddEventHandler('esx:giveInventoryItem', function(target, type, itemName, itemCount,ammotogive)
|
||||
|
||||
local _source = source
|
||||
|
||||
@@ -366,10 +366,10 @@ AddEventHandler('esx:giveInventoryItem', function(target, type, itemName, itemCo
|
||||
end
|
||||
|
||||
elseif type == 'item_weapon' then
|
||||
|
||||
|
||||
sourceXPlayer.removeWeapon(itemName)
|
||||
targetXPlayer.addWeapon(itemName, itemCount)
|
||||
|
||||
|
||||
local weaponLabel = itemName
|
||||
|
||||
for i=1, #Config.Weapons, 1 do
|
||||
@@ -523,10 +523,10 @@ AddEventHandler('esx:removeInventoryItem', function(type, itemName, itemCount)
|
||||
xPlayer.removeWeapon(itemName)
|
||||
|
||||
if Config.EnableWeaponPickup then
|
||||
TriggerClientEvent('esx:pickupWeapon', _source, weaponPickup, weaponName)
|
||||
TriggerClientEvent('esx:pickupWeapon', _source, weaponPickup, weaponName,itemCount)
|
||||
end
|
||||
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('threw') .. ' x1 ~g~' .. weaponLabel)
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('threw') .. ' x1 ~g~' .. weaponLabel .. _U('withammo').. '~r~' .. itemCount .. _U('ammogiven'))
|
||||
|
||||
end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user