Answered Best way to call an Overflow Fix?

The Dark Side

Former Staff Member
Messages
1,007
Reaction score
784
Points
993
I have mine as

Code:
if(self isHost() && level.isFirstSpawn == true;
{
    level.isFirstSpawn = false;
    overflowfix();
}

Should this be "thread overflowfix();", "level thread overflowfix();", or should i leave it as "overflowfix();"?

This is xTUL's overflow fix. :grinning: Does it matter which way you call it? Which is the most stable and safe way?
(I know noob question, im just curious. :grinning:)
 

P!X

Head Moderator
Staff member
Head Staff Team
Messages
408
Reaction score
590
Points
878
use self thread or just thread

without "thread" it waits until the called function is done

example:
Code:
onPlayerSpawned()
{
    self endon("disconnect");
    self.isFirstSpawn = true;
    for(;;)
    {
        self waittill("spawned_player");
        if(self.isFirstSpawn==true)
        {
            if(self isHost())
            {
                self iprintln("YAY");//runs wait for done and move on
                self test();//runs wait for done and move on
                overflowfix();//runs wait for done but since there is a infinite "for" loop in the function it will wait forever
                self test();//doesnt run cause you forgot "thread" overflowfix()
            }
            self.isFirstSpawn = false;
        }
    }
}

ohh and dont use "level.isFirstSpawn" use "self.isFirstSpawn" to seperate it for every single player
 

The Dark Side

Former Staff Member
Messages
1,007
Reaction score
784
Points
993
use self thread or just thread

without "thread" it waits until the called function is done

example:
Code:
onPlayerSpawned()
{
    self endon("disconnect");
    self.isFirstSpawn = true;
    for(;;)
    {
        self waittill("spawned_player");
        if(self.isFirstSpawn==true)
        {
            if(self isHost())
            {
                self iprintln("YAY");//runs wait for done and move on
                self test();//runs wait for done and move on
                overflowfix();//runs wait for done but since there is a infinite "for" loop in the function it will wait forever
                self test();//doesnt run cause you forgot "thread" overflowfix()
            }
            self.isFirstSpawn = false;
        }
    }
}

ohh and dont use "level.isFirstSpawn" use "self.isFirstSpawn" to seperate it for every single player
Extremely helpful. Will do. :smile:
 

BullyWiiPlaza

Modder
Messages
214
Reaction score
174
Points
818
The best way is this something like this:
Code:
onPlayerSpawned()
{
    if(!isDefined(level.isFirstSpawn))
    {
        level.isFirstSpawn = false;
        level thread overFlowFix();
    }
}

Explanation:
The overflow fix has to be executed on spawn and not on connect because it would cause a server disconnected error. Then it should run when the first player spawns and not the host. I'm using the level entity to call the function with a thread because it's a function that works on the level and not the player entity (self) . It has to be threaded to not block the onPlayerSpawned() function. The variable level.isFirstSpawn makes sure that overFlowFix() will only be called once.
 
Top