ID:1854727
 
(See the best response by Nadrew.)
Code:
usr.contents += typesof (new /obj/hair/)
usr.contents += new /obj/hair/hair1


Problem description:

There are about 35 hair icons underneath the directory of obj/hair but the typesof doesn't work for me when I try this and I need it unless I want to make my code look messy with the second part of the code which is doing it individually
Best response
You're calling it wrong, you're passing an object to it, not a type-path.

for(var/T in typesof(/obj/hair)-/obj/hair)
contents += new T


Note; typesof() includes the parent type, not just the children, which is why we have the "-/obj/hair" bit there, unless you want that included as well.
In response to Nadrew
Thanks a lot, when I'm coding tomorrow I'll remember to try that out.