save system please help

0 favourites
  • 4 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Hey, I am making an online multiplayer platform/shooting game. Your character can shoot the other person playing and he can shoot you. At the end of the level, you receive coins and can spend them on items. How do I save and load only the player name/amount of coins they have??? I tried researching arrays and dictionary, but it only confused me further. here's what I have for collecting coins during the level. When I try to play it after saving the value c, it says NaN

  • the first string, you have to change in Webstorage.Localvalue("amount")

    you never make a C local value.... this is why you get NaN

    anyway, I will repeat everytime, that kind of savegame is not sure, is very easy to hack if you don't make encrypt or some secure string, and can be deleted by cleare the cache of the browser....

    I suggest to use AJAX and a database to store the variable, the best savegame system...hard to hack, and you can open the savegame with differente device

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I suggest to use AJAX and a database to store the variable, the best savegame system...hard to hack, and you can open the savegame with differente device

    So, do I need to rent server space for this?

    Also, how would saving and retrieving that data look like on an event sheet?

  • >

    > I suggest to use AJAX and a database to store the variable, the best savegame system...hard to hack, and you can open the savegame with differente device

    >

    So, do I need to rent server space for this?

    Also, how would saving and retrieving that data look like on an event sheet?

    try to find some database free, I belive exsist some service who give to you a free database... but I'm not sure...

    you need to use AJAX plugin, and of course you have to use php to save/update value in your database...

    in event sheet looks like:

    in the action of the event, select AJAX > Post to URL

    "tag" = make some names for the tag, you can see if the AJAX finish to works, or has some error...

    "URL" = url of the php file, for example, if your "example.php" (if is in the same folder of the game, index.html)

    "Method" = POST.

    "data" = this is the data that you want to send to a php file, so for example, if the player register an account in your game (at the start of the game) you have to send user,mail,password like this:

    "username="&usernameinC2&"&"&"password"&passwordinC2&"&"&"email="&emailinC2

    with this, you will send the 3 variables to a php file... and now, when you have the variable, you can make a script who send the data on the database... and to read these variables in php, insert this:

    $username= $_POST['username'];

    $password= $_POST['password'];

    $email= $_POST['email'];

    now, you have to know some PHP.... for example, to make works this perfect, you have to:

    --make a function (in php) that check if an email or user exsist before the registration (and in the database select email/user unique)

    if exsist, echo an error like "user already registered", so, when the AJAX retrieve data in construct2, you can menage the situation.

    --make sure the send data in a database (like mysqli_real_escape_string)

    --when the php file register the user, if the user start with some coins or something else, just insert data in the database...etc

    --in the LOGIN.php, check if the password insert is correct with the e-mail/username, if isn't correct, just retrieve a data as before for the registration.

    if everything is working, load the data from the database from that user...

    now, if you don't know how made it, you can find some tutorial/a full example how to make a php registration/login... contruct2 just send and retrieve data...

    when you are sending data with the "Post to URL ", you can see what you retrive in the condition:

    AJAX > On completed , and now, you can set a text with the AJAX.lastData, and see, if the php works well.

    if you have more question just tell me

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)