Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • API and SDK Questions /
avatar image
Question by Denzie Gray · Oct 26, 2020 at 08:10 AM · Matchmaking

MatchMaking Questions

@Brendan

I was reading the tutorial and I have a few questions.

I would like to use the information in PlayerStatistics for Matchmaking, how would I achieve this?

The guide has examples of the ticket attributes created on client side. Is there a way to control what Kind of attributes a client can use for queues?

Can a get a clarification on the difference between an attribute from a User vs the Player Entity? Do I have to use Entity.SetObjects beforehand?

The documentation mentions:

"This allows data to be stored for a user, rather than the title needing to specify it on each create ticket call."

Does this mean there is a global way for me to define/set attributes for Players?



Has the MatchMaking API been updated to work in CloudScript?

Here is a link for reference:
https://docs.microsoft.com/en-us/gaming/playfab/features/multiplayer/matchmaking/

Thanks in advance. And thanks for before.

Comment

People who like this

0 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

8 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Citrus Yan · Oct 26, 2020 at 09:37 AM

>>I would like to use the information in PlayerStatistics for Matchmaking, how would I achieve this?

You’d need to manually specify Player Statistics either in the ticket or player's Entity Objects.

>>The guide has examples of the ticket attributes created on client side. Is there a way to control what Kind of attributes a client can use for queues?

You cannot control what’s sent from the client side, it’s possible for a malicious client to send false attributes that may abuse your game. In that case, you can choose to use attributes from the Player Entity, and make sure that only server side can modify such data by updating the policy, please see this thread for more details: https://community.playfab.com/questions/43653/matchmaking-attributes-and-security.html

>> Can a get a clarification on the difference between an attribute from a User vs the Player Entity? Do I have to use Entity.SetObjects beforehand?

Attribute from a User means attributes specified during ticket creation, while Player Entity means entity objects specified by SetObjects beforehand.

>> Does this mean there is a global way for me to define/set attributes for Players?

Yes, you can set them via SetObjects.

>> Has the MatchMaking API been updated to work in CloudScript?

Yes, you access it using “ multiplayer.<Matchmaking APIs> ”, for instance, multiplayer.GetMatch({});

Hope this helps.

Comment

People who like this

0 Show 0 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

Answer by Denzie Gray · Oct 26, 2020 at 04:38 PM

@Citrus Yan

Your responses are in quotes.

>>"You’d need to manually specify Player Statistics either in the ticket or player's Entity Objects"

How would I do this? Can you provide a Clousdscript example for both?

>>"In that case, you can choose to use attributes from the Player Entity, and make sure that only server side can modify such data by updating the policy,"

Thanks for the link! I have some Questions related to it:

Is there a policy update I can use to prevent client-side ticket creations? I don't mind them checking for matches but I want all creation to happen server-side.
And can I make a policy to stop all entity related changes from the client?

>>"Attribute from a User means attributes specified during ticket creation, while Player Entity means entity objects specified by SetObjects beforehand."

Ok so for Attribute from a User, the client sends the attribtutes.

For Player Entity, it is based on the fields stored in Playfab Entities.


Did I get the above right?


And earlier you said I could use PlayerStatistics, is that apart of the second option in 'Player Entity'?


>>"Yes, you can set them via SetObjects."

Where is the Global SetObjects?

Is this available via GameManager or must I use Entity.SetObjects?

I would prefer the Game Manager, is that possible?

Some Player Statistic Questions:

1. Is there a way to Initialize a PlayerStatistic? I'd like to have a statistic for 'ELO' set to 1200. I think it currently starts at 0.

2. The fields are 32-bit integers - are they signed or unsigned?

3. When using 'Sum' as an UpdateType, may we pass negative numbers for subtraction?

Lastly the Cloudscript tutorial is missing the global handlers for:
1. entity

2. multiplayer

I am referring to this link:

https://docs.microsoft.com/en-us/gaming/playfab/features/automation/cloudscript/writing-custom-cloudscript

Thanks for the response btw.

Comment

People who like this

0 Show 0 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

Answer by Citrus Yan · Oct 27, 2020 at 07:53 AM

>>How would I do this? Can you provide a Clousdscript example for both?

