Creating a Innocent-Shop (TTT)

Hey everyone,
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!

Sincerely,
Santifocus

What exactly are you looking for help with? We’re not going to code the entire thing for you…

Oh yeah I guess I did not specify that, the list I made is more of a ToDo list so if someone wants he can imagine how the script should look like in the end.

What im having the most trouble with is
**- 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**
    I don’t know how a function that searches for the right items would look like.
    probably something like this:

      for k, v in pairs(weapons.GetList()) do
         if v and v.CanBuy then

Not sure tho.

I think you’re biting off more than you can chew with this project, nevermind that it would break one of the core functions of TTT.

“Hey, prove yourself by buying x from the item shop.”

The “Inno”-Shop is available for everyone, I just called it that way because Innocents normaly have shop (except Pointshop)

Isn’t it just possible to copy the Traitor shop, but change a couple of things?

That would be the simplest way, yes. Give cl_euqip.lua a look as that’s where most of the equipment menu is, but good luck working out the selling bit and multiple credits part, as TTT was never built with that in mind and Bad King was against it.

Any tips for editing it?
As I said before I’m really mediocre when it comes to programming :s:

Tip: Trial and error.

Bonus Tip: Don’t give up. You’re not going to get it right the first time and no one expects you to.
You aren’t going to improve beyond mediocrity without first making errors to learn from.

The wiki will be your greatest ally.
Start reading.

Good luck!

Thanks a bunch :happy:
Ima try my best ^^