[Release] vGear v1.2 | Simple gear on (re)spawn/button press

vGear v1.2

Simple gear on (re)spawn/button press

Update 17-12-2018

I will no longer be maintaining/supporting this resource. The GitHub repo has been archived. Fork it if you want to update it yourself.

This is a VERY simple resource that gives players some pre-defined (configurable) gear when they (re)spawn (configurable) or press a button (configurable).

Features:

  • Give weapons (completely configurable)
  • Give weapon components (flashlight, surpressor, extended clips etc… completely configurable)
  • Enable/Disable manual gear equip button
  • Customize manual gear equip button bind
  • Customize “gear equipped” message.
  • Enable/Disable gear equipment on player (re)spawn
  • Enable/Disable cleaning player clothes when equipping the gear
  • Enable/Disable giving max armor to player when equipping the gear
  • Enable/Disable healing the player when equipping the gear
  • Custom command to equip gear
  • Enable/Disable custom command

Default configuration

spoiler
local GiveLoadoutOnRespawn = false      -- should players receive the gear when they (re)spawn? (default: false)
local EnableManualButton = true         -- Should players be able to use the ManualLoadoutButton (default F7) to get the gear? (default: true)
local ManualLoadoutButton = 168         -- The button to be pressed to receive the loadout (default: 168 (F7))
local ClearPlayerClothes = true         -- Should the player's clothes be cleaned? (remove blood etc.) (default: true)
local HealPlayer = true                 -- 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.
local LoadoutCommand = "loadout"        -- The command that equips the loadout. (Default: "loadout")
local EnableCommand = false             -- Should the command be enabled? (true = yes, false = no) (default: false)
-- 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 = {  
    {0x34A67B97, 1},    -- Jerry Can
    {0x8BB05FD7, 1},    -- Flashlight
    {0x678B81B1, 1},    -- Nightstick
    {0x060EC506, 1},    -- Fire Extinguisher
    {0x3656C8C1, 1},    -- Stun Gun
    {0x5EF9FEC4, 200},  -- Combat Pistol
    {0x83BF0278, 200},  -- Carbine Rifle
}

-- 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
}

To download punch here.

Current version:

  • v1.2 (Added custom command)

Old versions:

  • v1.1
  • v1.0 (no longer available)
10 Likes

Thanks for this, this will be useful. Anyway you could do a command version as well? Like /loadout or something?

Thanks!

2 Likes

Sure, just added it. download v1.2 for that. You can customize the “loadout” command to whatever you like and you can also enable or disable the command completely. By default the command is /loadout and it’s disabled. Change the config to enable it.

2 Likes

Awesome, thank you! (character limit)

3 Likes

Can i like add this into the weapon shop

1 Like

I don’t get armor with it…wierd.It’s set to true.Is this some esx thing that I’m not getting it??

1 Like

Not sure how this could possibly be related to something ESX does.

Can you show me the config part? Do you get all the weapons just fine, so just the armor isn’t working? Or are you getting it with any weapon?

1 Like

I’m getting all the weapons but I’m not getting armor. :confused:

1 Like

Can you show me your config setup?

1 Like
VARIABLES --------------------------------

local GiveLoadoutOnRespawn = false      -- should players receive the gear when they (re)spawn? (default: true)
local EnableManualButton = true         -- Should players be able to use the ManualLoadoutButton (default F9) to get the gear? (default: true)
local ManualLoadoutButton = 57         -- The button to be pressed to receive the loadout (F10)
local ClearPlayerClothes = true         -- Should the player's clothes be cleaned? (remove blood etc.) (default: true)
local HealPlayer = true                 -- 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.
local LoadoutCommand = "loadout"        -- The command that equips the loadout. (Default: "loadout")
local EnableCommand = true             -- Should the command be enabled? (true = yes, false = no) (default: false)
-- 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
    {0x94E81BC7, 200},   -- Assault 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
    {0x94E81BC7, 0x7BC4CDDC},   -- Assault Shotgun Flashlight
    }



-------------------------- CODE, DON'T TOUCH -------------------------------
AddEventHandler("playerSpawned", function()
    if GiveLoadoutOnRespawn then
        GiveLoadout()
    end
end)

if EnableCommand then
    RegisterCommand(LoadoutCommand, function()
        GiveLoadout()
    end, false)
end

if EnableManualButton then
    Citizen.CreateThread(function()
        while true do
            Citizen.Wait(0)
            if IsControlJustReleased(0, ManualLoadoutButton) then
               GiveLoadout()
            end
        end
    end)
end

function GiveLoadout()
    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 GiveMaxArmor then
        SetPedArmor(ped, 100)
    end
    if HealPlayer then
        SetEntityHealth(ped, 200)
    end
    TriggerEvent('chatMessage', '', {255,255,255}, ReceivedLoadoutMessage)
end


----------------------------------------------------------------------------

1 Like

Ah I see the issue. SetPedArmor() is being used instead of SetPedArmour(). I’ll update this in a future update. However, for now simply go here:

And change SetPedArmor(ped, 100) to SetPedArmour(ped, 100)

That should temporarily fix it.

1 Like

but I have this line already in my config.I’m confused :smiley:

if GiveMaxArmor then
SetPedArmor(ped, 100)

end

1 Like

There is a slight difference.
SetPedArmor vs:
SetPedArmour
See the difference? SetPedArmour

For it to work, it has to be SetPedArmour

1 Like

Oh ye sorry I read it wrong mate,thanks I will try it :wink:

1 Like

It works now,just one more question man,Is there any way I could change it that only police officers could use this command and nobody else? :stuck_out_tongue:

2 Likes

You’ll either have to implement a permissions system yourself, using player identifiers and aces. Or implement it through some framework if that’s what you prefer, however for that I won’t be able to support you. As I don’t use such frameworks myself.

1 Like

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

@Vespura you create less tables if you do it like this. Maybe you can OR the components too or?

function ApplyWeaponLoadout (ped, weapons)
	local hash
	local ammo

	ped = ped or GetPlayerPed(-1)

	RemoveAllPedWeapons(ped)

	for _, weapon in pairs(weapons) do
		hash = MODULE.UTILS.toModel(weapon[1])
		ammo = weapon[2] or 1

		GiveWeaponToPed(ped, hash, ammo, false, weapon[4] == true)

		for i, component in ipairs(weapon[3]) do
			GiveWeaponComponentToPed(ped, hash, component)
		end
	end
end

ApplyWeaponLoadout(PlayerPedId(), {
	CombatPistol = { 0x5EF9FEC4, 200, { 0x359B7AAE, 0xD67B4F2D } }, -- Flashlight | Extended Clip
	CarbineRifle = { 0x83BF0278, 200, { 0x7BC4CDDC, 0x91109691, 0xC164F53,  0xA0D89C42 }, true } -- Flashlight | Extended Clip | Grip | Scope
})

1 Like

Why would you do it like this though? You’re creating tables for each weapon and it’s components, not much different from the current setup?

MODULE.UTILS.toModel is not even a thing…

1 Like

You’re creating one table per weapon component otherwise.
Forgot to swap it out. It’s just tonumber(model) or GetHash(model)

1 Like