Hi, this is my first post.
I am creating a unity game.
I would like to know how can i implement the internet time solution to the cheating problem.
I have a timer in my game. 15 lives after 4 hours. How can i implement it in the game. I know the code, how to get the time and parse it and show it BUT Hosting? what's up with that?
What url should i pass in my code? is it possible to use PlayFab's Servers to get the current time of the player? Do I have to upload a php file to Player'sData in PlayFab?
How does that work? I am new, kindly help me out, Mr.Google is saying I need a website and have to host the php file there? is there another alternative?
What will I pass in string _url in the scenario where PlayFab servers (GetTime) function is used?
using System.Collections; using System.Collections.Generic; using UnityEngine; public class TimeManager : MonoBehaviour { /* necessary variables to hold all the things we need. php url timedata, the data we get back current time current date */ public static TimeManager sharedInstance = null; private string _url = "http://localhost/Wireal/Time.php"; private string _timeData; private string _currentTime; private string _currentDate; //make sure there is only one instance of this always. void Awake() { if (sharedInstance == null) { sharedInstance = this; } else if (sharedInstance != this) { Destroy (gameObject); } DontDestroyOnLoad(gameObject); } //time fether coroutine public IEnumerator getTime() { Debug.Log ("==> step 1. Getting info from internet now!"); WWW www = new WWW (_url); yield return www; Debug.Log ("==> step 2. Got the info from internet!"); _timeData = www.text; string[] words = _timeData.Split('/'); //timerTestLabel.text = www.text; Debug.Log ("The date is : "+words[0]); Debug.Log ("The time is : "+words[1]); //setting current time _currentDate = words[0]; _currentTime = words[1]; } //get the current time at startup void Start() { Debug.Log ("==> TimeManager script is Ready."); StartCoroutine ("getTime"); } //get the current date public string getCurrentDateNow() { return _currentDate; } //get the current Time public string getCurrentTimeNow() { return _currentTime; } }