This is a fairly complicated set of laws. There are three types of “gun violence restraining orders” possible.
(1) A temporary emergency (by police), (2) ex parte (by family member or police) and (3) after notice and hearing (for one year term). There is also a penalty if someone makes a false petition, e.g. a misdemeanor penalty.
There are judicial council forms for this: http://www.courts.ca.gov/33683.htm