From 40033d48b5e157edc9d00c9f0f5b8a987c1885e1 Mon Sep 17 00:00:00 2001 From: KingMcDonalds Date: Sun, 30 Apr 2023 16:05:33 -0700 Subject: [PATCH] Add new scripts called holsters --- resources/holster/__resource.lua | 1 + resources/holster/client.lua | 95 ++++++++++++++++++++++++++++++++ server.cfg | 1 + 3 files changed, 97 insertions(+) create mode 100644 resources/holster/__resource.lua create mode 100644 resources/holster/client.lua diff --git a/resources/holster/__resource.lua b/resources/holster/__resource.lua new file mode 100644 index 000000000..dbf7a9455 --- /dev/null +++ b/resources/holster/__resource.lua @@ -0,0 +1 @@ +client_script "client.lua" diff --git a/resources/holster/client.lua b/resources/holster/client.lua new file mode 100644 index 000000000..8b82c69b9 --- /dev/null +++ b/resources/holster/client.lua @@ -0,0 +1,95 @@ +-- Created by Deziel0495 and IllusiveTea -- + +-- NOTICE +-- This script is licensed under "No License". https://choosealicense.com/no-license/ +-- You are allowed to: Download, Use and Edit the Script. +-- You are not allowed to: Copy, re-release, re-distribute it without our written permission. + +--- DO NOT EDIT THIS +local holstered = true + +-- RESTRICTED PEDS -- +-- I've only listed peds that have a remote speaker mic, but any ped listed here will do the animations. +local skins = { + "mp_f_freemode_01", + "mp_m_freemode_01", + "copx2", + "markocop", +} + +-- Add/remove weapon hashes here to be added for holster checks. +local weapons = { + "WEAPON_COMBATPISTOL", + "WEAPON_PISTOL", + "WEAPON_PISTOL_MK2", + "WEAPON_SIG", + "WEAPON_G17", + "WEAPON_GLOCK19X", + "WEAPON_GLOCK19X2", + "WEAPON_M1911A", +} + +-- HOLSTER/UNHOLSTER PISTOL -- + + Citizen.CreateThread(function() + while true do + Citizen.Wait(0) + local ped = PlayerPedId() + if DoesEntityExist( ped ) and not IsEntityDead( ped ) and not IsPedInAnyVehicle(PlayerPedId(), true) and CheckSkin(ped) then + loadAnimDict( "rcmjosh4" ) + loadAnimDict( "weapons@pistol@" ) + if CheckWeapon(ped) then + if holstered then + TaskPlayAnim(ped, "rcmjosh4", "josh_leadout_cop2", 8.0, 2.0, -1, 48, 10, 0, 0, 0 ) + Citizen.Wait(130) + ClearPedTasks(ped) + holstered = false + end + --SetPedComponentVariation(ped, 9, 0, 0, 0) + elseif not CheckWeapon(ped) then + if not holstered then + TaskPlayAnim(ped, "weapons@pistol@", "aim_2_holster", 8.0, 2.0, -1, 48, 10, 0, 0, 0 ) + Citizen.Wait(500) + ClearPedTasks(ped) + holstered = true + end + --SetPedComponentVariation(ped, 9, 1, 0, 0) + end + end + end +end) + +-- DO NOT REMOVE THESE! -- + +function CheckSkin(ped) + for i = 1, #skins do + if GetHashKey(skins[i]) == GetEntityModel(ped) then + return true + end + end + return false +end + +function CheckWeapon(ped) + for i = 1, #weapons do + if GetHashKey(weapons[i]) == GetSelectedPedWeapon(ped) then + return true + end + end + return false +end + +function DisableActions(ped) + DisableControlAction(1, 140, true) + DisableControlAction(1, 141, true) + DisableControlAction(1, 142, true) + DisableControlAction(1, 37, true) -- Disables INPUT_SELECT_WEAPON (TAB) + DisablePlayerFiring(ped, true) -- Disable weapon firing +end + +function loadAnimDict( dict ) + while ( not HasAnimDictLoaded( dict ) ) do + RequestAnimDict( dict ) + Citizen.Wait( 0 ) + end +end diff --git a/server.cfg b/server.cfg index 86e242990..9939a4bc9 100644 --- a/server.cfg +++ b/server.cfg @@ -182,6 +182,7 @@ start AIBackup start cvpiv8 start r_pepperspray start scully_sling +start holster #[-----Discord Perms-----] start Discord-Presence