Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local LDRP = {}
- local function MC(num)
- return math.Clamp(num,1,255)
- end
- function CreateButton(x, y, w, h, txt, font, parent, func)
- local btn = vgui.Create("DButton", parent)
- btn:SetPos(x, y)
- btn:SetSize(w, h)
- btn:SetText(txt)
- btn:SetTextColor(Color(255, 255, 255))
- DLabel.SetFont( btn, font )
- local btnCol = Color(25, 25, 25, 245)
- btn.Paint = function(s, w, h)
- draw.RoundedBox(4, 0, 0, w, h, btnCol)
- end
- btn.OnCursorEntered = function()
- btnCol = Color(55, 55, 55, 245)
- end
- btn.OnCursorExited = function()
- btn:SetTextColor(Color(255, 255, 255))
- btnCol = Color(25, 25, 25, 245)
- end
- btn.OnMousePressed = function()
- btn:SetTextColor(Color(45, 150, 225))
- end
- btn.OnMouseReleased = function()
- btn:SetTextColor(Color(255, 255, 255))
- func()
- end
- function btn:PerformLayout()
- if ( IsValid( self.m_Image ) ) then
- self.m_Image:SetPos( 15, (self:GetTall() - self.m_Image:GetTall()) * 0.5 )
- end
- DLabel.PerformLayout( self )
- end
- return btn
- end
- function LDRP.ConfirmVender(Type,Item,Cost)
- local item = string.lower(Item)
- local ConfirmWindow = vgui.Create("DFrame")
- local w,h = ScrW(),ScrH()
- local ws,hs = 240,150
- ConfirmWindow:SetSize(ws,hs)
- ConfirmWindow:SetPos(-ws,h*.5-(hs*.5))
- ConfirmWindow:MoveTo(w*.5-(ws*.5),h*.5-(hs*.5),.2,.2)
- ConfirmWindow:MakePopup()
- ConfirmWindow:SetTitle("")
- ConfirmWindow:ShowCloseButton(false)
- local CantSell = (Type == "sell") and (!LocalPlayer().Inventory[item] or LocalPlayer().Inventory[item] < 1)
- local WindowSize = (CantSell and hs*.5) or hs
- ConfirmWindow.Paint = function()
- draw.RoundedBox(6,0,0,ws,WindowSize,Color(215,85,80,225))
- if Type == "buy" then
- draw.SimpleTextOutlined( "Are you sure you want to buy", "Trebuchet22", 4, hs*.2, Color(255,255,255,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER, 2, Color(0,0,0,255) )
- draw.SimpleTextOutlined( "a " .. Item .. " for $" .. Cost, "Trebuchet22", 4, hs*.35, Color(255,255,255,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER, 2, Color(0,0,0,255) )
- elseif Type == "sell" then
- if CantSell then
- draw.SimpleTextOutlined( "You don't have any to sell.", "Trebuchet22", ws*.5, WindowSize*.5, Color(255,255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 2, Color(0,0,0,255) )
- return
- end
- local am = LocalPlayer().Inventory[Item]
- draw.SimpleTextOutlined( "Are you sure you want to sell", "Trebuchet22", 4, hs*.2, Color(255,255,255,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER, 2, Color(0,0,0,255) )
- draw.SimpleTextOutlined( am .. " " .. Item .. " for $" .. Cost*am, "Trebuchet22", 4, hs*.35, Color(255,255,255,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER, 2, Color(0,0,0,255) )
- end
- end
- if CantSell then
- ConfirmWindow:SetSize(ws,WindowSize)
- ConfirmWindow:ShowCloseButton(true)
- return
- end
- local YesButton = vgui.Create("DButton",ConfirmWindow)
- YesButton:SetPos(4,hs*.5)
- YesButton:SetSize(ws-8,hs*.22)
- YesButton:SetText("Yes")
- YesButton.DoClick = function()
- RunConsoleCommand("__shp",Type,item)
- ConfirmWindow:MoveTo(w,h*.5-(hs*.5),.2,.2)
- timer.Simple(.4,function()
- ConfirmWindow:Close()
- end)
- end
- local NoButton = vgui.Create("DButton",ConfirmWindow)
- NoButton:SetPos(4,hs*.74)
- NoButton:SetSize(ws-8,hs*.22)
- NoButton:SetText("No")
- NoButton.DoClick = function()
- ConfirmWindow:MoveTo(w,h*.5-(hs*.5),.2,.2)
- timer.Simple(.4,function()
- ConfirmWindow:Close()
- end)
- end
- end
- function LDRP_SH.OpenStoreMenu(name,model,saying,selltable,buytable)
- local Store = {}
- local w,h = 600,600
- Store.BG = vgui.Create("DFrame")
- Store.BG:SetSize(600,600)
- Store.BG:Center()
- Store.BG:MakePopup()
- Store.BG:SetTitle("")
- Store.BG.Paint = function()
- draw.RoundedBox(3,0,0,w,h,Color(36,36,36,255))
- --draw.RoundedBox(3,25,120,w-56,h-145,Color(42,42,42,255))
- draw.RoundedBox(3,0,0,w,h-500,Color(215,85,80,255))
- --surface.DrawLine(0,h,w,h) --top
- surface.DrawLine(0,599,599,599) --bottom
- surface.DrawLine(0,599,0,599) --left
- surface.DrawLine(599,599,599,599) --right
- draw.SimpleTextOutlined( name,"HUDNumber", w*.5, h*.03, Color(255,255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 2, Color(0,0,0,255) )
- draw.SimpleTextOutlined( saying,"Trebuchet24", w*.5+15, h-528, Color(255,255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 2, Color(0,0,0,255) )
- draw.RoundedBox(6,2,h*.184,w-4,h-114,Color(30,30,30,30))
- draw.SimpleTextOutlined( "Selling","HUDNumber", w*.07, h*.23, Color(255,255,255,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER, 2, Color(0,0,0,255) )
- draw.SimpleTextOutlined( "Buying","HUDNumber", w*.07, h*.62, Color(255,255,255,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER, 2, Color(0,0,0,255) )
- end
- Store.NPCPic = vgui.Create("SpawnIcon",Store.BG)
- Store.NPCPic:SetPos(6,20)
- Store.NPCPic:SetModel(model)
- Store.SellingList = vgui.Create("DPanelList",Store.BG)
- Store.SellingList:SetPos(37,h*.285)
- Store.SellingList:SetSize(w-12,h*.29)
- Store.SellingList:SetSpacing(4)
- Store.SellingList:SetPadding(4)
- Store.SellingList:EnableHorizontal(true)
- Store.SellingList:EnableVerticalScrollbar(true)
- Store.BuyingList = vgui.Create("DPanelList",Store.BG)
- Store.BuyingList:SetPos(37,h*.67)
- Store.BuyingList:SetSize(w-12,h*.31)
- Store.BuyingList:SetSpacing(4)
- Store.BuyingList:SetPadding(4)
- Store.BuyingList:EnableHorizontal(true)
- Store.BuyingList:EnableVerticalScrollbar(true)
- for k,v in pairs(selltable) do
- local Lower = string.lower(k)
- local ItemIcon = CreateIcon(nil,LDRP_SH.AllItems[Lower].mdl,76,76,function() LDRP.ConfirmVender("buy",Lower,v) end)
- ItemIcon:SetToolTip(k .. "\nSell Price: $" .. v)
- Store.SellingList:AddItem(ItemIcon)
- end
- for k,v in pairs(buytable) do
- local Lower = string.lower(k)
- local ItemIcon = CreateIcon(nil,LDRP_SH.AllItems[Lower].mdl,76,76,function() LDRP.ConfirmVender("sell",string.lower(Lower),v) end)
- ItemIcon:SetToolTip(k .. "\nBuy Price: $" .. v)
- Store.BuyingList:AddItem(ItemIcon)
- end
- end
- function LDRP.RulesMenu()
- local Loading = true
- local Window = vgui.Create("DFrame")
- local w,h = ScrW()*.8,ScrH()*.8
- Window:SetSize(w,h)
- Window:SetPos(ScrW()*.1,ScrH()*.1)
- Window.Paint = function()
- draw.RoundedBox( 8, 0, 0, w, h, Color(-40,-40,-40,60) )
- if Loading then
- draw.SimpleTextOutlined("Loading Webpage", "HUDNumber", w*.5, h*.5, Color(255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 2, Color(0,0,0) )
- end
- end
- Window:SetTitle("Rules")
- Window:MakePopup()
- local HTML = vgui.Create("HTML",Window)
- HTML:SetPos(6,22)
- HTML:SetSize(w-8,h-30)
- HTML:OpenURL("http://www.LiquidGaming.org/helprulesdrp.html")
- HTML.FinishedURL = function()
- Loading = false
- end
- HTML.OpeningURL = function()
- Loading = true
- end
- return ""
- end
- concommand.Add("rules",LDRP.RulesMenu)
- -- Bank bullshit
- function LDRP.SendItemInfo(um)
- LocalPlayer().Bank[tostring(um:ReadString())] = um:ReadFloat()
- end
- usermessage.Hook("SendBItem",LDRP.SendItemInfo)
- function LDRP.SendMaxWeight(um)
- LocalPlayer().MaxBWeight = um:ReadFloat()
- end
- usermessage.Hook("SendBWeight",LDRP.SendMaxWeight)
- function LDRP.ShopItemOptions(item, Type, nicename, items, shopent)
- local TypeTbl = (Type == "bank" and LocalPlayer().Inventory) or LocalPlayer().Bank
- if shopent and shopent:IsOpen() then chat.AddText(Color(15,75,255),"[SHOP] ",Color(255,255,255),"Shop must be closed to edit items!") return end
- if (Type == "shop") then TypeTbl = LocalPlayer().Inventory end
- if items then TypeTbl = items end
- if TypeTbl[item] then
- local OptionsMenu = vgui.Create("DFrame")
- OptionsMenu:SetSize(200, shopent and 160 or 140)
- OptionsMenu:Center()
- local Tbl = LDRP_SH.AllItems[item]
- OptionsMenu.Paint = function(s,w,h)
- draw.RoundedBox(6,0,0,w,h,Color(50,50,50,180))
- local name = LDRP_SH.NicerWepNames[Tbl.nicename] or Tbl.nicename
- draw.SimpleTextOutlined(name .. " - " .. (items and TypeTbl[item].amount or TypeTbl[item]) .. " left","Trebuchet20",100,14,Color(255,255,255,200),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER, 2, Color(0,0,0,200) )
- end
- OptionsMenu:SetTitle("")
- OptionsMenu.MakeClose = function()
- OptionsMenu:MoveTo(ScrW(),ScrH()*.5-80,.3)
- timer.Simple(.3,function()
- if OptionsMenu:IsValid() then OptionsMenu:Close() end
- end)
- end
- local SellAmount
- local Counter
- local UseButton = vgui.Create("DButton",OptionsMenu)
- UseButton:SetPos(4,30)
- UseButton:SetSize(192,32)
- UseButton:SetText(nicename)
- UseButton.DoClick = function()
- if (Type == "shop") or items then
- if SellAmount then
- LastSalePriceValue = SellAmount:GetValue()
- end
- OptionsMenu.MakeClose()
- else
- RunConsoleCommand("_bnk",Type,item, Counter:GetValue())
- OptionsMenu.MakeClose()
- end
- end
- Counter = vgui.Create("DNumSlider",OptionsMenu)
- Counter:SetPos(4,shopent and 125 or 60)
- Counter:SetSize(200,32)
- Counter.TextArea:SetTextColor(Color(209,209,209))
- Counter:SizeToContents()
- Counter:SetText((Type == "bank" or Type == "shop") and "Put in" or "Takeout")
- Counter:SetMax(items and TypeTbl[item].amount or TypeTbl[item])
- Counter:SetMin(1)
- Counter:SetDecimals(0)
- Counter:SetValue(1)
- Counter.OnValueChanged = function (s,val)
- if not shopent then return end
- UseButton:SetText(string.format("%s %s of these",items and "Take out" or "Sell",val <= 1 and "one" or tostring(math.Round(val))))
- end
- if (Type == "shop") and not items then
- local SellAmountLbl = vgui.Create("DLabel",OptionsMenu)
- SellAmountLbl:SetPos(4,60)
- SellAmountLbl:SetSize(192,32)
- SellAmountLbl:SetText("Enter the sale price ($):")
- SellAmount = vgui.Create("DNumberWang",OptionsMenu)
- SellAmount:SetPos(4,85)
- SellAmount:SetSize(192,32)
- SellAmount:SetText(LastSalePriceValue)
- SellAmount:SetMin(2)
- SellAmount:SetMax(1000000000)
- end
- OptionsMenu.Think = function()
- OptionsMenu:MakePopup()
- end
- end
- end
- local WepNames = LDRP_SH.NicerWepNames
- function LDRP.BankMenu(ply,cmd,args)
- local MainBankBackground = vgui.Create("DFrame")
- local w,l = 800,630
- MainBankBackground:SetWidth(w)
- MainBankBackground:SetHeight(l)
- MainBankBackground:MakePopup()
- MainBankBackground:Center()
- MainBankBackground:SetTitle("")
- MainBankBackground:ShowCloseButton(true)
- function MainBankBackground:Paint()
- draw.RoundedBox(3,0,0,w,l,Color(36,36,36,255))
- local BankWeight = 0
- for k,v in pairs(LocalPlayer().Bank) do
- if k == "curcash" then continue end
- if v and v >= 1 then
- BankWeight = BankWeight+(LDRP_SH.AllItems[k].weight*v)
- end
- end
- surface.SetDrawColor(255,0,0)
- surface.DrawLine(w / 2,0,w / 2,630)
- draw.SimpleTextOutlined("Bank Weight: " .. BankWeight .. " out of " .. LocalPlayer().MaxBWeight,"Trebuchet22",w*.5,l*.97,Color(215, 85, 80,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER, 2, Color(0,0,0,200) )
- end
- local btndeposit = vgui.Create("DButton",MainBankBackground)
- btndeposit:SetText("Deposit Money")
- btndeposit:SetPos(10, 700)
- btndeposit:SetSize(50, 30)
- btndeposit.DoClick = function()
- local am = tonumber(InputCash:GetValue())
- if am and am > 0 then RunConsoleCommand("_bnk","money",-am)
- else
- LocalPlayer():ChatPrint("Please enter a valid number.")
- end
- end
- local btnwithdraw = vgui.Create("DButton",MainBankBackground)
- btnwithdraw:SetText("Withdraw Money")
- btnwithdraw:SetPos(10, 735)
- btnwithdraw:SetSize(50, 30)
- btnwithdraw.DoClick = function()
- local am = tonumber(InputCash:GetValue())
- if am and am > 0 then RunConsoleCommand("_bnk","money",am)
- else
- LocalPlayer():ChatPrint("Please enter a valid number.")
- end
- end
- local btnclose = vgui.Create("DButton",MainBankBackground)
- btnclose:SetText("Close Bank")
- btnclose:SetPos(10, 770)
- btnclose:SetSize(50, 30)
- btnclose.DoClick = function()
- MainBankBackground:Close()
- end
- local BankLabel = vgui.Create("DLabel",MainBankBackground)
- BankLabel:SetText("Bank")
- BankLabel:SetFont("HUDNumber")
- BankLabel:SetColor(Color(215, 85, 80,255))
- BankLabel:SetPos(w / 4 * 0.5 + 40,10)
- BankLabel:SizeToContents()
- local BankItemsList = vgui.Create("DPanelList",MainBankBackground)
- BankItemsList:SetPos(6,50)
- BankItemsList:SetWidth(400)
- BankItemsList:SetHeight(400)
- BankItemsList:SetPadding(4)
- BankItemsList:SetSpacing(4)
- BankItemsList:EnableVerticalScrollbar(true)
- BankItemsList:EnableHorizontal(true)
- BankItemsList.Paint = function()
- draw.RoundedBox(3,0,0,390,400,Color(42,42,42,255))
- end
- local CurIcons = {}
- function BankItemsList:Think()
- for k,v in pairs(LocalPlayer().Bank) do
- if k == "curcash" then continue end
- local Check = CurIcons[k]
- if Check then
- if Check.am != v or v <= 0 then
- local ItemTbl = LDRP_SH.AllItems[k]
- if !ItemTbl then continue end
- if v <= 0 then
- BankItemsList:RemoveItem(Check.vgui)
- CurIcons[k] = nil
- else
- local Namez = WepNames[ItemTbl.nicename] or ItemTbl.nicename
- Check.vgui:SetToolTip(Namez .. "\n" .. ItemTbl.descr .. "\nAmount: " .. v .. "\nWeight: " .. ItemTbl.weight)
- CurIcons[k].am = v
- end
- end
- elseif v > 0 then
- local ItemTbl = LDRP_SH.AllItems[k]
- if !ItemTbl then continue end
- local ItemIcon = CreateIcon(BankItemsList,ItemTbl.mdl,79,79,function() LDRP.ShopItemOptions(k,"takeout","Take Out") end)
- CurIcons[k] = {["vgui"] = ItemIcon,["am"] = v}
- local Namez = WepNames[ItemTbl.nicename] or ItemTbl.nicename
- ItemIcon:SetToolTip(Namez .. "\n" .. ItemTbl.descr .. "\nAmount: " .. v .. "\nWeight: " .. ItemTbl.weight)
- BankItemsList:AddItem(ItemIcon)
- end
- timer.Simple(.001,function()
- if !BankItemsList:IsValid() then return end
- BankItemsList:Rebuild()
- BankItemsList:PerformLayout()
- end)
- end
- end
- local InvLabel = vgui.Create("DLabel",MainBankBackground)
- InvLabel:SetText("Inventory")
- InvLabel:SetFont("HUDNumber")
- InvLabel:SetColor(Color(215, 85, 80,255))
- InvLabel:SetPos(w / 6 * 4,10)
- InvLabel:SizeToContents()
- local InvItemsList = vgui.Create("DPanelList",MainBankBackground)
- InvItemsList:SetPos(w / 2 + 5, 50)
- InvItemsList:SetWidth(400)
- InvItemsList:SetHeight(400)
- InvItemsList:SetPadding(4)
- InvItemsList:SetSpacing(4)
- InvItemsList:EnableVerticalScrollbar(true)
- InvItemsList:EnableHorizontal(true)
- InvItemsList.Paint = function()
- draw.RoundedBox(3,0,0,390,400,Color(42,42,42))
- end
- local CurIcons2 = {}
- function InvItemsList:Think()
- for k,v in pairs(LocalPlayer().Inventory) do
- local Check = CurIcons2[k]
- if Check then
- if Check.am != v or v <= 0 then
- local ItemTbl = LDRP_SH.AllItems[k]
- if !ItemTbl then continue end
- if v <= 0 then
- InvItemsList:RemoveItem(Check.vgui)
- CurIcons2[k] = nil
- else
- local Namez = WepNames[ItemTbl.nicename] or ItemTbl.nicename
- Check.vgui:SetToolTip(Namez .. "\n" .. ItemTbl.descr .. "\nAmount: " .. v .. "\nWeight: " .. ItemTbl.weight)
- CurIcons2[k].am = v
- end
- end
- elseif v > 0 then
- local ItemTbl = LDRP_SH.AllItems[k]
- if !ItemTbl then continue end
- local ItemIcon = CreateIcon(InvItemsList,ItemTbl.mdl,79,79,function() LDRP.ShopItemOptions(k,"bank","Put in bank") end)
- CurIcons2[k] = {["vgui"] = ItemIcon,["am"] = v}
- local Namez = WepNames[ItemTbl.nicename] or ItemTbl.nicename
- ItemIcon:SetToolTip(Namez .. "\n" .. ItemTbl.descr .. "\nAmount: " .. v .. "\nWeight: " .. ItemTbl.weight)
- InvItemsList:AddItem(ItemIcon)
- end
- timer.Simple(.001,function()
- if !InvItemsList:IsValid() then return end
- InvItemsList:Rebuild()
- InvItemsList:PerformLayout()
- end)
- end
- end
- local MoneyLabel = vgui.Create("DLabel",MainBankBackground)
- MoneyLabel:SetPos(8,470)
- MoneyLabel:SetText(" ")
- MoneyLabel:SetFont("HUDNumber")
- function MoneyLabel:Paint()
- draw.SimpleTextOutlined("Balance: $" .. LocalPlayer().Bank["curcash"], "HUDNumber", 0, ScrH()*.02, Color(215, 85, 80), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER, 1, Color(0,0,0) )
- end
- MoneyLabel:SizeToContents()
- local InputCash = vgui.Create("DTextEntry",MainBankBackground)
- InputCash:SetPos(280,470)
- InputCash:SetWidth(314)
- InputCash:SetHeight(35)
- InputCash:SetEnterAllowed(false)
- InputCash:SetText("Input money amount here")
- local HasClicked
- InputCash.OnMousePressed = function()
- if !HasClicked then InputCash:SetText("") HasClicked = true end
- end
- function InputCash:Paint()
- draw.RoundedBox(6,0,0,self:GetWide(),self:GetTall(),Color(70,70,70,20))
- self:DrawTextEntryText(Color(255, 255, 255), Color(0, 255, 0), Color(255, 255, 255))
- end
- local CloseButton = CreateButton(10, 770,50, 30,"Deposit Money","HUDNumber", MainBankBackground,function()
- MainBankBackground:Close()
- end)
- end
- usermessage.Hook("SendBankMenu",LDRP.BankMenu)
- concommand.Add("_banker", LDRP.BankMenu)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement