Fixed Jail

This commit is contained in:
Cooldude2606
2017-04-09 00:34:17 +01:00
parent b92a4af064
commit 55ac27054c
2 changed files with 49 additions and 44 deletions

File diff suppressed because one or more lines are too long

View File

@@ -119,27 +119,44 @@ function callRank(msg, rank, inv)
local inv = inv or false local inv = inv or false
for _, player in pairs(game.players) do for _, player in pairs(game.players) do
rankPower = getRank(player).power rankPower = getRank(player).power
if inv then if rankPower >= rank.power then player.print(msg) end else if inv then
if rankPower <= rank.power then if rankPower >= rank.power then
if rank.shortHand then player.print(('[Everyone]: '..msg))
player.print(('['..(rank.shortHand)..']: '..msg)) end
else else
player.print(('[Everyone]: '..msg)) if rankPower <= rank.power then
end if rank.shortHand ~= '' then player.print(('['..(rank.shortHand)..']: '..msg)) else player.print(('[Everyone]: '..msg)) end
end end
end end
end end
end end
function giveRank(player,rank,byPlayer) function giveRank(player,rank,byPlayer,sys)
local byPlayer = byPlayer or 'system' local byPlayer = byPlayer or 'system'
oldRank = getRank(player) local rank = stringToRank(rank) or rank
local oldRank = getRank(player)
local message = 'demoted' local message = 'demoted'
if rank.power <= oldRank.power then message = 'promoted' end if rank.power <= oldRank.power then message = 'promoted' end
callRank(player.name..' was '..message..' to '..rank.name..' by '..byPlayer.name,oldRank.name) if byPlayer.name then
callRank(player.name..' was '..message..' to '..rank.name..' by '..byPlayer.name,oldRank.name)
else
callRank(player.name..' was '..message..' to '..rank.name..' by <system>',oldRank.name)
end
player.tag = rank.tag player.tag = rank.tag
drawToolbar(player) drawToolbar(player)
drawPlayerList() drawPlayerList()
if sys then else
game.print(jail[player.index][1])
game.print(rank.name)
game.print(jail[player.index][1] and rank.name ~= 'Jail')
if rank.name == 'Jail' and not jail[player.index][1] then
jailPlayer(player,byPlayer)
elseif jail[player.index][1] and rank.name ~= 'Jail' then
game.print('Unjail')
jail[player.index][1]=false
player.character.active = true
end
end
end end
function autoRank(player) function autoRank(player)
@@ -162,19 +179,27 @@ function autoRank(player)
if getRank(player).power <= 3 and not player.admin then if getRank(player).power <= 3 and not player.admin then
callRank(player.name..' needs to be promoted.') callRank(player.name..' needs to be promoted.')
end end
if jail[player.index] == nil then
jail[player.index]={false,getRank(player).name}
end
if jail[player.index][1] then
player.tag=stringToRank('Jail').tag
if player.character then player.character.active = false end
end
saveVar()
end end
function jail(player,byplayer) function jailPlayer(player,byplayer)
if player.character then if player.character then
if player.character.active then if player.character.active then
jail[player.index][1]=true jail[player.index][1]=true
jail[player.index][2]=getRank(player).name jail[player.index][2]=getRank(player).name
giveRank(player,'Jail',byplayer) giveRank(player,'Jail',byplayer,true)
player.character.active = false player.character.active = false
else else
jail[player.index][1]=false jail[player.index][1]=false
local rank = stringToRank(jail[player.index][2]) or stringToRank('Guest') local rank = jail[player.index][2] or 'Guest'
giveRank(player,rank,byplayer) giveRank(player,rank,byplayer,true)
player.character.active = true player.character.active = true
end end
saveVar() saveVar()
@@ -198,15 +223,15 @@ function clearSelection(player)
end end
function autoMessage() function autoMessage()
rank = stringToRank('Regular') local lrank = 'Regular'
hrank = stringToRank('Mod') local hrank = 'Mod'
callRank('There are '..#game.connected_players..' players online',hrank,true) callRank('There are '..#game.connected_players..' players online',hrank,true)
callRank('This map has been on for '..ticktohour(game.tick)..' Hours and '..(ticktominutes(game.tick)-60*ticktohour(game.tick))..' Minutes',hrank,true) callRank('This map has been on for '..ticktohour(game.tick)..' Hours and '..(ticktominutes(game.tick)-60*ticktohour(game.tick))..' Minutes',hrank,true)
callRank('Please join us on:',rank,true) callRank('Please join us on:',lrank,true)
callRank('Discord: https://discord.gg/RPCxzgt',rank,true) callRank('Discord: https://discord.gg/RPCxzgt',lrank,true)
callRank('Forum: explosivegaming.nl',rank,true) callRank('Forum: explosivegaming.nl',lrank,true)
callRank('Steam: http://steamcommunity.com/groups/tntexplosivegaming',rank,true) callRank('Steam: http://steamcommunity.com/groups/tntexplosivegaming',lrank,true)
callRank('To see these links again goto: Readme > Server Info',rank,true) callRank('To see these links again goto: Readme > Server Info',lrank,true)
end end
---------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------
---------------------------Table Functions---------------------------------------------- ---------------------------Table Functions----------------------------------------------
@@ -553,12 +578,6 @@ function drawPlayerList()
clearElement(Plist) clearElement(Plist)
Plist.style.maximal_height = 200 Plist.style.maximal_height = 200
for i, player in pairs(game.connected_players) do for i, player in pairs(game.connected_players) do
if player.character then
if player.tag == '[Jail]' or player.character.active == false then
player.character.active = false
player.tag = '[Jail]'
end
end
playerRank = getRank(player) playerRank = getRank(player)
if playerRank.power <= 3 then if playerRank.power <= 3 then
if playerRank.shortHand ~= '' then Plist.add{type = "label", name=player.name, style="caption_label_style", caption={"", ticktohour(player.online_time), " H - " , player.name , ' - '..playerRank.shortHand}} if playerRank.shortHand ~= '' then Plist.add{type = "label", name=player.name, style="caption_label_style", caption={"", ticktohour(player.online_time), " H - " , player.name , ' - '..playerRank.shortHand}}
@@ -589,21 +608,7 @@ addButton('bring',
local p = game.players[frame.parent.name] local p = game.players[frame.parent.name]
p.teleport(game.surfaces[player.surface.name].find_non_colliding_position("player", player.position, 32, 1)) p.teleport(game.surfaces[player.surface.name].find_non_colliding_position("player", player.position, 32, 1))
end) end)
addButton('jail', addButton('jail',function(player,frame) jailPlayer(game.players[frame.parent.name],player) end)
function(player,frame)
local p = game.players[frame.parent.name]
if p.character then
if p.character.active then
p.character.active = false
p.tag = '[Jail]'
drawPlayerList()
else
p.character.active = true
p.tag = '[Guest]'
drawPlayerList()
end
end
end)
addButton('kill', addButton('kill',
function(player,frame) function(player,frame)
local p = game.players[frame.parent.name] local p = game.players[frame.parent.name]
@@ -652,7 +657,7 @@ function drawPlayerTable(player, frame, commands, select,filters)
drawButton(frame.playerTable[p.name],'goto','Tp','Goto to the players location') drawButton(frame.playerTable[p.name],'goto','Tp','Goto to the players location')
drawButton(frame.playerTable[p.name],'bring','Br','Bring player player to your location') drawButton(frame.playerTable[p.name],'bring','Br','Bring player player to your location')
if getRank(p).power > getRank(player).power then if getRank(p).power > getRank(player).power then
drawButton(frame.playerTable[p.name],'jail','Ja','Jail/Unjail player player') drawButton(frame.playerTable[p.name],'jail','Ja','Jail/Unjail player')
drawButton(frame.playerTable[p.name],'kill','Ki','Kill this player') drawButton(frame.playerTable[p.name],'kill','Ki','Kill this player')
end end
elseif select then elseif select then