Fengist's Recent Forum Activity

  • For the 2 cents it's worth, my advice would be to install nodeJS on your server, become good friends with ChatGPT and write a websocket server. Not only will it allow you to communicate with your clients it'll allow you to do fun stuff like capture their IP address and stuff it into databases.

  • And for those wondering how this preflight check works, here's the PHP code I used. If this is called pretty early in your code, it'll keep the overhead lower. In wordpress I hooked it into the init.

     public function pre_flight() {
     	// Allow requests from any origin
    	 header("Access-Control-Allow-Origin: *");
     	// Handle preflight (OPTIONS) request
     	if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
     		// Specify the allowed headers
     		header("Access-Control-Allow-Methods: POST, GET, OPTIONS");
     		header("Access-Control-Allow-Headers: Content-Type, Authorization");
     		// Set the content type for all responses
     		header("Content-Type: text/plain");
     		// Send a 200 response for preflight checks
     		http_response_code(200);
     		exit;
     	}
     }
    
  • It looks like the problem is that since the AJAX plugin added support for 'On upload progress', cross-domain requests have changed from simple requests to "preflighted" requests. These make an OPTIONS request before carrying out the real request. It looks like your server is configured to respond with Access-Control-Allow-Origin: * for GET requests but not OPTIONS requests, so it now fails with a CORS error as the preflight request is not allowed. So I don't think it's a bug, it's just that the way requests are made has changed, and you now need to update your server configuration. There's more information in the MDN guide on CORS and I added a note about this to the AJAX manual entry.

    You are correct. It is the CORS preflight.

    But, that brings up the request I made to lock a version into the apps. I'm using wordpress as a server. Now my c3 game is gonna bang on the server twice for what amounts to 1 request. Thus, wordpress is going to load twice per request. I don't need a preflight check. If I could lock 407 into my apps setting it would prevent this double-tap.

    That or can you add a setting to Ajax to prevent preflight?

    Thx

  • The only change was the addition of the 'On upload progress' trigger, which should not have affected any existing projects at all. I'm afraid it's impossible to say any more without the details provided by a bug report, as we need that information to be able to investigate.

    Again, having issues getting signed in to Github. Here's what I can tell you:

    Here are 2 c3p. Both are identical. One in 416, one is 407

    drive.google.com/file/d/1u9h63j1Pbh53iUt1n4Sn11flneqzOHpN/view

    drive.google.com/file/d/1dp-nLFxixwaLh-Rxne4u2vb_ajZVJGZu/view

    Both look like this:

    I added this line to my PHP class right at the top of the __construct function for my class that handles communication. This logs the output of the ajax post to the debug log.

    error_log(print_r($_POST,true));

    When I run this c3p in 407, I get this correct response in my debug log:

    [20-Nov-2024 23:41:00 UTC] Array ( [command] => connection_check [PV] => 1.0.0.0 [N] => Ajax 407 [SH] => Layout 1 )

    When I run the same code in 416, I get this in the debug log:

    [20-Nov-2024 23:40:59 UTC] Array ( )

    This indicates to me that for whatever reason, the 416 version is not passing the post data to my php file. In 416, this ends up generating a CORS error as there's no post data to process so it sends back nothing, which is expected. In 407, this runs fine with the c3p reporting success and no console errors.

  • I was hoping to see that selectability on the apps. Right now I can select latest stable or beta.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Would this be possible. I've been working on a game for months... no years... just keep putting it down and picking it back up. Today when all of my Ajax calls failed after a forced upgrade it occurred to me just how nice it would be to stick with one stable version until my project is complete and then decide if I need to rummage through the code to upgrade versions.

    I know other IDE's do this, like Unity. They don't force an upgrade on the end user. It would be nice if the app on my phone and desktop didn't force an upgrade so that I wasn't forced to go use a specific browser version.

  • Ok, so I went to GitHub to post this bug and it's whole 2fa thing has gone over the top. You'll pardon me if I don't spend 2 hours of what little free time I have getting THAT to work.

    This worked fine in 407.2 earlier today on the desktop app. My desktop app upgraded to 416 and now this falls over to the Ajax any error with an error code of 0. Before my phone app upgraded, I loaded the last autosave and it worked fine. As soon as it upgraded to 416, Ajax error. I open the last autosave in the browser 407.2 and it works as intended.

    And it's not just this Ajax call. Any event sheet that I have with an Ajax call in the system on load fails with an error code of 0 if I try to run with it as the main event sheet.

    Did I miss something about Ajax in the patch notes??????

  • Ajax request is returning me an array and setting it into JSON

    How to take the object itself from JSON, which has an array with objects inside, and extract the value from it by key?

    i want to write generator of shop cards from this data

    for example in this array is 6 items(objects) with their own data

    i need to generate 6 shop cards with this data

    is there any methods in construct or with JavaScript ?

    The easiest way I've found is to have your json contain a key/value pair where the value is a simple csv. Then, create an array and

    -> MyArray: Split string JSONValue with separator "," (type Number)

    That'll create a basic 1 dim array.

    If you have a pure JSON of the data you could also use MyArray.Load then enter var that contains the json.

    You could do your ajax call, make the value of a key to be the json you want to load, assign that value to a variable and then, load that variable into the array.

  • As you know Construct is great for teaching the basics of coding in a low code environment. Boolean logic, loops, arrays, etc. I've worked with a number of IDE's from Delphi to Unity. For rapidly developing an app, even with 40+ years of writing code, I keep coming back to Construct to do what I need.

  • Please how can I do it that when a person tries to play a game. My game can extract the game URL and the client id from a URL that has the game URL / client id and turn passes this information to an API endpoint that verifies if the person has access or not

    It lets the person play if it's successful but if the person doesn't have access, an error message is displayed

    What you're asking for is a user management system. And it's a bit more complicated than just passing a client ID. Anything that can be stored on the client, like a user ID, can be accessed and changed.

    There are a few ways to handle this. One is with Firebase and Google logins. I have no experience with either of those but lots of C3 creators use them.

    I opted for what you're describing with is an API to my own server and I wrote the code in PHP using MySQL. This took a good bit of work because you're going to need to handle user names, passwords, hashing, nonces, salting, email verification, forgotten passwords, account creation, etc.

  • You can do everything you want (memory limitations excepted) by using arrays. You don't need SQLite or Mysql or PHP. What I was suggesting was an easier way to generate the data for those arrays. You can always enter them manually. One thing to consider to reduce memory usage is to procedurally create an array map of your level then use that array to draw your level. Here's an example I did years ago using I think 12 image tiles to generate a procedural map. The array to create the map is just numbers.

    construct.net/en/forum/construct-3/your-construct-creations-9/procedural-archipelago-every-146271

    and the working demo:

    twistedvoid.com/c3examples/Castaway2

  • See the Learn JavaScript in Construct course or the quick-start guide which covers the basics of accessing objects from JavaScript. I'd also recommend using TypeScript which will catch coding mistakes like this for you so probably save a lot of trouble.

    Thanks Ashley. I try really hard to avoid using direct JS as I'm not that good at it. I have so many languages and API's in my head now for this and that IDE that I end up trying to jam Pascal into PHP code.

Fengist's avatar

Fengist

Member since 6 Nov, 2015

Twitter
Fengist has 5 followers

Trophy Case

  • 9-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • x3
    Coach One of your tutorials has over 1,000 readers
  • x2
    Educator One of your tutorials has over 10,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

16/44
How to earn trophies