ID:2074536
 
(See the best response by Ter13.)
Problem description:
Hello guys, my problem is that by killing an NPC I get this error.

Code:
runtime error: Cannot create objects of type null.
proc name: dropea (/mob/proc/dropea)
source file: 1.6 Procs 3.dm,724
usr: (src)
src: Jety4 (/mob)
src.loc: NaruterosV3 (332,239,1) (/turf/HIerba/dgrass)
call stack:
Jety4 (/mob): dropea(Nidaime (/mob/enemy/Nidaime))
Nidaime (/mob/enemy/Nidaime): Death(Jety4 (/mob))
Jety4 (/mob): ataproc()
Jety4 (/mob): Atacar()


Code:
mob/proc/dropea(mob/M)
var/ropa=""
var/rand1=rand(1,17)
if(rand1==1) ropa="Kankuorusuit"
if(rand1==2) ropa="Shinigamitraje"
if(rand1==3) ropa="trajedemadara"
if(rand1==4) ropa="Zabuzasuit"
if(rand1==5) ropa="Scroll_Doton1"
if(rand1==6) ropa="Scroll_Fuuton1"
if(rand1==7) ropa="Kankuorusuit"
if(rand1==8) ropa="Shinigamitraje"
if(rand1==9) ropa="trajedemadara"
if(rand1==10) ropa="Zabuzasuit"
if(rand1==11) ropa="Scroll_Rai1"
if(rand1==12) ropa="Scroll_Katon1"
if(rand1==13) ropa="RockLeesuit"
if(rand1==14) ropa="Narutosuit"
if(rand1==15) ropa="Neijisuit"
if(rand1==16) ropa="Windmill"
if(rand1==17) ropa="Trikunai"
var/obj/O = "/obj/ropas/tienda/[ropa]"
O=new O//this is the line 724 of code
O.loc = M.loc
O.xco = O.x;O.yco = O.y;O.zco = O.z//nuevo
spawn(600)//nuevo
if(O&&O.loc==locate(O.xco,O.yco,O.zco))del O//nuevo

Best response
var/obj/O = text2path("/obj/ropas/tienda/[ropa]")
The problem is that "/obj/ropas/tienda/[ropa]" is a string, not a typepath. Look up the text2path() proc in the reference (F1 in Dream Maker) and that should fix your problem.
Thank you sou much Ter13 and Poisfizzy, vote for Ter13, firts response.
Dude, get rid of that massive if chain..
var/list/all_ropa = list("Kankuorusuit","Shinigamitraje","trajedemadara","Zabuzasuit","Scroll_Doton1","Scroll_Fuuton1","Scroll_Rai1","Scroll_Katon1","RockLeesuit","Narutosuit","Neijisuit","Windmill","Trikunai")
var pick_ropa = pick(all_ropa)
var/obj/ropa = text2path("/obj/ropas/tienda/[pick_ropa]")
In response to GreatPirateEra
Yeah, I should've remarked on that but I only paid attention the immediate issue.
this is the result:
mob/proc/dropea(mob/M)
var/list/all_ropa = list("Kankuorusuit","Shinigamitraje","trajedemadara","Zabuzasuit","Scroll_Doton1","Scroll_Fuuton1","Scroll_Rai1","Scroll_Katon1","RockLeesuit","Narutosuit","Neijisuit","Windmill","Trikunai")
var pick_ropa = pick(all_ropa)
var/obj/ropa = text2path("/obj/ropas/tienda/[pick_ropa]")
ropa=new ropa
ropa.loc = M.loc
ropa.xco = ropa.x;ropa.yco = ropa.y;ropa.zco = ropa.z
spawn(600)//nuevo
if(ropa&&ropa.loc==locate(ropa.xco,ropa.yco,ropa.zco))del ropa


thank you GreatPirateEra,ter13 and popisfizzy.