I can provide a basic workflow:

First, Call GetPlayerStatistics to retrieve the statistics of a specific player.

If specify in the ticket: Call CreateServerMatchmakingTicket with the player’s statistics specified in MatchmakingPlayerAttributes.

If sepcify in player’s Entity Object: use SetObjects to specify the player’s statistics into player’s Entity Object, then call CreateServerMatchmakingTicket.

>> Is there a policy update I can use to prevent client-side ticket creations?

Currently it’s not supported.

>> And can I make a policy to stop all entity related changes from the client?

Sure, just change the aforementioned policy to the following:

{
    "Resource": "pfrn:data--*!*/Profile/Objects/* ",
    "Action": "Write",
    "Effect": "Deny",
    "Principal": "*",
    "Comment": "Only title can edit user Objects",
    "Condition": {
        "CallingEntityType": "title_player_account"
    }
},
{
    "Resource": "pfrn:data--*!*/Profile/Objects/* ",
    "Action": "Write",
    "Effect": "Deny",
    "Principal": "*",
    "Comment": "Only title can edit user MatchmakingObj Objects",
    "Condition": {
        "CallingEntityType": "character"
    }
},
{
    "Resource": "pfrn:data--*!*/Profile/Objects/* ",
    "Action": "Write",
    "Effect": "Deny",
    "Principal": "*",
    "Comment": "Only title can edit user MatchmakingObj Objects",
    "Condition": {
        "CallingEntityType": "master_player_account"
    }
},

>> Did I get the above right?

Yes, that’s correct.

>>Where is the Global SetObjects? Is this available via GameManager or must I use Entity.SetObjects?I would prefer the Game Manager, is that possible?

Using Entity.SetObjects with your title’s Entity Token (obtained from GetEntityToken with your title SecrectKey) is authorized to set all the other entities’ objects within the title. In the Game Manager, you can set objects for a specific player in its Player Tab:

>>Is there a way to Initialize a PlayerStatistic? I'd like to have a statistic for 'ELO' set to 1200. I think it currently starts at 0.

You’d need to use UpdatePlayerStatistics to update it, or sets it in Player Tab for a specific player.

>> The fields are 32-bit integers - are they signed or unsigned?

They are unsigned.

>> When using 'Sum' as an UpdateType, may we pass negative numbers for subtraction?

Sure.

>> Lastly the Cloudscript tutorial is missing the global handlers for:

Thanks for your feedback on this, I’ll report this to the doc team.


1.png (50.4 kB)
Comment

People who like this

0 Show 0 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

Answer by Denzie Gray · Oct 27, 2020 at 01:37 PM

@Citrus Yan

>>"Yes, you access it using “ multiplayer.<Matchmaking APIs> ”, for instance, multiplayer.GetMatch({});"

>>"I can provide a basic workflow:"

Firstly, the 'multiplayer' global variable/definition is missing in the cloudscript.d.ts.
Am I missing something?

Secondly, I am asking for a Cloudscript example. The RESTAPI you guys link to is not a good substitute for a code example. It clears some things up but a line of code showing the proper method call parameters would be better as it would also eliminate the trial and error of following the workflow you've laid out. Similar to your Entity Policy explanation, may I have an example in CloudScript of this:

multiplayer.CreateServerMatchmakingTicket({});

that has been tested?

" Is there a policy update I can use to prevent client-side ticket creations?

>> Currently it’s not supported."

Can they create tickets with Queue attributes via 'User' or will my queue settings to 'PlayerEntity' make that impossible?

If I handle Ticket creation in the cloudscript and the client doesn't know the queue name, would they be able make any tickets?

>>"Using Entity.SetObjects with your title’s Entity Token (obtained from GetEntityToken with your title SecrectKey) is authorized to set all the other entities’ objects within the title. In the Game Manager, you can set objects for a specific player in its Player Tab:"

Is there a way to do this globally for all players?

May I have a Cloudscript example of the PlayerEntity.SetObjects?
One where the Cloudscript function is using currentPlayerId?

If the values are unsigned for statistics will there be underflow, operation cancel, or will it clamp to 0?

Thanks for the responses so far, especially the Policy example.

Comment

People who like this

0 Show 0 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

