savvito123's Recent Forum Activity

  • You do not have permission to view this post

  • Sorry my fault.

    I thought was for a single issue.

    So a friend send me his C2 project and this error appear when i try to save the project to Dropbox.

    I open it using C3.

    I think is have to deal with the assets, it didnt find their urls.

    It let me save it as a single file but not to Dropbox.

  • first time i see that

  • Image point position maybe

  • You do not have permission to view this post

  • For a game with 4 players. When the host disconnect or leave the room, who is able to send to the other peers who is win or lose?

    Its a card game with 2 teams of 2 players in each team.

    If the host disconnect and is at team A then i have to send wins to the leaderboard for the 2 players in Team B.

  • A quick answer to you is, do you set the width of the array to the entries you want to load?

  • Update:

    On start of layout you have to set the "uniqe" string variable to the fb instant game uniqe id.

    Here is a way to fill your array

    Also when you retrieve images you have to URLdecode it.

    Good luck with that and remember, if you try to edit some php files search for MySQLi and not for MySQL.

  • Hello,

    I will try to make it as soon as i can.

    It means you have allready create a database somewhere (i use hostinger) it accept PHP 7.2.

    On start of layout check if that is the first run of the game (use a global variable "firstRun" = 0)

    and run this action.

    saveinfo.php must create it and save it to a folder to you site file manager.

    DOMAIN_SCORE variable is your filepath.

    We run this because we do not want every time the game end and return to menu to run the saveinfo.php

    This php file look if a player compared by his uniqe id (uniqe id is the fb instant game id or whatever platfor you want) allredy exist.If its not exist it create a row in your database with (uniqe,name,pics,wins and loses)

    Notice that i delete the first and last line (<php.....?>) because want let me insert it.

    saveinfo.php

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

    $servername = "localhost";

    $username = "***********";

    $password = "**************";

    $dbname = "*************";

    // Create connection

    $conn = new mysqli($servername, $username, $password, $dbname);

    $name = strip_tags(mysqli_real_escape_string($conn, $_GET['name']));

    $uniqe = strip_tags(mysqli_real_escape_string($conn, $_GET['uniqe']));

    $pics = strip_tags(mysqli_real_escape_string($conn, $_GET['pics']));

    $win = strip_tags(mysqli_real_escape_string($conn, $_GET['win']));

    $lose = strip_tags(mysqli_real_escape_string($conn, $_GET['lose']));

    // Check connection

    if ($conn->connect_error) {

    die("Connection failed: " . $conn->connect_error);

    }

    $sql = "SELECT id, name, uniqe, pics FROM scores WHERE uniqe='$uniqe'";

    $result = $conn->query($sql);

    if ($result->num_rows > 0) {

    // output data of each row

    while($row = $result->fetch_assoc()) {

    echo "id: " . $row["id"]. "uniqe: " . $row["uniqe"]. "pics: " . $row["pics"]. " - Name: " . $row["name"]. " " . "<br>";

    $sql =mysqli_query($conn, "UPDATE scores SET pics='$pics' WHERE uniqe='$uniqe'");

    }

    } else {

    echo "0 results";

    $sql = mysqli_query($conn, "INSERT INTO scores (name, uniqe, pics)

    VALUES ('$name','$uniqe','$pics');" );

    }

    $conn->close();

    On AJAX request "PostScore" complete we run this action

    This will retrieve a number of entries you want.

    getscores.php

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

    include 'login.php';

    // Connect to server and select database.

    $con = mysqli_connect($host, $db_username, $db_password, $db_name);

    // Retrieve data from database

    $sql = "SELECT *

    FROM scores

    ORDER BY score DESC

    LIMIT 100000000"; // The 'LIMIT 100000000' part will only read 100 scores. Feel free to change this value

    $result = mysqli_query($con, $sql);

    // Start looping rows in mysql database.

    while($rows = mysqli_fetch_array($result)){

    echo $rows['name'] ." ". $rows['score'] ." ". $rows['pics'] ." ". $rows['uniqe'] ." ". $rows['lose'] ." ". $rows['win'] . "|";

    }

    // close MySQL connection

    mysqli_close($con);

    You notice include 'login.php';

    Its a file that you create also in your file manager so no need every time to enter your informations.

    login.php

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

    $host = "localhost"; // Host name

    $db_username = "***********"; // Mysql username

    $db_password = "***********"; // Mysql password

    $db_name = "**************"; // Database name

    $db_table = "*********"; // Table name

    After you retreive the AJAX "getscores" request save the information to an array and run this action.

    ran.php file will retreive your inforamtion

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

    $servername = "localhost";

    $username = "***********";

    $password = "****************";

    $dbname = "****************";

    $mysqli = new mysqli($servername, $username, $password, $dbname);

    $uniqe = strip_tags(mysqli_real_escape_string($mysqli, $_GET['uniqe']));

    if( $result = $mysqli->query( "SELECT * FROM scores WHERE uniqe ='".$uniqe."'") )

    {

    while( $row = $result->fetch_assoc() ) {

    echo $row["name"]." ".$row["score"]." ".$row["win"]." ".$row["lose"]." ".$row["pics"]." ".$row["emo1"]." ".$row["emo2"]." ".$row["emo3"]." ".$row["spells"]." ". "<br>";

    }

    }

    After that you need to run this action

    This will run the rank1 php file and this file will rank all the players.

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

    $servername = "localhost";

    $username = "*************";

    $password = "*************";

    $dbname = "*************";

    $mysqli = new mysqli($servername, $username, $password, $dbname);

    $uniqe = strip_tags(mysqli_real_escape_string($mysqli, $_GET['uniqe']));

    $sql3 = $mysqli->query("SELECT * FROM scores ORDER BY score DESC") or die("Could not allocate information!");

    $rank = 0;

    while($row = mysqli_fetch_assoc($sql3)) {

    $rank++;

    if ($row['uniqe'] == $uniqe){

    echo $rank;

    }

    }

    The only think now is to send the score to the database.

    We run this action

    And the savewin php file is

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

    $servername = "localhost";

    $username = "*************";

    $password = "***************";

    $dbname = "***************";

    // Create connection

    $conn = new mysqli($servername, $username, $password, $dbname);

    $name = strip_tags(mysqli_real_escape_string($conn, $_GET['name']));

    $uniqe = strip_tags(mysqli_real_escape_string($conn, $_GET['uniqe']));

    $win = strip_tags(mysqli_real_escape_string($conn, $_GET['win']));

    $lose = strip_tags(mysqli_real_escape_string($conn, $_GET['lose']));

    // Check connection

    if ($conn->connect_error) {

    die("Connection failed: " . $conn->connect_error);

    }

    $sql = "SELECT id, name, score, uniqe FROM scores WHERE uniqe='$uniqe'";

    $result = $conn->query($sql);

    if ($result->num_rows > 0) {

    // output data of each row

    while($row = $result->fetch_assoc()) {

    echo "id: " . $row["id"]. "uniqe: " . $row["uniqe"]. " - Name: " . $row["name"]. " " . $row["win"]. " " . $row["lose"]. "<br>";

    $sql =mysqli_query($conn, "UPDATE scores SET win=win+'$win' WHERE uniqe='$uniqe'");

    $sql =mysqli_query($conn, "UPDATE scores SET lose='$lose'+lose WHERE uniqe='$uniqe'");

    $sql =mysqli_query($conn, "UPDATE scores SET score=(win/lose)*100 WHERE uniqe='$uniqe'");

    }

    } else {

    echo "0 results";

    $sql = mysqli_query($conn, "INSERT INTO scores (name, uniqe, win, lose)

    VALUES ('$name','$uniqe','$win','$lose');" );

    }

    $conn->close();

    Note that you maybe need to change the formula in the last php for sending the score.

    I forgot to mention , when is the first run , "firstrun = 0" run the actions and set the "firstrun to 1"

    When the players return to the menu and the firstrun = 1 just run the getscores php.

  • So how its possible to send some codes while this?

    Im writing about 1 hour here and it want let me upload it.

    Hmmmm, solutions please....

  • Yes, non contexual are not enough.

    I have allready implement a leaderboard in a game that store the fb uniqe id, picture, name, score and rank and retreive it by rank.

    It take time to make a tutorial and now i have No time for make this due to my first work.

    I only work on construct 30 minutes 2 days in a week, so If i found some time this weekend i will send you some informations.

  • If you want to add a leaderboard in your game i suggest you to make your own leaderboard system using ajax and some phps, this would be help you adding leaderboards in any of your games.

    You only need a place to host a MySQL database "i use hostinger" , some phps files and ajax.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
savvito123's avatar

savvito123

Member since 6 Dec, 2017

Twitter
savvito123 has 2 followers

Trophy Case

  • 6-Year Club
  • RTFM Read the fabulous manual
  • Email Verified

Progress

8/44
How to earn trophies