Fengist's Forum Posts

  • Ok, let's start eliminating the obvious.

    Is the function and Char on the same event sheet?

    I just did this and it worked as expected.

    + Button: On clicked

    -> Button: Set ButtonVariable1 to Functions.DoSomething

    -> Text: Set text to Button.ButtonVariable1

    * On function 'DoSomething'

    -> Functions: Set return value "This is the return value"

    Maybe because he's not lying. While the multiplayer plugin may work, I've found it to be wholly inadequate for doing much more than a lan game. Were I to write a multi-player app that were going to work over the internet, I wouldn't even look at that plugin, I'd write my own websocket server (In C# mind you, not JS).

    IMHO, He answered the question honestly and with a link to a very interesting article on server design.

    Either way, at least he didn't bomb the thread by asking people to donate cash in order to get an answer.

  • Wow, I wouldn't have come up with that one as an answer.

  • Is your website HTTPS?

    My god I'm beginning to sound like a broken record.

  • that looks correct.

    But please, post your code as JS. It's much easier to read.

  • No problem. I'm again going to refer to an old online game Netrek. The way it worked is that players could join and leave at any time. When they first joined, the were placed in a wait queue. If there were other players and bots in the game, it would wait for a bot to get killed (or kill a bot if no players were near it) and then replace that bot with a player. If there were no players in the game, it would kill off a bot and load the player.

    Just something to think about. But without promoting your game, you'll just have bots running around.

  • I haven't made a mobile game in years so my knowledge of them is limited but:

    As far as I know, all Construct apps run inside a browser, whether they're mobile or not and as far as the browser is concerned, you're running it inside a 'window'. Thus, and I'm assuming here, that by telling the browser to close the window, it should exit out of the app.

    Did it work?

  • And I believe (not positive) there will be another problem.

    You have the global var count set as an integer. I'm pretty sure AJAX.LastData is considered a string which means you'd need to convert it like so:

    Set count to int(Ajax.LastData)

  • I see several problems here. First, you're not binding anything to your SQL statement so it's searching for:

    SELECT id FROM members where username = ?

    It's looking for a user who's name is ?

    Next problem, you have your AJAX query malformed. It's sending exactly this:

    http://localhost/login.php?name=&Username&

    Which means, your $_GET will = &Username&

    This is how the URL should look:

    "http://localhost/login.php?name="&Username

    Notice the quote locations? Here, you're telling Construct to add in the contents of the variable Username. You don't need the & at the end unless you're adding something else to the query.

    Next problem. You're trying to use the $_GET like an array but you're saying you just want the ID of a specific user. Plus, you're passing the $_GET as a string and you're not 'imploding' it into an array.

    And finally, you're not telling MySQL to look for an array of names by using the "IN" statement, you're telling it to use the "WHERE" statement which probably would confuse it and therefore, your $stmt->execute would fail and return nothing.

    If you just want the ID of ONE user try this:

    $sql = "SELECT id FROM members where username = ?";
    $stmt = $base->prepare($sql);
    $stmt->bind_param("s", $_GET['name']);
    $stmt->execute();
    $result = $stmt->get_result();
    $row = $result->fetch_object();
    echo $row->id;
    

    Assuming that your usernames are unique, it will return just the first occurence of the $_GET that it finds.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • -> Browser: Execute javascript "window.close();"

  • Whether there was a change to the AJAX plugin or not is irrelevant. You are trying to load insecure data from an HTTP into secure data from an HTTPS. This may have worked in the past but it's a security hole that all browsers are fixing and I imagine, so is the Construct team.

    If you are going to continue to use AJAX you are going to need an HTTPS certificate.

    -> AJAX: Request "http://www.mysite.com/folder/home.txt" (tag "url")

    One of the things Chrome is doing now is to block access to the entire site and display a shield icon in the address bar to notify the user that the site is trying to load insecure data from an HTTP site. It's forcing users to click on that shield in order to load that insecure data. Because most Construct apps do not have an address bar the user does not see it and can't click on it. Therefore, it gets blocked.

    And, if anyone is going to use WebSockets, this applies to it as well. If you make a ws:/ WebSocket server and try to connect inside of Construct, Chrome will block access and display that shield. You'll need a wss:/ server.

  • My response to the same problem from another guy:

    construct.net/en/forum/construct-3/general-discussion-7/construct-ajax-crossdomain-144008

  • Found it.

    This kinda explains it. It's called 'mixed content'

    developers.google.com/web/fundamentals/security/prevent-mixed-content/what-is-mixed-content

    It's not that it isn't supported, it's a security hole for HTTPS. When you go from a HTTPS site and make a request to a HTTP site, it falls under the 'mixed content' and gets blocked.

    If you made the AJAX call from an HTTP site to another HTTP site, it would likely have gone through without issue. It was the call from HTTPS to HTTP that caused the problem.

    preview.construct.net is an HTTPS site.

  • I do not have HTTPS certificate on the server. Maybe this is a problem?

    That is almost definitely the problem.

    I'm going to venture a guess that the J5 is using an older version of Chrome that allowed you to access non secure sites but it doesn't give the http origin as a security measure, which would normally get blocked by AJAX being off-site. That's most likely is why you're seeing it's IP and not an origin. You may have been allowed to run your previous script as it allowed any site to run it. My script only allows specific sites to access it so it would have failed to run.

    The J6 and the desktop are using newer versions of Chrome which are simply refusing to let you go from a secure site (https://preview.construct.net) to your insecure site (http://www.mysite.com) which is why they're not even attempting to make the AJAX call.

    It's the same problem the other guy was having in the post I linked to: trying to make an AJAX call to a http site.

  • And this brings up another question. If you're accessing it from the phone's browser, which browser are you using? The Samsung browser or Chrome?