RalfD's Forum Posts

  • 10 posts
  • Many thanks for the reply. I will take a look on the page you mentioned.

  • Hi,

    It should be possibel to set up multiple variations of 1 game in multiplayer. Let's say the game is called 'hello world'. Multiple 'rooms' of this game can be hosted and then be joined by peers I asume? The host makes a new game/room by giving it a name and peers can join randomly or by giving in the exact game or code to enter. Am I correct that this is possible?

    If this is the case my question is this: How can I receive the info of a single game/room and see how many peers have joined a room/game? Is this possible and how is this done? How to check how many games/rooms are active etc?

    Any ideas? I hope you can help me out a bit.

  • What you say is correct: when person 'x' is choosen in a list, data of this person is shown. If person 'Y' is picked in the list, data from person 'Y' must be shown. I've tried your idea only the provided code doesn't seem to do the trick.

    I've seen the tutorials you mentioned. I've used one of them for the PHP part. Any other ideas on how to achieve what i want/need?

    Again tnx for the help!

  • Thanks for your reply,

    I've already tried that and for just one name that's ok. In the list there are all different names. So this is a variable.

    How to set the code that when 'x' name is choosen, that line pops up from the database

    any ideas?

    kind regards

  • Hello,

    Let me begin with the famous words: "I'm not a coder "

    I'm wondering if somebody here knows the answer for my current issue:

    I would like the following:

    I have a list. This list contains names. When the user chooses, let's say, the name 'John Doe' construct 2 calls a PHP file and it echos the row that contains the name 'John Doe' and underlying tables like 'scores' etc.

    What I currently have in my 'get php file' is:

    $sql="SELECT * FROM scores ORDER BY score DESC LIMIT 100";
    $result=mysql_query($sql);
    
    // Start looping rows in mysql database.
    while($rows=mysql_fetch_array($result)){
    echo $rows['name'] . "|" . $rows['score'] . "|" . $rows['data1'] . "|" . $rows['data2'] . "|" . $rows['data3'] . "|" . $rows['data4'] . "|" ;[/code:3bsb2lxc]
    
    Construct is set up that It provides the right data in the app for calling the rows. Only for the person with the highest score. When I select a different name, nothing happens.
    
    Anybody any ideas on how to resolve this?
    
    Many thanks in advance!
    
    Kind regards
  • hello,

    Download Android Studio. You can build an APK with it. Then upload this APK to Adobe Phonegap to build the complete APK release for example android. Then go to the playstore for developers and upload the APK release file created with Phonegap.

    Good luck!

  • Hi again,

    A friend of mine mentioned the following:

    $sqlInsert = mysql_query("INSERT INTO `$db`.`fil078` (`id`,`name`,`score`) VALUES ('','$name','$score')");
    $sqlUpdate = mysql_query ("UPDATE `$db`.`fil078` SET score = score + '$score' WHERE name = '$name';");[/code:i3t9s6lj]
    
    They work when used seperatly. When combined only the INSERT query works.
    
    Any idea on how to combine these queries?
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Again tnx for your reply.

    I asume using an ID number is ofcourse better to avoid conflicts. In this case it doesn't matter since it will be a small group of people who'll be using/playing it.

    The thing is don't know how to make the right query/function (or whatever it takes ) on the database so that scores are added up incase of an already excisting name.

    Any ideas on how to do that?

  • Thank you for your reply.

    After spending some time searching and trying I almost got it to work. I have found the following PHP file for saving a name & score:

    <?php
    
    $db = "";//Your database name
    $dbu = "";//Your database username
    $dbp = "";//Your database users' password
    $host = "";//MySQL server - usually localhost
    
    $dblink = mysql_connect($host,$dbu,$dbp);
    $seldb = mysql_select_db($db);
    
    if(isset($_GET['name']) && isset($_GET['score'])){
    
         //Lightly sanitize the GET's to prevent SQL injections and possible XSS attacks
         $name = strip_tags(mysql_real_escape_string($_GET['name']));
         $score = strip_tags(mysql_real_escape_string($_GET['score']));
    	 $sql = mysql_query("INSERT INTO `$db`.`fil078` (`id`,`name`,`score`) VALUES ('','$name','$score');");
         
         if($sql){
         
              //The query returned true - now do whatever you like here.
              echo 'Your score was saved. Congrats!';
              
         }else{
         
              //The query returned false - you might want to put some sort of error reporting here. Even logging the error to a text file is fine.
              echo 'There was a problem saving your score. Please try again later.';
              
         }
         
    }else{
         echo 'Your name or score wasnt passed in the request. Make sure you add ?name=NAME_HERE&score=1337 to the tags.';
    }
    
    mysql_close($dblink);//Close off the MySQL connection to save resources.
    ?>[/code:1l7ga20t]
    
    I managed to get it to work for 50% of my needs. What I still would like to achieve:
    1. When a new player uploads his/her score that he/she pops up in the highscore list (this happens now)
    2. When a excisting player uploads his/her score the score is added to the amount he/she already has (not happening now)
    
    Hope someone can help me with this
  • Hello there!

    I've looked around for my issue. I've found several tutorials and forum topics about highscores with AJAX and PHP. In other small games I've made that all works great. What I'm trying is not to achieve a new score but to add a score on top of a already excisting one. I'm not a coder, if someone gives me a head start that would be great to start with!

    What I would like to achieve is the following:

    On the inputpage I have a 'list' called names and a 'list' called numbers. What I would like to achieve is then when I press a button the amount in the list 'numbers is added to the present score in the MYSQL database of the person mentioned in the 'list' names. If the name doesn't exist it creates one.

    Other thing is how to subtract and how to reset all scores to 0 in the database and how to show the scores of all persons on a page.

    Many thanks in advance!

    Ralf

  • 10 posts