Advertisement
Guest User

Untitled

a guest
Oct 21st, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1.  
  2. local rank = "donator" -- The ulx rank name to add the user to.
  3. local DonorPage = "http://usgamingservers.com/donate2/" -- Change this to the url of your donation page.
  4. --local rafflespage - "http://usgamingservers.com/donate2/raffle.php"
  5.  
  6. hook.Add( "PlayerSpawn", "CheckEliteDonor", function(ply)
  7.  
  8. db = mysqloo.connect( HOST, USERNAME, PASSWORD, DATABASE, 3306 )
  9. function db:onConnected()
  10.  
  11. print( "Database has connected!" )
  12.  
  13. local q = self:query( "UPDATE `elite_donations` SET `used`= '1' WHERE `steamid`='"..db:escape(ply:SteamID()).."' AND `server`='"..SERVER_ID.."';" )
  14.  
  15. function q:onSuccess( data )
  16. if( q:affectedRows() > 0 ) then
  17. -- What to do if they bought donor.
  18. ply:ChatPrint("Thank you for your donation, You have been given your rank!") -- Tell them it worked
  19. RunConsoleCommand("ulx", "adduserid", ply:SteamID(), rank) -- set there rank to donor
  20. ply:addMoney(30000) -- Give them $30,000 cash
  21. -- Add anything else you want inside this if statement
  22. end
  23. end
  24.  
  25. function q:onError( err, sql )
  26.  
  27. print( "Query errored!" )
  28. ply:ChatPrint( "Query:", sql )
  29. ply:ChatPrint( "Error:", err )
  30.  
  31. end
  32.  
  33. q:start()
  34.  
  35. end
  36.  
  37. function db:onConnectionFailed( err )
  38.  
  39. print( "Connection to database failed!" )
  40. print( "Error:", err )
  41.  
  42. end
  43.  
  44. db:connect()
  45.  
  46. end)
  47.  
  48.  
  49. function donateCommand( pl, text, teamonly )
  50. if text == "!donate" or text == "/donate" then
  51. pl:SendLua('gui.OpenURL("'.DonorPage.'")') -- Make sure to replace this with the url to YOUR donation page!
  52. return ""
  53. end
  54. end
  55. hook.Add( "PlayerSay", "Chat", donateCommand )
  56.  
  57. -- function rafflesCommand( pl, text, teamonly )
  58. -- if text == "!raffle" or text == "!raffles" then
  59. -- pl:SendLua('gui.OpenURL("'.rafflespage.'")') -- Make sure to replace this with the url to YOUR donation page!
  60. -- return ""
  61. -- end
  62. -- end
  63. -- hook.Add( "PlayerSay", "Chat", raffleCommand )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement