2018-11-20 12:46:19 +02:00
|
|
|
local Event = require 'utils.event'
|
2018-09-23 00:25:13 +02:00
|
|
|
local Game = require 'utils.game'
|
2018-04-29 21:29:43 +02:00
|
|
|
|
2018-11-20 12:46:19 +02:00
|
|
|
Event.add(
|
|
|
|
defines.events.on_player_died,
|
|
|
|
function(event)
|
|
|
|
local player = event.player_index
|
|
|
|
if Game.get_player_by_index(player).name ~= nil then
|
|
|
|
print('PLAYER$die,' .. player .. ',' .. Game.get_player_by_index(player).name .. ',' .. Game.get_player_by_index(player).force.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
)
|
2018-04-29 21:29:43 +02:00
|
|
|
|
2018-11-20 12:46:19 +02:00
|
|
|
Event.add(
|
|
|
|
defines.events.on_player_respawned,
|
|
|
|
function(event)
|
|
|
|
local player = event.player_index
|
|
|
|
if Game.get_player_by_index(player).name ~= nil then
|
|
|
|
print('PLAYER$respawn,' .. player .. ',' .. Game.get_player_by_index(player).name .. ',' .. Game.get_player_by_index(player).force.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
)
|
2018-04-29 21:29:43 +02:00
|
|
|
|
2018-11-20 12:46:19 +02:00
|
|
|
Event.add(
|
|
|
|
defines.events.on_player_joined_game,
|
|
|
|
function(event)
|
|
|
|
local player = event.player_index
|
|
|
|
if Game.get_player_by_index(player).name ~= nil then
|
|
|
|
print('PLAYER$join,' .. player .. ',' .. Game.get_player_by_index(player).name .. ',' .. Game.get_player_by_index(player).force.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
)
|
2018-04-29 21:29:43 +02:00
|
|
|
|
2018-11-20 12:46:19 +02:00
|
|
|
Event.add(
|
|
|
|
defines.events.on_player_left_game,
|
|
|
|
function(event)
|
|
|
|
local player = event.player_index
|
|
|
|
if Game.get_player_by_index(player).name ~= nil then
|
|
|
|
print('PLAYER$leave,' .. player .. ',' .. Game.get_player_by_index(player).name .. ',' .. Game.get_player_by_index(player).force.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
)
|
2018-04-29 21:29:43 +02:00
|
|
|
|
|
|
|
function heartbeat()
|
2018-11-20 12:46:19 +02:00
|
|
|
--Do nothing, this is just so managepgm can call something as a heartbeat without any errors occurring
|
2018-04-29 21:29:43 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function playerQuery()
|
2018-11-20 12:46:19 +02:00
|
|
|
if #game.connected_players == 0 then
|
|
|
|
print('output$pquery$none')
|
|
|
|
else
|
|
|
|
local response = 'output&pquery$'
|
|
|
|
for _, player in pairs(game.connected_players) do
|
|
|
|
local playerdata = player.name .. '-' .. player.force.name
|
|
|
|
response = response .. playerdata .. ','
|
|
|
|
end
|
|
|
|
print(response:sub(1, #str - 1))
|
|
|
|
end
|
2018-11-06 13:55:52 +02:00
|
|
|
end
|