Spinner help

I know there is like alot of csgo spinners in gmod. BUT, I want to code mine from scratch without reading other theirs. With some help ofcourse.
No you’r probably expecting code, but my question is: how would you make the DermaPanel’s move and dissapear and come back like csgo case opening, and how would you make the little bar that decides what you get when it hits it?

If you can help me out here, thanks.

  • PS, I have a good knowledge of how to use Derma and draw functions. (HUD) *

You should proofread what you type. Kinda hard to understand you.

You don’t have good knowledge of Lua I assume so you might want to start there.

Now for your questions. To make the images spin you will have to make a random table with each value being a table with value of the image file path, the ent (or prize), color of how rare it is, etc.

The prize will be pre-defined. You will have it choosen as soon as the user hits “Spin”. You can then create a loop with a timer that just checks which table key is currently active and make it stop spinning (after a certain amount of time defined by the timer) when it hits the key of the prize that the guy won.

Animation and vgui is up to you.
This doesn’t work solely off of vgui. All the thinking is done with Lua fundamentals.

Thanks for explaining :smiley:

[editline]2nd December 2016[/editline]

How would I make the panels move? Lua wise? what vgui?

[editline]2nd December 2016[/editline]

local rewards = {}
-- Name, Model, Chance % --
rewards[1] = { "Crowbar", "models/weapons/v_crowbar.mdl", 90 }
rewards[2] = { "Crossbow", "models/weapons/v_crossbow.mdl", 10 }

function Spinner()
	if running then
		local DermaPanel = vgui.Create( "DFrame" )
		DermaPanel:SetSize( ScrW()/2, ScrH()/2 )
		DermaPanel:SetTitle( "SPINNA" )
		DermaPanel:SetDraggable( true )
		-- 5 panels going past at a time --
		local RewardPanel = vgui.Create( "DImage", DermaPanel )
		RewardPanel:SetSize( DermaPanel:GetWide()/4, DermaPanel:GetTall()/3 )
		RewardPanel:SetPos( DermaPanel:GetWide()/2, DermaPanel:GetTall()/2 )
		local RewardPanel1 = vgui.Create( "DImage", DermaPanel )
		RewardPanel1:SetSize( DermaPanel:GetWide()/4, DermaPanel:GetTall()/3 )
		RewardPanel1:SetPos( DermaPanel:GetWide()/2, DermaPanel:GetTall()/2 )
		local RewardPanel2 = vgui.Create( "DImage", DermaPanel )
		RewardPanel2:SetSize( DermaPanel:GetWide()/4, DermaPanel:GetTall()/3 )
		RewardPanel2:SetPos( DermaPanel:GetWide()/2, DermaPanel:GetTall()/2 )
		local RewardPanel3 = vgui.Create( "DImage", DermaPanel )
		RewardPanel3:SetSize( DermaPanel:GetWide()/4, DermaPanel:GetTall()/3 )
		RewardPanel3:SetPos( DermaPanel:GetWide()/2, DermaPanel:GetTall()/2 )
		local RewardPanel4 = vgui.Create( "DImage", DermaPanel )
		RewardPanel4:SetSize( DermaPanel:GetWide()/4, DermaPanel:GetTall()/3 )
		RewardPanel4:SetPos( DermaPanel:GetWide()/2, DermaPanel:GetTall()/2 )
		local RewardPanel5 = vgui.Create( "DImage", DermaPanel )
		RewardPanel5:SetSize( DermaPanel:GetWide()/4, DermaPanel:GetTall()/3 )
		RewardPanel5:SetPos( DermaPanel:GetWide()/2, DermaPanel:GetTall()/2 )
		-- Every second go past another reward for a minute --
		timer.Create( "spin", 1, 60, function()
			for k,v in pairs( rewards ) do
				-- something here math.random( panels[ math.random( #panels ) ] )
				RewardPanel:SetImage( v[2] )
				-- Somthing set name v[1]
				-- something else like v[3] ?? pls help
		running = true

Lerp most likely. Or some other pre-defined function on the Wiki.

CodeBlue explains it, but I am still confused. How would I Lerp values to make panels move?