h1k3's Forum Posts

  • You can find an example of my working Ajax construct2 at the following link.

    scirra.com/forum/what-am-i-doing-wrong-here_topic56751.html

    Between the php example and the capx in the above link I'm hoping you can get yourself up and running. :)

  • Try the php I had posted earlier and just change the variables around to meet your needs. I know it works because I use it on my server with construct2. If it works you'll have a good starting point that just needs the security stuff put in.

  • I don't think construct2 utilizies the localhost directory path. Change it to the physical http path in the event.

    IE:

    "localhost/killmonster/sanderswin1.php?&score=1"

    to

    "http://colsandersisrad.com/killmonster/sanderswin1.php?score=1"

    I think that may solve your problem. I think the localhost is only for the php side. Thats all I can see in your ajax request. But make sure you add it an on complete event and on error event to make verify the score updated.

  • you know what, are you using godaddy? I am and for some reason it will not let me use localhost. I have to plug in the server address when creating the mysql connection along with the password. Had a freehost before I think it wass fii.me that had the same problem. Maybe try plugging in the server address and password for a trial run? BTW feel free to tell me how to secure my php code. :) I would gladly accept the guidance.

  • ramones,

    I switched checking to two groups, one for x and one for y based on what you thought and you were right. :):):) Thanks bud :)

  • ramones What I want to do is this. Say I enter 1 and 1 for the x and y and set the number of records to 3. I want to first start by filling in positions by the x mark so x1y1,x1y2,x1y3 then when y reaches the record amount set x to the next item and reset y. So x2y1,x2y2,x2y3 The do it again one last time with the x variable set to 3. Then when x and y are both filled completely(9 records) I want it to stop.

  • Thats way out of my league for php programming. I utilize one php file for each type of request. I know it takes up more room and is redundant but its more easy for me to get my head around. What your doing in the capx looks fine though. Heres a copy of one of my php files(work in progress I know I need to add the safety check like stripslashes :)) Anyways heres what works for me:

    And the php file:

    <?php

    $minx = $_REQUEST['min_x'];

    $miny = $_REQUEST['min_y'];

    $terrain = $_REQUEST['ter'];

    $SFood = $_REQUEST['food'];

    $SWood = $_REQUEST['wood'];

    $SStone = $_REQUEST['stone'];

    $SOre = $_REQUEST['ore'];

    $SGems = $_REQUEST['gems'];

    //Connect To Database

    $hostname='#####';

    $username='#####;

    $password='#####';

    $dbname='#####';

    $usertable='#####';

    $MapID = 'Map_ID';

    $MapX = 'Map_X';

    $MapY = 'Map_Y';

    $MapTYPE = 'Map_TYPE';

    $Food = 'Map_FOOD';

    $Wood = 'Map_WOOD';

    $Stone = 'Map_STONE';

    $Ore = 'Map_ORE';

    $Gems = 'Map_GEMS';

    $con = mysql_connect($hostname,$username,$password);

    if (!$con)

    {

    die('Could not connect: ' . mysql_error());

    }

    mysql_select_db($dbname, $con);

    $sql="INSERT INTO $usertable ($MapX, $MapY, $MapTYPE, $Food, $Wood, $Stone, $Ore, $Gems)

    VALUES

    ('$minx','$miny','$terrain','$SFood','$SWood','$SStone','$SOre','$SGems')";

    if (!mysql_query($sql,$con))

    {

    die('Error: ' . mysql_error());

    }

    echo "1 record added";

    mysql_close($con);

    ?>

    Just remember this isn't an effective php script yet. Still need the safety features so feel free to take from it what you want just be warned it's currently not secure enough for commercial use. :)

  • Anyone around able to figure out what I'm doing wrong with my conditions? I know that the php side works fine as it uploads tiles in the right format.

  • Here's a copy of a stripped down version of my capx.

    CapX

    When it counts off in the database the x variable works fine. The Y seems to lose a digit. It should be everytime the y variable passes the number of records variable the y should reset back to the stsrting y position. But it resets back to the y position + 1 instead. I'm sure it's something relatively easy but with a lack of sleep I can't seem to place my finger on it.

  • I don't see why not. Create the banner, place it in the program, add the browser object. Then for an event ad when ad clicked, open link in new tab. Should be that simple, right?

  • ok, thanks :)

  • I can do that to generate the physical tiles and just send out another ajax call to see if any player sprites are on the screen every couple of seconds. So at most it would be 10 ajax calls at a time.

  • Try Construct 3

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

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

    I have been looking a little bit more into it and was wondering what you think about this potential solution. I've got a grid 9 by 9 in construct that will be the visible map tiles. Live streaming doesn't work and I have no idea how to upload websockets to a godaddy server. How about this. Check visible tiles and send out an ajax call to update them as they become visible? I know it won't be real time but it may work for this in the short term. If I limit movement to left right up down then I'll only be sending out ajax calls 9 times per move.

  • lol Ashley,

    No I havent found the perfect world size as of yet. I need to be able to update each square every few seconds. It's a multiplayer game along the lines of civilization. The world is 2000 by 2000 squares but I'm only going to show a fraction of that at a time. Just need to figure out the best way to transfer it to construct.

  • Hi everyone,

    I've got a mysql database with 4 million squares using x,y rows. I want to display say 100 by 100 of those square on the screen based on their x,y position. I'm not sure how to go about doing this. I've currently got a php script to download 1 tile at a time but with 10,000 squares I know thats probably not the right way. So I'll work on one that echos back 1 row at a time(100 squares) but the map also contains info per square such as 4 resource types and troop types. So each square is roughly 12 pieces long which makes a really long echo string. Any recommendations using the tokenat to handle those squares without making my construct file weighed down with events? I do have a licensed copy so I'm not concerned with the number of events outside of streamlining the code. Any ideas on transferring that string into variables without bogging down the program?

    Thank you in advance,

    Lance