Creating variables that are the same across all players
S
Sean Young
started a topic
almost 6 years ago
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
C
Customer Support
said
almost 6 years ago
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.
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
S
Sean Young
said
almost 6 years ago
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
Customer Support
said
almost 6 years ago
Hey Sean, There is a brief tutorial on saving and loading player data available here.
Sean Young
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
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
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCustomer Support
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
Sean Young
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
Customer Support
Hey Sean, There is a brief tutorial on saving and loading player data available here.
Sean
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics