Skip to content

Commit

Permalink
Merge pull request #8 from StaRTkek/master
Browse files Browse the repository at this point in the history
Added report command and option to reset warns every round
  • Loading branch information
RektInator authored Feb 4, 2018
2 parents ff8dc42 + 60d2d31 commit 7b40d9e
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 43 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ luac.out
*.hex

.vscode/settings.json
scripts/mp/plutoadmin.lua
6 changes: 1 addition & 5 deletions admins.json
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
{
"admins": [

]
}
{"admins":[]}
10 changes: 1 addition & 9 deletions bans.json
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
{
"bans": [
{
"name": "",
"xuid": "",
"reason": ""
}
]
}
{"bans":[]}
4 changes: 3 additions & 1 deletion language.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@

"dspl_usage": "^1Usage^7: !dspl <dspl>",

"scream_usage": "^1Usage: ^7!scream <message>",
"scream_usage": "^1Usage: ^7!scream <message>",




Expand Down Expand Up @@ -293,4 +294,5 @@
"clients": "^7[{entity}] ^2{player}^7, ",

"player_joined": "Player ^5{player} ^7has joined"

}
11 changes: 9 additions & 2 deletions scripts/mp/plutoadmin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ adminhandler = require "scripts.mp.plutoadmin.adminhandler"
messagequeue = require "scripts.mp.plutoadmin.messagequeue"
anticamp = require "scripts.mp.plutoadmin.anticamp"
rules = require "scripts.mp.plutoadmin.rules"
playerhandler = require "scripts.mp.plutoadmin.playerhandler"

languagehandler = require "scripts.mp.plutoadmin.languagehandler"

util.print("Starting up plutoadmin by RektInator...")
Expand Down Expand Up @@ -176,15 +176,22 @@ function onFrame()

end

if settingshandler.settings.reset_warns_after_every_round == true then
function onPreGame()
playerWarns = {}
end
end

function isEmpty(s)
return s == nil or s == ''
end
end


-- install callbacks
callbacks.frame.add(onFrame)
callbacks.playerSay.add(onPlayerSay)
callbacks.playerConnected.add(onPlayerConnected)
callbacks.preGameInit.add(onPreGame)

-- init subscripts
messagequeue.init()
Expand Down
18 changes: 10 additions & 8 deletions scripts/mp/plutoadmin/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function commands.onVoteMapCommand(sender, args)
if numArgs(args) == 2 then
logCommand(sender, args)
if onGoingVote == false then
local map = getMapName(args)
local map = getMapName(args[2])

if map ~= nil and map ~= languagehandler.language.map_disabled then

Expand Down Expand Up @@ -320,7 +320,7 @@ function parseTimeToRealTime(number)
elseif number == 31557600 and number < 63115200 then
return "1 Year"
else
return string.format("%s Years", tostring(math.floor(number/31557600)))
return string.format("%s Years", tostring(math.ceil(number/31557600)))
end
end

Expand Down Expand Up @@ -489,11 +489,11 @@ function commands.onUnMuteCommand(sender, args)

end

function getMapName(args)
function getMapName(mapName)

for map in ipairs(votemapConfig.votemap.mapList) do
if votemapConfig.votemap.mapList[map].enabled == true then
if args[2]:lower() == votemapConfig.votemap.mapList[map].shortName:lower() or args[2]:lower() == votemapConfig.votemap.mapList[map].longName:lower() then
if mapName:lower() == votemapConfig.votemap.mapList[map].shortName:lower() or mapName:lower() == votemapConfig.votemap.mapList[map].longName:lower() then
return votemapConfig.votemap.mapList[map].longName
end
else
Expand Down Expand Up @@ -886,7 +886,7 @@ function commands.onMapCommand(sender, args)

if numArgs(args) == 2 then
logCommand(sender, args)
local map = getMapName(args)
local map = getMapName(args[2])
if map ~= nil or map ~= languagehandler.language.map_disabled then
utils.chatPrint(languagehandler.language.map_changed:gsub("{map}", args[2]:lower()))
callbacks.afterDelay.add(1000, function()
Expand Down Expand Up @@ -1806,13 +1806,14 @@ function commands.onDSRCommand(sender, args)

if numArgs(args) == 2 then
logCommand(sender, args)
utils.createDSPLFile(args[2], gsc.getdvar("mapname"))
utils.createDSPLFile(gsc.getdvar("mapname"), args[2])
elseif numArgs(args) == 3 then
local map = getMapName(args[2])
utils.createDSPLFile(map, args[3])
local map = getMapName(args[3])
utils.createDSPLFile(map, args[2])
else
utils.tell(sender, languagehandler.language.dsr_usage)
end
return true

end

Expand All @@ -1824,6 +1825,7 @@ function commands.onDSPLCommand(sender, args)
else
utils.tell(sender, languagehandler.language.dspl_usage)
end
return true

end

Expand Down
13 changes: 5 additions & 8 deletions scripts/mp/plutoadmin/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,8 @@ end

function utils.loadDSPLFile(dspl)

local dsplFile = dspl
if string.match( dspl, ".dspl" ) == false then
dsplFile = dsplFile .. ".dspl"
end

-- rotate to dspl file
gsc.setdvar("sv_mapRotation", dsplFile)
gsc.setdvar("sv_mapRotation", dspl)
util.executeCommand("map_rotate")

end
Expand All @@ -105,10 +100,12 @@ function utils.createDSPLFile(map, dsr)

-- save dspl
local dspl = string.format("%s,%s,1\n", map, dsr)
utils.write_file("admins\\plutoadmin.dspl", dspl)
local file = io.open("admin\\plutoadmin.dspl", "w")
file:write(dspl)
file:close()

-- load new dspl file
utils.loadDSPLFile("plutoadmin.dspl")
utils.loadDSPLFile("plutoadmin")

end

Expand Down
4 changes: 3 additions & 1 deletion settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

"default_ban_time": "2h",

"reset_warns_after_every_round": false,

"title": "^0[{title}^0]^7",

"ranks": [
Expand Down Expand Up @@ -377,4 +379,4 @@
"enabled": true
}
]
}
}
58 changes: 49 additions & 9 deletions votemapConfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"voteTime": 10,
"voteTime": 20,
"mapList": [
{
"longName": "mp_alpha",
Expand All @@ -18,7 +18,7 @@
},
{
"longName": "mp_carbon",
"shortName": "crabon",
"shortName": "carbon",
"enabled": true
},
{
Expand Down Expand Up @@ -47,7 +47,7 @@
"enabled": true
},
{
"longName": "mogadishu",
"longName": "mp_mogadishu",
"shortName": "bakaara",
"enabled": true
},
Expand Down Expand Up @@ -87,7 +87,7 @@
"enabled": true
},
{
"longName": "mp_aqueduct_ss",
"longName": "mp_courtyard_ss",
"shortName": "erosion",
"enabled": true
},
Expand All @@ -97,7 +97,7 @@
"enabled": true
},
{
"longName": "cement",
"longName": "mp_cement",
"shortName": "foundation",
"enabled": true
},
Expand All @@ -113,12 +113,12 @@
},
{
"longName": "mp_meteora",
"shortName": "Sanctuary",
"shortName": "sanctuary",
"enabled": true
},
{
"longName": "mp_morningwood",
"shortName": "Black Box",
"shortName": "blackbox",
"enabled": true
},
{
Expand All @@ -128,18 +128,58 @@
},
{
"longName": "mp_park",
"shortName": "Liberation",
"shortName": "liberation",
"enabled": true
},
{
"longName": "mp_qadeem",
"shortName": "Oasis",
"shortName": "oasis",
"enabled": true
},
{
"longName": "mp_restrepo_ss",
"shortName": "lookout",
"enabled": true
},
{
"longName": "mp_boardwalk",
"shortName": "boardwalk",
"enabled": true
},
{
"longName": "mp_moab",
"shortName": "gulch",
"enabled": true
},
{
"longName": "mp_nola",
"shortName": "parish",
"enabled": true
},
{
"longName": "mp_roughneck",
"shortName": "offshore",
"enabled": true
},
{
"longName": "mp_shipbreaker",
"shortName": "decommission",
"enabled": true
},
{
"longName": "mp_crosswalk_ss",
"shortName": "intersection",
"enabled": true
},
{
"longName": "mp_burn_ss",
"shortName": "uturn",
"enabled": true
},
{
"longName": "mp_six_ss",
"shortName": "vortex",
"enabled": true
}
]
}

0 comments on commit 7b40d9e

Please sign in to comment.