Advertisement
Guest User

asdsasdsd

a guest
Jul 23rd, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.56 KB | None | 0 0
  1. ------------------------------------------------------------------
  2. -- ______ _____ __ _ _______ _______ _____ _____ __ _ --
  3. -- | \ | | | \ | |_____| | | | | | \ | --
  4. -- |_____/ |_____| | \_| | | | __|__ |_____| | \_| --
  5. -- --
  6. -- _ _ _______ __ __ _______ --
  7. -- |____/ |______ \_/ |______ --
  8. -- | \_ |______ | ______| --
  9. ------------------------------------------------------------------
  10.  
  11. -- Welcome to the Donation keys script! Follow these instructions and
  12. -- you will be able to have a successful donation key system on your
  13. -- server!
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34. local DONATIONTYPES = {}
  35.  
  36. if SERVER then
  37. util.AddNetworkString("cl_sendDonationKey")
  38. local ulx = true; -- Are you using ulx?
  39. local evolve = false; -- Are you using evolve?
  40. -- if we are not using any of the above we assume you are using default FAdmin
  41.  
  42. DONATIONTYPES["1"] = function(ply)
  43. --code to apply reward for donation of type 1
  44. ply:addMoney(10000)
  45. ply:PrintMessage(HUD_PRINTTALK, "You received 10k cash!")
  46. game.ConsoleCommand("say " ..ply:Nick().. " Has purchased 10k cash! Thank you!")
  47. end
  48.  
  49. DONATIONTYPES["2"] = function(ply)
  50. if(ulx)then
  51. game.ConsoleCommand("ulx adduser "..ply:Nick().." donator")
  52. elseif(evolve) then
  53. game.ConsoleCommand("ev rank "..ply:Nick().." donator")
  54. else
  55. ply:SetUserGroup("donator")
  56. end
  57. ply:addMoney(50000)
  58. ply:PrintMessage(HUD_PRINTTALK, "You received donator status and 50k cash!")
  59. game.ConsoleCommand("say " ..ply:Nick().. " Has purchased 50k! Thank you!")
  60. end
  61.  
  62. DONATIONTYPES["3"] = function(ply)
  63. if(ulx)then
  64. game.ConsoleCommand("ulx adduser "..ply:Nick().." donator")
  65. elseif(evolve) then
  66. game.ConsoleCommand("ev rank "..ply:Nick().." donator")
  67. else
  68. ply:SetUserGroup("donator")
  69. end
  70. ply:addMoney(100000)
  71. ply:PrintMessage(HUD_PRINTTALK, "You received donator status and 100k cash!")
  72. game.ConsoleCommand("say " ..ply:Nick().. " Has purchased 1ook Thank you!")
  73. end
  74.  
  75. DONATIONTYPES["4"] = function(ply)
  76. if(ulx)then
  77. game.ConsoleCommand("ulx adduser "..ply:Nick().." Vip")
  78. elseif(evolve) then
  79. game.ConsoleCommand("ev rank "..ply:Nick().." Vip")
  80. else
  81. ply:SetUserGroup("Xeon")
  82. end
  83. ply:addMoney(250000)
  84. ply:PrintMessage(HUD_PRINTTALK, "You received Vip status and 250k cash!")
  85. game.ConsoleCommand("say " ..ply:Nick().. " Has purchased 250k! Thank you!")
  86. end
  87.  
  88. DONATIONTYPES["5"] = function(ply)
  89. if(ulx)then
  90. game.ConsoleCommand("ulx adduser "..ply:Nick().." Super-Vip")
  91. elseif(evolve) then
  92. game.ConsoleCommand("ev rank "..ply:Nick().." Super-Vip")
  93. else
  94. ply:SetUserGroup("Super-Vip")
  95. end
  96. ply:addMoney(250000)
  97. ply:PrintMessage(HUD_PRINTTALK, "You received Super-Vip status and 1m cash!")
  98. game.ConsoleCommand("say " ..ply:Nick().. " Has purchased 1m! Thank you!")
  99. end
  100. DONATIONTYPES["6"] = function(ply)
  101.  
  102. ply:PS_GivePoints(5000)
  103. ply:PrintMessage(HUD_PRINTTALK, "You received 5k points!")
  104. game.ConsoleCommand("say " ..ply:Nick().. " Has purchased 5k points! Thank you!")
  105. end
  106.  
  107. DONATIONTYPES["7"] = function(ply)
  108. if(ulx)then
  109. game.ConsoleCommand("ulx adduser "..ply:Nick().." donator")
  110. end
  111. ply:PS_GivePoints(50000)
  112. ply:PrintMessage(HUD_PRINTTALK, "You received 50k points!")
  113. game.ConsoleCommand("say " ..ply:Nick().. " Has purchased 50k points and donator rank ! Thank you!")
  114. end
  115.  
  116. DONATIONTYPES["8"] = function(ply)
  117. game.ConsoleCommand("ulx adduser "..ply:Nick().." donator")
  118. end
  119. ply:PS_GivePoints(100000)
  120. ply:PrintMessage(HUD_PRINTTALK, "You received 100k points and donator rank!")
  121. game.ConsoleCommand("say " ..ply:Nick().. " Has purchased 100k points! Thank you!")
  122. end
  123.  
  124. DONATIONTYPES["9"] = function(ply)
  125. game.ConsoleCommand("ulx adduser "..ply:Nick().." Vip")
  126. end
  127. ply:PS_GivePoints(250000)
  128. ply:PrintMessage(HUD_PRINTTALK, "You received 250k points and vip rank!)
  129. game.ConsoleCommand("say " ..ply:Nick().. " Has purchased 250k points! Thank you!")
  130. end
  131.  
  132. DONATIONTYPES["10"] = function(ply)
  133. game.ConsoleCommand("ulx adduser "..ply:Nick().." Super-Vip")
  134. end
  135. ply:PS_GivePoints(100000)
  136. ply:PrintMessage(HUD_PRINTTALK, "You received 500k points and supervip rank!")
  137. game.ConsoleCommand("say " ..ply:Nick().. " Has purchased 500k points! Thank you!")
  138. end
  139. end
  140.  
  141. if CLIENT then
  142.  
  143. --This is the chat command. THIS CHAT COMMAND ONLY WORKS ON DARKRP. If you are using anything else you need
  144. -- to delete the code between the word start and end. Users can redeem their code by openeing console and typing redeem.
  145.  
  146.  
  147. --START
  148. hook.Add( "OnPlayerChat", "donateCommand", function( ePlayer, sText )
  149.  
  150. if ( ePlayer ~= LocalPlayer() ) then
  151. return;
  152. end
  153.  
  154. if ( string.StartWith( string.lower( sText ), "/redeem" ) ) then
  155. DonationKeyEnter();
  156. return;
  157. end
  158.  
  159. end );
  160.  
  161. --END
  162.  
  163. function DonationKeyEnter()
  164. local frame = vgui.Create("DFrame")
  165. frame:SetPos(ScrW()/2-200,ScrH()/2-100)
  166. frame:SetSize(400,100)
  167. frame:SetTitle("Redeem Donation Key")
  168. frame:SetVisible(true)
  169. frame:ShowCloseButton(true)
  170. frame:MakePopup()
  171. frame.Paint = function()
  172. draw.RoundedBox(4,0,0,frame:GetWide(),frame:GetTall(),Color(0,0,0,170))
  173. end
  174.  
  175. local label = vgui.Create("DLabel", frame)
  176. label:SetText("Enter your key and press enter: ")
  177. label:SetPos(10,40)
  178. label:SizeToContents()
  179.  
  180. local textbox = vgui.Create("DTextEntry", frame)
  181. textbox:SetPos(15+label:GetWide(),40)
  182. textbox:SetSize(200,20)
  183. textbox:SetEnterAllowed(true)
  184. textbox.OnEnter = function()
  185. if(textbox:GetValue() == "") then return end
  186. net.Start("cl_sendDonationKey")
  187. net.WriteString(textbox:GetValue())
  188. net.SendToServer()
  189. end
  190. end
  191.  
  192. concommand.Add("redeem",DonationKeyEnter, 1.5)
  193.  
  194. end
  195.  
  196. if SERVER then
  197. require("tmysql4")
  198.  
  199. local host = "t-servers.site.nfoservers.com" //use this instead of locahost
  200. local user = "thalexs"
  201. local pass = "LTdcG3wvXn"
  202. local dbname = "thalexs_donations"
  203. local port = 3306
  204. local db = {}
  205. local err = ""
  206.  
  207. function connectDatabase()
  208.  
  209. db, err = tmysql.initialize( host,user,pass,dbname,port)
  210. end
  211.  
  212. hook.Add("Initialize", "connectDatabase", connectDatabase)
  213.  
  214. net.Receive("cl_sendDonationKey", function(len,ply)
  215. local key = net.ReadString()
  216. ProcessKey(ply,key)
  217. end)
  218.  
  219. function ProcessKey(ply,key)
  220.  
  221. db:Query("SELECT * FROM donationkeys WHERE donationkey='"..tmysql.escape(key).."' AND used=0", function(result,status,error)
  222. if status then
  223. if #result > 0 and #result < 2 then
  224. if DONATIONTYPES[result[1]["type"]] then
  225. DONATIONTYPES[result[1]["type"]](ply)
  226. db:Query("UPDATE donationkeys SET used=1 WHERE donationkey='"..tmysql.escape(key).."' AND used=0", function(res,stat,err)
  227. if stat then
  228. print(ply:Nick().."'s key was used, updated database")
  229. else
  230. print(ply:Nick().."'s key could not be updated, something went wrong: "..err)
  231. end
  232. end,1)
  233. else
  234. ply:PrintMessage(HUD_PRINTTALK,"Key found but no code exists, contact administrator")
  235. end
  236. elseif #result > 0 then
  237. ply:PrintMessage(HUD_PRINTTALK, "Multiple keys exist, contact administrator")
  238. else
  239. ply:PrintMessage(HUD_PRINTTALK, "Nothing found")
  240. end
  241. else
  242. ply:PrintMessage(HUD_PRINTTALK, "Could not contact server, contact administrator")
  243. end
  244. end, 1)
  245. db:Poll()
  246.  
  247. end
  248.  
  249. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement