mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-30 09:48:52 +00:00
- Pickups now require you to press E once nearby to pick up - Fixed pickup objects sometimes not showing up #420 - Added animation to picking up and throwing items - Added message when inventory cannot accept picking up item
This commit is contained in:
+10
-3
@@ -1199,19 +1199,26 @@ ESX.ShowInventory = function()
|
||||
end
|
||||
elseif data1.current.action == 'remove' then
|
||||
if IsPedOnFoot(playerPed) then
|
||||
local dict, anim = 'weapons@first_person@aim_rng@generic@projectile@sticky_bomb@', 'plant_floor'
|
||||
ESX.Streaming.RequestAnimDict(dict)
|
||||
|
||||
if type == 'item_weapon' then
|
||||
TriggerServerEvent('esx:removeInventoryItem', type, item)
|
||||
menu1.close()
|
||||
else -- type: item_standard
|
||||
TaskPlayAnim(playerPed, dict, anim, 8.0, 1.0, 1000, 16, 0.0, false, false, false)
|
||||
Citizen.Wait(1000)
|
||||
TriggerServerEvent('esx:removeInventoryItem', type, item)
|
||||
else
|
||||
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'inventory_item_count_remove', {
|
||||
title = _U('amount')
|
||||
}, function(data2, menu2)
|
||||
local quantity = tonumber(data2.value)
|
||||
|
||||
if quantity then
|
||||
TriggerServerEvent('esx:removeInventoryItem', type, item, quantity)
|
||||
menu2.close()
|
||||
menu1.close()
|
||||
TaskPlayAnim(playerPed, dict, anim, 8.0, 1.0, 1000, 16, 0.0, false, false, false)
|
||||
Citizen.Wait(1000)
|
||||
TriggerServerEvent('esx:removeInventoryItem', type, item, quantity)
|
||||
else
|
||||
ESX.ShowNotification(_U('amount_invalid'))
|
||||
end
|
||||
|
||||
+38
-25
@@ -51,13 +51,14 @@ AddEventHandler('esx:createMissingPickups', function(missingPickups)
|
||||
ESX.Game.SpawnLocalObject('prop_money_bag_01', v.coords, function(obj)
|
||||
SetEntityAsMissionEntity(obj, true, false)
|
||||
PlaceObjectOnGroundProperly(obj)
|
||||
FreezeEntityPosition(obj, true)
|
||||
|
||||
pickups[pickupId] = {
|
||||
id = pickupId,
|
||||
obj = obj,
|
||||
label = v.label,
|
||||
inRange = false,
|
||||
coords = v.coords
|
||||
coords = vector3(v.coords.x, v.coords.y, v.coords.z)
|
||||
}
|
||||
end)
|
||||
end
|
||||
@@ -273,7 +274,7 @@ AddEventHandler('esx:spawnVehicle', function(vehicle)
|
||||
if IsModelInCdimage(model) then
|
||||
local playerPed = PlayerPedId()
|
||||
local coords = GetEntityCoords(playerPed)
|
||||
|
||||
|
||||
ESX.Game.SpawnVehicle(model, coords, 90.0, function(vehicle)
|
||||
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
|
||||
end)
|
||||
@@ -287,22 +288,19 @@ AddEventHandler('esx:pickup', function(id, label, player)
|
||||
local ped = GetPlayerPed(GetPlayerFromServerId(player))
|
||||
local coords = GetEntityCoords(ped)
|
||||
local forward = GetEntityForwardVector(ped)
|
||||
local x, y, z = table.unpack(coords + forward * -2.0)
|
||||
coords = (coords + forward * 2.0)
|
||||
|
||||
ESX.Game.SpawnLocalObject('prop_money_bag_01', {
|
||||
x = x,
|
||||
y = y,
|
||||
z = z - 2.0,
|
||||
}, function(obj)
|
||||
ESX.Game.SpawnLocalObject('prop_money_bag_01', coords, function(obj)
|
||||
SetEntityAsMissionEntity(obj, true, false)
|
||||
PlaceObjectOnGroundProperly(obj)
|
||||
FreezeEntityPosition(obj, true)
|
||||
|
||||
pickups[id] = {
|
||||
id = id,
|
||||
obj = obj,
|
||||
label = label,
|
||||
inRange = false,
|
||||
coords = {x = x, y = y, z = z}
|
||||
coords = coords
|
||||
}
|
||||
end)
|
||||
end)
|
||||
@@ -462,32 +460,47 @@ end
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(0)
|
||||
|
||||
local playerPed = PlayerPedId()
|
||||
local coords = GetEntityCoords(playerPed)
|
||||
|
||||
-- if there's no nearby pickups we can wait a bit to save performance
|
||||
if next(pickups) == nil then
|
||||
Citizen.Wait(500)
|
||||
end
|
||||
local playerCoords, letSleep = GetEntityCoords(playerPed), true
|
||||
local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
|
||||
|
||||
for k,v in pairs(pickups) do
|
||||
local distance = GetDistanceBetweenCoords(coords, v.coords.x, v.coords.y, v.coords.z, true)
|
||||
local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
|
||||
local distance = #(playerCoords - v.coords)
|
||||
|
||||
if distance < 5 then
|
||||
local label = v.label
|
||||
letSleep = false
|
||||
|
||||
if distance < 1 then
|
||||
if IsControlJustReleased(0, 38) then
|
||||
if IsPedOnFoot(playerPed) and (closestDistance == -1 or closestDistance > 3) and not v.inRange then
|
||||
v.inRange = true
|
||||
|
||||
local dict, anim = 'weapons@first_person@aim_rng@generic@projectile@sticky_bomb@', 'plant_floor'
|
||||
ESX.Streaming.RequestAnimDict(dict)
|
||||
TaskPlayAnim(playerPed, dict, anim, 8.0, 1.0, 1000, 16, 0.0, false, false, false)
|
||||
Citizen.Wait(1000)
|
||||
|
||||
TriggerServerEvent('esx:onPickup', v.id)
|
||||
PlaySoundFrontend(-1, 'PICK_UP', 'HUD_FRONTEND_DEFAULT_SOUNDSET', false)
|
||||
end
|
||||
end
|
||||
|
||||
label = ('%s~n~%s'):format(label, _U('threw_pickup_prompt'))
|
||||
end
|
||||
|
||||
if distance <= 5.0 then
|
||||
ESX.Game.Utils.DrawText3D({
|
||||
x = v.coords.x,
|
||||
y = v.coords.y,
|
||||
z = v.coords.z + 0.25
|
||||
}, v.label)
|
||||
}, label, 1.2, 1)
|
||||
elseif v.inRange then
|
||||
v.inRange = false
|
||||
end
|
||||
end
|
||||
|
||||
if (closestDistance == -1 or closestDistance > 3) and distance <= 1.0 and not v.inRange and IsPedOnFoot(playerPed) then
|
||||
TriggerServerEvent('esx:onPickup', v.id)
|
||||
PlaySoundFrontend(-1, 'PICK_UP', 'HUD_FRONTEND_DEFAULT_SOUNDSET', false)
|
||||
v.inRange = true
|
||||
end
|
||||
if letSleep then
|
||||
Citizen.Wait(500)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
+4
-2
@@ -33,10 +33,12 @@ Locales['br'] = {
|
||||
['imp_invalid_quantity'] = 'acao impossivel, quantidade invalida',
|
||||
['imp_invalid_amount'] = 'acao impossivel, valor invalido',
|
||||
['threw_standard'] = 'you threw ~y~%sx~s~ ~b~%s~s~',
|
||||
['threw_money'] = 'you threw ~r~$%s~s~ ~b~cash~s~',
|
||||
['threw_account'] = 'you threw ~r~$%s~s~ ~b~%s~s~',
|
||||
['threw_money'] = 'you threw ~g~$%s~s~ ~b~cash~s~',
|
||||
['threw_account'] = 'you threw ~g~$%s~s~ ~b~%s~s~',
|
||||
['threw_weapon'] = 'you threw ~b~%s~s~',
|
||||
['threw_weapon_ammo'] = 'you threw ~b~%s~s~ with ~o~%sx~s~ bullets',
|
||||
['threw_cannot_pickup'] = 'you cannot pickup that because your inventory is full!',
|
||||
['threw_pickup_prompt'] = 'press ~y~E~s~ to pickup',
|
||||
-- Salary related
|
||||
['received_salary'] = 'voce recebeu seu salario: ~g~$%s~s~ ',
|
||||
['received_help'] = 'voce recebeu seu cheque de bem-estar: ~g~$%s~s~ ',
|
||||
|
||||
+4
-2
@@ -33,10 +33,12 @@ Locales['cs'] = {
|
||||
['imp_invalid_quantity'] = 'akce není možná, neplatný počet',
|
||||
['imp_invalid_amount'] = 'akce není možná, neplatné množství',
|
||||
['threw_standard'] = 'you threw ~y~%sx~s~ ~b~%s~s~',
|
||||
['threw_money'] = 'you threw ~r~$%s~s~ ~b~cash~s~',
|
||||
['threw_account'] = 'you threw ~r~$%s~s~ ~b~%s~s~',
|
||||
['threw_money'] = 'you threw ~g~$%s~s~ ~b~cash~s~',
|
||||
['threw_account'] = 'you threw ~g~$%s~s~ ~b~%s~s~',
|
||||
['threw_weapon'] = 'you threw ~b~%s~s~',
|
||||
['threw_weapon_ammo'] = 'you threw ~b~%s~s~ with ~o~%sx~s~ bullets',
|
||||
['threw_cannot_pickup'] = 'you cannot pickup that because your inventory is full!',
|
||||
['threw_pickup_prompt'] = 'press ~y~E~s~ to pickup',
|
||||
-- Salary related
|
||||
['received_salary'] = 'obdrželi jste výplatu: ~g~$%s~s~',
|
||||
['received_help'] = 'obdrželi jste sociální dávku: ~g~$%s~s~',
|
||||
|
||||
+4
-2
@@ -33,10 +33,12 @@ Locales['de'] = {
|
||||
['imp_invalid_quantity'] = 'aktion nicht möglich, ungültige Anzahl',
|
||||
['imp_invalid_amount'] = 'aktion nicht möglich, ungültiger Betrag',
|
||||
['threw_standard'] = 'you threw ~y~%sx~s~ ~b~%s~s~',
|
||||
['threw_money'] = 'you threw ~r~$%s~s~ ~b~cash~s~',
|
||||
['threw_account'] = 'you threw ~r~$%s~s~ ~b~%s~s~',
|
||||
['threw_money'] = 'you threw ~g~$%s~s~ ~b~cash~s~',
|
||||
['threw_account'] = 'you threw ~g~$%s~s~ ~b~%s~s~',
|
||||
['threw_weapon'] = 'you threw ~b~%s~s~',
|
||||
['threw_weapon_ammo'] = 'you threw ~b~%s~s~ with ~o~%sx~s~ bullets',
|
||||
['threw_cannot_pickup'] = 'you cannot pickup that because your inventory is full!',
|
||||
['threw_pickup_prompt'] = 'press ~y~E~s~ to pickup',
|
||||
-- Salary related
|
||||
['received_salary'] = 'du hast dein Gehalt erhalten: ~g~$%s~s~',
|
||||
['received_help'] = 'du hast deine Sozialhilfe erhalten: ~g~$%s~s~',
|
||||
|
||||
+4
-2
@@ -33,10 +33,12 @@ Locales['en'] = {
|
||||
['imp_invalid_quantity'] = 'action impossible, invalid quantity',
|
||||
['imp_invalid_amount'] = 'action impossible, invalid amount',
|
||||
['threw_standard'] = 'you threw ~y~%sx~s~ ~b~%s~s~',
|
||||
['threw_money'] = 'you threw ~r~$%s~s~ ~b~cash~s~',
|
||||
['threw_account'] = 'you threw ~r~$%s~s~ ~b~%s~s~',
|
||||
['threw_money'] = 'you threw ~g~$%s~s~ ~b~cash~s~',
|
||||
['threw_account'] = 'you threw ~g~$%s~s~ ~b~%s~s~',
|
||||
['threw_weapon'] = 'you threw ~b~%s~s~',
|
||||
['threw_weapon_ammo'] = 'you threw ~b~%s~s~ with ~o~%sx~s~ bullets',
|
||||
['threw_cannot_pickup'] = 'you cannot pickup that because your inventory is full!',
|
||||
['threw_pickup_prompt'] = 'press ~y~E~s~ to pickup',
|
||||
-- Salary related
|
||||
['received_salary'] = 'you received your salary: ~g~$%s~s~',
|
||||
['received_help'] = 'you recieved your welfare check: ~g~$%s~s~',
|
||||
|
||||
+4
-2
@@ -33,10 +33,12 @@ Locales['fi'] = {
|
||||
['imp_invalid_quantity'] = 'toiminto mahdoton, virheellinen määrä',
|
||||
['imp_invalid_amount'] = 'toiminto mahdoton, virhellinen summa',
|
||||
['threw_standard'] = 'you threw ~y~%sx~s~ ~b~%s~s~',
|
||||
['threw_money'] = 'you threw ~r~$%s~s~ ~b~cash~s~',
|
||||
['threw_account'] = 'you threw ~r~$%s~s~ ~b~%s~s~',
|
||||
['threw_money'] = 'you threw ~g~$%s~s~ ~b~cash~s~',
|
||||
['threw_account'] = 'you threw ~g~$%s~s~ ~b~%s~s~',
|
||||
['threw_weapon'] = 'you threw ~y~1x~s~ ~b~%s~s~',
|
||||
['threw_weapon_ammo'] = 'you threw ~y~1x~s~ ~b~%s~s~ with ~o~%sx~s~ bullets',
|
||||
['threw_cannot_pickup'] = 'you cannot pickup that because your inventory is full!',
|
||||
['threw_pickup_prompt'] = 'press ~y~E~s~ to pickup',
|
||||
-- Salary related
|
||||
['received_salary'] = 'sinä vastaanotit palkkaa: ~g~$%s~s~',
|
||||
['received_help'] = 'sinä vastaanotit valtion tukea: ~g~$%s~s~',
|
||||
|
||||
+4
-2
@@ -33,10 +33,12 @@ Locales['fr'] = {
|
||||
['imp_invalid_quantity'] = 'action impossible, ~r~quantité invalide',
|
||||
['imp_invalid_amount'] = 'action impossible, ~r~montant invalide',
|
||||
['threw_standard'] = 'vous avez jeté ~y~%sx~s~ ~b~%s~s~',
|
||||
['threw_money'] = 'vous avez jeté ~r~$%s~s~ ~b~cash~s~',
|
||||
['threw_account'] = 'vous avez jeté ~r~$%s~s~ ~b~%s~s~',
|
||||
['threw_money'] = 'vous avez jeté ~g~$%s~s~ ~b~cash~s~',
|
||||
['threw_account'] = 'vous avez jeté ~g~$%s~s~ ~b~%s~s~',
|
||||
['threw_weapon'] = 'vous avez jeté ~y~1x~s~ ~b~%s~s~',
|
||||
['threw_weapon_ammo'] = 'vous avez jeté ~y~1x~s~ ~b~%s~s~ avec ~o~%sx~s~ balles',
|
||||
['threw_cannot_pickup'] = 'you cannot pickup that because your inventory is full!',
|
||||
['threw_pickup_prompt'] = 'press ~y~E~s~ to pickup',
|
||||
-- Salary related
|
||||
['received_salary'] = 'vous avez reçu votre salaire: ~g~$%s~s~',
|
||||
['received_help'] = 'vous avez reçu une aide de l\'état: ~g~$%s~s~',
|
||||
|
||||
+4
-3
@@ -33,11 +33,12 @@ Locales['pl'] = {
|
||||
['imp_invalid_quantity'] = 'akcja jest niemożliwa, nieprawidłowa ilość',
|
||||
['imp_invalid_amount'] = 'akcja jest niemożliwa, nieprawidłowa kwota',
|
||||
['threw_standard'] = 'wyrzuciłeś/aś ~y~%sx~s~ ~b~%s~s~',
|
||||
['threw_money'] = 'wyrzuciłeś/aś ~r~$%s~s~ ~b~gotówki~s~',
|
||||
['threw_account'] = 'wyrzuciłeś/aś ~r~$%s~s~ ~b~%s~s~',
|
||||
['threw_money'] = 'wyrzuciłeś/aś ~g~$%s~s~ ~b~gotówki~s~',
|
||||
['threw_account'] = 'wyrzuciłeś/aś ~g~$%s~s~ ~b~%s~s~',
|
||||
['threw_weapon'] = 'wyrzuciłeś/aś ~b~%s~s~',
|
||||
['threw_weapon_ammo'] = 'wyrzuciłeś/aś ~b~%s~s~ z ~o~%sx~s~ nabojami',
|
||||
|
||||
['threw_cannot_pickup'] = 'you cannot pickup that because your inventory is full!',
|
||||
['threw_pickup_prompt'] = 'press ~y~E~s~ to pickup',
|
||||
-- Salary related
|
||||
['received_salary'] = 'otrzymałeś wynagrodzenie: ~g~%s$~s~',
|
||||
['received_help'] = 'otrzymałem zapomogę: ~g~$%s~s~',
|
||||
|
||||
+4
-2
@@ -33,10 +33,12 @@ Locales['sv'] = {
|
||||
['imp_invalid_quantity'] = 'åtgärd omöjlig, ogiltig mängd',
|
||||
['imp_invalid_amount'] = 'åtgärd omöjlig, ogiltig belopp',
|
||||
['threw_standard'] = 'du kastade ~y~%sx~s~ ~b~%s~s~',
|
||||
['threw_money'] = 'du kastade ~r~$%s~s~ ~b~kontanter~s~',
|
||||
['threw_account'] = 'du kastade ~r~$%s~s~ ~b~%s~s~',
|
||||
['threw_money'] = 'du kastade ~g~%s SEK~s~ ~b~kontanter~s~',
|
||||
['threw_account'] = 'du kastade ~g~%s SEK~s~ ~b~%s~s~',
|
||||
['threw_weapon'] = 'du kastade ~b~%s~s~',
|
||||
['threw_weapon_ammo'] = 'du kastade ~b~%s~s~ med ~o~%sx~s~ skott',
|
||||
['threw_cannot_pickup'] = 'du kan inte plocka upp det på grund av att det kommer ej få plats i ditt förråd!',
|
||||
['threw_pickup_prompt'] = 'tryck ~y~E~s~ för att plocka upp',
|
||||
-- Salary related
|
||||
['received_salary'] = 'du har mottagit din lön på ~g~%s SEK~s~',
|
||||
['received_help'] = 'du har mottagit bidrag på ~g~%s SEK~s~',
|
||||
|
||||
+18
-14
@@ -419,24 +419,28 @@ end)
|
||||
|
||||
RegisterServerEvent('esx:onPickup')
|
||||
AddEventHandler('esx:onPickup', function(id)
|
||||
local playerId = source
|
||||
local pickup = ESX.Pickups[id]
|
||||
local xPlayer = ESX.GetPlayerFromId(playerId)
|
||||
local pickup, xPlayer, success = ESX.Pickups[id], ESX.GetPlayerFromId(source)
|
||||
|
||||
if pickup.type == 'item_standard' then
|
||||
if xPlayer.canCarryItem(pickup.name, pickup.count) then
|
||||
xPlayer.addInventoryItem(pickup.name, pickup.count)
|
||||
if pickup then
|
||||
if pickup.type == 'item_standard' then
|
||||
if xPlayer.canCarryItem(pickup.name, pickup.count) then
|
||||
xPlayer.addInventoryItem(pickup.name, pickup.count)
|
||||
success = true
|
||||
else
|
||||
xPlayer.showNotification(_U('threw_cannot_pickup'))
|
||||
end
|
||||
elseif pickup.type == 'item_money' then
|
||||
success = true
|
||||
xPlayer.addMoney(pickup.count)
|
||||
elseif pickup.type == 'item_account' then
|
||||
success = true
|
||||
xPlayer.addAccountMoney(pickup.name, pickup.count)
|
||||
end
|
||||
|
||||
if success then
|
||||
ESX.Pickups[id] = nil
|
||||
TriggerClientEvent('esx:removePickup', -1, id)
|
||||
end
|
||||
elseif pickup.type == 'item_money' then
|
||||
ESX.Pickups[id] = nil
|
||||
TriggerClientEvent('esx:removePickup', -1, id)
|
||||
xPlayer.addMoney(pickup.count)
|
||||
elseif pickup.type == 'item_account' then
|
||||
ESX.Pickups[id] = nil
|
||||
TriggerClientEvent('esx:removePickup', -1, id)
|
||||
xPlayer.addAccountMoney(pickup.name, pickup.count)
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user