Hey guys! I have a question, is there any way in UE to make a single-player builds playable for a limited amount of time without client-server communications and verifications? Some sort of login key system?
Let’s say for example I want to send builds to my friends and want them to play it only for one week. And after that time make the build inaccessible.
I know that I can link the login logic to the pc local time. But it will still be playable if the player changes the date and time on his pc, right? Is there some other way?
I remember running into something like this a while back so I dug up the thread. Let me know if this answers your question or you need additional clarification!
Initially I was searching the possibility of blocking the login directly on the local machine. But I’m not sure that’s possible at all. I was just hoping that UE have some built-in packaging functions that allow to set the playtime limit.
But you just gave me an idea! I’m probably just gonna make a fast checking request for date and time from the server and if it exceeds the allowed limit the login will be blocked. Thanks alot!
There are online date/time servers you can check those.
You can also get time in blueprints.
Now only one problem would be how to store time of expiration that is not easy to find/read/modify
Best would be something like CRC32, you make such checksum of hour,day,month,year, then compare to date from internet server.
But anything that is client side can be found and changed/hacked.
Hey @Ocean.Heart , Single Player builds do not have servers so to speak. The client is the server.
To legit lock down your SP game for duration play you’ll need to write a little C++ that’s requires an internet connection. The class would simply ping a webserver (your domain) for the current Unix timestamp packed in a JSON response.
Unix Timestamp is the elapsed seconds since January 1st, 1970 at UTC.
Hard code a Unix timestamp in the class header for when the trial is to sunset.
e.g. Sunset = 1743393600 // Sunday March 30 2025 at midnight
Compare it against the current response Unix Timestamp ( Current >= Sunset).
IF greater than or equal to… don’t allow the main menu to load and show a trial is over message.
Else… IF remaining time (Sunset - Current) is less than 3600s (1 hour), set a Timer. Timer will shutdown/lock out the game and show trial is over.
During play you’ll need to ping the server every 30 minutes or so to trigger the timer if needed.
C++ Modules required are HTTP and JSON
How to Add Modules to your MyProject.Build.cs file.
For giggles here’s the PHP for the webserver to pass the Json encoded current time.
<?php
// json encode the current unix timestamp
$response = json_encode(array('CurrentTime' => Time()));
// Set page header to JSON output
header('Content-Type: application/json; charset=utf-8');
print_r($response);
?>