Game replay?

0 favourites
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • Yann no I didn't. Should that theoretically make it easier to send data and then retrieve it?

  • I don't know if you noticed but the 'log' variable... is in CSV (Coma Separated Value)... Just saying :D

    I did, thats why I said he has to change the delimiters in his PHP <img src="smileys/smiley2.gif" border="0" align="middle" />

  • GingerBatMan

    Not at all... Just saying :D

    A string is a string there's no spacial treatment if a string as some coma or not.

  • Weishaupt, Any news? :)

  • Sorry GingerBatMan - I had not had a chance to look at it today :-(

    No bad feelings please - there are days I am just not able to "work" <img src="smileys/smiley11.gif" border="0" align="middle" />

  • Weishaupt, No worries mate. Whenever your feeling good. <img src="smileys/smiley1.gif" border="0" align="middle" />

  • GingerBatMan:

    Try the following PHPs:

    <?php

    // read variables from POST data.

    $username = $HTTP_GET_VARS[name]; <-- DEFINE THE USER??

    $log = $HTTP_GET_VARS[log]; // <-- MODIFY THIS TO SEND THE REPLAY??

    // verify the username is set and not empty

    if (!isset($username) || $username == "") {

        echo "failure";

        exit;

    }

    // verify the log is set and a number

    if (!isset($log) || $log == "") {

        echo "failure";

        exit;

    }

    // format the username and log as a comma delimited row

    $entry = $username . "#" . $log . "\n";

    // append entry to the log file

    if (!file_put_contents("logs.csv", $entry, FILE_APPEND)) {

        echo "failure"; // failed to write to file

        exit;

    }

    echo "success";

    ?>

    ...and...

    <?php

    /** Return a list of top logs. */

    // read variables from GET data

    $num_logs = $HTTP_GET_VARS[num_logs];

    // read each line in logs.csv as a string into an array

    $logs = file("logs.csv");

    // define a comparator to sort items by log

    function compare($s1, $s2) {

        // split the strings by their delimiter

        $a1 = explode("#", $s1);

        $a2 = explode("#", $s2);

        // compare the logs

        return $a2[1] - $a1[1];

    }

    // sort the array of logs

    usort($logs, "compare");

    // output the requested number of top logs

    for ($i = 0; $i < $num_logs && $i < count($logs); $i++) {

        echo $logs[$i];

    }

    ?>

  • Weishaupt, Thanks for this, I understand it quite well.

    Take a look at the capx, I cannot really figure out how to then play the downloaded replay.. There are a few questions within the capx if you wouldn't mind answering if you can.

    Also Is it possible to display a list depending on the username?

    • So for example if a user searched 'Jhon' then it would display a a list of 'Jhon's replays?
    • Or something like corresponding the replay with the scoreboard?

         -> for example the top 100 people in the world, you can view there replay?

    The second one kinda answers itself if the first one is possible. Because you could search for the name depending on the position of the user.

  • first of all, does saving and loading now work?

    ....and where is the CAPX for me to look at?! <img src="smileys/smiley5.gif" border="0" align="middle" />

  • for that kind of stuff, I think it would be better to store the log in database along with user name and scores.

  • Yann, Yeah im actually trying to make a database now.

    But then construct doesn't directly support mysql does it?

    Its still gonna have to be done through php, right?

    What I was planning, Have a mysql database managing a login system, then use the usernames from that to find the replays..

  • Try Construct 3

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

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

    Yeah that's a good way, even if you still can't be sure that the player doesn't manually send score and log.

    And yeah

    C2 game: Ajax Call -> server side php/asp/perl/cgi/etc -> database

    There's no way around that.

  • Even if I couln't have the feature of viewing the replays of the top 100 users, I could still download the actual users replays if i can search the php for a name,

    I dont actually need the login system, But its something that can easily be done with mySql if i can figure out how to make one ;D

  • The whole leaderboard/replay upload/download/management, etc...

    This is all server side there. (so yeah, PHP/Mysql, you need to learn it/them)

  • I come from a programming background. I understand basic PHP, but have not used it in many years.

    When I programmed games from start to finish, I used various web API's instead of things like mySQL database's ect.

    Im currently using a free host and its asking me to select user, and there is none from the dropdown so im really confused :S

    http://dl.dropbox.com/u/51270524/Host.JPG

Jump to:
Active Users
There are 2 visitors browsing this topic (0 users and 2 guests)