Answer by Citrus Yan · Oct 28, 2020 at 07:59 AM

@Denzie Gray

Currently the 'multiplayer' global definition is not reflected in cloudscript.d.ts. And, here is an working example of multiplayer.CreateServerMatchmakingTicket({}):

handlers.TestCreateMatchmaking = function(args,context){
    var response = multiplayer.CreateServerMatchmakingTicket(
        {
            GiveUpAfterSeconds: 60,
            Members: [
                {    
                  "Entity": {
                        "Id": "xxxx",
                        "Type": "title_player_account",
                        "TypeString": "title_player_account"
                    },
                    "Attributes": {
                        "DataObject": {
                            "skill" : "fire",
                            "level": "master"
                                    }
                        }
                }
                    ],
            QueueName: "xxx"
            
        }
        )
    return {
        "Response": response
        
    };
}

>>Can they create tickets with Queue attributes via 'User' or will my queue settings to 'PlayerEntity' make that impossible?

They can still create tickets with ‘User’ attribute, however, that’s useless when your queue don’t have a rule that uses such Attribute source & path.

>>If I handle Ticket creation in the cloudscript and the client doesn't know the queue name, would they be able make any tickets?

Queue name is a necessity for ticket creation, they cannot make any tickets with the queue name.

>>Is there a way to do this globally for all players? May I have a Cloudscript example of the PlayerEntity.SetObjects? One where the Cloudscript function is using currentPlayerId?

What do you mean “globally”? Do you mean setting objects for all the players within your title? And, here is example for you:

handlers.TestSetObjects = function (args, context){
/*Get title player account id from currentPlayerId(master player account id)*/
    var title_player_account_id = entity.GetTitlePlayersFromMasterPlayerAccountIds({
        MasterPlayerAccountIds: [
            currentPlayerId
            ]
        
    }).TitlePlayerAccounts[currentPlayerId].Id;
/* set objects for the player:*/
    var response = entity.SetObjects({
        
        Objects: [
            {
            "ObjectName": "testobject",
            "DataObject": {
                "PlayerAttributes": {
                  "Skill": "fire",
                  "Role": "wizard",
                  "level": "master"
                }
            }       
        }
        ],
        Entity: {
                "Id": title_player_account_id,
                "Type": "title_player_account",
                "TypeString": "title_player_account"


             }
    })
    return {
        "Response": response
        
    };
}

>>If the values are unsigned for statistics will there be underflow, operation cancel, or will it clamp to 0?

Sorry for the confusion made earlier, statistics are specifically int32 values, and if the value you provided will result into a overflow, the UpdatePlayerStatistics API will simply return “StatisticValueAggregationOverflow” error and leaves the statistic value intact.

Comment

People who like this

0 Show 0 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

Answer by Denzie Gray · Oct 28, 2020 at 05:13 PM

@Citrus Yan

">>Currently the 'multiplayer' global definition is not reflected in cloudscript.d.ts"

Is there an ETA for this? Or maybe a preview branch?

">>multiplayer.CreateServerMatchmakingTicket({}):"

The example you gave is for when the queue is set to 'User'.
May I have an example of multiplayer.CreateServerMatchmakingTicket({}): with the queue set to 'PlayerEntity'? Or do I just remove the 'Attributes' field in the Ticket Members Object if the queue is set to 'PlayerEntity'?

Oh and is the EntityID in Members the same kind like currentPlayfabId or the title_player_account_id ?

In your multiplayer.CreateServerMatchmakingTicket example you have

"Id": "xxxx",

Using your set objects example, assuming I used

