How to block the possibility of running Game from /index.html or other domains?

0 favourites
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • If someone checks the source code of my site, then he can see the address of the folder in which the game is located.Then he can use it without going to the main page.

    You can block the iframe on different domains, but that will not help because the user can play from my domains using index.html because he knows URL>

    Post with game: example.com/best-game/

    Game catalog: example.com/myproject/index.html

    Iframe placed on example.com/best-game/

    <iframe src="https://example.com/myproject/index.html" width="800px" height="700px" frameborder="0" scrolling="no">Your browser does not support iframes.

    </iframe></center>

    Tagged:

  • No, but you can use the Browser plug to check a variable in the url:

    QueryParam

    Return a query string parameter by name. For example, if the URL ends with index.html?foo=bar&baz=ban, QueryParam("foo") returns bar and QueryParam("baz") returns ban.

  • newt

    I dont understand. Is that plugin will change the address project/index.html? in source code?

  • No, but you can use the Browser plug to check a variable in the url:

    QueryParam

    Return a query string parameter by name. For example, if the URL ends with index.html?foo=bar&baz=ban, QueryParam("foo") returns bar and QueryParam("baz") returns ban.

    I tried this recently, and I think something's changed with the browser object; originally it would would return the address show in the browser (or the top page), so if your game was in a iframe on a homepage it would return "example.com" when you queried the URL, however now it will return "example.com/c3directory/index.html" - the actual path of the file, regardless of the browsers current location.

    Other than that, what Newt said is correct; you (at least used to be able to) query the page URL and act based on this, so if the current page the user is on is the one you want, play the game, if not, go to a blank layout or something.

  • Elliott

    newt

    I do not know if we understand each other. My game is available at: example.com/mygame-2019/ This is the address for wordpress and there is a paid access.

    When you buy access and check the source of this page, you can (unfortunately) check the path address:

    <iframe src="example.com/gamefolder/index.html" width="800px" height="700px" frameborder="0" scrolling="no">Your browser does not support iframes.

    </iframe>

    OK You Said "query the page URL and act based on this, so if the current page the user is on is the one you want, play the game"

    For example, if the URL ends with index.html

    Yes but how to do this? In C2? Where is this plugin?

  • You won't be able to hide the URL path from an iframe/inspect element - that's simply not how the internet works.

    What you might (and definitely used to be able to) do is use the browser object (it's a a default object in Construct) to look at the current page URL, and based on this, you can execute events. For example you could have it so that if a user was to extract the path from the iframe, if they visited it directly, the game would load a blank screen instead.

    This is how you typically protect your game from being show on different websites.

  • That won't work. You can't keep a secret after you tell it.

    You can require a password.

    Edit:

    What he said ^

    Also there's many other ways to get an address than looking at source code.

  • newt

    Elliott

    it could be greate I understand now ;-P,

    I can't find proper condition for checking url

    I think it's similar subject:

    construct.net/en/forum/construct-2/general-discussion-17/url-param-save-variable-128595

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I think you might want to take a look at the section "controlling framing" in the tutorial Publishing to the web.

  • I think you might want to take a look at the section "controlling framing" in the tutorial Publishing to the web.

    Ashley Is there any way of using the browser object to return the current page URL? I swear this used to be possible, however an iframed game will now return the frame source URL when you use Browser.URL

    With scripting, admittedly this is now much easier to get the top/parent URL, I was just wondering if I've misremembered how Browser.URL works

  • Why would you want to do that? The frame control options are better for that and more secure.

  • Why would you want to do that? The frame control options are better for that and more secure.

    Mainly sniffing out UTM variables - and what I'd argue is a point of confusion in that Browser.URL is described as returning the URL of the window:

    Get the complete current URL in the browser address bar, including the protocol.

    Which it doesn't do?

    EDIT//

    Just realised queryParam would work much better for UTM, however I think the description of Browser.URL could be clearer

  • so maybe this

    GLobalVar = URL

    at start of lay > System/ set URL to Browser.QueryParam("location")

    and what then?

    Compare global Variable if not equal to URL "example.com/mygame/ then do SOMETHING

    hmm not working becaue see "seomething" on example.com/mygame/ and on example.com/mygame/index.html

    This second one shouldn't have "something"

  • If you're not very familiar with the query system you can try a simple password system.

    They purchase access, you tell them a password after payment, they enter the pass in the game.

    The game itself, like all websites, is public.

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