#Server kick out players

91 messages · Page 1 of 1 (latest)

gentle trench
#

Usually indicates you're trying to send a msg or call a Cmd too soon, or you've got an override that's missing a call to the base method or the call is out of sequence.

rare dagger
#

I usually get this when an exception is thrown directly in a cmd on the server

#

be sure to check log files for both client and server

#

something has gotta be there

neon oyster
#

@gentle trench @rare dagger Thank you very much

I have realized something:

To give context, the game I'm working on is one where ideally you can play different characters. My solution was to pass an empty object as playerPrefab to the networkManager who would ask the server to create the character that the user would actually handle. This used to work great, no problem. But now as soon as the player asks the server to create the playable character, it throws me the error that I mentioned in this post. The only new thing I've done is some logic to load scenes asynchronously to load different maps.

#

I did a test where the player instead of requesting the playable character from the server, instantiated a simple cube and the error did not appear.

neon oyster
#

basically this happens after this line:

neon oyster
#

@gentle trench what do you mean with too soon?

neon oyster
#

@rapid jungle can you see this post?

austere coral
#

So to explain MrGadget, as I mentioned in other thread. From my project:

  1. I connect to server Aka start client
  2. Send custom network message to spawn character;
    Will not work. As it run in one frame, both these commands is too slow to happen one after each other.
  3. I connect to server Aka start client
  4. wait several frames
  5. Send custom network message to spawn character;

This variant works, as it have time to start server, initialize stuff and then do your stuff.

But for this exact logic I am confusing with you spawning. As you pretty much adding character twice.

as after this: NetworkServer.AddPlayerForConnection(conn, gameobject); you already spawned player and assigned them with the player prefab. and then immediately you send another message, to Spawn another network object which authority belongs to a user? So one connection have authority over 2 objects?

Player can be kicked out if there is an error on player object or somehwere on server, as it is security measure. Please check logs

neon oyster
#

@austere coral The player object that Mirror creates automatically makes a request to the server to create a playable agent. I did it this way because the player should be able to play with different skins and characters, like in overwatch there are different characters with abilities and attributes

#

The problem is that this was working fine before, until I added logic to load the game maps additively

austere coral
neon oyster
#

@austere coral

austere coral
#

You assume that server and client will change scene at the same time?

#

Have you checked the example scene in mirror folder for additive scenes?

neon oyster
#

i wait till server loads scene and client

#

since I am sending the message to the client to load a scene, I am sure that the method OnClientChangeScene will be executed

#

ReadyToPlay its the method that calls the cmd to create the playable agent

austere coral
#

you are making your life difficult with custom implementation when you can go way easier way that is already implemented.;

#

As then you dont need to take in account that something is not spawned and etc. which problems you have now.

#

as you youse load async, not aditive there will be no difference.

neon oyster
#

That was my first try, but I have some scripts that repeat every scene, the minimum necessary for the game to work. So the online mirror scene has those scripts, so the map scenes just have the maps and no logic, since the base scene already has it.

#

It's not making life difficult, it's a requirement for the way the game works, as I told you, in our game each round is a different map so I must be able to change the scene with the ability to continue using things like, the script that saves the points in the database, ui , player manager and deaths etc

austere coral
#

if you change scene, you requere respawn players, make sure they all ready and server is ready before spawning and etc. so thats why I suggest use mirror scene changes rather than your own. As it isjsut harder

#

For things that saves data you you DOL (dont destroy on load) objects, which stays even if you change scene.

neon oyster
#

to be honest, this error appears after building a server for playfab, it worked fine locally, but after building for plyafab it doesn't even work locally

austere coral
#

have in mind they cannot be objects with network identity, for reason that all objects are beeing disabled with netowrk identity until player is SPAWNED.

#

Oh playfab. I noticed people have a lot of problems with it recently 😄 Well working localy and remotely is always different if you code is not prepared. Expecially with Timing is very different. And even depends on system functions: findFirstordefault can return different results and etc. so it is important to test throughfully.

#

Example: Had two event managers one for you one for character. Localy it worked perfectly, my collegue got same version. didnt work at all. as for him different event manager were selected first by default. Have in mind identical project, just different PC.

I still think main problem you have is spawning is out of order, or calling commands too fast.

#

You can try create buttons for each action and make sure at which it fails.

neon oyster
#

I'll try with some delays

austere coral
#

and once again, try using as much mirror examples as possible, as there is quite a lot of things behind the scenes, especially with scenes changing. So it is super highly recommended to use mirror functions.

neon oyster
#

actually my logic is based in one mirro example

#

there is an example called additive scenes

#

i just made a test were im not using additive scenes and the error persist after create the agent

#

lol

#

im dead

#

2 weeks stuck

#

i wanna cry so bad

austere coral
#

To be honest idk if OnClientChangeScene is called when you use additive scenes 😄

#

unles you change active scene? jsut a guess tho.

#

Okey lets clear things: YOU CHANGINGS SCENES OR ADDING ADDITIVE SCENES?

#

I know how you feel, I was in your shoes before

neon oyster
austere coral
#

And it is only on Playfeb or locally as well?

neon oyster
#

locally as well

#

Im using parrel sync

#

I'll make a test just making a build

#

hold on

neon oyster
#

Jajaja

austere coral
#

sorry For security reason I cannot open any files on this pc 😦

neon oyster
#

I'm pretty sure the scene handling logic is good

#

I know I missing something but i dont know what,

#

as you can see, for example, my logic works perfectly with the loading screen

austere coral
#

For me it still looks like your timing is off. What with resuming handlers after scene was loaded Debug line?

neon oyster
#

And I'm sure you're right

austere coral
#

why ypu have autocreate player option on?

neon oyster
#

let show

neon oyster
austere coral
#

well you handling your spawning manually right? so there is small chance that it add player object for you, than it tries to run code and you add another player object, and the handlers got double call or something

neon oyster
#

ok let my try brother

neon oyster
#

what do you suggest, create player inside onclientconnected?

#

@austere coral testing

austere coral
#

Either follow the logic of additive scenes in Aditive scenes examples of mirror. The examples folder have pretty clean code.

I would spawn character on network message. And send network message when I know that everything is loaded 100 % on client.

neon oyster
#

works

#

man i told you the scene handling logic is so good and is pretty clean as well 100% you will fall in love with my code

#

200%

austere coral
#

You connect to server. You load scene on server. Then you load scene on client. When scene is loaded on client to send network message to server asking to spawn. The server checks if scene is loaded, then if it is true it spawns. that would be secure way to do.

neon oyster
#

but now works brotyher

#

thank you

#

was the auto create players

neon oyster
#

10/10 your help man

austere coral
#

Noticed that on accident. Glad you found a way. Just dont forget, never assume client and server have same timings 🙂 golden rule of netowrking 😄 well it seems not this time tho 🙂

neon oyster
#

For sure bro

#

thanks

neon oyster
#

@austere coral Hi! how are you doing?

austere coral
#

good, have any more problems?>

neon oyster
#

working locally but not in playfab ajajj]

austere coral
#

sorry, havent touch playfab at all, so cant help on that section