Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2015
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.50 KB | None | 0 0
  1. -- Alien-Kush-Community Donation System
  2. -- Coded by Jok3r | v1.0 | Beta
  3.  
  4. -- Globale Variablen
  5. local plyer = LocalPlayer()
  6. local myTable
  7. local DonationUI
  8. local lastTimeDonated
  9. canDonate = true
  10.  
  11. function openDonationUI()
  12. DonationUI = vgui.Create( "DFrame" )
  13. DonationUI:SetPos(5,5)
  14. DonationUI:SetSize(500, 350)
  15. DonationUI:SetTitle("Spende an den AKC-Server")
  16. DonationUI:SetVisible(true)
  17. DonationUI:SetDraggable(true)
  18. DonationUI:ShowCloseButton(true)
  19. DonationUI:Center()
  20. DonationUI:MakePopup()
  21. DonationUI.Paint = function (s,w,h)
  22.     draw.RoundedBox(0,0,0, w,h, Color(52, 44, 44, 2200))
  23. end
  24.  
  25. local Credits = vgui.Create("DLabel", DonationUI)
  26. Credits:SetPos(381,325)
  27. Credits:SetText("Coded by AKC Jok3r")
  28. Credits:SetTextColor( Color( 255, 255, 255 ) )
  29. Credits:SetFont("Default")
  30. Credits:SizeToContents()
  31.  
  32. local AdminButton = vgui.Create( "DButton", DonationUI)
  33. AdminButton:SetText( "Admin" )
  34. AdminButton:SetTextColor( Color( 255,255,255 ) )
  35. AdminButton:SetPos( 190, 310 )
  36. AdminButton:SetSize( 100, 30 )
  37. AdminButton:SetImage("icon16/user_red.png")
  38. AdminButton.Paint = function( self, w, h )
  39.     draw.RoundedBox( 0, 0, 0, w, h, Color( 215,40,40,250 ) )
  40. end
  41. AdminButton.DoClick = function()
  42.     -- Admin Panel
  43.     plyer:ConCommand("OpenAdminPanel")
  44. end
  45.  
  46. local warnungLabel = vgui.Create("DLabel", DonationUI)
  47. warnungLabel:SetPos( 72, 230 )
  48. local buildString3 = "Falsche Eingaben werden geahndet! Du darfst 1x pro Stunde spenden."
  49. warnungLabel:SetText(buildString3)
  50. warnungLabel:SetTextColor( Color( 255, 0, 0, 255 ) )
  51. warnungLabel:SizeToContents()
  52.  
  53. local help_img = vgui.Create( "DImageButton", DonationUI ) 
  54. help_img:SetPos( 465, 35 ) 
  55. help_img:SetSize( 16, 16 ) 
  56. help_img:SetImage( "icon16/information.png" )
  57. help_img.DoClick = function()
  58.     local HelpFrame = vgui.Create( "DFrame", DonationUI)
  59.     HelpFrame:SetPos(5,5)
  60.     HelpFrame:SetSize(350, 100)
  61.     HelpFrame:SetTitle("Information")
  62.     HelpFrame:SetVisible(true)
  63.     HelpFrame:SetDraggable(false)
  64.     HelpFrame:ShowCloseButton(true)
  65.     HelpFrame:Center()
  66.     HelpFrame:MakePopup()
  67.  
  68.     local HelpLabel = vgui.Create( "DLabel", HelpFrame)
  69.     HelpLabel:SetPos( 40, 40 )
  70.     HelpLabel:SetFont("default")
  71.     local buildString = " Hallo " .. plyer:Nick() .. "! \n Das Team freut sich, dass du spenden möchtest. \n Deine Spende wird so schnell wie möglich bearbeitet. \n Wende dich an ein Teammitglied wenn du es eilig hast!"
  72.     HelpLabel:SetText(buildString)
  73.     HelpLabel:SizeToContents()
  74.    
  75.     local HelpLabelImage = vgui.Create( "DImage", HelpFrame )  
  76.     HelpLabelImage:SetPos( 15, 55 )
  77.     HelpLabelImage:SetSize( 16,16 )
  78.     HelpLabelImage:SetImage( "icon16/emoticon_happy.png" )
  79. end
  80. --Paysafecard Bild
  81. local pscBild = vgui.Create( "DImage", DonationUI )
  82. pscBild:SetPos( 195, 85 )  
  83. pscBild:SetSize( 100,100 ) 
  84. pscBild:SetImage( "paysafe.png" )
  85.  
  86. --AKC Bild
  87. local pscBild = vgui.Create( "DImage", DonationUI )
  88. pscBild:SetPos( 210, 5 )   
  89. pscBild:SetSize( 75,75 )   
  90. pscBild:SetImage( "akc_logo.png" )
  91.  
  92. -- Paysafecode Textfelder (global)
  93. psc1 = vgui.Create( "DTextEntry", DonationUI )  -- create the form as a child of frame
  94. psc1:SetPos( 55, 200 )
  95. psc1:SetSize(65, 25 )
  96. psc1:SetText( "" )
  97. psc1.MaxChars = 4
  98. psc1.OnTextChanged = function(self)
  99.     local txt = self:GetValue()
  100.     local amt = string.len(txt)
  101.     if amt > self.MaxChars then
  102.         self:SetText(self.OldText)
  103.         self:SetValue(self.OldText)
  104.         self:SetCaretPos(4)
  105.     else
  106.         self.OldText = txt
  107.     end
  108. end
  109. psc1.OnEnter = function( self )
  110.     chat.AddText( self:GetValue() ) -- print the form's text as server text
  111. end
  112. local psc1Strich = vgui.Create("DLabel", DonationUI) psc1Strich:SetPos(135,205) psc1Strich:SetFont("default") psc1Strich:SetText("-") psc1Strich:SizeToContents()
  113. psc2 = vgui.Create( "DTextEntry", DonationUI )  -- create the form as a child of frame
  114. psc2:SetPos( 155, 200 )
  115. psc2:SetSize(65, 25 )
  116. psc2:SetText( "" )
  117. psc2.MaxChars = 4
  118. psc2.OnTextChanged = function(self)
  119.     local txt = self:GetValue()
  120.     local amt = string.len(txt)
  121.     if amt > self.MaxChars then
  122.         self:SetText(self.OldText)
  123.         self:SetValue(self.OldText)
  124.         self:SetCaretPos(4)
  125.     else
  126.         self.OldText = txt
  127.     end
  128. end
  129. psc2.OnEnter = function( self )
  130.     chat.AddText( self:GetValue() ) -- print the form's text as server text
  131. end
  132. local psc2Strich = vgui.Create("DLabel", DonationUI) psc2Strich:SetPos(235,205) psc2Strich:SetFont("default") psc2Strich:SetText("-") psc2Strich:SizeToContents()
  133. psc3 = vgui.Create( "DTextEntry", DonationUI )  -- create the form as a child of frame
  134. psc3:SetPos( 255, 200 )
  135. psc3:SetSize(65, 25 )
  136. psc3:SetText( "" )
  137. psc3.MaxChars = 4
  138. psc3.OnTextChanged = function(self)
  139.     local txt = self:GetValue()
  140.     local amt = string.len(txt)
  141.     if amt > self.MaxChars then
  142.         self:SetText(self.OldText)
  143.         self:SetValue(self.OldText)
  144.         self:SetCaretPos(4)
  145.     else
  146.         self.OldText = txt
  147.     end
  148. end
  149. psc3.OnEnter = function( self )
  150.     chat.AddText( self:GetValue() ) -- print the form's text as server text
  151. end
  152. local psc3Strich = vgui.Create("DLabel", DonationUI) psc3Strich:SetPos(335,205) psc3Strich:SetFont("default") psc3Strich:SetText("-") psc3Strich:SizeToContents()
  153. psc4 = vgui.Create( "DTextEntry", DonationUI )  -- create the form as a child of frame
  154. psc4:SetPos( 355, 200 )
  155. psc4:SetSize(65, 25 )
  156. psc4:SetText( "" )
  157. psc4.MaxChars = 4
  158. psc4.OnTextChanged = function(self)
  159.     local txt = self:GetValue()
  160.     local amt = string.len(txt)
  161.     if amt > self.MaxChars then
  162.         self:SetText(self.OldText)
  163.         self:SetValue(self.OldText)
  164.         self:SetCaretPos(4)
  165.     else
  166.         self.OldText = txt
  167.     end
  168. end
  169. psc4.OnEnter = function( self )
  170.     chat.AddText( self:GetValue() ) -- print the form's text as server text
  171. end
  172.  
  173. DonateButton = vgui.Create( "DButton", DonationUI )
  174. DonateButton:SetText( "Spenden" )
  175. DonateButton:SetTextColor( Color( 255, 255, 255 ) )
  176. DonateButton:SetPos( 190, 260 )
  177. DonateButton:SetSize( 100, 30 )
  178. DonateButton:SetImage("icon16/money_euro.png")
  179. DonateButton.Paint = function( self, w, h )
  180.     draw.RoundedBox( 0, 0, 0, w, h, Color( 111, 128, 185, 250 ) )
  181. end
  182. DonateButton.DoClick = function()
  183.     if canDonate then
  184.    
  185.     --get donation time
  186.     lastTimeDonated = os.date("%c")
  187.    
  188.     -- neue donation
  189.     paysafeCodeString = tostring(psc1:GetValue() .. "-" .. psc2:GetValue() .. "-" .. psc3:GetValue() .. "-" .. psc4:GetValue())
  190.     -- prüfen ob der benutzer mist eingegeben hat
  191.     if paysafeCodeString == '' or string.len(paysafeCodeString) > 19 or string.len(paysafeCodeString) < 19 or paysafeCodeString:match("%a")then
  192.    
  193.     local FalscheEingabe = vgui.Create( "DFrame", DonationUI)
  194.     FalscheEingabe:SetPos(5,5)
  195.     FalscheEingabe:SetSize(350, 100)
  196.     FalscheEingabe:SetTitle("Uuuups...")
  197.     FalscheEingabe:SetVisible(true)
  198.     FalscheEingabe:SetDraggable(false)
  199.     FalscheEingabe:ShowCloseButton(true)
  200.     FalscheEingabe:Center()
  201.     FalscheEingabe:MakePopup()
  202.    
  203.     local FalscheEingabeText = vgui.Create( "DLabel", FalscheEingabe)
  204.     FalscheEingabeText:SetPos( 40, 40 )
  205.     FalscheEingabeText:SetFont("default")
  206.     local buildString2 = " Tut mir leid, \n das sieht nicht nach einer Paysafekarte aus... \n Bitte gebe den 16-stelligen Code ein. \n Danke!"
  207.     FalscheEingabeText:SetText(buildString2)
  208.     FalscheEingabeText:SizeToContents()
  209.    
  210.     local FalscheEingabeBild = vgui.Create( "DImage", FalscheEingabe ) 
  211.     FalscheEingabeBild:SetPos( 15, 55 )
  212.     FalscheEingabeBild:SetSize( 16,16 )
  213.     FalscheEingabeBild:SetImage( "icon16/emoticon_unhappy.png" )
  214.     return
  215.     end
  216.     -- Sende Donation Paket an Server, er wartet darauf!
  217.     net.Start("donation")
  218.         net.WriteString(plyer:Nick())
  219.         net.WriteString(plyer:SteamID())
  220.         net.WriteString(paysafeCodeString)
  221.         net.WriteString(lastTimeDonated)
  222.     net.SendToServer()
  223.     canDonate = false
  224.     local VielenDankFrame = vgui.Create("DFrame", DonationUI)
  225.     VielenDankFrame:SetPos(5,5)
  226.     VielenDankFrame:SetSize(400, 100)
  227.     VielenDankFrame:SetTitle("Vielen Dank!")
  228.     VielenDankFrame:SetVisible(true)
  229.     VielenDankFrame:SetDraggable(false)
  230.     VielenDankFrame:ShowCloseButton(false)
  231.     VielenDankFrame:Center()
  232.     VielenDankFrame:MakePopup()
  233.    
  234.     local VielenDankText = vgui.Create("DLabel", VielenDankFrame)
  235.     VielenDankText:SetPos( 40, 30 )
  236.     local buildString4 = " Wir bedanken uns bei Dir! \n Deine Eingaben wurden in der Datenbank hinterlegt. \n Wir versuchen deinen Fall so schnell wie möglich zu bearbeiten."
  237.     VielenDankText:SetText(buildString4)
  238.     VielenDankText:SetFont("default")
  239.     VielenDankText:SizeToContents()
  240.     local VielenDankOk = vgui.Create("DButton", VielenDankFrame)
  241.     VielenDankOk:SetText( "Okay." )
  242.     --VielenDankOk:SetTextColor( Color( 255, 255, 255 ) )
  243.     VielenDankOk:SetPos( 145, 70 )
  244.     VielenDankOk:SetSize( 100, 20 )
  245.     VielenDankOk:SetImage("icon16/database.png")
  246.     VielenDankOk.DoClick = function()
  247.         VielenDankFrame:SetVisible(false)
  248.         end
  249.     -- Anti-Spam
  250.     end
  251.     if not canDonate then
  252.     local DuHastSchonGespendet = vgui.Create("DFrame", DonationUI)
  253.     DuHastSchonGespendet:SetPos(5,5)
  254.     DuHastSchonGespendet:SetSize(400,100)
  255.     DuHastSchonGespendet:SetTitle("Fehler")
  256.     DuHastSchonGespendet:SetVisible(true)
  257.     DuHastSchonGespendet:SetDraggable(false)
  258.     DuHastSchonGespendet:ShowCloseButton(false)
  259.     DuHastSchonGespendet:Center()
  260.     DuHastSchonGespendet:MakePopup()
  261.    
  262.     local DuHastSchonGespendetText = vgui.Create("DLabel", DuHastSchonGespendet)
  263.     DuHastSchonGespendetText:SetPos( 40, 30 )
  264.     local buildString5 = " Tut uns Leid! \n Du darfst nur einmal pro Stunde spenden. \n Zeitpunkt der Spende: " .. lastTimeDonated .. " Uhr. \n Rechne zu diesem Zeitpunkt 1 Stunde drauf und du kannst \n wieder spenden!"
  265.     DuHastSchonGespendetText:SetText(buildString5)
  266.     DuHastSchonGespendetText:SetFont("default")
  267.     DuHastSchonGespendetText:SizeToContents()
  268.     local DuHastSchonGespendetOk = vgui.Create("DButton", DuHastSchonGespendet)
  269.     DuHastSchonGespendetOk:SetText( "Okay." )
  270.     --VielenDankOk:SetTextColor( Color( 255, 255, 255 ) )
  271.     DuHastSchonGespendetOk:SetPos( 145, 78 )
  272.     DuHastSchonGespendetOk:SetSize( 100, 20 )
  273.     DuHastSchonGespendetOk:SetImage("icon16/cross.png")
  274.     DuHastSchonGespendetOk.DoClick = function()
  275.         DuHastSchonGespendet:SetVisible(false)
  276.         DonationUI:SetVisible(false)
  277.         end
  278.     end
  279.     timer.Create("AntiSpamTimer", 3600, 1, function()
  280.         --setze variable auf true wenn 1 stunde um ist / 3600s = 1h
  281.         canDonate = true
  282.     end)
  283. end
  284.  
  285. end
  286.  
  287.  
  288. function openAdminUI()
  289.  
  290. net.Start("willDonations")
  291. net.SendToServer()
  292.  
  293.  
  294.  DonationUI:SetVisible(false)
  295.  local AdminUI = vgui.Create("DFrame")
  296.  AdminUI:SetPos( 100, 100 )
  297.  AdminUI:SetSize( 600, 400 )
  298.  AdminUI:SetTitle( "Administration - Spenden" )
  299.  AdminUI:SetDraggable( false )
  300.  AdminUI:ShowCloseButton(true)
  301.  AdminUI:Center()
  302.  AdminUI:MakePopup()
  303.  
  304. local DonationList = vgui.Create( "DListView" , AdminUI )
  305. DonationList:SetSize(500,300)
  306. DonationList:SetPos(5,5)
  307. DonationList:Center()
  308. DonationList:SetMultiSelect( false )
  309. DonationList:AddColumn( "Name" )
  310. DonationList:AddColumn( "Steam-ID" )
  311. DonationList:AddColumn( "PSC" )
  312. DonationList:AddColumn( "Datum" )
  313. DonationList:SetMultiSelect( true )
  314. DonationList.OnRowSelected = function(panel, line)
  315. local Menu = DermaMenu()        -- Is the same as vgui.Create( "DMenu" )
  316. local btnWithIcon = Menu:AddOption( "Erledigt", function()
  317.  -- Funktion wenn Erledigt geklickt wird.
  318.  selectedLineIndex = DonationList:GetSelectedLine()
  319.  net.Start("removeLine")
  320.  net.WriteInt(selectedLineIndex, 32)
  321.  net.SendToServer()
  322.  DonationList:RemoveLine(selectedLineIndex)
  323. end)
  324. btnWithIcon:SetIcon( "icon16/accept.png" )
  325. Menu:Open()
  326. end
  327.  
  328. net.Receive("sendeDonations", function(len)
  329.     tableGUI = net.ReadTable()
  330.     for k, v in pairs(tableGUI) do
  331.         DonationList:AddLine(v.PlayerName, v.SteamID, v.Paysafecode, v.Date)
  332.     end
  333.    
  334. end)
  335. end
  336. -- ConsoleCommands
  337. concommand.Add("OpenDonationMenu", openDonationUI)
  338. concommand.Add("OpenAdminPanel", openAdminUI)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement