forked from TeamUlysses/ulib
commit
8bf1e303ec
@ -150,15 +150,16 @@ hook.Add( "CheckPassword", "ULibBanCheck", checkBan, HOOK_LOW )
|
||||
ply - The player to kick.
|
||||
reason - *(Optional)* The reason to give for kicking.
|
||||
calling_ply - *(Optional)* The player doing the kicking.
|
||||
is_ban - *(Optional)* Called from a ban, or just a kick.
|
||||
|
||||
Revisions:
|
||||
|
||||
v2.60 - Fixed a bug with the parameters if you didn't pass reason and calling_ply together.
|
||||
]]
|
||||
function ULib.kick( ply, reason, calling_ply )
|
||||
function ULib.kick( ply, reason, calling_ply, is_ban )
|
||||
local nick = calling_ply and calling_ply:IsValid() and
|
||||
(string.format( "%s(%s)", calling_ply:Nick(), calling_ply:SteamID() ) or "Console")
|
||||
|
||||
local steamid = ply:SteamID()
|
||||
if reason and nick then
|
||||
ply:Kick( string.format( "Kicked by %s - %s", nick, reason ) )
|
||||
elseif nick then
|
||||
@ -166,6 +167,7 @@ function ULib.kick( ply, reason, calling_ply )
|
||||
else
|
||||
ply:Kick( reason or "[ULX] Kicked from server" )
|
||||
end
|
||||
hook.Call( ULib.HOOK_USER_KICKED, _, steamid, reason or "[ULX] Kicked from server", calling_ply or "Console" )
|
||||
end
|
||||
|
||||
|
||||
@ -272,7 +274,7 @@ function ULib.addBan( steamid, time, reason, name, admin )
|
||||
|
||||
local ply = player.GetBySteamID( steamid )
|
||||
if ply then
|
||||
ULib.kick( ply, longReason )
|
||||
ULib.kick( ply, longReason, nil, true)
|
||||
end
|
||||
|
||||
-- Remove all semicolons from the reason to prevent command injection
|
||||
@ -284,6 +286,7 @@ function ULib.addBan( steamid, time, reason, name, admin )
|
||||
game.ConsoleCommand( "writeid\n" )
|
||||
|
||||
ULib.fileWrite( ULib.BANS_FILE, ULib.makeKeyValues( ULib.bans ) )
|
||||
hook.Call( ULib.HOOK_USER_BANNED, _, steamid, t )
|
||||
end
|
||||
|
||||
--[[
|
||||
@ -311,6 +314,8 @@ function ULib.unban( steamid, admin )
|
||||
--ULib banlist
|
||||
ULib.bans[ steamid ] = nil
|
||||
ULib.fileWrite( ULib.BANS_FILE, ULib.makeKeyValues( ULib.bans ) )
|
||||
hook.Call( ULib.HOOK_USER_UNBANNED, _, steamid, admin or "Console" )
|
||||
|
||||
end
|
||||
|
||||
local function doInvis()
|
||||
|
@ -336,6 +336,7 @@ function ucl.addGroup( name, allows, inherit_from, from_CAMI )
|
||||
ucl.groups[ name ] = { allow=allows, inherit_from=inherit_from }
|
||||
ucl.saveGroups()
|
||||
|
||||
hook.Call( ULib.HOOK_GROUP_CREATED, _, name, ucl.groups[ name ] )
|
||||
hook.Call( ULib.HOOK_UCLCHANGED )
|
||||
|
||||
-- CAMI logic
|
||||
@ -414,6 +415,7 @@ function ucl.groupAllow( name, access, revoke )
|
||||
|
||||
ucl.saveGroups()
|
||||
|
||||
hook.Call( ULib.HOOK_GROUP_ACCESS_CHANGE, _, name, access, revoke or false )
|
||||
hook.Call( ULib.HOOK_UCLCHANGED )
|
||||
end
|
||||
|
||||
@ -473,6 +475,7 @@ function ucl.renameGroup( orig, new )
|
||||
ucl.saveUsers()
|
||||
ucl.saveGroups()
|
||||
|
||||
hook.Call( ULib.HOOK_GROUP_RENAMED, _, orig, new )
|
||||
hook.Call( ULib.HOOK_UCLCHANGED )
|
||||
|
||||
-- CAMI logic
|
||||
@ -536,6 +539,7 @@ function ucl.setGroupInheritance( group, inherit_from, from_CAMI )
|
||||
|
||||
ucl.saveGroups()
|
||||
|
||||
hook.Call( ULib.HOOK_GROUP_INHERIT_CHANGE, _, group, inherit_from, old_inherit )
|
||||
hook.Call( ULib.HOOK_UCLCHANGED )
|
||||
|
||||
-- CAMI logic
|
||||
@ -566,9 +570,11 @@ function ucl.setGroupCanTarget( group, can_target )
|
||||
if not ucl.groups[ group ] then return error( "Group does not exist (" .. group .. ")", 2 ) end
|
||||
|
||||
if ucl.groups[ group ].can_target == can_target then return end -- Nothing to change
|
||||
|
||||
local old = ucl.groups[ group ].can_target
|
||||
ucl.groups[ group ].can_target = can_target
|
||||
|
||||
hook.Call( ULib.HOOK_GROUP_CANTARGET_CHANGE, _, group, can_target, old )
|
||||
|
||||
ucl.saveGroups()
|
||||
|
||||
hook.Call( ULib.HOOK_UCLCHANGED )
|
||||
@ -616,7 +622,7 @@ function ucl.removeGroup( name, from_CAMI )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local oldgroup = table.Copy( ucl.groups[ name ] )
|
||||
ucl.groups[ name ] = nil
|
||||
for _, groupInfo in pairs( ucl.groups ) do
|
||||
if groupInfo.inherit_from == name then
|
||||
@ -627,6 +633,7 @@ function ucl.removeGroup( name, from_CAMI )
|
||||
ucl.saveUsers()
|
||||
ucl.saveGroups()
|
||||
|
||||
hook.Call( ULib.HOOK_GROUP_REMOVED, _, name, oldgroup )
|
||||
hook.Call( ULib.HOOK_UCLCHANGED )
|
||||
|
||||
-- CAMI logic
|
||||
@ -733,12 +740,14 @@ function ucl.addUser( id, allows, denies, group, from_CAMI )
|
||||
CAMI.SignalUserGroupChanged( ply, oldgroup, group or "user", CAMI.ULX_TOKEN )
|
||||
end
|
||||
|
||||
hook.Call( ULib.HOOK_USER_GROUP_CHANGE, _, id, allows, denies, group, oldgroup )
|
||||
ucl.probe( ply )
|
||||
else -- Otherwise this gets called twice
|
||||
if not from_CAMI then
|
||||
CAMI.SignalSteamIDUserGroupChanged( id, oldgroup, group or "user", CAMI.ULX_TOKEN )
|
||||
end
|
||||
hook.Call( ULib.HOOK_UCLCHANGED )
|
||||
hook.Call( ULib.HOOK_USER_GROUP_CHANGE, _, id, allows, denies, group, oldgroup )
|
||||
end
|
||||
end
|
||||
|
||||
@ -857,6 +866,7 @@ function ucl.userAllow( id, access, revoke, deny )
|
||||
|
||||
ucl.saveUsers()
|
||||
|
||||
hook.Call( ULib.HOOK_USER_ACCESS_CHANGE, _, id, access, revoke or false, deny or false )
|
||||
hook.Call( ULib.HOOK_UCLCHANGED )
|
||||
end
|
||||
|
||||
@ -910,6 +920,7 @@ function ucl.removeUser( id, from_CAMI )
|
||||
|
||||
if changed then -- If the user is only added to the default garry file, then nothing changed
|
||||
ucl.saveUsers()
|
||||
hook.Call( ULib.HOOK_USER_REMOVED, _, id, userInfo )
|
||||
end
|
||||
|
||||
local ply = ULib.getPlyByID( id )
|
||||
|
@ -254,6 +254,216 @@ ULib.HOOK_GETUSERS_CUSTOM_KEYWORD = "ULibGetUsersCustomKeyword"
|
||||
]]
|
||||
ULib.HOOK_GETUSER_CUSTOM_KEYWORD = "ULibGetUserCustomKeyword"
|
||||
|
||||
--[[
|
||||
Hook: ULibPlayerKicked
|
||||
|
||||
Called during ULib.kick.
|
||||
This alerts you to the player being kicked.
|
||||
|
||||
Parameters passed to callback:
|
||||
|
||||
steamid - SteamID of the kicked player.
|
||||
reason - Kick reason. Can be nil.
|
||||
caller - Whomever did the kick. Can be nil.
|
||||
|
||||
Revisions:
|
||||
|
||||
v2.61 - Initial
|
||||
]]
|
||||
ULib.HOOK_USER_KICKED = "ULibPlayerKicked"
|
||||
|
||||
--[[
|
||||
Hook: ULibPlayerBanned
|
||||
|
||||
Called during ULib.addBan.
|
||||
This alerts you to the player being banned.
|
||||
|
||||
Parameters passed to callback:
|
||||
|
||||
steamid - SteamID of the banned player.
|
||||
ban_data - The data about the ban, exactly like it would be stored in ULib.bans.
|
||||
|
||||
Revisions:
|
||||
|
||||
v2.61 - Initial
|
||||
]]
|
||||
ULib.HOOK_USER_BANNED = "ULibPlayerBanned"
|
||||
|
||||
--[[
|
||||
Hook: ULibPlayerUnBanned
|
||||
|
||||
Called during ULib.unban.
|
||||
This alerts you to the player being banned.
|
||||
|
||||
Parameters passed to callback:
|
||||
|
||||
steamid - SteamID of the unbanned player.
|
||||
admin - If passed, it will be the unbaning admin, else it will show as console..
|
||||
|
||||
Revisions:
|
||||
|
||||
v2.61 - Initial
|
||||
]]
|
||||
ULib.HOOK_USER_UNBANNED = "ULibPlayerUnBanned"
|
||||
|
||||
--[[
|
||||
Hook: ULibGroupCreated
|
||||
|
||||
Called during ULib.ucl.addGroup.
|
||||
This alerts you to the group being created.
|
||||
|
||||
Parameters passed to callback:
|
||||
|
||||
group_name - Group Name
|
||||
group_data - Group table as it is store in ULib.ucl.groups[ name ].
|
||||
|
||||
Revisions:
|
||||
|
||||
v2.61 - Initial
|
||||
]]
|
||||
ULib.HOOK_GROUP_CREATED = "ULibGroupCreated"
|
||||
|
||||
--[[
|
||||
Hook: ULibGroupRemoved
|
||||
|
||||
Called during ULib.ucl.removeGroup.
|
||||
This alerts you to the group being removed.
|
||||
|
||||
Parameters passed to callback:
|
||||
|
||||
group_name - Group Name
|
||||
group_data - Group table as it is store in ULib.ucl.groups[ name ].
|
||||
|
||||
Revisions:
|
||||
|
||||
v2.61 - Initial
|
||||
]]
|
||||
ULib.HOOK_GROUP_REMOVED = "ULibGroupRemoved"
|
||||
|
||||
--[[
|
||||
Hook: ULibGroupAccessChanged
|
||||
|
||||
Called during ULib.ucl.groupAllow.
|
||||
This alerts you to the group access being changed.
|
||||
|
||||
Parameters passed to callback:
|
||||
|
||||
group_name - Group Name
|
||||
access - Acess being changed
|
||||
revoke - Are we adding(false) or revoking(true)
|
||||
|
||||
Revisions:
|
||||
|
||||
v2.61 - Initial
|
||||
]]
|
||||
ULib.HOOK_GROUP_ACCESS_CHANGE = "ULibGroupAccessChanged"
|
||||
|
||||
--[[
|
||||
Hook: ULibGroupRenamed
|
||||
|
||||
Called during ULib.ucl.renameGroup.
|
||||
This alerts you to the group being renamed.
|
||||
|
||||
Parameters passed to callback:
|
||||
|
||||
old_name - Old Group Name
|
||||
new_name - New Group Name
|
||||
|
||||
Revisions:
|
||||
|
||||
v2.61 - Initial
|
||||
]]
|
||||
ULib.HOOK_GROUP_RENAMED = "ULibGroupRenamed"
|
||||
|
||||
--[[
|
||||
Hook: ULibGroupInheritanceChanged
|
||||
|
||||
Called during ULib.ucl.setGroupInheritance.
|
||||
This alerts you to the group Inheritance being changed.
|
||||
|
||||
Parameters passed to callback:
|
||||
|
||||
group_name - Group Name
|
||||
new_inherit - New Inheritance
|
||||
old_inherit - Old Inheritance
|
||||
|
||||
Revisions:
|
||||
|
||||
v2.61 - Initial
|
||||
]]
|
||||
ULib.HOOK_GROUP_INHERIT_CHANGE = "ULibGroupInheritanceChanged"
|
||||
|
||||
--[[
|
||||
Hook: ULibGroupCanTargetChanged
|
||||
|
||||
Called during ULib.ucl.setGroupCanTarget.
|
||||
This alerts you to the group CanTarget being changed.
|
||||
|
||||
Parameters passed to callback:
|
||||
|
||||
group_name - Group Name
|
||||
new_target - New CanTarget
|
||||
old_target - Old CanTarget
|
||||
|
||||
Revisions:
|
||||
|
||||
v2.61 - Initial
|
||||
]]
|
||||
ULib.HOOK_GROUP_CANTARGET_CHANGE = "ULibGroupCanTargetChanged"
|
||||
|
||||
--[[
|
||||
Hook: ULibUserGroupChange
|
||||
|
||||
Called during ULib.ucl.addUser.
|
||||
This alerts you to the user's group being changed.
|
||||
|
||||
Parameters passed to callback:
|
||||
|
||||
id - Steamid of the user.
|
||||
allows - Allows Table
|
||||
denies - Denies Table
|
||||
new_group - New Group
|
||||
old_group - Old Group
|
||||
Revisions:
|
||||
|
||||
v2.61 - Initial
|
||||
]]
|
||||
ULib.HOOK_USER_GROUP_CHANGE = "ULibUserGroupChange"
|
||||
|
||||
--[[
|
||||
Hook: ULibUserAccessChange
|
||||
|
||||
Called during ULib.ucl.userAllow.
|
||||
This alerts you to the user's acess being changed.
|
||||
|
||||
Parameters passed to callback:
|
||||
|
||||
id - Steamid of the user.
|
||||
access - Acess being changed
|
||||
revoke - Are we adding(false) or revoking(true)
|
||||
deny - Are we denying(true) or allowing(false)
|
||||
Revisions:
|
||||
|
||||
v2.61 - Initial
|
||||
]]
|
||||
ULib.HOOK_USER_ACCESS_CHANGE = "ULibUserAccessChange"
|
||||
|
||||
--[[
|
||||
Hook: ULibUserRemoved
|
||||
|
||||
Called during ULib.ucl.removeUser.
|
||||
This alerts you to the user's group being removed.
|
||||
|
||||
Parameters passed to callback:
|
||||
|
||||
id - Steamid of the user.
|
||||
user_info - Old User Info(group, allows, denys, etc) as stored in ULib.ucl.users[id] before the change
|
||||
Revisions:
|
||||
|
||||
v2.61 - Initial
|
||||
]]
|
||||
ULib.HOOK_USER_REMOVED = "ULibUserRemoved"
|
||||
|
||||
--[[
|
||||
Section: UCL Helpers
|
||||
|
||||
|
@ -1 +1 @@
|
||||
1489017527
|
||||
1489347349
|
Loading…
Reference in New Issue
Block a user