Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------------------------------------------------------------------
- -- ______ _____ __ _ _______ _______ _____ _____ __ _ --
- -- | \ | | | \ | |_____| | | | | | \ | --
- -- |_____/ |_____| | \_| | | | __|__ |_____| | \_| --
- -- --
- -- _ _ _______ __ __ _______ --
- -- |____/ |______ \_/ |______ --
- -- | \_ |______ | ______| --
- ------------------------------------------------------------------
- -- Welcome to the Donation keys script! Follow these instructions and
- -- you will be able to have a successful donation key system on your
- -- server!
- local DONATIONTYPES = {}
- if SERVER then
- util.AddNetworkString("cl_sendDonationKey")
- local ulx = true; -- Are you using ulx?
- local evolve = false; -- Are you using evolve?
- -- if we are not using any of the above we assume you are using default FAdmin
- DONATIONTYPES["1"] = function(ply)
- --code to apply reward for donation of type 1
- ply:addMoney(10000)
- ply:PrintMessage(HUD_PRINTTALK, "You received 10k cash!")
- game.ConsoleCommand("say " ..ply:Nick().. " Has purchased 10k cash! Thank you!")
- end
- DONATIONTYPES["2"] = function(ply)
- if(ulx)then
- game.ConsoleCommand("ulx adduser "..ply:Nick().." donator")
- elseif(evolve) then
- game.ConsoleCommand("ev rank "..ply:Nick().." donator")
- else
- ply:SetUserGroup("donator")
- end
- ply:addMoney(50000)
- ply:PrintMessage(HUD_PRINTTALK, "You received donator status and 50k cash!")
- game.ConsoleCommand("say " ..ply:Nick().. " Has purchased 50k! Thank you!")
- end
- DONATIONTYPES["3"] = function(ply)
- if(ulx)then
- game.ConsoleCommand("ulx adduser "..ply:Nick().." donator")
- elseif(evolve) then
- game.ConsoleCommand("ev rank "..ply:Nick().." donator")
- else
- ply:SetUserGroup("donator")
- end
- ply:addMoney(100000)
- ply:PrintMessage(HUD_PRINTTALK, "You received donator status and 100k cash!")
- game.ConsoleCommand("say " ..ply:Nick().. " Has purchased 1ook Thank you!")
- end
- DONATIONTYPES["4"] = function(ply)
- if(ulx)then
- game.ConsoleCommand("ulx adduser "..ply:Nick().." Vip")
- elseif(evolve) then
- game.ConsoleCommand("ev rank "..ply:Nick().." Vip")
- else
- ply:SetUserGroup("Xeon")
- end
- ply:addMoney(250000)
- ply:PrintMessage(HUD_PRINTTALK, "You received Vip status and 250k cash!")
- game.ConsoleCommand("say " ..ply:Nick().. " Has purchased 250k! Thank you!")
- end
- DONATIONTYPES["5"] = function(ply)
- if(ulx)then
- game.ConsoleCommand("ulx adduser "..ply:Nick().." Super-Vip")
- elseif(evolve) then
- game.ConsoleCommand("ev rank "..ply:Nick().." Super-Vip")
- else
- ply:SetUserGroup("Super-Vip")
- end
- ply:addMoney(250000)
- ply:PrintMessage(HUD_PRINTTALK, "You received Super-Vip status and 1m cash!")
- game.ConsoleCommand("say " ..ply:Nick().. " Has purchased 1m! Thank you!")
- end
- DONATIONTYPES["6"] = function(ply)
- ply:PS_GivePoints(5000)
- ply:PrintMessage(HUD_PRINTTALK, "You received 5k points!")
- game.ConsoleCommand("say " ..ply:Nick().. " Has purchased 5k points! Thank you!")
- end
- DONATIONTYPES["7"] = function(ply)
- if(ulx)then
- game.ConsoleCommand("ulx adduser "..ply:Nick().." donator")
- end
- ply:PS_GivePoints(50000)
- ply:PrintMessage(HUD_PRINTTALK, "You received 50k points!")
- game.ConsoleCommand("say " ..ply:Nick().. " Has purchased 50k points and donator rank ! Thank you!")
- end
- DONATIONTYPES["8"] = function(ply)
- game.ConsoleCommand("ulx adduser "..ply:Nick().." donator")
- ply:PS_GivePoints(100000)
- ply:PrintMessage(HUD_PRINTTALK, "You received 100k points and donator rank!")
- game.ConsoleCommand("say " ..ply:Nick().. " Has purchased 100k points! Thank you!")
- end
- DONATIONTYPES["9"] = function(ply)
- game.ConsoleCommand("ulx adduser "..ply:Nick().." Vip")
- ply:PS_GivePoints(250000)
- ply:PrintMessage(HUD_PRINTTALK, "You received 250k points and vip rank!")
- game.ConsoleCommand("say " ..ply:Nick().. " Has purchased 250k points! Thank you!")
- end
- DONATIONTYPES["10"] = function(ply)
- game.ConsoleCommand("ulx adduser "..ply:Nick().." Super-Vip")
- ply:PS_GivePoints(100000)
- ply:PrintMessage(HUD_PRINTTALK, "You received 500k points and supervip rank!")
- game.ConsoleCommand("say " ..ply:Nick().. " Has purchased 500k points! Thank you!")
- end
- end
- if CLIENT then
- --This is the chat command. THIS CHAT COMMAND ONLY WORKS ON DARKRP. If you are using anything else you need
- -- to delete the code between the word start and end. Users can redeem their code by openeing console and typing redeem.
- --START
- hook.Add( "OnPlayerChat", "donateCommand", function( ePlayer, sText )
- if ( ePlayer ~= LocalPlayer() ) then
- return;
- end
- if ( string.StartWith( string.lower( sText ), "/redeem" ) ) then
- DonationKeyEnter();
- return;
- end
- end );
- --END
- function DonationKeyEnter()
- local frame = vgui.Create("DFrame")
- frame:SetPos(ScrW()/2-200,ScrH()/2-100)
- frame:SetSize(400,100)
- frame:SetTitle("Redeem Donation Key")
- frame:SetVisible(true)
- frame:ShowCloseButton(true)
- frame:MakePopup()
- frame.Paint = function()
- draw.RoundedBox(4,0,0,frame:GetWide(),frame:GetTall(),Color(0,0,0,170))
- end
- local label = vgui.Create("DLabel", frame)
- label:SetText("Enter your key and press enter: ")
- label:SetPos(10,40)
- label:SizeToContents()
- local textbox = vgui.Create("DTextEntry", frame)
- textbox:SetPos(15+label:GetWide(),40)
- textbox:SetSize(200,20)
- textbox:SetEnterAllowed(true)
- textbox.OnEnter = function()
- if(textbox:GetValue() == "") then return end
- net.Start("cl_sendDonationKey")
- net.WriteString(textbox:GetValue())
- net.SendToServer()
- end
- end
- concommand.Add("redeem",DonationKeyEnter, 1.5)
- end
- if SERVER then
- require("tmysql4")
- local host = "t-servers.site.nfoservers.com" //use this instead of locahost
- local user = "thalexs"
- local pass = "LTdcG3wvXn"
- local dbname = "thalexs_donations"
- local port = 3306
- local db = {}
- local err = ""
- function connectDatabase()
- db, err = tmysql.initialize( host,user,pass,dbname,port)
- end
- hook.Add("Initialize", "connectDatabase", connectDatabase)
- net.Receive("cl_sendDonationKey", function(len,ply)
- local key = net.ReadString()
- ProcessKey(ply,key)
- end)
- function ProcessKey(ply,key)
- db:Query("SELECT * FROM donationkeys WHERE donationkey='"..tmysql.escape(key).."' AND used=0", function(result,status,error)
- if status then
- if #result > 0 and #result < 2 then
- if DONATIONTYPES[result[1]["type"]] then
- DONATIONTYPES[result[1]["type"]](ply)
- db:Query("UPDATE donationkeys SET used=1 WHERE donationkey='"..tmysql.escape(key).."' AND used=0", function(res,stat,err)
- if stat then
- print(ply:Nick().."'s key was used, updated database")
- else
- print(ply:Nick().."'s key could not be updated, something went wrong: "..err)
- end
- end,1)
- else
- ply:PrintMessage(HUD_PRINTTALK,"Key found but no code exists, contact administrator")
- end
- elseif #result > 0 then
- ply:PrintMessage(HUD_PRINTTALK, "Multiple keys exist, contact administrator")
- else
- ply:PrintMessage(HUD_PRINTTALK, "Nothing found")
- end
- else
- ply:PrintMessage(HUD_PRINTTALK, "Could not contact server, contact administrator")
- end
- end, 1)
- db:Poll()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement