Sign In Register

How can we help you today?

Start a new topic
Answered

Creating variables that are the same across all players

Hello!


Every hour I'd like for the server to generate 5 random numbers in an array. 

How can I have it so that all clients may check this data, and it will be the same 5 random numbers across all players?


(There is a merchant in my game who sells random items every hour but I want all players to see the SAME random items, not each generate their own 5 random items.)


Thanks for your time.

-Sean


Best Answer

Hi Sean,


There are a number of ways to achieve this kind of functionality.


The one I recommend the most would be the following.


In your Every Hour script, code would run that would generate the 5 random numbers, and store them in an array in a runtime collection (maybe call it "hourlyRandom" or something).


Once the numbers have been saved, you can create an event, or attach some code to regular requests such as Authentication, that will retrieve this array and respond to the client. This is of course on the assumption that the client will initiate the check itself.


Another way of handling this is to send a message to every player every hour with the 5 numbers on generation, but we wouldn't recommend this as this won't scale well.


-Pádraig







Answer

Hi Sean,


There are a number of ways to achieve this kind of functionality.


The one I recommend the most would be the following.


In your Every Hour script, code would run that would generate the 5 random numbers, and store them in an array in a runtime collection (maybe call it "hourlyRandom" or something).


Once the numbers have been saved, you can create an event, or attach some code to regular requests such as Authentication, that will retrieve this array and respond to the client. This is of course on the assumption that the client will initiate the check itself.


Another way of handling this is to send a message to every player every hour with the 5 numbers on generation, but we wouldn't recommend this as this won't scale well.


-Pádraig






Hey Padraig thanks for the response!


Could you point me in the right direction to where I can find the proper syntax for creating a runtime collection in cloud code?


Thanks a ton.

-Sean

Hey Sean, There is a brief tutorial on saving and loading player data available here.

Sean

Login to post a comment