MrTek's Forum Posts

  • 8 posts
  • Hi! I was wondering if you could update your plugin, the "filler" glitch when he needs to fill an empty space (alpha = 0)

  • I found out myself how to build a simple ajax send and get program to retreive the data from a text file.

    YOU HAVE TO USE PHP FILES! in fact 2: a .php to send and a .php to get

    0~~~~~~~~~~~~~~~~0

    I do it like this:

    0~~/

    -Create 2 .php file, one called "send.php" and one called "get.php"

    -inside send.php you write:

    <?php file_put_contents("data.txt", $_GET['data']);?>

    -inside get.php you write:

    <?php header('Access-Control-Allow-Origin: *'); ?>

    <?php $data = $_GET['data'];

    file_get_contents("data.txt", $data);

    echo ( file_get_contents("data.txt", $data) ); ?>

    -And add a file named data.txt (empty or not it doesnt matter)

    So in total you'v just created 3 files, that you'll put in the same folder than your index.html file, once your project exported.

    0~~~~~~~~~~~~~~~~0

    FINALLY:

    In construct 2:

    0~~/

    (create 2 buttons, or any event to trigger theses actions:)

    -to send (on button 1):

    You add the action 'AJAX send to url':

    ~TAG "done-send"

    ~URL "./send.php?data=" & VAR

    (you put your own variable instead of VAR, like textbox.text for exemple)

    -to get(on button 2):

    You add the action 'AJAX request from url':

    ~TAG "done-get"

    ~URL "./get.php?data"

    -Then you add the event 'AJAX: on tag "quest-done" completed'

    Who trigger the action 'set textbox.text to ajax.lastdata'

    or even 'set variable to ajax.lastdata'

    (It's purpose is to retreive the "ajax.lastdata", the text you just asked your php to get,in your data.txt file)

    Then you can export!

    0~~~~~~~~~~~~~~~~0 /!\

    -Dont forget to add send.php, get.php and data.txt in the same folder than index.html once you exported your game!

    -Ajax dont work on preview mode! You have to publish it on your website to try it out!

    0~~~~~~~~~~~~~~~~0

    Like this you'll be able send and get what's in the file "data.txt" of your website!

    I'v tried a lot of ways to do it, but for now it's the only one who works for me.

    Working exemple:

    humain.tech/ajaaa

  • DONE!

    Found out myself!

    just use a .php to post and a .php to get..

    I do it like this =

    I create 2 .php file, one "send.php" and one "get.php"

    inside send.php you write:

    <?php file_put_contents("data.txt", $_GET['data']);?>

    inside get.php you write:

    <?php file_get_contents("data.txt", $data)?>

    And ADD an empty file named data.txt

    So in total you just created 3 files that you will put in the same folder than your index.html file once exported.

    FINALLY

    In construct 2:

    to send:

    You add the action AJAX send to url:

    ~TAG "done-send"

    ~URL "./send.php?data=" & VAR

    (you put your own variable instead of VAR, like textbox.text for exemple)

    to get:

    You add the action AJAX request from url:

    ~TAG "done-get"

    ~URL "./get.php?data"

    Then you can add an event 'AJAX: on tag "quest-done" '

    Who trigger the action 'set textbox.text to ajax.lastdata'

    or even 'set variable to ajax.lastdata'

    Like this you'll be able send and get what's in the file "data.txt" of your website!

  • Actually if I try to request from project, it's not working at all, there's an error (of course I cannot know what error it is because AJAX dont have a ajax.error)

  • Are you sure the problem is in Construct2, and not in your PHP script or server or browser etc.?

    -I'm not sure of anything.. Do you think I can use another php code to retreve my .txt data? and if yes how?

    ~~~~

    Have you tried requesting the same file directly from the browser address line?

    -Yes I'v made a tchat in ajax, without C2 and it's working just fine.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You should be able to sync the number of the dice (target) by sending it as a "room property" in photon.

    • right after your text is set to target:

    \-You put a "set property of my room"

    • You use a prop name like "DICE" to find it later
    • You set the value to: target
    • create a new event "On my room proprety changes"

    \-Action 1: Set target to Photon.property of my room("DICE")

    • Action 2: Set text to target

    Here you are, the dice is sync!

    You can do this for the "turn of wich player" ect ect

    Note: you can also make someone load the value "target" with room prop' at the start of the layout!

  • It's been weeks now since I'm searching an anwser but I can't find any.

    I can post ajax and read ajax, but only once! Even if I reload firefox or chrome, I get the same output than the last time I read the "ajax.lastdata", so I need to delete my cookie , my history ect ect, and then I can post/request once again, but still only once.

    humain.tech/QQCH

    To write on MYFILE.txt I write on a php who redirect:

    <?php file_put_contents("MYFILE.txt", $_GET['DATA']); ?>

    But I dont really think it's usefull... it's not showing any errors.

    So when I request somthing, ajax.lastdata stay the same (until I delete my history,cookie,ect,ect) even if I change the data on my server myself.(even tho it's working with my write.php code)

  • Well meeeeh

    Im a creative person

    since im 8 i play on lbp (1/2/3)

    and one day , i was like "eh why dont create a pc game?"

    and HERE I AM!

    im doing this for fun , and to create

    somtimes make laught my friends and have a good time!

  • 8 posts