[0.16.51] Only able to run command in multiplayer?
Posted: Sat Jun 23, 2018 4:41 pm
I'm attempting to fun the following command to get the play time for all players on 43 maps, sadly one at a time.
Command:
Issue: When a map is loaded in single player the command shows its ran as a command but doesn't export the file like it should, Load the map on a headless or 'Host saved game'
Command:
Code: Select all
/command
game.write_file("TimeOnline/timeOnline.txt","",false,0)
for _,player in pairs(game.players) do
local tick = player.online_time
local pre_seconds = tick/60
local pre_minutes = pre_seconds/60
local pre_hours = pre_minutes/60
local days = math.floor((pre_hours)/24)
local hours = math.floor(pre_hours - 24*days)
local minutes = math.floor((pre_minutes - 60*(hours + 24*days)))
local seconds = math.floor(((pre_seconds - 60*minutes)-60*(60*(hours + 24*days))))
local returnString = "name: "..player.name.." has played on the server for "..days.." days "..hours.." hours "..minutes.." minutes "..seconds.." seconds" game.write_file("TimeOnline/timeOnline.txt",returnString.."\n",true,0) end