-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: crouch and tackle distance check
* 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
Showing
2 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |