PDA

View Full Version : Destroy model when player killed/discnonnects



guiismiti
4th December 2014, 20:44
Hi again,

This is the main bug in the gunship script I'm editing right now.
The model is spawned, but if the player changes team / disconnects, the model doesn't get deleted.

The code here is not complete, but I just need to know why this doesn't work.



level._ac_model=spawn("script_model",self.origin+(2000,0,0));
level._ac_model linkTo(self._ac);
level._ac_model setmodel("xmodel/vehicle_condor");
level._ac_model.gunner = self;

level thread ac_monitor(self);

ac_monitor(gunner)
{
while((isDefined(level._ac_model.gunner))&&(gunner.pers["usinggunship"] == 1))
{
wait 0.3;
iprintlnbold("in loop");
}

if(isDefined(level._ac_model))
{
level._ac_model destroy();
iprintlnbold("destroyed by monitor");
}
}


The result is, I can read the "in loop" text while using the gunship, and, after I leave it (using /kill or changing team to spec), I read "destroyed by monitor", but the gunship does not get destroyed.

IzNoGoD
4th December 2014, 21:10
delete() instead of destroy() for models

guiismiti
4th December 2014, 23:23
Yea, that worked.... funny thing is that the original script uses destroy() after the ac_move() is completed.

Btw izno, I asked you once, not sure if you read it, do you know who wrote this code?

http://pastebin.com/mvqeVmQc

It's the gunship code I'm using, and I'd like to credit whoever created it. It's really different from the eXtreme mod code.

IzNoGoD
4th December 2014, 23:42
I honestly have no clue who wrote it, but judging by the codestyle, I'd have to say that it was written by two or more people, one of which uses proper indentation and spacing, and one who does no such thing.