"

  1. var title_player_account_id = entity.GetTitlePlayersFromMasterPlayerAccountIds({

" ,

Would this be appropriate:

"Id": title_player_account_id,

instead of 'xxxx' or etc?

">>They can still create tickets with ‘User’ attribute, however, that’s useless when your queue don’t have a rule that uses such Attribute source & path."

When you say useless, do you mean it will throw an error? Will a ticket be created at all?

">>Queue name is a necessity for ticket creation, they cannot make any tickets with the queue name."

So if I hide the queue names on the server and the client doesn't know the name and uses a bad queue name, would they get an error? Will a ticket be created?

">>What do you mean “globally”? Do you mean setting objects for all the players within your title?"

Yes, that is what I mean. This would allow me to initialize values on account creation.

BTW, when I use UpdatePlayerStatistics, it requires a playfabId, Do I use 'currentPlayfabId' or the retrieved 'title_player_account_id' ?

Right now I save my information of UserInternalData using currentPlayfabId, is that Okay?

">>the value you provided will result into a overflow,"

I was talking about 'underflow' but I guess they work the same way?

Comment

People who like this

0 Show 0 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

Answer by Citrus Yan · Oct 29, 2020 at 06:57 AM

@Denzie Gray

>>Is there an ETA for this? Or maybe a preview branch?

Sorry there is no ETA on this because some “multiplayer” features are still in public preview, which are subject to changes. You can make a feature request about it in the forum.

>>Or do I just remove the 'Attributes' field in the Ticket Members Object if the queue is set to 'PlayerEntity'?

You don’t need to specify that when using “PlayerEntity”.

>>…Would this be appropriate, ... , instead of 'xxxx' or etc?

Entity ID used in Members is the title_player_account_id, and yes, that’s correct.

>>When you say useless, do you mean it will throw an error? Will a ticket be created at all?

No, it won’t throw an error, tickets gets created successfully. What I meant is that the User attributes specified by the clients won’t affect the matchmaking process because no Rules are utilizing it, hence clients won't be able to cheat.

>> So if I hide the queue names on the server and the client doesn't know the name and uses a bad queue name, would they get an error? Will a ticket be created?

It will return an error, and no ticket gets created.

>>BTW, when I use UpdatePlayerStatistics, it requires a playfabId, Do I use 'currentPlayfabId' or the retrieved 'title_player_account_id' ?

“playfabId” is the “currentPlayfabId”

>>Right now I save my information of UserInternalData using currentPlayfabId, is that Okay?

That’s OK.

>>I was talking about 'underflow' but I guess they work the same way?

Yes, it will return error when underflow or overflow (outside of the valid 32 bit integer range).

Comment
Denzie Gray

People who like this

1 Show 9 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Denzie Gray · Oct 29, 2020 at 11:40 PM 0
Share

@Citrus Yan

Thanks for the responses. I will test out some of this and come back if I have any questions.

avatar image Denzie Gray · Oct 30, 2020 at 03:22 AM 0
Share

@Citrus Yan

I have a new question:

Is the InternalUserData split by Title?

Say I call "server.UpdateUserInternalData({})" in one title, would the data be accessible in another title if the keys were the same?

avatar image Citrus Yan ♦ Denzie Gray · Oct 30, 2020 at 05:38 AM 0
Share

InternalUserData is title specific, if you want the data to span multiple titles, consider using Publisher data, in your case the corresponding API is UpdateUserPublisherInternalData, and, here is a doc with more details:https://docs.microsoft.com/en-us/gaming/playfab/features/data/titledata/using-publisher-data

avatar image Denzie Gray Citrus Yan ♦ · Oct 30, 2020 at 11:09 PM 0
Share

@Citrus Yan

Say I have 3 Attributes [A, B, C] in a queue.

If I make a Ticket do I have to use all 3 Attributes or can I make a ticket using a subset?

ex: Attributes: [A, C]

Show more comments
Show more comments
avatar image

Answer by Denzie Gray · Nov 07, 2020 at 04:03 AM

@Citrus Yan


When creating or cancelling tickets via the multiplayer handler does that count toward the API call limit?

Also does "server.WriteTitleEvent" add to The API request Limit?

I am referring to this in the Limits section of CloudScript:

"Cloud Script execution API requests issue - 25"
Comment

People who like this

0 Show 1 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Citrus Yan ♦ · Nov 09, 2020 at 06:21 AM 0
Share

Yes, they all add to API requests limit.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    4 People are following this question.

    avatar image avatar image avatar image avatar image

    Related Questions

    Direct Challenges,Direct Challenges (via FB) 2 Answers

    Matchmake and StartGame returning 500 Internal Server Error 1 Answer

    Turn based multiplayer card game 1 Answer

    Servers not starting 1 Answer

    backfill tickets match id 1 Answer

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges