Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Simple anti Time Cheating on android/IOS

Discussion in 'Scripting' started by Quantum_Surt, Aug 17, 2017.

  1. Quantum_Surt

    Quantum_Surt

    Joined:
    Apr 25, 2015
    Posts:
    39
    Hi, I need to protect a game from changing device time to cheat, I saw there was the server way but I would like my players to be able to do it offline...

    There are assets I saw but I prefer to understand it by myself...

    So I have an idea, what if my time code is lock if device time is not set on automatic (date and hour given by phone network), do you think it is powerful ? It is even possible, or not too difficult ?

    Any other way ?

    Thks !
     
  2. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    943
    Not sure how that time cheating works, but what about having multiple time records to compare. For example one with increments based on rendered frames (if you have vsync enabled that should work), one based on system time and one that you think is definitely influenced by this cheat method (Time.time i think). That way you should be able to tell (if the difference is too huge) if it has been tampered with. But keep in mind every anti-cheat can be worked around, especially if it's offline.

    Edit: re-read your post, i think i misunderstood it, sorry.
    But a simple way would be storing the current session date in the player prefs and compare it to the last stored date with a certain hour-threshold to allow timezone changes. That way you can atleast detect if it's been set back. This can be cheated by deleting or modifying the playerprefs too though.
     
    Last edited: Aug 17, 2017
    xVergilx likes this.
  3. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Another option would be to have a server requests of current time.
    Though you would need an internet connection and an actual server running to request the time.
     
  4. Quantum_Surt

    Quantum_Surt

    Joined:
    Apr 25, 2015
    Posts:
    39
    Yeah, ok I am going to do this, have you a tuto or something ?
    I saw posts about it but I will need an ulong var for my date and time, how can I do ?

    Thanks
     
  5. TaleOf4Gamers

    TaleOf4Gamers

    Joined:
    Nov 15, 2013
    Posts:
    825
    So? Its just a data type

    Theres plenty of posts about it with a simple search:
    http://answers.unity3d.com/questions/219155/systemdatetimenow-and-how-to-avoid-time-cheats.html
    http://saadkhawaja.com/get-time-server/
    http://answers.unity3d.com/questions/1332956/getting-the-time-from-a-server.html