as the title suggests I’m working on creating a Shop for Innocents in the Garry’s Mod Game-mode TTT.
However I’m really mediocre when it comes to scripting so I’m now stuck and don’t know what to do with the code:
function innoshop() --SIZES local pw,ph = 570,412 --BaseFrame Size local bw = 48 --Size of Buttons local bh = bw local ssw,ssh = pw*0.965,ph*0.92 --Sheet size (Adapts to BaseFrame) --LOCALPLAYER local ply = LocalPlayer() --SHOP COMPONENTS local base = vgui.Create( "DFrame" ) local sheet = vgui.Create( "DPropertySheet",base ) local sheettab1 = vgui.Create( "DPanel",sheet) local sheettab2 = vgui.Create( "DPanel",sheet) local butt1 = vgui.Create( "DImageButton",sheettab1) local butt2 = vgui.Create( "DImageButton",sheettab2) --BASEFRAME base:SetSize(pw, ph) base:Center() base:SetTitle("Innocent Shop") base:SetVisible(true) base:SetDraggable(true) base:ShowCloseButton(true) base:MakePopup() base.Paint = function(s,w,h) draw.RoundedBox(7,0,0,w,h,Color(37,80,37,240)) end --1.SHEETTAB sheettab1:Dock( FILL ) sheettab1.Paint = function( self, w, h) draw.RoundedBox(0,0,0,w,h,Color(0,0,0,0)) end --2.SHEETTAB sheettab2:Dock( FILL ) sheettab2.Paint = function( self, w, h) draw.RoundedBox(0,0,0,w,h,Color(0,0,0,0)) end --1.BUTTON butt1:SetSize(bw,bh) butt1:SetImage( "vgui/ttt/icon_id" ) butt1:SetPos(15,10) butt1.DoClick = function() chat.AddText(Color( 255, 0, 0 ),"Sending ", Color(0,255,0), "BOUGTHITEM", Color( 255, 0, 0 )," to your location.") end --2.BUTTON butt2:SetSize(bw,bh) butt2:SetImage( "vgui/ttt/icon_id" ) butt2:SetPos(15,10) butt2.DoClick = function() chat.AddText(Color( 255, 0, 0 ),"Sold ", Color(0,255,0), "SOLDITEM",Color( 255, 0, 0 ),".") end --SHEET sheet:SetPos( ((1-(ssw/pw))/2)*pw,((1-(ssh/ph))/1.5)*ph) --Math is cool sheet:SetSize( ssw, ssh ) --SHEETTABS sheet:AddSheet( "Buy Items", sheettab1, "icon16/cart.png", false, false, "Buy Items" ) sheet:AddSheet( "Sell Items", sheettab2, "icon16/coins_add.png", false, false, "Sell Items" ) end --CONCOMMAND concommand.Add("innoshop",innoshop)
So basically all it does right now is: Opening a DFrame with 2 Sheets that both have one ImageButton which chat.AddText upon pressing.
I tried looking into the cl_equip.lua file of TTT to maybe copy paste some stuff, but I really have no idea what I should copy and what not.
To explain how the shop should look in its end stage:
- Innocent/Detectives/Traitor can open this shop from start of the round till its end
- I/D/T have a base amount of “Money” in the shop which will be reset at every round start
- You can sell weapons/items that you have in your inventory
- You can buy weapons/items just like in the Traitor/Dete ContextMenu
- All buy able items are listen in the first Sheet with their Icons and Descriptions
- Items that you can sell are listen in the second Sheet with their Icons+Descriptions+How much “Money” you receive for selling them
- Removing “SWEP.AutoSpawnable= true” on all weapons/ammo and instead spawning sellable items - with the help of “Weaponsplacer” ofc**
So basically the same as the T/D shop but with customisable prices and different weapons + possibility of selling your items to receive more money.
I’m thankful for any help at all!