Files
cuberite-2a/MCServer/Plugins/Core/rank-groups.lua
T

64 lines
1.5 KiB
Lua
Raw Normal View History

2013-07-27 16:24:03 +01:00
function HandleRankCommand( Split, Player )
2013-08-11 16:00:53 +01:00
2013-07-27 16:24:03 +01:00
if Split[2] == nil or Split[3] == nil then
2013-08-11 16:00:53 +01:00
SendMessage( Player, "Usage: /rank [Player] [Group]" )
2013-07-27 16:24:03 +01:00
return true
end
2013-08-11 16:00:53 +01:00
local GroupsIni = cIniFile( "groups.ini" )
if GroupsIni:ReadFile() == false then
LOG( "Could not read groups.ini!" )
2013-07-27 16:24:03 +01:00
end
2013-08-11 16:00:53 +01:00
2013-07-27 16:24:03 +01:00
if GroupsIni:FindKey(Split[3]) == -1 then
2013-08-11 16:00:53 +01:00
SendMessageFailure( Player, "Group does not exist" )
2013-07-27 16:24:03 +01:00
return true
end
2013-08-11 16:00:53 +01:00
2013-07-27 16:24:03 +01:00
local UsersIni = cIniFile("users.ini")
2013-08-11 16:00:53 +01:00
if UsersIni:ReadFile() == false then
LOG( "Could not read users.ini!" )
2013-07-27 16:24:03 +01:00
end
2013-08-11 16:00:53 +01:00
UsersIni:DeleteKey( Split[2] )
UsersIni:GetValueSet( Split[2], "Groups", Split[3] )
2013-07-27 16:24:03 +01:00
UsersIni:WriteFile()
2013-08-11 16:00:53 +01:00
2013-07-27 16:24:03 +01:00
local loopPlayers = function( Player )
if Player:GetName() == Split[2] then
2013-08-11 16:00:53 +01:00
SendMessageSuccess( Player, "You were moved to group " .. Split[3] )
2013-07-27 16:24:03 +01:00
Player:LoadPermissionsFromDisk()
end
end
2013-08-11 16:00:53 +01:00
2013-07-27 16:24:03 +01:00
local loopWorlds = function ( World )
World:ForEachPlayer( loopPlayers )
end
2013-08-11 16:00:53 +01:00
2013-07-27 16:24:03 +01:00
cRoot:Get():ForEachWorld( loopWorlds )
2013-08-11 16:00:53 +01:00
SendMessageSuccess( Player, "Player " .. Split[2] .. " Was moved to " .. Split[3] )
2013-07-27 16:24:03 +01:00
return true
2013-08-11 16:00:53 +01:00
2013-07-27 16:24:03 +01:00
end
2013-07-31 17:10:59 +01:00
function HandleGroupsCommand( Split, Player )
2013-08-11 16:00:53 +01:00
local GroupsIni = cIniFile( "groups.ini" )
2013-07-27 16:24:03 +01:00
if GroupsIni:ReadFile() == false then
2013-08-11 16:00:53 +01:00
SendMessageFailure( Player, "No groups found" )
2013-07-27 16:24:03 +01:00
end
2013-08-11 16:00:53 +01:00
2013-07-27 16:24:03 +01:00
Number = GroupsIni:NumKeys() - 1
Groups = {}
for i=0, Number do
2013-08-11 16:00:53 +01:00
table.insert( Groups, GroupsIni:KeyName( i ) )
2013-07-27 16:24:03 +01:00
end
2013-08-11 16:00:53 +01:00
SendMessage( Player, "Found " .. #Groups .. " groups" )
SendMessage( Player, table.concat( Groups, " " ) )
2013-07-27 16:24:03 +01:00
return true
2013-08-11 16:00:53 +01:00
end