ecb247247's Forum Posts

  • Hi,

    I need a way to send the player's username & password from my website to the game after they login.

    Right now the player's have to login on each game, but it would be more easy to login once on the website and have access to all the games without having to login again.

    I was thinking sending the login details as a variable through the browser but not sure how to do that and I don't think it would be that secure either.

    If anyone has any ideas I would greatly appreciate it.

    Have a great day!

    Regards,

    Edgar

  • a galaxy fold is 280 CSS pixels, an iphone 5 is 320, galaxy s5 is 360, so probably 320

    Thank you.

    One last question about this, eh how do I change the screen size once it has been detected?

    Regards,

    Edgar

  • PlatformInfo.WindowInnerHeight

    I don'T feel comfortable going into further detail here on the forums

    Thanks for that, I should manage something with that.

    Would you suggest a minimum size?

    Regards,

    Edgar

  • choose a minimum size that will fit all of your UI and then a maximum size and on resized, check the size of the screen and calculate the most appropriate screen size to use within those numbers

    Thanks for your help!

    How can I check the screen size, does construct have something that can detect the size of the screen?

    Or maybe better, do you have an example you can show me?

    Regards,

    Edgar

  • Hi,

    I was wondering if anyone can give some suggestions on developing for different mobile screens that will be played in the browser, not as an app.

    I have already tried a couple of things, one is that I have the layout to as low as 320x480 then I do scale inner and that fits perfectly on an iPhone 6, but for my Samsung A50 objects pop out of the screen. I have also tried to set the layout to 360x640 which I read is the most common used screen size, but the same issue occur. I have tried all the full screen and scaling options Construct offers.

    I wanted to check here first if anyone has any suggestions before I make a layout for all mobile screens.

    Regards,

    Edgar

  • Not sure how to do using Ajax but the native Multiplayer plugin supports this function.

    You can simply use the conditions like:

    On Peer Disconnected ->

    On Kicked ->

    Thanks for that shepherdgames, the On Peer Disconnected works as I want it.

    So basically I have just implemented that into my existing framework.

    Thanks.

    Regards,

    Edgar

  • Why AJAX? Are you not using the Multiplayer plugin?

    After receiving every successful ping on the host, you can restart a timer, for example "Player1IsAlive" for 10 seconds. When this timer triggers, this means that the host hasn't received a ping from this player for 10 seconds.

    I'm not using the Multiplayer plugin, everything is done with Ajax.

    I looked at your example, but not absolutely sure how to implement it.

    You wouldn't know if there is a way to disable the red cross that closes the game with NW.js applications or playable ad? or even a setting to remove the window around the application? That would be an easy solution, so then the player is forced to click on the leave button.

    Thanks.

    Regards,

    Edgar

  • Don't think it's possible. What you can do is send a ping from each player to the host every couple of seconds or so. If there have been no pings from a peer for some time, you can assume it has disconnected or quit the game.

    Thanks for the suggestion dop2000.

    I have been trying to set up something like this for a while but not sure how the condition will be.

    Basically what I'm trying now is this:

    Every 2 Seconds

    - Add 1 To Ping Variable

    - Send Ping To database

    But I'm struggling with what the condition would be to check if there has been no ping from the other player for some time. I only have the action for getting the ping from the database.

    Every 2 Seconds

    - Request Ping

    - Set Ping Variable To Ajax.Last.Data

    Thanks for the help.

    Regards,

    Edgar

  • Hi,

    Is there a way to detect if a player closed their browser?

    I am working on a multiplayer game and need a way to check if the other player closed the game tab or their entire browser, if that happens and just before they leave I want an action to be sent to the database informing that the other player left.

    I have checked the Browser object but there is nothing there as far as my knowledge goes, and the end of layout command does not do it either.

    I have a leave button in the game but sometimes people will just close their browser instead, and then there is now way for the other player to know what happened.

    Thanks.

    Regards

    Edgar

  • Hi,

    Have anyone been successful in sending data with POST using AJAX to PHPH scripts and retrieving data back to Construct?

    I myself have not had any issues with sending a one time POST then another one at a later stage in the game, but as soon as I started sending POST requests every X amount of seconds since the game I'm working on needs to check for a message every 2 seconds, that's when the problem started with CORS.

    All I have used all a long is this code at the top of my PHP scripts:

    header("Access-Control-Allow-Origin: *");

    This is working, and I am able to play a few game rounds before the game stops and in the console log it's saying that the request has been blocked by CORS since NO Access-Control-Allow-Origin is present, but it is present.

    Then I wonder why don't I get this error in the beginning, and it only comes later in the game?

    I have been reading online on how to stop CORS from blocking the requests and have found bunch of code to add together with the above header, but none of them worked. Even to add some code to .htaccess.

    I seem to have been trying everything for literally months now, and it's really frustrating since this stops me from properly previewing and testing the game.

    If anyone know how to fix this issue I would be very grateful if you could share the fix with me her.

    Thanks.

    Regards,

    Edgar

  • When previewing the game, or running an exported game in browser, press F12 and select Console tab. This is the first place you need to look when there are issues with AJAX.

    Thanks, got it now.

    So I am getting this error message:

    Access to XMLHttpRequest at 'https://gem24.cc/get_host_message.php' from origin 'https://preview.construct.net' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

    I have this code on top of all my PHP scripts and it has always worked.

    header("Access-Control-Allow-Origin: *");

    Do you know if i need to add something else in the script? Do I perhaps need to request data over HTTP instead of HTTPS?

    Thanks.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Have you find the error message in the console log?

    I have not seen any errors in the console log. Where exactly can i see it?

    Thanks.

  • Would anyone else have any other ideas?

    Thanks.

  • Sending AJAX requests on every tick is not a good idea, your server will probably not be able to respond that fast.

    Have you tried checking browser console log? When there are any issues with AJAX, you can usually find an error message in console log.

    Thanks for the response dop2000.

    I didn't find any error message in the console.

    Would you recommend another way other than placing it every tick? I was also thinking that since I have about 6 - 7 requests running simultaneously the reason they stop is because the server cannot respond to so many requests at one time. But for example when the player makes a move the opponent needs to have a request that checks for the message from the player as often as possible or else the game will be delayed if I have a request on lets say every 5 seconds to give the server time to respond. I also thought it could be poor connection on my side, but the network is fine and still some of the requests are able to get through.

    I would appreciate any ideas you might have. Perhaps a POST command would work more sufficient? Eventually I have to change all the requests to POST because I have to post the username of the players to make sure they are receiving data only for their hosted game, to not interfere or accidentally update other games.

    Thanks.

  • Hi.

    I am working on a multiplayer game where both player and opponent is using a request AJAX command to get data from the database, can for example be that it gets info if both players are ready to start a new game and so on... So what happens is after a few games some of the requests (never all of them at the same time) seems to stop and the game stops because its waiting to receive the data before continuing. Sometimes after waiting a while 30 sec - 1 min the request resumes and the game continues, while other times it is stuck forever.

    I am using the request command on every X amount of sec and tried to have it on its own and inside a every tick command, and both are producing the same results.

    Sometimes I am able to play a game for a couple of min without anything happening, but sooner or later it always happens..

    I know it is the request command as I have used "On Error" and whenever there is an error with the request I have added a custom text that shows up always when the game stops.

    I wonder if anyone of you are familiar with AJAX request and have had this issue before, and maybe knows some suggestions I could try to fix it.

    Thanks a lot.

    Regards,

    Edgar