Okay, here's the script that I'm using.
[desc = random weapon
:state=0:localvar=20
:state=0:hudreset,hudx=50,hudy=90,hudimagefine=gamecore\text\generateweapon.tga,hudname=use,hudhide=1,hudmake=display
:state=0,plrdistwithin=60:hudshow=use
:state=0,plrdistwithin=60,scancodekeypressed=18:state=1
:state=1,varless=50,random=5:hudunshow=use,globalvar=99,setvar=1,localvar=20,setvar=51,state=2
:state=1,varless=51,random=10:hudunshow=use,globalvar=99,setvar=2,localvar=20,setvar=52,state=2
:state=1,varless=52,random=15:hudunshow=use,globalvar=99,setvar=3,localvar=20,setvar=53,state=2
:state=1,varless=53,random=20:hudunshow=use,globalvar=99,setvar=4,localvar=20,setvar=54,state=2
:state=1,varless=54,random=25:hudunshow=use,globalvar=99,setvar=5,localvar=20,setvar=55,state=2
:state=2,plrdistfurther=60:state=0
:plrdistfurther=60:hudunshow=use]
AMD FX-6300 Vishera 3.5GHz, Radeon HD 7850 2GB, 8 GB RAM, Win 7 Pro 64 Bit