-
Notifications
You must be signed in to change notification settings - Fork 350
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
Disable handsup when dead, inlaststand or in vehicle. #491
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,35 @@ | ||
local handsUp = false | ||
local animDict = "missminuteman_1ig_2" | ||
local anim = "handsup_base" | ||
local handsup = false | ||
local QBCore = exports['qb-core']:GetCoreObject() | ||
|
||
RegisterCommand(Config.HandsUp.command, function() | ||
local ped = PlayerPedId() | ||
if not HasAnimDictLoaded('missminuteman_1ig_2') then | ||
RequestAnimDict('missminuteman_1ig_2') | ||
while not HasAnimDictLoaded('missminuteman_1ig_2') do | ||
if QBCore.Functions.GetPlayerData().metadata['isdead'] then return end | ||
if IsPedInAnyVehicle(PlayerPedId(), false) then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is redundant and already checked on line 20 |
||
-- Do nothing if the player is in a vehicle | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be removed since hands up in vehicles allows for the ability to roleplay hands up in a traffic stop. |
||
return | ||
end | ||
if not HasAnimDictLoaded(animDict) then | ||
RequestAnimDict(animDict) | ||
while not HasAnimDictLoaded(animDict) do | ||
Wait(10) | ||
end | ||
end | ||
handsUp = not handsUp | ||
local PlayerData = QBCore.Functions.GetPlayerData() | ||
if exports['qb-policejob']:IsHandcuffed() or PlayerData.metadata["isdead"] or PlayerData.metadata["inlaststand"] then | ||
return | ||
end | ||
handsup = not handsup | ||
if exports['qb-policejob']:IsHandcuffed() then return end | ||
if handsUp then | ||
TaskPlayAnim(ped, 'missminuteman_1ig_2', 'handsup_base', 8.0, 8.0, -1, 50, 0, false, false, false) | ||
exports['qb-smallresources']:addDisableControls(Config.HandsUp.controls) | ||
if handsup then | ||
TaskPlayAnim(ped, animDict, anim, 8.0, 8.0, -1, 50, 0, false, false, false) | ||
exports['qb-smallresources']:addDisableControls(Config.Disable.controls) | ||
else | ||
ClearPedTasks(ped) | ||
exports['qb-smallresources']:removeDisableControls(Config.HandsUp.controls) | ||
exports['qb-smallresources']:removeDisableControls(Config.Disable.controls) | ||
end | ||
end, false) | ||
|
||
RegisterKeyMapping(Config.HandsUp.command, 'Hands Up', 'keyboard', Config.HandsUp.keybind) | ||
exports('getHandsup', function() return handsUp end) | ||
exports('getHandsup', function() return handsup end) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handsup
would look better ashandsUp
for the bool variable