StefanN's Forum Posts

  • kcalpesh, could you please tell me more about what are you searching?

    I solved my problem by doing the following things.

    1. When I want to show the AD, I will have 2 Javascript lines (Browser > Execute Javascript). The first one is: "cr_setSuspended(true);" that will suspend (pause) the game and the next is "window[preroll.config.loaderObjectName].refetchAd();" that will fetch my AD.

    2. After I export the game, I will add in the index.html file, in header, the AD, like this:

    <script type="text/javascript" src="example.iframe.conf.js"></script>

    <script type="text/javascript" src="example.js"></script>

    Those two scripts are provided by our partners, Google Certificate Partners that manage our Adsense account. I don't know more about them.

  • Try Construct 3

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

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

    Yes, the script will not work in preview.construct.net, just when uploaded to our servers.

    Fengist

    I've solved (for a moment) the problem with your trick; JQuery plugin for Construct 3. In this way I can import my script from Construct 2. For a moment it's ok. I will try to remake it using your idea in the future.

    Thank you all! :)

  • Nepeo

    Sure. Here is the Construct 3 test project and PHP script: gofile.io

    For testing, you can use: zuzu.games/upload/our/get-content_NEW.php - the script is working properly, because it is used in my old Construct 2 projects. That page receive an URL, and search in the URL's example.com/ads.txt, testing if there is or not our Google Publisher ID.

    What else could I provide for you?

  • silbedbg

    I saw that you know Javascript, and from what I understand you make games in Construct using scripts. Is there a chance to look at my problem? I'm try for some days to solve it, and I'm out of ideas.

    If you could, that would be great! :D

  • Nepeo

    No, the script runs ok, but I don't get any data in.

    The problem is that I can't get any data through:

    .then(res => res.text())
    .then(data => runtime.callFunction("cauta_pub_id", data))
    

    Here is the script in Construct 3:

    Image: i.postimg.cc/Ghr3Z4Nq/code.png

    Sort explanation:

    • 'mod_reclama' = ad_mode ( I set 1 if it's partner - and display google ADS, 2 if it's not - I display banners)
    • 'executa' = is just for test - to see if it's stuck, how many times he tried to send data, and so on. Is incrementing with 1 until he send any data to function. When is some data send, it becomes 99.
    • 'partner' = is the variable that store the data send by your script; is 0 or 1 - by default it's -1.

    I extract the application test, upload to my server, and it's not working. The PHP part is 100% correct because I use it in the Construct 2 games.

    If you have nerves, the page where I need to send the URL where is the game running is in the image too. I'm trying to find a solution for more then 5 days. :))

    PS: If it helps you, I can provide the PHP script too.

  • Nepeo

    I use it in an event sheet script block, but I don't know why it's not working. If I delete 'away' operator, I don't get any errors, but the script will not work properly.

    I don't get any data, just 'Promise' or 'undefined'.

  • Nepeo

    It seems that I have an error at 'fetch', "Unexpected token".

  • Hmm.. yes, I understand what are you saying. So, the better way is like it is now. :D

  • Ashley

    Ok, I got that. So no jQuery anymore. I will try to use fetch, but I'm not familiar with it. I'm out of the city for the moment, but when I come back to my laptop, I will try to switch to 'fetch'.

    About the errors, I don't get any. Thanks for heads-up.

    Nepeo

    Thank you. After I will get home I will try your idea too.

    Have a great day! :)

  • Yes, that should work.

    But I don't think there will be many user who will do this. But, if we would have somewhere an option, check mark, something to mark as solved, maybe they will use it.

    In this way we can improve the usability of the forum.

  • Hi,

    I developed for Construct 2 a small 'script' that will tell if the site where the game is running (post with iframe) is or is not a partner (is partner if have our pub-id in thier ads.txt page).

    How?

    The game will send to a PHP page the domain where it's running. On that PHP page, we have a script that goes to domain.com/ads.txt page, and test if our pub-id is there, returning 0 if it is, or 1 if it's not there. In Construct 2, if it's 0 we will show Google ADS, and if it's 1 we will show banner ads.

    The Problem?

    I can't do the same in Construct 3. For a reason the script will not work properly and it get stuck "$.POST".

    CONSTRUCT 2

    In the Browser function, I have:

    "var url = document.referrer;
    var found;
    $.post('https://www.mydomain.com/upload/get_content.php', {posturl:url}, function(data){
    found = data.indexOf(0);
    c2_callFunction('pub_id', [found]);
    });"
    

    In the 'pub_id' function I have a simple event that assign a variable to the value of 'found'.

    PHP

    In the 'https://www.mydomain.com/upload/get_content.php' file I have:

    <?php
    $pubid1 ='mypubid';
    $url = $_POST['posturl']; //URL get from Construct 2
    
    -----
    Here I test if the domain get through Construct 2 is or is not a partner.
    If it is, I will have: $data['response'] = 0; 
    If it's not, I will have: $data['response'] = 1;
    -----
    
    echo $data['response'];
    ?>
    

    This script it's running perfectly on over 30 games. But, If I try to make it in Construct 3, I can't. It won't work. It will not enter here: "$.post('https://www.mydomain.com/upload/get_content.php', {posturl:url}, function(data){....".

    Construct 3

    The difference between C2 and C3 script is that in Construct 3 I use 'c3_callFunction' insted of 'c2_callFunction', and in the Construct 3 'pub_id' function I add parameters and after that I use them.

    Somebody had this type of issue?

    Cheers! :)

  • Magistross

    I tried in that way, but it won't work.

    piranha305

    Now I see the image. I will try it right away.

    EDIT:

    It worked. Thank you piranha305! :)

  • piranha305

    No.

  • this seems to be working

    piranha305

    It seems that your image is broke, or something. :)

    "Access to doc-0s-bc-docs.googleusercontent.com was denied"

  • Hi,

    I hope here it's ok to post a feedback.

    There days I wanted to try answering some questions in "How do I..." section, but many of them are already solved. So I lose some time till I found one that's not.

    It would't be nice to have a tag that says if the thread is solved or not? Maybe just the creator of that topic to be able to mark it, that will be nice.

    What do you think?

    Laura_D