Skip to content

Cloud Code

36 Topics 150 Posts

General cloud code discussions...

  • Bank Woori Saudara

    Unsolved
    1
    0 Votes
    1 Posts
    2 Views
    No one has replied
  • Does LeaderboardService.RemovePlayerScore revert rewards?

    Solved
    6
    0 Votes
    6 Posts
    846 Views
    J
    Q1: The removed player is completely excluded from reward calculation, so if the deletion happens before the job runs, that player is never iterated over and receives no rank or rewards. Q2: Yes, the modified score will be used. The job always reads live state. Note that whether the score actually gets modified depends on the leaderboard type (e.g., for the LOW_VALUE type, only updates if the new score is less than the existing) Q3: No backfilling, the next joiner goes to the latest instance, not the freed spot in ^2. No loop over earlier instances (^1, ^2) ever happens. The next joiner goes to ^3 (or ^4 if ^3 is full). The freed spot in ^2 stays empty permanently.
  • Are the Cloud Code type definitions (.d.ts) in the local setup guide outdated?

    Solved
    6
    0 Votes
    6 Posts
    1k Views
    J
    Yes, the link provided in that article is automatically updated. For your reference, here is the actual embedded link behind it: https://portalx.braincloudservers.com/dts/cloudcode_dts_files.zip
  • ScheduleRunScriptUTCv2 doesn't seem to work as expected?

    Solved
    7
    1
    0 Votes
    7 Posts
    2k Views
    Paul WinterhalderP
    Cool - good to hear it. And once again: thanks for reporting it!
  • Recurring scheduled tasks?

    Unsolved
    6
    0 Votes
    6 Posts
    2k Views
    Paul WinterhalderP
    We agree with that @antony - we'll get that request to the devs.
  • "Player Location" custom session/matchmaking id

    Solved
    4
    0 Votes
    4 Posts
    2k Views
    Paul WinterhalderP
    Ah - perfect. Yeah - that sounds like a better option given the full requirements. Glad you found it... and welcome to brainCloud!
  • bridge.getCustomEntityServiceProxy()

    Unsolved
    5
    1
    0 Votes
    5 Posts
    2k Views
    Paul WinterhalderP
    Hi @kinco-h - I assume (hope) you got the info you needed from our support folks? Hint - you access chat support by clicking on the "Ask Support" button in the top right-hand corner of the Design Portal... [image: 1733321320013-2024-12-04_09-07-57.png]
  • Webhook routes

    Solved webhook cloud code s2s
    12
    0 Votes
    12 Posts
    4k Views
    Paul WinterhalderP
    Cool. Thanks for sharing the solution here @devsleeper !
  • Filter online players in Matchmaking

    Solved
    8
    0 Votes
    8 Posts
    3k Views
    A
    Ciao @Paul-Winterhalder , yes there is not much else to add, except perhaps the fact that the CompleteMatch is sent at the end of the game. Instead, AbandonMatch is sent if one of the players abandons the game prematurely. Thanks for the support!
  • This topic is deleted!

    Unsolved
    2
    0 Votes
    2 Posts
    5 Views
  • 0 Votes
    5 Posts
    2k Views
    Paul WinterhalderP
    There is a global list of reason codes here - https://docs.braincloudservers.com/api/appendix/reasonCodes
  • Cloud code retries, error handling question

    Unsolved cloud code error
    2
    0 Votes
    2 Posts
    1k Views
    P
    A good way to handle failure besides retrying in code, is to schedule another script to run 1 minute later that will basically repeat the same action.
  • Lobby creation/deletion events in CloudCode

    Unsolved
    13
    0 Votes
    13 Posts
    4k Views
    Paul WinterhalderP
    Hi Alessio, I have a suggestion. Why not create a global chat channel called "lobbyListeners". Then - when a user is viewing the lobbies - have them connect to and listen to the lobbyListeners channel. Then you don't need to maintain a global entity at all. Whenever you create a lobby or delete it - send an event to lobbyListeners - and it will automatically send it to everyone who has registered for the channel. Would that work? (or is there a part of your use case that I am missing?) Paul.
  • 0 Votes
    3 Posts
    1k Views
    G
    @JasonL Thanks, I ended up with this cloudCode: isForceCreate = String(data.callingMessage.forceCreate) == "true"; isNewUser = String(data.message.newUser) == "true"; var response = {}; response.status = 200; response.data = data.message; if (isForceCreate && isNewUser) { var min = 10000000, max = 999999999 prefix = ["player", "user", "member"] const num = Math.floor(Math.random() * (max - min + 1)) + min; const pre = prefix[Math.floor(Math.random() * prefix.length)]; var defaultPlayerName = pre + String(num); var playerStateProxy = bridge.getPlayerStateServiceProxy(); // We are changing the player name on the server. playerStateProxy.updatePlayerName(defaultPlayerName); // And in this API Call's return data. response.data.playerName = pre + String(num); } response; //return the object This works just the way I need
  • bridge.include doesn't exists

    bug
    2
    0 Votes
    2 Posts
    1k Views
    J
    Hey, there must be some syntax error in your script, would you be able to provide your script code here?
  • HTTP Client API - DELETE calls

    cloudscript
    3
    0 Votes
    3 Posts
    1k Views
    Kenneth LightnerK
    Delete call update and everything is working now. Thanks!
  • 0 Votes
    1 Posts
    949 Views
    No one has replied
  • How to add to an array in Cloud Code?

    function push cloud code script array cloud code
    2
    0 Votes
    2 Posts
    1k Views
    H
    I posted this almost 13 days ago with zero answers, so I took some time to look through a bunch of documentation and did a ton of trial and error. Please Braincloud for the love of god add this to your API. Rhino does not handle Arrays the way that other coding languages do. I figured it out, unlike most arrays that return an array after you call push- Rhino returns the new length. So if you call push, don't set it's value. var copyArray = []; //I assume this line tells it to be an array for (var i = 0; i < postResult.data..length; i++) { copyArray[i] = postResult.data[i]; //arrays do not behave like .Net arrays, you can change length without initializing, so you just set each index to the index of the array you're copying } copyArray.push(variableToAdd); //Do NOT set this as the value of your array, the push method returns an int (length of array) NOT an array! //you probably dont need to call push at all to add to the array as shown in the for loop above if you already know your length or want a specific length Then just set your value to the variable, like this var entityData = { "variableName": copyArray }; //No need to call Array(copyArray) or any of the prototype. slice stuff. If you call Array() you'll just nest the array a second time. Use this page for further info on functions you can do with arrays.
  • How to access Lobby Data in a Lobby Filter script?

    cloudscript lobbyid lobby
    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • Stacktrace for Cloud Code errors?

    cloud code script rhino cloud code
    6
    2 Votes
    6 Posts
    3k Views
    Paul WinterhalderP
    Well - the new release isn't out yet - it's just a Release Candidate. https://github.com/mozilla/rhino/releases That said - we are very happy to see the progress - since it has been over a year since 1.7.13 was released! Hopefully soon!