Added module: ExpGamingCore.Ranking

This commit is contained in:
Cooldude2606
2018-06-02 21:08:33 +01:00
parent 4d05f13cb3
commit b8b514b133
12 changed files with 432 additions and 353 deletions

View File

@@ -6,6 +6,7 @@
local Sync = {}
local Sync_updates = {}
local module_verbose = false --true|false
--- Global Table
-- @table global

View File

@@ -18,9 +18,8 @@ end
-- @treturn table contains the ranks and the players in that rank
function Sync.count_ranks()
if not game then return {'Offline'} end
if not Ranking then return {'Ranking module not installed'} end
local _ranks = {}
for power,rank in pairs(Ranking._ranks()) do
for name,rank in pairs(Ranking.ranks) do
local players = rank:get_players()
for k,player in pairs(players) do players[k] = player.name end
local online = rank:get_players(true)
@@ -35,4 +34,22 @@ if Sync.add_to_gui then
Sync.add_to_gui(function(player,frame)
return 'You have been assigned the rank \''..Ranking.get_rank(player).name..'\''
end)
end
end
-- adds a discord emit for rank chaning
script.on_event('rank_change',function(event)
local rank = Ranking.get_rank(event.new_rank)
local player = Game.get_player(event)
local by_player_name = Game.get_player(event.by_player_index) or '<server>'
local global = global('Ranking')
if rank.group.name == 'Jail' and global.last_change ~= player.name then
Sync.emit_embeded{
title='Player Jail',
color=Color.to_hex(defines.textcolor.med),
description='There was a player jailed.',
['Player:']='<<inline>>'..player.name,
['By:']='<<inline>>'..by_player_name,
['Reason:']='No Reason'
}
end
end)