[How-to][vRP] Add weapon attachments to weapon shops or make a shop with them

I tried to add COMPONENTS_XXX_XX_SUP for example to the gunshop.lua but when you buy the attachments are not get attached to the weapon.

I found that has to be called something like that because that way armor works in vRP:

function vRPas.getArmour()
  return GetPedArmour(GetPlayerPed(-1))
end

function vRPas.setArmour(armour,vest)
  local player = GetPlayerPed(-1)
  if vest then
	if(GetEntityModel(player) == GetHashKey("mp_m_freemode_01")) then
	  SetPedComponentVariation(player, 9, 4, 1, 2)  --Bulletproof Vest
	else 
	  if(GetEntityModel(player) == GetHashKey("mp_f_freemode_01")) then
	    SetPedComponentVariation(player, 9, 6, 1, 2)
	  end
	end
  end
  local n = math.floor(armour)
  SetPedArmour(player,n)
end

local state_ready = false

AddEventHandler("playerSpawned",function() -- delay state recording
  state_ready = false
  
  Citizen.CreateThread(function()
    Citizen.Wait(30000)
    state_ready = true
  end)
end)

Citizen.CreateThread(function()
  while true do
    Citizen.Wait(10000)
    if IsPlayerPlaying(PlayerId()) and state_ready then
      ASserver.updateArmor({vRPas.getArmour()})
	  if vRPas.getArmour() == 0 then
	    if(GetEntityModel(GetPlayerPed(-1)) == GetHashKey("mp_m_freemode_01")) or (GetEntityModel(GetPlayerPed(-1)) == GetHashKey("mp_f_freemode_01")) then
	      SetPedComponentVariation(GetPlayerPed(-1), 9, 0, 1, 2)
		end
	  end
    end
  end
end)

Can anyvbody help?

1 Like

I did not understand what you mean, adding silencer or things like that to weapons is not possible as vRP does not memorize it, the script you published is the armorshop, it serves to fill the blue bar, what does it have to do with weapons?

I mean is there any way to add the weapon attachments to a shop so we can add a silencer of scope to the weapon. If not a shop is there any other way to attach attachments on weapons in vrp?

Yes it is possible to add weapon attachments in vrp. I’ve been working on developing it myself. However, it will take a bit of modifications to the core vrp framework. It will not be just download this script and plug it in.

But out of the box, no you cannot. It will take some development to get it working.

1 Like

Could we have an idea on it has to be done?