DarkRP sell printers?

What function would I use to see what printers a player has and when they run a command it sells them all/sells the one they’re looking at



--Sell prices
function SellPrinter()
Money_printer = 750
Topaz_money_Printer = 750
Amethyst_money_printer = 1275
Emerald_money_printer = 1875
Ruby_ money_printer = 4250
Sapphire_money_printer = 5625
--if the player types /SellPrinter then sell the printer they are looking at for the above price and remove it
--if the player types /SellAllPrinters then add up the sell prices of all the printers they own and give --them the money and remove the printers
      end
end
hook.Add("PlayerSay","SellPrinters",SellPrinters)

Sorry this is all the code I have currently, typed this up on my phone and couldn’t do much research
I’ll update the supplied code when I’m able to

Any help with this code would help, thanks in adance

these should be relevant

http://forum.facepunch.com/showthread.php?t=1354667

[lua]

local printervals={}
printvals[“Money_printer”] = 750
–Add the rest here

function SellPrinters(mode, ply)
if mode == 1 then
local tr = ply:GetEyeTrace().Entity
–Do some validation to check if it the world/valid
–Remove the entity and give money by looking up the value in the table above
if printvals[tr:GetClass()] == nil then
DarkRP.notify( ply, 1, 4, “You can’t do that!” )
return false
end
tr:Remove()
ply:Player.addMoney( printvals[tr:GetClass()] )
DarkRP.notify( ply, 1, 4, “You sold your printer for " … printvals[tr:GetClass()] …”!" )
elseif mode == 2 then
local printers = {}
local totalcash = 0
for k,v in pairs(printervals) do
printers = ents.FindByClass( k )
for k2,v2 in pairs(printers) do
if v2:Getowning_ent() == ply then
v2:Remove()
totalcash = totalcash + printvals[v2:GetClass()]
end
end
end
DarkRP.notify( ply, 1, 4, “You sold all your printers for " … totalcash…”!" )
ply:Player.addMoney( totalcash )
end
end

hook.Add( “PlayerSay”, 0, function( ply, text, team )
if ( string.sub( text, 1, 12 ) == “/SellPrinter” ) then
SellPrinters(1, ply)
return “”
end
if ( string.sub( text, 1, 16 ) == “/SellAllPrinters” ) then
SellPrinters(2, ply)
return “”
end
end )
[/lua]

Sorry I would finish this, but I can’t atm, and I’m not on my personal computer.

Edit: I updated it, I recommend adding so much more validation though, and tidy it up a little.