Skip to content

Commit

Permalink
feat: crouch and tackle distance check
Browse files Browse the repository at this point in the history
* Tackle Distance Check

* Wrong target lol

* Add crouch

I have used K as C and LCTRL already do the half crouch. This is a full crouch.

* Update client.lua
  • Loading branch information
Jamie9192 authored Jul 19, 2024
1 parent 25fbd12 commit 4e92f3d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
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)

0 comments on commit 4e92f3d

Please sign in to comment.