Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 30 additions & 14 deletions modules/weapon/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,28 +92,44 @@ CreateThread(function()
while true do
local wait = 1000
local ped = PlayerPedId()
if not IsPlayerDead(ped) and not IsPedInAnyVehicle(ped, true) then
for k,v in pairs(ThrownWeapons) do
if NetworkDoesNetworkIdExist(v.net_id) then
if not IsPlayerDead(ped) and not IsPedInAnyVehicle(ped, true) then
for k, v in pairs(ThrownWeapons) do
if NetworkDoesNetworkIdExist(v.net_id) then
local entity = NetToObj(v.net_id)
local coords = GetEntityCoords(entity)
local dist = #(GetEntityCoords(ped) - coords)
if dist < 5.0 then
if dist < 5.0 then
wait = 0
if dist < 1.25 and not ShowInteractText(_L("pickup_weapon")) and IsControlJustPressed(1, 51) then
ClearPedTasksImmediately(ped)
FreezeEntityPosition(ped, true)
PlayAnim(ped, "pickup_object", "pickup_low", -8.0, 8.0, -1, 49, 1.0)
Wait(800)
TriggerServerEvent("pickle_weaponthrowing:pickupWeapon", k)
Wait(800)
ClearPedTasks(ped)
FreezeEntityPosition(ped, false)
if dist < 1.25 then
HelpNotify(_L("pickup_weapon"), HelpNotifyType, coords)
local keybind = string.upper(Config.ThrowKeybind) -- Робимо ключ чутливим до регістру
local controlIndex = GetKeyIndex(keybind) -- Отримуємо відповідний індекс для клавіші
if controlIndex and IsControlJustPressed(1, controlIndex) then
ClearPedTasksImmediately(ped)
FreezeEntityPosition(ped, true)
PlayAnim(ped, "pickup_object", "pickup_low", -8.0, 8.0, -1, 49, 1.0)
Wait(800)
TriggerServerEvent("pickle_weaponthrowing:pickupWeapon", k)
Wait(800)
ClearPedTasks(ped)
FreezeEntityPosition(ped, false)
end
end
end
end
end
end
end
Wait(wait)
end
end)

-- Функція для перетворення клавіші в індекс
function GetKeyIndex(key)
local keys = {
["E"] = 51,
["F"] = 23,
["G"] = 47,
-- Додайте інші ключі за потреби
}
return keys[key] or nil
end