AnD4D's Forum Posts

  • So this is what I have...

    But I have no idea if it'll work or not, as I do not know the name of what Gamee stores the save data as.

    The log I use at the top simply doesn't do anything, so I can't even take a peek at the JSON.

    I just guessed at "save" because why not? :D

  • From what I can tell, there's no way to test the save state mechanic. Anyone managed to have any luck with that?

    I have created the data that needs to be saved, and can submit that data as save data, but I have no way to figure out how to get that data back down to me :D

    Saving isn't really that important... but it sure would be a nice feature...

  • You can get the userID by calling the action "Request Player Data" or Player's Friends userID "Request Social" then you will receive a JSON with the player data :

    > {name:"playerName", firstName: "John", lastName: "Wick", highScore:1000, avatar:url, userID: 123456, coins:1000}
    

    Then you can use the userID for "Request Player Replay" or "Request Player SaveState"

    Check this JS Wiki for better understanding github.com/gameeapp/gamee-js/wiki/advanced-usage or the Construct Documentation : github.com/gameeapp/gamee-js-construct

    The problem is that we can't see any of this data within Construct 2's debug mode. This means that testing these features are like pulling teeth unfortunately. It's a lot of trial and error.

    For example, I have a bug now where it's pulling up the wrong data, but the only way to test it is with the CTRL-SHIFT-J approach, which gives me:

    {"c2array":true,"size":[4,3,1],"data":[[[55681],[55681],["data:image/jpeg;base64,/9j/4RHlRXhpZgAAT

    Etc... etc... The actual amount of this small array's JSON is significantly longer in console, and I mean 84996 characters long...

    This makes searching through all of the code insanely time consuming.

    Is there a reason why we can't have access to the Gamee dummy data while using Construct's debug? Or are we forced to use the emulator?

    *EDIT*

    As a heads up to people, it turns out that the huge amount of data I was seeing was only appearing while trying to access the Avatar icons. If you don't access these (at least during testing) you'll have a lot less data to sort through :)

    Hope that helped!!!

  • Would someone be kind enough to explain me the meaning of" unique id of the player you want to get the save state"

    I have still not begun my work

    I'm not 100% sure! That's something that's bothering me. I know I can grab the user's ID with the other steps, but how I go about using that is a mystery to me :(

    For example, I have no idea if I can save different sets of data; I.E. individual highscores for multiple levels.

  • The most painful thing seems to be that we can't use Construct 2's debug to actually look at the data we're accessing.

    This means that when I'm testing, I have to run it through Gamee's Emulator and create logs all over the place, then open up the console and figure it all out.

    This is doubling the time it would usually take to make the game.

    I just want to be able to grab the data, and look at it within C2.

    I'm currently looking at savestates, and it's really tricky, while in Construct 2, it's really simple.

    Isn't there a way of being able to see my downloaded JSON within Construct's Debug?

  • Ahhh, ok, I may be able to do something for that! Thanks!

  • Say for example I have some data that reads:

    "Bob|25|Male|Tall|Mary|24|Female|Short|Alex|48|Male|Medium"

    I note that each section is divided into 4. So every 4 tokens is a different Name, and the following 3 are details about said person.

    I want to put this data into an array.

    Now, I've found that when I have data such as:

    "Bob|25|Mary|24|Alex|48|"

    I can sort this data easily by counting the "|" tokens and using a for-loop.

    For 0 to TokenCount-1

    if loopindex%2 = 0

    How do I do this kind of thing when I have more than 2 columns for my data?

    Sorry if I'm not making much sense :) Please ask and I'll try again to explain :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Nice one sizcoz !

    Quick question. Why do you have &"" at the end? I haven't tested it, but I was told by a friend today that if I replaced intval with spritef it would then work.

    Interesting that there are so many ways to get the same result.

    Thanks again! I'll implement it soon!

  • Well... I'm confused then...

  • Wait... intval is referring to integer variables. Might that be throwing things off?

    In the example you provided, they're searching for an ID number, aren't they?

  • Is it a publicly hosted dB? If you post the url we could have a play around - this definitely seems like a solvable problem

    Yeah, I was thinking about that, but unfortunately it isn't :(

    I've altered the php file so that it reads:

    $q = intval($_GET['q']);
    $link = mysqli_connect("$host", "$username", "$password", "$db_name");
    
    // Retrieve data from database 
    $sql="SELECT * FROM drawings WHERE name = '".$q."'";
    //DESC LIMIT 10";
    $result=mysqli_query($link,$sql);
    
    // Start looping rows in mysql database.
    while($rows=mysqli_fetch_array($result)){
    echo $rows['name'] . "#" . $rows['artist'] . "|" . $rows['score'] . "|";

    Along with changing the end of my AJAX request so that it has ".php?q=Pickaxe" on the end (as that's one of the words I want to grab.

    Now, instead of grabbing the database, it's grabbing a comma (,) which it's not done before :D

    Obviously that's not what I was hoping for... but a different result is at least interesting.

  • If I’m reading the following correctly, I’d imagine you append ?q=“3” to the end of your get request to complete your example above

    https://www.w3schools.com/php/php_ajax_database.asp

    Hmmm, I see... So it's not quite that simple, as that's basically searching for the ID. So I need to add a GET command to my php, then have the q command linked to something in the AJAX GET.

  • Thank you for the message, but that's pretty much what I already have. My issue appears to be the Construct 2 side of things. Where/How do I tell Construct to tell the Database what word to search for?

    From that example you provided, how do I tell Construct to only download the row associated with the CustomerName Antonio Moreno Taquería?

    AJAX - Request - "https://address/phpname.php?CustomerName=Antonio Moreno Taquería"

    ?

  • I have a database that is accessed using the following php code:

    // Connect to server and select database.
    $link = mysqli_connect("$host", "$username", "$password", "$db_name");
    
    // Retrieve data from database 
    $sql="SELECT * FROM drawings ORDER BY name";
    $result=mysqli_query($link,$sql);
    
    // Start looping rows in mysql database.
    while($rows=mysqli_fetch_array($result)){
    echo $rows['name'] . "#" . $rows['artist'] . "|" . $rows['score'] . "|";
    
    // close while loop 
    }
    
    // close MySQL connection 
    mysqli_close($link);
    ?>
    

    I'm currently using an AJAX GET command such as: "https://address/phpname.php" to grab the data.

    This was fine at first, but the more data I have, the longer it's taking to download it all.

    Does anybody know what changes I need to make to my AJAX GET and the PHP file to grab a specific row, instead of the entire database?

    Say for example I want to grab the row that is titled "Banana" or "John" or "Penguin". What do I need to change the AJAX GET command to so that it states what it's looking for? As well as the changes required to make it work with the php.

    Sorry if this isn't really the right place for such a question, but I've been searching all over the internet, and can't really see how to tie any of their suggestions into Construct 2.

  • Is there a limit to how much data can be uploaded from Construct 2 via AJAX?

    I've created an online database that can support something like 1mil+ characters, and can manually paste data into there without issue. However, when I try to get C2 to post say 100k characters to it, it won't go through. The code is correct in the sense that I can send 5k without issue, but I was just wondering where I might be getting things wrong.

    Is it the AJAX, or might it be something I've done wrong with my database?