Hello! So I watched a tutorial and made it possible to be able to make a server, browse servers, and then join one. However, I now want to make it so when creating the server you can put in a code, and then when people are looking for the server there would be a search box which they can then write in the code, and then when you click a button or seach you would join the server directly, e.g if you play with friends.
The only problem is I have no idea how to do this. I have no idea either how the blueprints work. I tried adding “server code” to the server settings and played around with that, however, I still did not understand anything. I would appreciate it a lot if anyone could help me. Thank you for any help!!! If anyone needs screenshots of my code to make it more clear I would be more than happy as I’ve tried doing this for about 5 hours and have had no luck, again thanks!!
Hi Lord,
Are you using UE4’s networking on its own or with additional net code, like the “Advanced Sessions” plugin?
I know I have gotten a system very similar to work with Advanced Sessions, when hosting a server with their “Extra Settings” feature, and I’d be glad to help you figure it out with that plugin. If you want to get started with it here is a download link (it has support for 4.7.0 - 4.26.0)
Hello! Yes, exactly! I’m using the advanced sessions, with steam. Thank you for offering help!!!. Should I send screenshots of my code? If so write which parts of my code you would want to see
Ok, this is the list of steps I would use, feel free to change it and make it better fit you, and if you need any more help ask me.
NOTE: THERE ARE SCREENSHOTS OF THE PROCESS AT lordoftheseas_IMAGES - Google Drive
When hosting the server, first you need a way to generate a code to add to the extra settings.
My personal way of doing this, as there currently is not a “random string of length” node would be to have a variable (Array of strings), called ‘CharacterSet’ and make the default value have all of the characters you want present in your codes, each as it’s own entry. This will most likely be the entire alphabet, so just make it A, B, C, D, etc.
Create an empty string variable called Code.
Create a ‘Set Code’ node and make the value blank, connect this to your “On Host Server” event.
Make a For Loop, with the first index set to 0 and the last index set to the length of the code you want to generate (something reasonable, like 5)
Connect a ‘Set Code’ node to the loop body pin, and make the value of the set node to the output of an Append String node, with the input A being a random element of the Character Set variable, and B being the Code variable.
Next up is going to be making sure 2 servers can not be generated with the same code, as this would make it impossible to join the right server if 2 servers had the same code.
Place a ‘Make Literal Session Property String’ node down and set the Key input to ‘Code’ and make the value equal to the ‘Code’ variable we created earlier. (MAKE SURE YOU ALSO ADD THIS TO YOUR EXTRA SETTINGS WHEN CREATING THE SESSION)
Connect the Return Value to a ‘Make Literal Session Search Property’ node, with the Comparison Operator as Equals.
Connect that Return Value to a ‘Make Array’ node and then plug that into the ‘Filter’ input of a ‘Find Sessions Advanced’ node.
If this node returns “On Failure”, this means that there most likely is not a server with that current code. You can connect that to your ‘Create Advanced Sessions’ node.
If the ‘Find Sessions Advanced’ node returns “On Success”, then just call your “On Host Server” event again. this will loop back through the function until it gets an open code.
Hey, This has been super helpful, and I understand why it should work, but for me it is not working unfortunately, could you take a look at the images below and explain to me why its not working? Thank you so much for what you have already done!
I also put the value as “A” for now for testing purposes so I dont have to remember so many letters, but other then that it should be pretty identical to what you described above.