question

madmojoman avatar image
madmojoman asked

Best Practice - Initialize Player Custom Data Key/Value,Best Practice - In-Order Custom Player Data

Is there a best practice for how to give a player a number based on their position in a Segment? For example, the first player joins the segment and gets their player data key "Number" set to "0", the second player joins the segment and gets their player data key "Number" set to "1", etc. Or is there already a position number setup at join-time/tag-time/etc. instead of just a general "total" number of players in a Segment?

,

I'm curious if there's a suggested / best practice method of setting custom player data key/value combination when a player arrives in a segment.

I initially attempted to setup a rule (on player entering a segment) and run a CloudScript function to give the player a number based on the number of players in the segment. But nothing seemed to happen. (The function didn't seem to get called when player was tagged and entered into the segment.) So, I setup a CloudScript to run if the player didn't already have that key/value set and to give them a value based on the number of players in the segment. Obviously, of course, this ended up with multiple players getting the same number given to them as players were tagged into the segment relatively quickly and then the players were checked on if they needed the value set, and found that there were # people in the segment and both got assigned the same number.

Basically, I would like each player in a Segment to have a "Player Number". (This needs to not change without a specific call to change it from some other function down the road.) When a player joins a Segment, I want them to be given the latest available number. For example, the first player to join will be "0" (yeah, I wanna start there), then the second would be "1", and the third "2", and so-on.

Does a number/position number already exist for Segments? Or are there any suggestions on best way to set this for each player?

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.

madmojoman avatar image madmojoman commented ·

Sorry about the duplicate. I had been logged out during typing the second part and when I tried to post it showed there was no message. So I retyped it short-and-sweet and when I posted it, suddenly the rest of the text showed up. *shrugs*

0 Likes 0 ·

1 Answer

·
brendan avatar image
brendan answered

If you need to have a way to generate a reliably unique, incrementing number for your players (for any reason - segment, login, etc.), we would recommend using a Redis integer. In the future, we'll likely provide this as an integrated feature, but for the moment, it's not a built-in part of the service.

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.