question

Philip Alexander Prates Machado avatar image
Philip Alexander Prates Machado asked

How to get server port in unreal blueprints

Title is pretty self explanatory i guess...

I have been trying to get the info from the json that you get after doing "GetMatchMakingTicket->GetMatch"

Managed to get the IP but the port for some reason is a mistery.

Heres a pic with the IP working but the port not working, i also tried to get the port with "Num" in the field name alone but that didnt work either, im probably not even doing that how it is suposed to...

If some one can point me in the right direction it would be very much apreciated.

unreal
aaaaaaaaa.png (166.8 KiB)
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Philip Alexander Prates Machado avatar image Philip Alexander Prates Machado commented ·

Have also tried Ports[0].Num, nothing so far.

0 Likes 0 ·

1 Answer

·
Citrus Yan avatar image
Citrus Yan answered

The “Ports” field in ServerDetails is a list/array of the “Port” objects, first you’ll need to get it as an array of objects and then get the port num within by iterating that array.

Here is a sample that gets the port num at index 0:


7 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Philip Alexander Prates Machado avatar image Philip Alexander Prates Machado commented ·

Ok just so i can understand this, the node "get object array field" will get me an the "Ports" array because of the field name, it will basicly search the whole JSON for a an array named "whatever you put on field name", is this correct?

But then you do a get with 0 but the first field on the Ports array is called "Name" so that wouldnt bet me the actual port number? i would have to call that get with 1 because thats the position of the actual port number "Num"?

Or is the Get object array field just assuming that you would get more than one array?

It is the first time that i am working with JSON so this is all new for me and many things get lost in the syntax.

Thanks for the answer.

0 Likes 0 ·
Philip Alexander Prates Machado avatar image Philip Alexander Prates Machado Philip Alexander Prates Machado commented ·

Also there are some "decode" nodes that seem like they are intented to get the answer in an organized way, are we not suposed to use those?

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Philip Alexander Prates Machado commented ·

Yes, you can use those as well.

0 Likes 0 ·
Show more comments
Citrus Yan avatar image Citrus Yan Philip Alexander Prates Machado commented ·

1.Yes, that's correct.

2.The "Port" object itself is not an array. "0" refers to the first "Port" object at index of 0, not the "Name" field within it.

You can check out this doc on JSON objects: https://www.json.org/json-en.html

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.