End thread on disconnect *help*

Have questions about CoD4 mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

Post Reply
Nekoneko
CJ Fan
CJ Fan
Posts: 170
Joined: April 18th, 2011, 3:48 pm

End thread on disconnect *help*

Post by Nekoneko » May 10th, 2011, 12:48 pm

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

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: End thread on disconnect *help*

Post by Drofder2004 » May 10th, 2011, 2:00 pm

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();
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Nekoneko
CJ Fan
CJ Fan
Posts: 170
Joined: April 18th, 2011, 3:48 pm

Re: End thread on disconnect *help*

Post by Nekoneko » May 10th, 2011, 2:46 pm

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.

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: End thread on disconnect *help*

Post by Drofder2004 » May 10th, 2011, 6:46 pm

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.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests