Skip to content

Commit 47aed34

Browse files
committed
added !checkmap and !country command
1 parent 60e9b8c commit 47aed34

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

resources/irc/acl.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,5 @@
5050
<command name="!zone" level="0" echoChannelOnly="false" />
5151
<command name="!refreshall" level="4" echoChannelOnly="false" />
5252
<command name="!refresh" level="4" echoChannelOnly="false" />
53+
<command name="!country" level="2" echoChannelOnly="false" />
5354
</acl>

resources/irc/scripts/irccommands.lua

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,31 @@ addEventHandler("onIRCResourceStart",root,
510510
end
511511
end
512512
)
513+
514+
addIRCCommandHandler("!checkmap",
515+
function (server,channel,user,command,...)
516+
local map = table.concat({...}," ")
517+
if not map then ircNotice(user,"syntax is !changemap <name>") return end
518+
local maps = {}
519+
for i,resource in ipairs (getResources()) do
520+
if getResourceInfo(resource,"type") == "map" then
521+
if string.find(string.lower(getResourceName(resource)),string.lower(map),0,false) then
522+
table.insert(maps,resource)
523+
elseif string.find(string.lower(getResourceInfo(resource,"name")),string.lower(map),0,false) then
524+
table.insert(maps,resource)
525+
end
526+
end
527+
end
528+
if #maps == 0 then
529+
ircNotice(user,"No maps found!")
530+
else
531+
for i,resource in ipairs (maps) do
532+
maps[i] = getResourceName(resource)
533+
end
534+
ircNotice(user,"Found "..#maps.." matches: "..table.concat(maps,", "))
535+
end
536+
end
537+
)
513538

514539
addIRCCommandHandler("!changemap",
515540
function (server,channel,user,command,...)
@@ -518,9 +543,9 @@ addEventHandler("onIRCResourceStart",root,
518543
local maps = {}
519544
for i,resource in ipairs (getResources()) do
520545
if getResourceInfo(resource,"type") == "map" then
521-
if string.find(string.lower(getResourceName(resource)),string.lower(map)) then
546+
if string.find(string.lower(getResourceName(resource)),string.lower(map),0,false) then
522547
table.insert(maps,resource)
523-
elseif string.find(string.lower(getResourceInfo(resource,"name")),string.lower(map)) then
548+
elseif string.find(string.lower(getResourceInfo(resource,"name")),string.lower(map),0,false) then
524549
table.insert(maps,resource)
525550
end
526551
end
@@ -646,5 +671,27 @@ addEventHandler("onIRCResourceStart",root,
646671
end
647672
end
648673
)
674+
675+
addIRCCommandHandler("!country",
676+
function (server,channel,user,command,name)
677+
if not name then ircNotice(user,"syntax is !country <name>") return end
678+
local admin = getResourceFromName("admin")
679+
if admin and getResourceState(admin) == "running" then
680+
local player = getPlayerFromPartialName(name)
681+
if player then
682+
local country = exports.admin:getPlayerCountry(player)
683+
if country then
684+
ircSay(channel,tostring(getPlayerName(player)).."'s country: "..tostring(country))
685+
else
686+
ircSay(channel,"Could not find "..tostring(getPlayerName(player)).."'s country.")
687+
end
688+
else
689+
ircSay(channel,"'"..name.."' no such player")
690+
end
691+
else
692+
ircNotice(user,"the admin resource is not running")
693+
end
694+
end
695+
)
649696
end
650697
)

0 commit comments

Comments
 (0)