[SOLVED] Checking if a game is started Net Code

Hey, I got it. What I had to do is put

if (data.Running && !this.Started) {
    this.loadScene('Error-Full');
}

in playerMoved because data.Running is another player’s this.Started.

Great! So I was close with my suggestions. :upside_down_face:

Yes. You were very close

Hey @Albertos I Have An Issue Related To This Subject And Was Hoping For Second Pair Of Eyes On It.

So I’m Making Another Project And Tried To Use This Code Again With Minor Altercations For The Online Mode But It Just Stopped Working.

Here Is The Original:

Network.prototype.movePlayer = function (data) {
    if (this.initialized && !this.players[data.id].deleted) {
    var playersModel = this.players[data.id].entity.findByTag('Model');
        console.log(data);
        this.players[data.id].entity.rigidbody.teleport(data.x, data.y, data.z, data.rx, data.ry, data.rz);
        this.players[data.id].entity.children[5].children[0].element.text = data.name;
        this.players[data.id].entity.children[5].children[1].element.text = data.name;
        if (data.Light) {
            
            this.players[data.id].entity.children[1].light.intensity = 2.24;
            
        }
           if (!data.Light) {
            
            this.players[data.id].entity.children[1].light.intensity = 0;
            
        }
        if (data.Hat == 'Crown') {
            
            this.players[data.id].entity.children[7].children[0].enabled = true;
            
        }
              if (data.Hat == 'TopHat') {
        
        this.players[data.id].entity.children[7].children[4].enabled = true;
        
    }
        if (data.Hat == 'BaseBall Cap') {
        
        this.players[data.id].entity.children[7].children[1].enabled = true;
        
    }
        if (data.Hat == 'Pirate') {
        
        this.players[data.id].entity.children[7].children[2].enabled = true;
        
    }
        if (data.Hat == 'Straw') {
        
       this.players[data.id].entity.children[7].children[3].enabled = true;
        
    }
      if (data.Hat == 'Cat') {
        
       this.players[data.id].entity.children[7].children[5].enabled = true;
        
    }
      if (data.Hat == '3131') {
        
       this.players[data.id].entity.children[7].children[6].enabled = true;
        
    }
      if (data.Hat == 'BG') {
        
       this.players[data.id].entity.children[7].children[7].enabled = true;
        
    }
          if (data.BulletType == 'Flame') {
        
       this.players[data.id].entity.children[7].children[9].enabled = true;
        
    }else{
         this.players[data.id].entity.children[7].children[9].enabled = false;
    }
if (data.Running && !this.Started) {
if (this.app.RandomServer) {

this.app.Server = null;
this.Initialize();

}else{
this.loadScene('Error-Full');
}
}

    }
};

And Here Is The New One:

BattleRoyalGameManager.prototype.movePlayer = function (data) {
    if (this.initialized && !this.players[data.id].deleted && data.Room == this.app.ServerID) {
        console.log(data);
         this.players[data.id].entity.setPosition(data.x, data.y, data.z);
         this.players[data.id].entity.setEulerAngles(data.rx, data.ry, data.rz);
         this.players[data.id].entity.children[0].setEulerAngles(data.mx, data.my, data.mz);
         this.players[data.id].entity.children[1].element.text = data.name;
         this.players[data.id].entity.children[2].element.text = data.name;
       if (data.Running && !this.Started) {
    this.loadScene('Kicked-Full');
}
    }
};

Hi @WilliamBoersma31! What is not working exactly?

It’s Not Kicking People It Just Does Nothing. It Seems It’s Not Activating For Whatever Reason

Here Is The Whole Code
Redacted: No Longer Relevant

Probably one of your variables is undefined or doesn’t give the right result. Try to use the console of your browser to find out what’s going wrong.

There are 2 variables that matter here (data.Running (the other players started variable) and this.Started (the clients Started variable)) and both are being set correctly. Do you have any other ideas?

It’s hard to debug a large project when I don’t know how it’s set up. I assume the rule below doesn’t work?

this.loadScene('Kicked-Full');

Based on what I see, it seems odd to me that that part of the code is in the movePlayer function.

How do I get to the point where I can test that part of the script?

No that works I just tried it in my leave function and it works fine

image

So, what is not working and how can I test it?

That’s What I’ve Been Wondering For The Last 3 Weeks

How do you know something is not working?

When I Try To Run The App With My Friend He Can Just Die And Comeback As Many Times As He Wants

Here Is Access To The Scene
Redacted: Nolonger Relevant

Where do you prevent this? What should happen instead?

That’s What That Code Is Supposed To Do. It’s Supposed To Make It Kick You For Joining While The Game Is Running

When is the game running and when is it ending?