Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tackle Distance Check #115

Merged
merged 4 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
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
25 changes: 25 additions & 0 deletions qbx_crouch/client.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
AddStateBagChangeHandler('crouch', ('player:%s'):format(cache.serverId), function(_, _, value, _, replicated)
if replicated then return end
lib.requestAnimSet('move_Ped_crouched')
if not value then
ResetPedMovementClipset(cache.ped, 1.0)
ResetPedWeaponMovementClipset(cache.ped)
ResetPedStrafeClipset(cache.ped)
SetPedStealthMovement(cache.ped, false, 'DEFAULT_ACTION')
else
SetPedMovementClipset(cache.ped, 'move_Ped_crouched', 1.0)
SetPedStrafeClipset(cache.ped, 'move_Ped_crouched_strafing')
end
RemoveAnimSet('move_Ped_crouched')
end)

lib.addKeybind({
name = 'crouch',
description = 'Crouch',
defaultKey = 'K',
onReleased = function(self)
if cache.vehicle then return end
LocalPlayer.state:set("crouch", not LocalPlayer.state.crouch, false)
end
})

11 changes: 9 additions & 2 deletions qbx_tackle/server.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
RegisterNetEvent('tackle:server:TacklePlayer', function(source)
TriggerClientEvent('tackle:client:GetTackled', source)
RegisterNetEvent('tackle:server:TacklePlayer', function(target)
local src = source

local srcCoords = GetEntityCoords(GetPlayerPed(src))
local targetCoords = GetEntityCoords(GetPlayerPed(target))

if #(srcCoords - targetCoords) > 2.0 then return end

TriggerClientEvent('tackle:client:GetTackled', target)
end)