question

Philip Alexander Prates Machado avatar image
Philip Alexander Prates Machado asked

GetMatch() in c++

I have been trying to call GetMatch() in c++ in unreal but for the life of me i cant figure out why my code doesn't compile.

I am following this piece of documentation:
https://docs.microsoft.com/en-us/gaming/playfab/sdks/unreal/quickstart

but trying to use it with the MultiplayerAPI instead of the ClientAPI.

It says that PlayFab::UPlayFabMultiplayerAPI is undefined and that GetMatch is not a member of the playfab TShared pointer, is there any module i am forgetting to add ? i got Playfab, PlayfabCpp and PlayFabCommon.


Here's how the code looks:

#include "PlayFabClientDataModels.h"
#include "PlayFabError.h"
#include "PlayFabSettings.h"
#include "PlayFabClientAPI.h"
#include "PlayFabMultiplayerAPI.h"PlayFabMultiplayerPtr multiplayerAPI = IPlayFabModuleInterface::Get().GetMultiplayerAPI();



	
PlayFab::MultiplayerModels::FGetMatchRequest request;

//request filled here
	
multiplayerAPI->GetMatch(request,
PlayFab::UPlayFabMultiplayerAPI::FGetMatchDelegate::CreateUObject(this, &AArenaGameMode::OnGetMatchSuccess),
PlayFab::FPlayFabErrorDelegate::CreateUObject(this, &AArenaGameMode::OnGetMatchFailed));

Is there any place where i can take a look at a c++ implementation of this, there's quite a few in C# maybe add a c++ section as well, i am just a bit lost as to why this wouldn't work...

unreal
3 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 ·

Have been trying to fix this for more than a day now, i found out that i cant call "Microsoft::Azure::Gaming::GSDK::getConfigSettings()" either, it throws a LNK2019 error which leads me to belive i am missing includes but i have included everything i can think of and it still doesn't work.

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang commented ·

We will try to test it.

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

Have you had the chance to look into this? i am still stuck on this issue and following exactly what the tutorial says doesnt work. I also saw some one in the unreal forums with the exact same issue so this has to be something on your end.

0 Likes 0 ·
Sarah Zhang avatar image
Sarah Zhang answered

@Philip Alexander Prates Machado

Apologies for the delayed reply. We followed this documentation https://docs.microsoft.com/en-us/gaming/playfab/sdks/unreal/quickstart, tried to call the GetMatch API in Unreal Cpp. It works fine. We are not very sure why you want to use the PlayFabXplatCpp NuGet package in the Unreal Project. The above tutorial provides an example that using the Unreal Marketplace Plugin. Only when you use the PlayFab Unreal Marketplace Plugin, you need to follow the Unreal QuickStart.

If you want to use the PlayFabXplatCppSDK NuGet package in the CPP project, you need to follow this documentation -- https://docs.microsoft.com/en-us/gaming/playfab/sdks/playfab-cpp/quickstart-windows.

The example code from Unreal quickstart is not suitable for the project using the PlayFabXplatCppSDK NuGet package.

If you installed both the NuGet package and the Unreal Plugin for your project. You can target the Unreal Plugin by specifying the parent directory of the “h” file.

#include "Core/PlayFabClientAPI.h"
#include "Core/PlayFabMultiplayerAPI.h"
#include "Core/PlayFabError.h"
#include "Core/PlayFabClientDataModels.h"
#include "Core/PlayFabMultiplayerDataModels.h"
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 ·

After adding the "core/" in the includes everything compiles fine, more than a week for something so simple.

Intelisense led me to belive everything was as it should be, so i am blaming this one on microsoft.

Thank you for looking into this, if it werent for you i would probably still be stuck because those small details always go over my head.

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

I spoke with brendan about this, after a bit of a chat he told me that it could be because of how i got the sdk.

I used nuget BUT i moved the files from the default folder into the UE4 plugins folder because i was having some issues with buil.cs and for things to be more organized with smaller names.
I also unistaled the package after i got all the nescessary includes working for the server, do you think this could be the reason? it is my first time using nuget and i dont know how it works behind the scenes, is playfab not suposed to work if you do not have the nuget package? everything works just fine in blueprints tho.

4 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.

Sarah Zhang avatar image Sarah Zhang commented ·

If you moved the Nuget package to some folder that is not the default folder, have you changed the "Package Sources" for this Project? You can refer to this documentation -- https://docs.microsoft.com/en-us/nuget/consume-packages/install-use-packages-visual-studio for more info.

Besides, you can also use the scripts of the GSDK to instead the nuget package. You can find the code files in this repository -- https://github.com/PlayFab/gsdk/tree/master/cpp/cppsdk.

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

Messed around with this and couldnt get anything to work, downloaded the nuget package and tried using the include from the nuget and nothing.

Tried following this https://docs.microsoft.com/en-us/gaming/playfab/sdks/unreal/quickstart but the clientAPI functions dont work either.

Since the functions are recognized i am beggining to suspect this might have something to do with how the code is compiled, maybe some VS studio compiling option that i am missing.

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang Philip Alexander Prates Machado commented ·
0 Likes 0 ·
Show more comments
pagilmor avatar image
pagilmor answered

I suspect you need to include:

    #include "PlayFabMultiplayerDataModels.h"
    Client API needs Client Data Models, Multiplayer API needs Multiplayer Data Models.
    And similarly for every API group.

    10 |1200

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

    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.