Post: Deleting hud elements of disconnected players?
03-15-2016, 08:00 PM #1
BullyWiiPlaza
Climbing up the ladder
(adsbygoogle = window.adsbygoogle || []).push({}); I'm wondering if it makes sense to delete HUD elements that have been created for a player after he has disconnected from the game. If HUD elements are attached to the self entity, the reference becomes undefined when the player is gone so it doesn't work that way. However, if I keep a level variable array with all created HUD elements and player references in order to do a clean up once in a while, does this make sense in terms of improving stability or is it completely pointless? I still don't know exactly why my menu is randomly freezing sometimes so I'm trying to figure out what could help it become even more stable. Below is some code I wrote for testing this Snail

    testCleanUp()
{
self.testText = self createFontString("default", 1.Cool Man (aka Tustin);
self.testText setPoint("CENTER", "CENTER", "CENTER", "CENTER");
self.testText setSafeText("Test");
getHostPlayer() iPrintlnBold("Text set for " + self.name);

self thread cleanOnDisconnect();
self thread cleanOnGameEnded();
}

cleanOnGameEnded()
{
notification = "game_ended";
level waittill(notification);
self thread cleanText(notification);
}

cleanOnDisconnect()
{
notification = "disconnect";
self waittill(notification);
self thread cleanText(notification);
}

cleanText(notification)
{
if(isDefined(self.testText))
{
getHostPlayer() iPrintlnBold("Cleaning (" + notification + ")");
self.testText destroy();
wait 1;
getHostPlayer() iPrintlnBold("Cleaned (" + notification + ")");
}
else
{
getHostPlayer() iPrintlnBold("Not defined");
}
}
(adsbygoogle = window.adsbygoogle || []).push({});
03-16-2016, 12:01 AM #2
EternalHabit
Former Staff
Originally posted by BullyWiiPlaza View Post
I'm wondering if it makes sense to delete HUD elements that have been created for a player after he has disconnected from the game. If HUD elements are attached to the self entity, the reference becomes undefined when the player is gone so it doesn't work that way. However, if I keep a level variable array with all created HUD elements and player references in order to do a clean up once in a while, does this make sense in terms of improving stability or is it completely pointless? I still don't know exactly why my menu is randomly freezing sometimes so I'm trying to figure out what could help it become even more stable. Below is some code I wrote for testing this Snail

    testCleanUp()
{
self.testText = self createFontString("default", 1.Cool Man (aka Tustin);
self.testText setPoint("CENTER", "CENTER", "CENTER", "CENTER");
self.testText setSafeText("Test");
getHostPlayer() iPrintlnBold("Text set for " + self.name);

self thread cleanOnDisconnect();
self thread cleanOnGameEnded();
}

cleanOnGameEnded()
{
notification = "game_ended";
level waittill(notification);
self thread cleanText(notification);
}

cleanOnDisconnect()
{
notification = "disconnect";
self waittill(notification);
self thread cleanText(notification);
}

cleanText(notification)
{
if(isDefined(self.testText))
{
getHostPlayer() iPrintlnBold("Cleaning (" + notification + ")");
self.testText destroy();
wait 1;
getHostPlayer() iPrintlnBold("Cleaned (" + notification + ")");
}
else
{
getHostPlayer() iPrintlnBold("Not defined");
}
}


Pretty sure this isnt needed, but I've always found that the game gets unstable from using a lot of for(;Winky Winky statements. So make sure when things are toggled off they arent still looping. This is how i've made dynamic v3 and Radiant pretty much "freezeless"

The following 3 users say thank you to EternalHabit for this useful post:

BullyWiiPlaza, HiddenHour, Terrorize 420
03-16-2016, 09:52 AM #3
BullyWiiPlaza
Climbing up the ladder
Originally posted by xTurntUpLobbies View Post
Pretty sure this isnt needed, but I've always found that the game gets unstable from using a lot of for(;Winky Winky statements. So make sure when things are toggled off they arent still looping. This is how i've made dynamic v3 and Radiant pretty much "freezeless"

Yeah, I also made sure that everything stops looping when it's switched to off. Sometimes I can play for hours straight without freezing once. Still, there are 2 or 3 random freezes per day so it's quite irritating. It's never the same setup of functions that cause this apparently. Thanks for answering the question too Smile
03-16-2016, 01:13 PM #4
Loz
Vault dweller
Originally posted by BullyWiiPlaza View Post
-snip-


pass the hud as a arg

    self thread cleanOnDisconnect(self.testText);
self thread cleanOnGameEnded(self.testText);

cleanOnGameEnded(hud)
{
level waittill("game_ended");
hud destroy();
}

cleanOnDisconnect(hud)
{
self waittill("disconnect");
hud destroy();
}
03-16-2016, 05:22 PM #5
BullyWiiPlaza
Climbing up the ladder
Originally posted by Loz View Post
pass the hud as a arg

    self thread cleanOnDisconnect(self.testText);
self thread cleanOnGameEnded(self.testText);

cleanOnGameEnded(hud)
{
level waittill("game_ended");
hud destroy();
}

cleanOnDisconnect(hud)
{
self waittill("disconnect");
hud destroy();
}

This is wrong because self is undefined when the player left the game so self.testText will be too.

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo