- Home /
Question by
zak666 · Aug 31, 2020 at 02:54 PM ·
timescriptingbasics
Monthly subscriptions for mobile? how to calculate if its been X number of days?
Ok, so here I have a date and time and want to be able to calculate the saved to and the current internet time to see how long the player has had their subscription for? also how are you supposed to test such a system without having to wait a month in real time? XD I have another script that gets the time / DD/MM/YY from microsoft.com, and saves it so im using internet time, and not the phones time. :) then its saves it to the palyers save file, and now wan to check if 30 days has passed since the player got the VIP.`enter code here`
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Purchasing;
using System;
using UnityEngine.Networking;
using System.Collections;
public class VIPchecker : MonoBehaviour
{
public dateTimeCheckerOnStart dateTimeCheckerOnStartCS;
public AccountScript AccountScriptCS;
public GameObject viphasExpired_Obj;
public DateTime mySavedTime;
// Update is called once per frame
void Update()
{
if (mySavedTime == null)
{
mySavedTime = Convert.ToDateTime(AccountScriptCS.theDateIRegistedMyVIP);
}
// THIS IS NOT THE SAME!!!
if (mySavedTime != null)
{
// how do i get this? ....
int DaysBetween = //
if (DaysBetween > 30)
{
viphasExpired_Obj.SetActive(true);
AccountScriptCS.theDateIRegistedMyVIP = null; // RESER TO NOTHING....
AccountScriptCS.premiumActive = 0;
AccountScriptCS.SaveData();
// reset my VIP data so I cant do this next login...
}
}
}
}
Comment