vRP Edit for Police Permission
__resource.lua


dependency "vrp"

client_scripts{ 
  "client.lua"
}

server_scripts{ 
  "@vrp/lib/utils.lua",
  "server.lua"
}

svr

local Tunnel = module("vrp", "lib/Tunnel")
local Proxy = module("vrp", "lib/Proxy")

vRP = Proxy.getInterface("vRP")
vRPclient = Tunnel.getInterface("vRP","vRP_loadout")

AddEventHandler('chatMessage', function(source, name, msg)
	if msg == "/loadout" then
	  local user_id = vRP.getUserId({source})
	  local player = vRP.getUserSource({user_id})
	  if vRP.hasGroup({user_id,"Sheriff"}) then
		CancelEvent();
		TriggerClientEvent('xy:loadout', source);
	  elseif vRP.hasGroup({user_id,"Assistant Sheriff"}) then
		CancelEvent();
		TriggerClientEvent('xy:loadout', source);
	  elseif vRP.hasGroup({user_id,"Captain"}) then
		CancelEvent();
		TriggerClientEvent('xy:loadout', source);
	  elseif vRP.hasGroup({user_id,"Officer"}) then
		CancelEvent();
		TriggerClientEvent('xy:loadout', source);	  
	  elseif vRP.hasGroup({user_id,"Recruit"}) then
		CancelEvent();
		TriggerClientEvent('xy:loadout', source);	
	  elseif vRP.hasGroup({user_id,"SWAT"}) then
		CancelEvent();
		TriggerClientEvent('xy:loadout', source);		
	  elseif vRP.hasGroup({user_id,"Secret Agent"}) then
		CancelEvent();
		TriggerClientEvent('xy:loadout', source);	
	  elseif vRP.hasGroup({user_id,"Lieutenant"}) then
		CancelEvent();
		TriggerClientEvent('xy:loadout', source);
	  elseif vRP.hasGroup({user_id,"Sergeant"}) then
		CancelEvent();
		TriggerClientEvent('xy:loadout', source);		
	  end
	end
end)

cli

-- Name: vGear
-- Version: 1.0
-- Description: Gear up whenever you (re)spawn or press a button (configurable).
-- License: GNU Affero General Public License v3.0
-- Author: Vespura
-- GitHub Repo: https://github.com/TomGrobbe/vGear
--------------------------- LOCAL VARIABLES --------------------------------
local ClearPlayerClothes = true -- Should the player's clothes be cleaned? (remove blood etc.) (default: true)
local HealPlayer = false -- Should the player be healed (max health) (default: true)
local GiveMaxArmor = true -- Should the player receive full body armor? (default: true)
local ReceivedLoadoutMessage = '^1Gear equipped, enjoy!' -- the message the player receives after getting the gear.
-- note for the LoadoutCommand: don't add a / because that's already added in the code!

-- https://wiki.fivem.net/wiki/Weapons
-- {weaponHash, amountOfAmmoToGive} Too much ammo might crash the game, be careful!
local spawnLoadoutList = {  
    {0x8BB05FD7, 1},    -- Flashlight
    {0x678B81B1, 1},    -- Nightstick
    {0x3656C8C1, 1},    -- Stun Gun
    {0x5EF9FEC4, 200},  -- Combat Pistol
    {0x83BF0278, 200},  -- Carbine Rifle
	{0xFDBC8A50, 5}, --smoke gernade
	{0x1D073A89, 200}, -- pimp shotgun
}

-- https://wiki.fivem.net/wiki/Weapon_Components
-- {weaponHashToApplyComponentTo, weaponComponentHash} Any extras/components that need to be attached to certain weapons? Enter them below
local spawnLoadoutExtrasList = {   
    {0x5EF9FEC4, 0x359B7AAE},   -- Combat Pistol Flashlight
    {0x5EF9FEC4, 0xD67B4F2D},   -- Combat Pistol Extended Clip
    {0x83BF0278, 0x7BC4CDDC},   -- Carbine Rifle Flashlight
    {0x83BF0278, 0x91109691},   -- Carbine Rifle Extended Clip
    {0x83BF0278, 0xC164F53},    -- Carbine Rifle Grip
    {0x83BF0278, 0xA0D89C42},   -- Carbine Rifle Scope
	{0x1D073A89, 0x7BC4CDDC},
}

-------------------------- CODE, DON'T TOUCH -------------------------------
RegisterNetEvent('xy:loadout')

AddEventHandler('xy:loadout', function()
    local ped = GetPlayerPed(-1)

    for k, w in pairs(spawnLoadoutList) do
        GiveWeaponToPed(GetPlayerPed(-1), w[1], w[2], false, false)
    end

    for k, c in pairs(spawnLoadoutExtrasList) do
        GiveWeaponComponentToPed(ped, c[1], c[2])
    end

    if ClearPlayerClothes then
        ClearPedBloodDamage(ped)
    end

    if GiveMaxArmour then
        SetPedArmour(ped, 100)
    end

    if HealPlayer then
        SetEntityHealth(ped, 200)
    end

    TriggerEvent('chatMessage', '', {255, 255, 255}, ReceivedLoadoutMessage)
end)
----------------------------------------------------------------------------

works for my vrp so far…

1 Like