I can succesfully check wheter one team or the other wins (After checking which team has no members alive). Next, I want to restart the map. Imagine like Counter Strike, where after certain time or a team wins, the server restarts for a new round. How can I do this?
I tried implementing a console command “RestartLevel”, but it doesnt work when I test with 2 or more players running.
Then I tried creating a variable in the Game Mode for the current Level Name. Then I tried to simply call the node for OpenLevel, and pass the current level there. However, what ends up happening is that while the server restarts correctly. The client starts in the default example map!
You need to call “ServerTravel mapname” on the server itself for the server to be taking everyone along. Doing “Open Level” is what causes everyone to have their own map going.
Does it crash when you try to run it, or does it crash when you reach that point in the blueprint?
Do you have a space after ServerTravel?
Is the output from “Current Level” the proper name of the map?
I’ve used ServerTravel and it hasn’t produced a crash for me, which makes me wonder what could be causing it.
I created a small function inside of my multiplayer Game Mode as demonstrated below, and overwrote one of my server events in the Player State to call it. Since the event is set to run on server, client or host were both able to trigger it just fine.
I tried it with UE4.7, using the first person template. It relaunched the server, but the client was stucked, I couldn’t move with him. And then I tried restarting again and it crashed.
Using the command directly, I didn’t bother with blueprints for this test.
One more thing I’d like you to test, instead of going through the editor and using the play in editor option, could you launch two instances of the game from your .uproject inside of your project folder.
Make one the host, the other one join, then on the host run the ServerTravel command.
I want to say about this issue. I also was stuck with restarting my map and found this post. I tried to do this in the editor, but I had the same symptoms as Motanum had.
But then I tried to do the same things in my packaged game. (I created a session and client joined it with appropriate blueprint nodes). And ServerTravel worked correctly. Both of server and client characters respawn at their start position and have initial inventory state. So, I think it’s necessary to mark this post as Bug report (To fix editor crash)
Set seamless travel true in defaults settings in game mode, create blank map called Travel and set the map in project settings under transition map. Common thing is also setting default gamemode in the project settings. On the maps you play in world settings use your custom gamemode.
Then you can use ServerTravel command on the server(host).