![[STANDALONE] Pepper Spray main image](https://forum-cfx-re.akamaized.net/optimized/5X/c/d/5/d/cd5d8e5b24b05fa068c39ee88c66ced15cd04c97_2_690x388.jpeg)
Price
UnknownA script by Eviate
Price
UnknownAre you looking to introduce pepper spray to the arsenal of your police department, or add a new unique weapon to your server? Look no further! This script includes a new addon-weapon, which can be used just like any other existing weapon. The script detects whenever you hit another player with the pepper spray, and applies a configurable effect to the player which temporarily paralyses the target.
weapon_pepperspray
is included in the files.The code snippets below are accessible in the encrypted version:
Config = {}
-- If debug mode is enabled, you can use /pepperspray_effect to test out the pepper-spray effect
Config.Debug = false
-- The hash of the pepper-spray weapon
Config.PepperSprayWeaponHash = `weapon_pepperspray`
-- The keybind which on which the script will detect if the player is spraying, (24 = INPUT_ATTACK = LEFT MOUSE BUTTON)
Config.SprayDetectionKey = 24
-- These keys are disabled if the player is sprayed
Config.DisabledKeysWhenSprayed = { 24, 25, 22, 37, 73 } -- Attack, aim, jump, weapon wheel, X (see https://docs.fivem.net/docs/game-references/controls/ if you want to change these)
-- Configure the animation when someone is sprayed
Config.Animation = {
Dict = 'switch@trevor@floyd_crying',
Name = 'console_end_loop_floyd',
}
-- The time in milliseconds the spray-effect will last
Config.SprayEffectTimer = 10000
-- The main and extra timecycle modifier when someone is sprayed
Config.MainTimeCycle = 'drunk'
Config.ExtraTimeCycle = 'rply_vignette'
-- The maximum distance at which someone can get sprayed
Config.MaxmimumSprayDistance = 5.0
-- The maximum angle at which someone can get sprayed w.r.t. the players back, this ensure you cannot spray someone if you are not facing them, setting to zero allows you to also spray people from behind
Config.MaxmimumSprayAngle = 80
-- If you use the skinchanger script, you can add clothes below which make you immune to pepper-spray
-- If you dont the skinchanger script, you will have to edit the function Functions.DoesPedHaveImmuneClothes() in the bridge script before you can use this feature
Config.ImmuneClothes = {
['male'] = {
['helmet_1'] = { 18, 50, 51, 52, 53 },
['glasses_1'] = { 26 },
['mask_1'] = { 9, 10 },
},
['female'] = {
['helmet_1'] = { 18, 50, 51, 52, 53 },
['glasses_1'] = { 26 },
['mask_1'] = { 9, 10 },
}
}
Functions = {}
-- If this function returns true, the player will receive the pepper-spray effect
-- If this function returns false, the player will not receive the pepper-spray effect or the pepper-spray effect will be canceled
Functions.CanPlayerBeSprayed = function()
local ped = PlayerPedId()
local isDead = IsPedDeadOrDying(ped, true)
local isPedInAnyVehicle = IsPedInAnyVehicle(ped, false)
return (not isDead and not isPedInAnyVehicle)
end
-- Check if the ped has clothes which are immune to pepper-spray, like glasses or masks.
Functions.DoesPedHaveImmuneClothes = function()
local immuneClothes = false
-- This code below only works with skinchanger, but you can change it to the clothing script you are using
if (GetResourceState('skinchanger') ~= 'started') then
return immuneClothes
end
local skinReceived = false
while (not skinReceived) do
Wait(0)
TriggerEvent('skinchanger:getSkin', function(skin)
local gender = 'male'
if (skin.sex == 1) then gender = 'female' end
local clothesToCheck = Config.ImmuneClothes[gender]
for clothing, component in pairs(skin) do
if (clothesToCheck[clothing] ~= nil) then
for _, value in ipairs(clothesToCheck[clothing]) do
if (value == component) then
immuneClothes = true
break
end
end
end
end
-- Ensure the function waits for the event handler above to finish
skinReceived = true
end)
end
return immuneClothes
end
Functions.OnPlayerSprayed = function()
-- This function is triggered right before a player gets sprayed, you can execute any additional code you want here
end
local ESX = nil
local QBCore = nil
-- Select the correct framework
CreateThread(function()
if (GetResourceState('es_extended') == 'started') then
ESX = exports['es_extended']:getSharedObject()
elseif (GetResourceState('qb-core') == 'started') then
QBCore = exports['qb-core']:GetCoreObject()
end
end)
Functions = {}
-- This function is executed before a player applies the spray-effect to another player. In this case configured to only work if the player has the police-job
Functions.CanPlayerApplySprayEffect = function(source)
local xPlayer = nil
if (ESX ~= nil) then
xPlayer = ESX.GetPlayerFromId(source)
elseif (QBCore ~= nil) then
Player = QBCore.Functions.GetPlayer(source)
end
-- If neither framework is detected, we will allow the player to apply the spray-effect
if (xPlayer == nil) then
return true
end
if (xPlayer.job.name == 'police') then
return true
else
return false
end
end
Code is accessible | No, but core functions are accessible |
Subscription-based | No |
Lines (approximately) | 331 |
Requirements | None |
Support | Yes |
No approved reviews found for this script yet.