Verna's Forum Posts

  • 14 posts
  • Another question:I've load the specific player's data from localstorage sucessfully,but I still can't set these variables to global variables.

  • After I enter the user account and password, how can I set the locally stored variables as global variables?

    Here are my variable default values.

    And here is the set of variable data I want to load after entering the account and password.

    The current execution method is as follows. Is there any way to successfully load it? I have tried for a long time, but it still doesn't work. I'm very frustrated!

    /user check/

    /set variable/

    Thank you very much.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I used some variables in the system, hoping that these variables can be used to store individual player information and restore them the next time they return to the game.

    Currently, the data can be saved, but after closing the window, the variables are initialized upon the first login (I had originally set some default initial values for each new player). However, after that, the situation returns to normal. Does anyone know how to solve this issue?

    Here are the initial values of the system variables I set

    DEMO:

    the last game record of player TN11

    youtu.be/p1LMgfCNoUw

  • I want to set the game progress values using arrays so that when the player returns to the game, these values are restored. Although the values initially seem to be restored successfully, they eventually revert to the game's default values.

    DEMO:

    Here’s the way I have it set up currently:

    Could anyone provide some solutions to this issue?

    Thank you so much!!!

  • This looks fine assuming those events are running all the time, you didn't show the top of the event.

    I fix the problem!!!Thank you!\^o^/

  • You need to wait for Check userID to complete asynchronously before use userArray Load data. Just like you add the LocalStorage callback condition below. But you have already done this because you use another array object user_data below. And you don't have any information about AJAX here, so you may have written it wrong.

    And, the user_check function, This loop Array condition, you may need to use it as a sub-condition.

    I don't quite understand whether the two array objects user_data and userArray are the same thing, But what you want to load from LocalStorage is already in the user_data array object.

    中文版回答:

    LocalStorage 是一个异步动作,你需要等待异步完成才能得到请求的数据。不能直接挨着写 userArray 读取数据。要像下面一样: 先检查是否存在,如果存在再获取数据,获取到了再读取。

    不过,你已经是知道了要这么做的,因为你已经在 On item userID get 里面,用另一个数组 user_data Load 到了本地数据。本地数据都在这里面。

    我不是很理解 user_data 和 userArray 这 2 个数组对象是否是相同的东西,但如果你希望从 LocalStorage 中读取存档,再进行遍历数据,你需要将上面的 userArray 的 Load 动作,也放到下面的 On item get 里面。

    或者在中间夹一个 "等待前面异步完成" 动作,然后继续用 userArray 读取数据。然后添加一个子条件,把开头系统循环的事件放在子条件继续执行

    Hello~ "userArray" and "user_data" are used to store different types of data.

    Since my users are pre-established, I use AJAX to call the file and store the static data in "userArray."

    However, each user's attributes are dynamic and constantly change during the game, so "user_data" is used to store them.

    Then I tried adding "wait for the previous action to complete" after local storage, but I still can't restore the player's attribute variables when returning to the game next time. Do you have any suggestions? Thank you very much!

  • I am using arrays to store game data in the Localstorage.

    How can I restore different users' game states when I return to the game next time? Currently, I am using the following code to save individual user information, but I cannot successfully read and restore the game state.

    Thank You!

  • Currently, I am using the CLAMP function, but negative values still appear. How can I resolve this issue? Thank you very much, everyone!

  • It is clear that this method has a vulnerability, players can pass each other a name and password and play on one more pumped up account. But if everything suits you, here is a simple example of how to store and load data of different players. I have put together a simple registration and login form, you can add password complexity checks and encrypt the password. But I have made the simplest example.

    https://kibaga.org/c3-example/file_uploads/index.php?file_name=../storage-multiple-users-r397-2.c3p

    Thank you so much! Really helps me lot!😆

  • When you need to save a user's state, create a unique key for each user. This could be a user ID or username.

    Use the Dictionary object to store values associated with this unique key.

    When a user returns, use their unique key to fetch their saved data from the Dictionary.

    To manage multiple users, you might use nested dictionaries or a JSON object where each user's data is stored under their unique key.

    May I ask if a Dictionary can be permanently saved like local storage? Because whenever I close the game and reload it, the previous Dictionary data disappears. I have to add a "logout" button in the game to save the data. However, in reality, I cannot prevent players from accidentally closing the game window.

  • How do you identify a player? Does he just pick his name from the list or does he have to enter it somewhere?And if other players want to play with the same name? That's cheating.

    It's very important to identify the player. For this you can use either google services or firebase or another method of identification.

    Once you have a unique identifier of your player you need to check the local storage, if there is such a key, then download.

    I first used a file to store the username, user ID, and user password, and called that file using AJAX, storing the information in an array. When the user enters their ID and password, if it exists in the array, they log in successfully; otherwise, the login fails!

    Currently, my method is to store multiple user attributes in JSON format in local storage, and I want to save the records when the user leaves or finishes the game. The next time they return to the game, the system can recognize the user and restore their multiple attributes.

    How do I read the data stored in JSON format in local storage? There are still some issues that I haven't been able to resolve! Or would you recommend another method for storing and reading the data? Thank you very much!

  • Hi.

    You can use different names when you save each user's data to local storage, then after selecting a name, load exactly that user's saves.

    But.

    I would do via array or dictionary, store all variables for each player there, then after selecting a name load the desired array string into global variables.

    HI~I'm using Dictionary to store data!

    And now I'm curious about how to load these data so that I can identify and recover each user's game progress. Could you give me some advices? Thanks a lot!

  • "I am creating a game where certain values need to be stored individually for each user and restored to the previous game state when they return.

    For example:

    User A Mood: 50 Health: 35 Hunger: 65

    User B Mood: 30 Health: 45 Hunger: 25

    Could you please advise on how to achieve this? Thank you so much!

    some info:

  • I am creating a game where certain values need to be stored individually for each user and restored to the previous game state when they return.

    For example:

    User A Mood: 50 Health: 35 Hunger: 65

    User B Mood: 30 Health: 45 Hunger: 25

    Could you please advise on how to achieve this? Thank you so much!

  • 14 posts