NWint help and a little derma help

So I am trying to make a Custom Player Model Store and I am 100% done with the derma (I hope), what I am wondering is how I would go about making it subtract from the players GetNWInt(“Money”) and if they don’t have enough it would notify them. The main problem I am having with this is defining how much each playermodel costs etc making it so the gamemode knows how much a certain playermodel costs. I currently have as my Derma Menu:

[lua]
list.Set( “PlayerModels”, “kleiner”, “models/player/Kleiner.mdl” )
list.Set( “PlayerModels”, “mossman”, “models/player/mossman.mdl” )
list.Set( “PlayerModels”, “alyx”, “models/player/alyx.mdl” )
list.Set( “PlayerModels”, “barney”, “models/player/barney.mdl” )
list.Set( “PlayerModels”, “breen”, “models/player/breen.mdl” )
list.Set( “PlayerModels”, “odessa”, “models/player/odessa.mdl” )
list.Set( “PlayerModels”, “monk”, “models/player/monk.mdl” )
list.Set( “PlayerModels”, “eli”, “models/player/eli.mdl” )
list.Set( “PlayerModels”, “corpse”, “models/player/corpse1.mdl” )
list.Set( “PlayerModels”, “zombie”, “models/player/classic.mdl” )
list.Set( “PlayerModels”, “charple”, “models/player/charple01.mdl” )
list.Set( “PlayerModels”, “combine”, “models/player/combine_soldier.mdl” )
list.Set( “PlayerModels”, “prison”, “models/player/combine_soldier_prisonguard.mdl” )
list.Set( “PlayerModels”, “super”, “models/player/combine_super_soldier.mdl” )
list.Set( “PlayerModels”, “police”, “models/player/police.mdl” )
list.Set( “PlayerModels”, “gman”, “models/player/gman_high.mdl” )
list.Set( “PlayerModels”, “stripped”, “models/player/soldier_stripped.mdl” )
list.Set( “PlayerModels”, “zombine”, “models/player/zombie_soldier.mdl” )
list.Set( “PlayerModels”, “fzombie”, “models/player/Zombiefast.mdl” )

list.Set( “PlayerModels”, “female1”, “models/player/Group01/female_01.mdl” )
list.Set( “PlayerModels”, “female2”, “models/player/Group01/female_02.mdl” )
list.Set( “PlayerModels”, “female3”, “models/player/Group01/female_03.mdl” )
list.Set( “PlayerModels”, “female4”, “models/player/Group01/female_04.mdl” )
list.Set( “PlayerModels”, “female5”, “models/player/Group01/female_06.mdl” )
list.Set( “PlayerModels”, “female6”, “models/player/Group01/female_07.mdl” )
list.Set( “PlayerModels”, “female7”, “models/player/Group03/female_01.mdl” )
list.Set( “PlayerModels”, “female8”, “models/player/Group03/female_02.mdl” )
list.Set( “PlayerModels”, “female9”, “models/player/Group03/female_03.mdl” )
list.Set( “PlayerModels”, “female10”, “models/player/Group03/female_04.mdl” )
list.Set( “PlayerModels”, “female11”, “models/player/Group03/female_06.mdl” )
list.Set( “PlayerModels”, “female12”, “models/player/Group03/female_07.mdl” )

list.Set( “PlayerModels”, “male1”, “models/player/Group01/male_01.mdl” )
list.Set( “PlayerModels”, “male2”, “models/player/Group01/male_02.mdl” )
list.Set( “PlayerModels”, “male3”, “models/player/Group01/male_03.mdl” )
list.Set( “PlayerModels”, “male4”, “models/player/Group01/male_04.mdl” )
list.Set( “PlayerModels”, “male5”, “models/player/Group01/male_05.mdl” )
list.Set( “PlayerModels”, “male6”, “models/player/Group01/male_06.mdl” )
list.Set( “PlayerModels”, “male7”, “models/player/Group01/male_07.mdl” )
list.Set( “PlayerModels”, “male8”, “models/player/Group01/male_08.mdl” )
list.Set( “PlayerModels”, “male9”, “models/player/Group01/male_09.mdl” )

