Page 1 of 1

End thread on disconnect *help*

Posted: May 10th, 2011, 12:48 pm
by Nekoneko
Hello.
I need some help on a script.
When the player disconnects I want all the threads to be stoped and the entities attached to him deleted.
I know I could use the endon("disconnect");

but im trying to find another way

all my threads end on "stop_portal"

and I have this function threaded
Portal_Stop()
{
self common_scripts\utility::waittill_any("death","disconnect","joined_spectators","spawned");
self notify("stop_portal");
}

My Question now is, if the player (self) disconnects, will it still be able to notify self with "stop_portal", or will it be a script error (only on lan, so I cant test for sure)

And also i have another function, which is:

waitfor_Delete_Portals()
{
self waittill("stop_portal");
Delete_portals();
}

In Delete_Portals() it will delete the entities attached to self.
But will it work even if the player disconnected?
Or is there a workaround

Re: End thread on disconnect *help*

Posted: May 10th, 2011, 2:00 pm
by Drofder2004
Attached entities should delete when a player disconnects...
Why not just run a test, using either a dedi server, a bot or a friend...

If "delete_portals()" does not require a entity to be named or threaded...
You could maybe try:


self waittill("disconnect");
delete_portals();

Re: End thread on disconnect *help*

Posted: May 10th, 2011, 2:46 pm
by Nekoneko
so if i have something like self.ent it will delete itself ingame?
Will it do the same for a effect on self?
and im assuming the script wont give any errors, but ill test it out sometime.

Re: End thread on disconnect *help*

Posted: May 10th, 2011, 6:46 pm
by Drofder2004
ITs not somethign I have needed to ever test, but as long as you do not set up infinite loops on top of attached entities, then I cannot see any problems occuring.

Just simple create two entities (one a child of the other [self and self.child], attach them together and delete the parent ent and see what happens.