Here you go

RegisterCommand("armas", function(source, args, raw)
	local weapons = {pistol = "WEAPON_PISTOL", smg = "WEAPON_SMG"}
	local ped = GetPlayerPed(-1)
	local selectedWeapon = weapons["pistol"] -- Default Weapon
	local selectedAmmo = 60 -- Default Ammo

	-- Player Selected Weapon
	local chosenWeapon = nil
	if args[1] ~= nil then chosenWeapon = tostring(string.lower(args[1])) end

	-- Player Selected Ammo
	local chosenAmmo = nil
	if args[2] ~= nil ~= nil then chosenAmmo = tonumber(args[2]) end

	if chosenWeapon ~= nil then if weapons[chosenWeapon] ~= nil then selectedWeapon = weapons[chosenWeapon] end end
	if chosenAmmo ~= nil then selectedAmmo = chosenAmmo end

	GiveWeaponToPed(ped, GetHashKey(selectedWeapon), selectedAmmo, true, true)
end, false)