Added: Darrah Marts - Date: 19.10.2021 01:53 - Views: 34306 - Clicks: 8503
By jamespierceSeptember 6, in Phaser 2. I would like to prevent players from switching to any game state by typing "game. Has anyone found a way to prevent this from happening? Imagine you have a -screen and any user can just type "game. I have already tried using anonymous functions and closures but the problem is that the other states such as BootState, MenuState, GameState etc cannot access the game object created from new Phaser.
I cannot be the only one who's worried that users can simply skip any game state by typing one line into the console. How have others dealt with this security breach? I tried googling but couldn't find any posts about this whatsoever. I suppose we cannot prevent users from changing game states from inside the console but through prototyping we can have functions in all the game states that are NOT accessible from within the console.
So setting a variable in the game states to check that a user has properly arrived in this game state and re-directing the user back to the state if the check-variable is not set might be a possible way to prevent skipping game states. With the game.
We can then access these parameters in the init method of the new game state. In the example above, we simply create a variable "safeState" which we set to true when calling the "" method. In the following menuState we check if the "safeState" variable is set or not, and also if it is set to true.
Else we redirect back to the State. By the way, this only works if you prototype the game state function, else you can just execute the method "State. You can test it out now, it is not possible to skip game states in the console anymore. You can execute the method game. Okay sorry for opening this thread I guess I jumped a bit too fast on the forum.
However, maybe somebody has a better way of handling this issue? Else admins feel free to close this thread. If you ran the game on the server and only used the client for the visuals, you could reduce hacking a lot. Yes you can stop them, just stop declaring globals variables its not a terrible idea, but its almost always best avoided, outside of dev anyway. There is a caveat here that I haven't found a nice way to encapsulate either Pixi or Phaser both dump a global but their globals are only used to instantiate and control properties, so they won't be of any use for people aiming to fiddle with your game.
JS file structure" I found an answer on sitepoint which I think addresses the issue you have mentioned: not declaring global variables. Here is the code snippet from the sitepoint tutorial :. Now the method to change game states is not accessible anymore from the console, as it is not how to cheat html games in a global variable as you have suggested.
I find handling name space one of the best methods to reduce immediate cheating-threats and also keeps code a lot cleaner. If there is a better way to handle name space for this example, I would love to know. But I still want to remove as many leaks as possible. I think users will respect your game a lot more if you limit cheating as much as possible. Yes, even if a hardcore hacker could find a way around it, I still wanna remove all possible hacks for maybe a "hobby hacker".
I think you get the idea I think proper name spacing solves a lot of these issues already, as mattstyles explained above. I just couldn't figure out a way to do it in this case until I found the tutorial on sitepoint. Now the question that remains is: Is this the proper name spacing technique for this particular case? I think yes but if somebody has a different code snippet to show, it's always very appreciated.
BUT I still had to export the Phaser global, there were still internal requirements for this, it wouldn't work just in the closure scope. You can post now and register later.
If you have anin now to post with your. Note: Your post will require moderator approval before it will be visible. Paste as plain text instead. Only 75 emoji are allowed. Display as a link instead. Clear editor. or insert images from URL. Can you help moderate this forum? Changing Game States Inside the Console phaser.
Reply to this topic Start new topic. Recommended Posts. Posted September 6, Thanks in advance for all answers! Link to post Share on other sites. I guess I should have done more coding myself and less googling, I got an idea to solve it: I suppose we cannot prevent users from changing game states from inside the console but through prototyping we can have functions in all the game states that are NOT accessible from within the console. I will test it out update this post. Okay it was very easy to test actually, here is a simple check:. Use a proper module system or hack a simple one yourself google for JS namespacing.
Game, Phaser. AUTO, 'game-area' ; game. I think this is what you meant and is probably the cleanest way to do it?
Posted September 7, the conversation You can post now and register later. Reply to this topic Followers 0. Go to topic listing. Recently Browsing 0 members No registered users viewing this. In Up.How to cheat html games
email: [email protected] - phone:(577) 308-1151 x 2974