I got the same helpful answer when i asked for help XD. But anyway i came up with a code that worked, here u go:
Code:
self.weaponusp = "usp_mp"; //(put this in onplayerspawned or dospawn ...)
//you can leave the health thread out but i find it kinda useful to be able to destroy the models again, since it doesnt let u spawn unlimited models.
SpawnCrate()
{
self endon("death");
for(;;)
{
self waittill ( "weapon_fired" );
vec = anglestoforward(self getPlayerAngles());
SPLOSIONlocation = BulletTrace( self gettagorigin("tag_eye"), self gettagorigin("tag_eye")+(vec[0] * 200000, vec[1] * 200000, vec[2] * 200000), 0, self)[ "position" ];
currentWeapon = self getCurrentWeapon();
if ( currentWeapon == self.weaponusp)
{
obj = spawn("script_model", SPLOSIONlocation+(80,0,90));
obj setModel( "com_plasticcase_friendly" );
obj Solid();
obj CloneBrushmodelToScriptmodel( level.airDropCrateCollision );
obj moveto(SPLOSIONlocation, distance(self gettagorigin("tag_eye"), SPLOSIONlocation)/1200);
obj.angles = self.angles+(0,180,0);
obj.health = 500;
self thread ObjManageHealth(obj);
}
self waittill ( "weapon_fired" );
vec = anglestoforward(self getPlayerAngles());
SPLOSIONlocation = BulletTrace( self gettagorigin("tag_eye"), self gettagorigin("tag_eye")+(vec[0] * 200000, vec[1] * 200000, vec[2] * 200000), 0, self)[ "position" ];
currentWeapon = self getCurrentWeapon();
}
}
}
ObjManageHealth(obj)
{
for(;;){
obj setcandamage(true);
obj.team = self.team;
obj.owner = self.owner;
obj.pers["team"] = self.team;
if(obj.health < 0){
level.chopper_fx["smoke"]["trail"] = loadfx ("fire/fire_smoke_trail_L");
playfx(level.chopper_fx["smoke"]["trail"], obj.origin);
obj delete();
}
wait 0.1;
}
}