Odin's Recent Forum Activity

  • Anybody have a suggestion?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hello,

    I'm working in a game where the players have to loggin and they connect through ajax/PHP to a MySQL database, and then they get all the game stats. My problem is that in this very moment I can't avoid that 2 (or more) people connect to the same player account, so I want to verify if someone is allready connected to avoid to make simmultaneous connections.

    I thought to put a value in the database table called "connected" as token, so then, when the player is connected I changed the value to 1 (or true) but I don't know how to change it to 0 (or false) when the player loggout or close the navigator, so it keeps allways "connected".... My server is a normal web server (for the moment), so I can't install any application...

    Any ideas?

    thanks for your help.

  • Finally i found the error. The php code need "header("Access-Control-Allow-Origin: *");" in their header

    Rookie mistake , thanks for the help.

  • NaN means Not a Number. Save the output in a text variable and check what it says. Also I would suggest to use PDO rather than mysqli.

    If I change the variable to text the return is "" too, I think the problem is in the request but I can't find the error.

  • yeah remove the single qoutes in the data entry.

    Resulting in : "distanceTotal="&distanciaTotal

    To add more

    "distanceTotal="&distanciaTotal&"&playerID="&SomeConstruct2Var

    Result would look like

    "distanceTotal=100&playerID=10"

    Hello again, first of all so many thanks you !!

    It seems I can connect properly to send data to mysql db, my problem now is that I can't acces to data from the db!! My problem now is in the loging.

    My construct call is this:

    "http://myweb.com/myproject/php/login.php?nombreUsuario=" & nombreUsuario & "&passUsuario=" & passUsuario[/code:3dvx20px]
    
    An this is my php wich is actually working properly (i tested it):
    
    [code:3dvx20px]<?php
    	// Variables 
    	$nombreUsuario = $_GET['nombreUsuario'];
    	$passUsuario = $_GET['passUsuario'];
    	
    	$con=mysqli_connect("blebleble","bliblibli","blobloblo","blublublu");
    	// Check connection
    	if (mysqli_connect_errno())
    	{
    	 echo "Failed to connect to MySQL: " . mysqli_connect_error();
    	 }
    	$qz = "SELECT idUsuario FROM usuarios_aep where nombreUsuario='".$nombreUsuario."' and passUsuario='".$passUsuario."'" ;
    	$qz = str_replace("\'","",$qz);
    	$result = mysqli_query($con,$qz);
    	
    	if ($result->num_rows > 0) {
    		while($row = $result->fetch_assoc()){
    			echo $row["idUsuario"];
    		}
    	} else {
    		echo "Error al acceder a los datos: " . mysqli_error($con);
    	}
    	mysqli_close($con);
    ?>[/code:3dvx20px]
    
    I try to get as data "idUsuario" and I save this id in a variable, but when I run my project in debug mode the content of that variable is NaN (not a Number). I'm not sure what is happening, any idea??
    
    thanks.
  • yeah remove the single qoutes in the data entry.

    Resulting in : "distanceTotal="&distanciaTotal

    To add more

    "distanceTotal="&distanciaTotal&"&playerID="&SomeConstruct2Var

    Result would look like

    "distanceTotal=100&playerID=10"

    Hello again, first of all so many thanks you !!

    It seems I can connect properly to send data to mysql db, my problem now is that I can't acces to data from the db!! My problem now is in the loging.

    My construct call is this:

    "http://myweb.com/myproject/php/login.php?nombreUsuario=" & nombreUsuario & "&passUsuario=" & passUsuario[/code:3tqmklo3]
    
    An this is my php wich is actually working properly (i tested it):
    
    [code:3tqmklo3]<?php
    	// Variables 
    	$nombreUsuario = $_GET['nombreUsuario'];
    	$passUsuario = $_GET['passUsuario'];
    	
    	$con=mysqli_connect("blebleble","bliblibli","blobloblo","blublublu");
    	// Check connection
    	if (mysqli_connect_errno())
    	{
    	 echo "Failed to connect to MySQL: " . mysqli_connect_error();
    	 }
    	$qz = "SELECT idUsuario FROM usuarios_aep where nombreUsuario='".$nombreUsuario."' and passUsuario='".$passUsuario."'" ;
    	$qz = str_replace("\'","",$qz);
    	$result = mysqli_query($con,$qz);
    	
    	if ($result->num_rows > 0) {
    		while($row = $result->fetch_assoc()){
    			echo $row["idUsuario"];
    		}
    	} else {
    		echo "Error al acceder a los datos: " . mysqli_error($con);
    	}
    	mysqli_close($con);
    ?>[/code:3tqmklo3]
    
    I try to get as data "idUsuario" and I save this id in a variable, but when I run my project in debug mode the content of that variable is NaN (not a Number). I'm not sure what is happening, any idea??
    
    thanks.
  • After connecting, and after you have done the INSERT query, with your current approach with using a Ajax GET request, the following should work.

    [quote:2jh1h120]$query =("UPDATE usuarios_aep SET distanciaTotal = '".$distanciaTotal."' WHERE nombreUsuario = '".$_GET['nombreUsuario']."' AND passUsuario = '".$_GET['passUsuario']."' ");

    $mysqli->query($query);

    I would suggest switching to post methods, otherwise it would become very easy to cheat

    I come back with more problems!!

    Actually I have this php in my server, I tested it from chrome and it works, makes the UPDATE correctly.

    <?php
    	// Variables 
    	$nombreUsuario = "XXuser";
    	$passUsuario = "XXpass";
    	$distanciaTotal = $_GET['distanciaTotal'];
    	
    	$con=mysqli_connect("blablabla.com","blebleble","bliblibli","blublublu");
    	// Check connection
    	if (mysqli_connect_errno())
    	{
    	 echo "Failed to connect to MySQL: " . mysqli_connect_error();
    	 }
    	$qz =("UPDATE usuarios_aep SET distanciaTotal = '".$distanciaTotal."' 
    				WHERE nombreUsuario = '".$nombreUsuario."' 
    				AND passUsuario = '".$passUsuario."' 
    			");
    			
    	if (mysqli_query($con, $qz)) {
    		echo "Record updated successfully";
    	} else {
    		echo "Error updating record: " . mysqli_error($con);
    	}
    	mysqli_close($con);
    ?>[/code:2jh1h120]
    
    The problem appears when c2 has send (POST or GET method) the data to php, it seems that I am not sending data at all...  so I think that the problem is in the next images (the AJAX connection) but I don't know how to solve it.
    [img="http://www.therealgeekgirl.com/server1.jpg"]
    [img="http://www.therealgeekgirl.com/server2.jpg"]
  • I want to save one variable every 10 sec in the user row.

    My php code:

    <?php
    	// Variables 
    	$nombreUsuario = $_GET['nombreUsuario'];
    	$passUsuario = $_GET['passUsuario'];
    	$distanciaTotal = $_GET['distanciaTotal'];
    	
    	$con=mysqli_connect("mysql","database","userid","password");
    	// Check connection
    	if (mysqli_connect_errno())
    	{
    	 echo "Failed to connect to MySQL: " . mysqli_connect_error();
    	 }
    	$query =("INSERT INTO usuarios_aep (distanciaTotal) VALUES (".$distanciaTotal.") 
    					WHERE nombreUsuario like ".$nombreUsuario." 
    					AND passUsuario like ".$passUsuario." 
    				");
    	$mysqli->query($query);
    	
    	mysqli_close($con);
    ?>[/code:tb2wf9on]
    
    event "every 10 sec"
    [code:tb2wf9on]"http://fakefake.com/fakefake/php/insertDistanciaTotal.php?nombreUsuario='"&nombreUsuario&"'&passUsuario='"&passUsuario&"'&distanciaTotal='"&distanciaTotal&"'"[/code:tb2wf9on]
  • I mean set the height size of your image to minus, then rotate it and reposition it.

    This will remove of the black line.

    You was right!

    Thanks a lot.

  • I didn't see any black line when playing the game.

    Try to set the tiledbackground Y size in minus: e.g ( -20)

    This will solve the black line problem.

    Sorry, I can't understand your comment, are you saying I need invert the Y axis of the tiled background?

    That is the line like I can see in a 22" android tablet:

    http://therealgeekgirl.com/img/blackline.jpg

    And this is the 256x256 tiledbackground:

    http://therealgeekgirl.com/img/parallaxline.png

    Can you say me what property I need to change in the panel of the tiled background?

    Thanks

  • Hi everybody, I have a new rare problem I think its easy to solve. I'm doing two runner games with parallax tiled background:

    http://therealgeekgirl.com/torrijos/

    http://therealgeekgirl.com/felipe/

    The problem comes when I export the proyects to Android and appears several lines like 1px black higth in the tiled background (some times at top and other times at bottom of the tile) if you play in a tablet, also the lines can appear in some monitors/resolutions.

    Any solutions?

Odin's avatar

Odin

Member since 16 Mar, 2014

None one is following Odin yet!

Trophy Case

  • 10-Year Club
  • Coach One of your tutorials has over 1,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

14/44
How to earn trophies