I cannot use /giveweapon command HELP

HELP PLEASE. CANT UNDERSTAND :confused:

1 Like

Could you share line 167 of the commands.lua file you have? Thanks.

local weaponName = string.upper(args[2])

Checked the main legacy code from ESX’s Github real quick, didn’t see any ‘local weaponName = …’ in the giveweapon command.

Try and replace your codeblock with this one:

ESX.RegisterCommand('giveweapon', 'admin', function(xPlayer, args, showError)
	if args.playerId.hasWeapon(args.weapon) then
		showError(_U('command_giveweapon_hasalready'))
	else
		xPlayer.addWeapon(args.weapon, args.ammo)
	end
end, true, {help = _U('command_giveweapon'), validate = true, arguments = {
	{name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'},
	{name = 'weapon', help = _U('command_giveweapon_weapon'), type = 'weapon'},
	{name = 'ammo', help = _U('command_giveweapon_ammo'), type = 'number'}
}})
2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.