Anthr4x292

MindBlast Server Client Code: Donation/VIP System

Feb 11th, 2012
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.04 KB | None | 0 0
  1. local VIP_ENABLED = true
  2. local DONATE_URL = "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4LGM7Q6LB43DQ"
  3.  
  4. function ulx.vip( calling_ply )
  5.     if not VIP_ENABLED then return calling_ply:PrintMessage( HUD_PRINTTALK, "Buying VIP is currently disabled... check back another time." ) end
  6.  
  7.     umsg.Start( "VIPDonate", calling_ply ) umsg.End()
  8. end
  9.  
  10. local vip = ulx.command( "Utility", "ulx vip", ulx.vip, "!vip" )
  11. vip:defaultAccess( ULib.ACCESS_ALL )
  12. vip:help( "Opens the donation menu" )
  13.  
  14. usermessage.Hook( "VIPDonate", function( um )
  15.     local DermaPanel = vgui.Create( "DFrame" )
  16.     DermaPanel:SetPos( 50, 50 )
  17.     DermaPanel:SetSize( 300, 225 )
  18.     DermaPanel:Center()
  19.     DermaPanel:SetTitle( "VIP Donation Menu" )
  20.     DermaPanel:SetVisible( true )
  21.     DermaPanel:SetDraggable( true )
  22.     DermaPanel:ShowCloseButton( true )
  23.     DermaPanel:MakePopup()
  24.  
  25.     local DermaListView = vgui.Create("DListView")
  26.     DermaListView:SetParent( DermaPanel )
  27.     DermaListView:SetPos( 25, 50 )
  28.     DermaListView:SetSize( 250, 150 )
  29.     DermaListView:SetMultiSelect( false )
  30.  
  31.     local Nick = DermaListView:AddColumn( "Name" )
  32.     Nick:SetMinWidth( 128 )
  33.     Nick:SetMinWidth( 128 )
  34.  
  35.     DermaListView:AddColumn( "Is VIP" )
  36.     DermaListView:AddColumn( "Friend" )
  37.  
  38.     for _, v in pairs( player.GetAll() ) do
  39.         if v:CheckGroup( "moderator" ) or v:IsAdmin() then continue end -- moderator and up get VIP default.
  40.  
  41.         local IsVIP = "No"
  42.         if v:IsVIP() then IsVIP = "Yes" end
  43.  
  44.         local IsFriend = "No"
  45.         if v:GetFriendStatus() == "friend" then IsFriend = "Yes" end
  46.  
  47.         local Line = DermaListView:AddLine( v:Nick(), IsVIP, IsFriend )
  48.         Line.IsVIP = v:IsVIP()
  49.         Line.SteamID = v:SteamID()
  50.     end
  51.  
  52.     local function DonateFor( SteamID )
  53.         if not SteamID or SteamID == "NULL" then return end
  54.         gui.OpenURL( DONATE_URL .. "&custom=" .. SteamID )
  55.         LocalPlayer():PrintMessage( HUD_PRINTTALK, "When you donate, it takes around 1-2 minutes for it to process your donation to add you to VIP, once done it'll notice you in chatbox." )
  56.         LocalPlayer():PrintMessage( HUD_PRINTTALK, "You won't see a notification when you extend your VIP time, you can re-open this menu to check if your VIP expire date has changed." )
  57.  
  58.         DermaPanel:Close()
  59.     end
  60.  
  61.     local function OpenMenu( Info, Line )
  62.         local Panel = Info:GetLine( Line )
  63.  
  64.         if Panel then
  65.             local Nick = Panel:GetValue( 1 )
  66.             local IsVIP = Panel.IsVIP
  67.             local SteamID = Panel.SteamID
  68.  
  69.             local Popup = DermaMenu()
  70.             if IsVIP then
  71.                 if SteamID == LocalPlayer():SteamID() then
  72.                     Popup:AddOption( "Extend your VIP by two months", function() DonateFor( SteamID ) end )
  73.                 else
  74.                     Popup:AddOption( "Extend " .. Nick .. "'s VIP by two months", function() DonateFor( SteamID ) end )
  75.                 end
  76.             else
  77.                 if SteamID == LocalPlayer():SteamID() then
  78.                     Popup:AddOption( "Buy VIP for yourself", function() DonateFor( SteamID ) end )
  79.                 else
  80.                     Popup:AddOption( "Buy VIP for " .. Nick, function() DonateFor( SteamID ) end )
  81.                 end
  82.             end
  83.             Popup:Open()
  84.         end
  85.     end
  86.  
  87.     DermaListView.OnRowSelected = OpenMenu
  88.     DermaListView.OnRowRightClick = OpenMenu
  89. end )
Advertisement
Add Comment
Please, Sign In to add comment