We currently have a command on our servers that allows us to place certain players on a watchlist. I was wondering how I would go about creating a watchid command, and what'd I have to change in the already existing print watchlist command. Below are the current watch, unwatch and watchlist commands as well as any related functions. I've tried making one myself based off the existing banid example but I haven't reached any success.
function ulx.watch(calling_ply, target_ply, reason)
target_ply:SetPData("Watched","true")
target_ply:SetPData("WatchReason",reason)
ulx.fancyLogAdmin( calling_ply, true, "#A marked #T as watched: "..reason.. "" , target_ply )
end
local watch = ulx.command("Essentials", "ulx watch", ulx.watch, "!watch",true)
watch:addParam{ type=ULib.cmds.PlayerArg }
watch:addParam{ type=ULib.cmds.StringArg, hint="reason", ULib.cmds.takeRestOfLine }
watch:defaultAccess( ULib.ACCESS_ADMIN )
watch:help( "Puts a player on watch list." )
function ulx.unwatch(calling_ply, target_ply)
target_ply:SetPData("Watched","false")
target_ply:RemovePData("WatchReason")
ulx.fancyLogAdmin( calling_ply, true, "#A removed #T from watch list", target_ply )
end
local unwatch = ulx.command("Essentials", "ulx unwatch", ulx.unwatch, "!unwatch",true)
unwatch:addParam{ type=ULib.cmds.PlayerArg }
unwatch:defaultAccess( ULib.ACCESS_ADMIN )
unwatch:help( "Removes a player from watch list." )
function userAuthed( ply, stid, unid )
if ply:GetPData("Watched") == "true" then
ulx.fancyLogAdmin(nil, true, "#T ("..stid.. ") is on the watchlist: "..ply:GetPData("WatchReason").. "",ply)
end
end
hook.Add( "PlayerAuthed", "watchlisthook", userAuthed )
function ulx.watchlist(calling_ply)
watchlist = {}
for k, v in pairs(player.GetAll()) do
if v:GetPData("Watched") == "true" then
table.insert( watchlist, v:Nick() or v:displayid())
table.insert(watchlist, v:GetPData("WatchReason"))
end
end
local watchstring = table.concat( watchlist, ", " )
ulx.fancyLogAdmin( nil, true, "Watchlist: #s ",watchstring )
end
local watchlist = ulx.command("Essentials", "ulx watchlist", ulx.watchlist, "!watchlist",true)
watchlist:defaultAccess( ULib.ACCESS_ADMIN )
watchlist:help( "Prints watch list." )