How to print "current time" in server console, and how to log all CMD into a txt file

Hello all, im looking for printing server time in console, and a way to log cmd in a file, can be a json or txt doesn’t matter.

For date and time: Programming in Lua : 22.1

For writing to text files: Lua - File I/O

Thanks, so normal lua works in fivem too ?

Yup. Here is how I handled writing data to a file:

note: wait() between io.write() might not actually be necessary.

2 Likes

Instead of hardcoding the path

GetResourcePath(GetCurrentResourceName())

Also SaveResourceFile and LoadResourceFile exist though they can’t append.

That’s good to know.
For my example, I needed the file to be in a specific folder that is outside of the resources folder, hence the hardcoded folder.

Thanks for the amazing examples guys <3

This solved my damn problem! You don’t know how much I was struggling to write to files server sided!

Cheers pappa @CritteR

1 Like