list.Set( “PlayerModels”, “male10”, “models/player/Group03/male_01.mdl” )
list.Set( “PlayerModels”, “male11”, “models/player/Group03/male_02.mdl” )
list.Set( “PlayerModels”, “male12”, “models/player/Group03/male_03.mdl” )
list.Set( “PlayerModels”, “male13”, “models/player/Group03/male_04.mdl” )
list.Set( “PlayerModels”, “male15”, “models/player/Group03/male_06.mdl” )
list.Set( “PlayerModels”, “male16”, “models/player/Group03/male_07.mdl” )
list.Set( “PlayerModels”, “male17”, “models/player/Group03/male_08.mdl” )
list.Set( “PlayerModels”, “male18”, “models/player/Group03/male_09.mdl” )

list.Set( “PlayerModels”, “gasmask”, “models/player/gasmask.mdl” )
list.Set( “PlayerModels”, “riot”, “models/player/riot.mdl” )
list.Set( “PlayerModels”, “swat”, “models/player/swat.mdl” )
list.Set( “PlayerModels”, “urban”, “models/player/urban.mdl” )
list.Set( “PlayerModels”, “phoenix”, “models/player/phoenix.mdl” )
list.Set( “PlayerModels”, “arctic”, “models/player/arctic.mdl” )
list.Set( “PlayerModels”, “guerilla”, “models/player/guerilla.mdl” )
list.Set( “PlayerModels”, “leet”, “models/player/leet.mdl” )
list.Set( “PlayerModels”, “hostage_01”, “models/player/hostage/hostage_01.mdl” )
list.Set( “PlayerModels”, “hostage_02”, “models/player/hostage/hostage_02.mdl” )
list.Set( “PlayerModels”, “hostage_03”, “models/player/hostage/hostage_03.mdl” )
list.Set( “PlayerModels”, “hostage_04”, “models/player/hostage/hostage_04.mdl” )
list.Set( “PlayerModels”, “zelda”, “models/player/zelda.mdl” )
list.Set( “PlayerModels”, “zoey”, “models/player/left4dead/zoey.mdl” )

function SettingsFrame()
gui.EnableScreenClicker(true)

local frame = vgui.Create(“DFrame”)
frame:SetSize(510,440)
frame:SetPos(ScrW()/2 - 205,ScrH()/2 - 215)
frame:SetTitle(“Settings Menu”)
frame:SetMouseInputEnabled(true)
frame.Close = function()
frame:Remove()
gui.EnableScreenClicker(false)
end

local sheet = vgui.Create( "DPropertySheet" )
sheet:SetParent( frame )
sheet:SetPos( 5, 30 )
sheet:SetSize( 500, 400 )

local tab1 = vgui.Create( "DPanel" )
tab1:SetVisible(true)

//Playermodel Menu

local plist = vgui.Create("DPanelList",tab1)
plist:SetPos(40,30)
plist:SetSize(410, 325)
plist:SetSpacing( 1 )
plist:EnableHorizontal( true )
plist:EnableVerticalScrollbar( true ) 

for name, model in pairs( list.Get( "PlayerModels" ) ) do
	local icon = vgui.Create( "SpawnIcon", plist )
	icon:SetModel( model )
	icon:SetSize( 64, 64 )
	icon.OnMousePressed = function(mc)
		RunConsoleCommand("setplayermodel",name)
		surface.PlaySound(Sound("buttons/button14.wav"))
	end
	plist:AddItem(icon)
end

sheet:AddSheet( "Models", tab1, "gui/silkicons/user", false, false, "Choose a player model" )

end

concommand.Add( “colz_settings”, SettingsFrame )
[/lua]

As you can see I have my icon.OnMousePressed function and I have tables. Just wondering how I can make those models cost Money and possibly while your at it help me with adding DLabel tooltips to the models showing their price. Thank you so much! :slight_smile:

One thing you could do would be to have a table of models with their corresponding values:


local values = {
"models/player/leet.mdl" = 100,
"models/player/arctic.mdl" = 75
}

And then in your setplayermodel concommand, do something like this:


player:SetNWInt("colzCash",player:GetNWInt("colzCash") - values[args[1]])

As for the tooltips, all you need to do is this:


icon:SetToolTip("This is a tooltip!")

Thank you so much! All I need help on now is making the DModelList load the table. I’m sure thats very simple. And making it so if they don’t have enough cash it doesn’t still take their $ and having it so it checks if they bought the model then it sets it from a text file. hmmmm