Fixed a few things

This commit is contained in:
Cooldude2606
2018-01-05 22:52:28 +00:00
parent 232c595343
commit 2d0c12f9e2
3 changed files with 14 additions and 10 deletions

View File

@@ -89,11 +89,11 @@ function Ranking.print(rank_base,rtn,colour,below)
local ranks = Ranking._ranks()
if below then
for power,rank in pairs(ranks) do
if rank_base.power >= power then rank:print(rtn,colour) end
if rank_base.power <= power then rank:print(rtn,colour,true) end
end
else
for power,rank in pairs(ranks) do
if rank_base.power <= power then rank:print(rtn,colour) end
if rank_base.power >= power then rank:print(rtn,colour) end
end
end
end
@@ -224,13 +224,13 @@ end
--- Print a message to all players of this rank
-- @usage rank:print('foo')
-- @param rtn any value you want to return
function Ranking._rank:print(rtn,colour)
function Ranking._rank:print(rtn,colour,show_default)
local colour = colour or defines.color.white
local meta_data = Ranking._presets().meta
local default = Ranking.get_rank(meta_data.default)
if not Server or not Server._thread then
for _,player in pairs(self:get_players()) do
if thread.data.rank.name == thread.data.default then
if thread.data.rank.name == thread.data.default or show_default then
player_return({'ranking.all-rank-print',rtn},colour,player)
else
player_return({'ranking.rank-print',self.name,rtn},colour,player)
@@ -239,12 +239,12 @@ function Ranking._rank:print(rtn,colour)
else
-- using threads to make less lag
Server.new_thread{
data={rank=self,rtn=rtn,default=default.name}
data={rank=self,rtn=rtn,default=default.name,all=show_default}
}:on_event('resolve',function(thread)
return thread.data.rank:get_players(true)
end):on_event('success',function(thread,players)
for _,player in pairs(players) do
if thread.data.rank.name == thread.data.default then
if thread.data.rank.name == thread.data.default or thread.data.all then
player_return({'ranking.all-rank-print',thread.data.rtn},colour,player)
else
player_return({'ranking.rank-print',thread.data.rank.name,thread.data.rtn},colour,player)

View File

@@ -201,7 +201,7 @@ if commands._expgaming then
if Ranking and Ranking.get_rank and game.player then callback = 'local rank = Ranking.get_rank(game.player);'..callback end
local success, err = Server.interface(callback)
if not success and is_type(err,'string') then local _end = string.find(err,'stack traceback') if _end then err = string.sub(err,0,_end-2) end end
if err then player_return(err) end
if err or err == false then player_return(err) end
end)
end
@@ -255,6 +255,7 @@ function Server._thread:open()
self.opened = game.tick
threads.all[uuid] = threads.all[uuid] or self
threads.all._n = threads.all._n+1
if threads.paused[self.name] then threads.paused[self.name] = nil end
if is_type(self.timeout,'number') then table.insert(threads.timeout,uuid) end
if is_type(self._tick,'function') then table.insert(threads.tick,uuid) end
if is_type(self.name,'string') then threads.named[self.name] = threads.named[self.name] or self.uuid end
@@ -293,7 +294,8 @@ function Server._thread:close()
end
end)
end
if is_type(self.name,'string') then threads.paused[self.name] = self.uuid self.opened = nil
if is_type(self.name,'string') then threads.paused[self.name]=self.uuid self.opened=nil
if self.reopen == true then self:open() end
else threads.all[uuid] = nil threads.all._n = threads.all._n-1 end
return _return
end

View File

@@ -78,8 +78,10 @@ function ExpLib.discord_emit(args)
local description = is_type(args.description,'string') and args.description or ''
local server_detail = is_type(args.server_detail,'string') and args.server_detail or ''
local _count = 0
for _,player in pairs(game.connected_players) do
if player.admin then _count=_count+1 end
if game then
for _,player in pairs(game.connected_players) do
if player.admin then _count=_count+1 end
end
end
local mods_online = 'Mods Online: '.._count
local done, fields = {title=true,color=true,description=true,server_detail=true}, {{