Search in

Sort by:

Everything Blueprint Scripting

Current Space

Question Status:

All Questions With Answer With Accepted Answer

Quick results

Search help

Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both.
Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.

You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with
each other. Examples

Accessing real-world time from BP

0

Hi,

Is there a way to access a certain web directory containing the GMT time to download the time and date to UE? I am making a single-player game in which the gameplay would also be affected when not playing the actual game (like OGame and others), but since it is single-player I do not need a server to compute everything while the game is closed. Instead, the calculations would be performed upon the subsequent game run and based on the time difference. However, a player could easily hack the game mechanics by changing the time and date on their PC if I was to use the system time as a reference.

This is why I would need a more reliable source of the real-world time than the system one, hence the question about the web directory.

Uff, in Blueprints? I don't think that is possible. If you don't have a server to sync the time, you can only use the System Time. To prevent cheating, you always need a server. But even this can be cheated, because you will never actually check what time the player feeds the game. He could put something between the server and the game and fake the time.

So i would not really think about the cheaters. If it is a single player game, just accept that people like to cheat :X

You would need at HTTP sever that you would provide with SSL encoded time, in which client would validate if data comes from right sever (since public key can only decode message from private key which only server has, so you sure it's message from right server), problem is even that is not fully secure (user could potentially replace public key to fit specific private key, even if it was hard coded in machine code), but it's harder to do for more casual user. Also you would need to use C++ for that as UE4 has cryptography functions wrapped in APIs but are not accessible via blueprint.

Much more secure solution is to run game instance on server and let server manage the time, client hacking would not work here as you would use server clock to do any computations

Ok, but is there any solution to do that without owning a server? I mean, is there no way to access another website's html code (like THIS) and retrieve the specified information from it - in this case the datetime?

If they give access to any API then yes, if they use JSON then you could use VaRest to access it in blueprints. Problem is some APIs are made for server only use, they give you key which has specific limit of requests, i don't know search, anything on HTTP that will simply output just time will be good, but you need to be sure that they let you use it in your game (check licence and rules).

There also NTP servers, but UE4 does not support them (Since they mainly used only by OS and other devices to sync time), you would need to code your own support in C++.

Ok. I just thought, maybe I could launch an external executable file and retrieve the html without JSON? The datetime would be then saved to a file and read by UE. That would make it slightly more flexible, as long as UE allows launching external applications.

EDIT: Or I could make a custom .exe file which would firstly run the programme saving the datetime and secondly launching the actual UE game.

If you know C++ then make it inside UE4, C++ in UE4 is normal C++ you can do anything that C++ let you, you practicly extending engine code, If you gonna make external exe it will be even more hackable. UE4 APIs have su[pport for low level Sockets and HTTP as well as retriving data JSON and XML (i think) you get from HTTP, so you can use UE4 for that