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.