entity* ghostobject;
var isObjectSpawn = 0;
function spawn()
{
if(isObjectSpawned != 0) {return;}
temp.x = mouse_pos.x;
temp.y = mouse_pos.y;
temp.z = 0;
vec_set(target,temp);
target.z = 10000;
vec_for_screen(temp,view_build);
vec_for_screen(target,view_build);
if(c_trace(temp,target,IGNORE_ME | IGNORE_PASSABLE) > 0)
{
if(ghostobject == NULL)
{
ghostobject = ent_create("crate.mdl",target,NULL);
ghostobject.transparent = on;
ghostobject.passable = on;
ghostobject.alpha = 30;
}
else
{
vec_set(ghostobject.x,target);
}
if(mouse_left)
{
ent_create("crate.mdl",target,null);
isObjectSpawned = 1;
if(ghostobject != NULL)
{
ent_remove(ghostobject);
}
while(mouse_left) {wait(1);}
isObjectSpawned = 0;
}
}
}