Need help with nutscript car dealer plugin

I have a problem with this addon

1.button text not changing when I take a car out.

sh.plugin




local PLUGIN = PLUGIN
PLUGIN.name = "Garage / Vehicles"
PLUGIN.author = "_FR_Starfox64 (NS 1.0), Neon (NS 1.1)"
PLUGIN.desc = "EuRoleplay Vehicle Mod."

if !nut.plugin.list["_oldplugins-fix"] then
	print("[Garage Plugin] _oldplugins-fix Plugin is not found!")
	print("Download from GitHub: https://github.com/tltneon/nsplugins
")
	return
end

PLUGIN.maxVehicles = 15
PLUGIN.maxVehiclesOut = 2
PLUGIN.TowTruckPos = Vector(0.073730, -130.310547, 57.315475)
PLUGIN.TowPos = Vector(52.448242, 71.667969, 41.064854)
PLUGIN.RopeLength = 40
PLUGIN.RopeWidth = 10
PLUGIN.RopeMaterial = "materials/rope"
PLUGIN.VehDataTable = {}
PLUGIN.Storages = {}
PLUGIN.VehShops = {}

nut.util.Include("sv_plugin.lua")

/* Structure
PLUGIN.VehDataTable = {
	CarClass = {
		name = "CarName",
		script = "CarScript.txt",
		model = "error.mdl",
		type = "CIV",
		skin = 0,
		maxWeight = 75,
		price = 5000
	}
}
CharVeh = {
	{
	class = "CarClass",
	color = Color(0, 0, 0),
	fuel = 100,
	inv = {},
	money = 0,
	storage = "Downtown",
	onWorld = false,
	ent = nil
	}
}
Storages = {
	Storage = {
		pos = Vector(),
		ang = Angle(),
		spawnPos = Vector(),
		spawnAng = Angle()
	}
}
*/

nut.command.Register({
	onRun = function(ply, arguments)
		local ang1, ang2 = Vector(-1302, 7183, 60), Vector(-2579, 6143, 447)
		OrderVectors(ang1, ang2)

		if ply:GetPos():WithinAABox(ang1, ang2) then
			if ply:InVehicle() then
				netstream.Start(ply, "carColorMenu")
			else
				nut.util.Notify("You must be inside of a vehicle!", ply)
			end
		else
			nut.util.Notify("You must be at the garage in the industrial area!", ply)
		end
	end
}, "paint")

function PLUGIN.Register( class, carTable )
	if not class then
		error("Attempted to register a vehicle without a classname!")
	elseif not carTable then
		error("Attempted to register a vehicle without a table!")
	end
	if PLUGIN.VehDataTable[class] then
		print("Warning! "..class.." will be overridden!")
	end
	PLUGIN.VehDataTable[class] = carTable
	util.PrecacheModel(carTable.model)
end

nut.util.Include("sh_vehicles.lua")

function PLUGIN.AddStorage( name, dataTable )
	if not name then
		error("Attempted to add a storage without a name!")
	elseif not dataTable then
		error("Attempted to add a storage without a table!")
	end
	if PLUGIN.Storages[name] then
		print("Warning! "..name.." will be overridden!")
	end
	PLUGIN.Storages[name] = dataTable
end

function PLUGIN.AddVehShop( dataTable )
	if not dataTable then
		error("Attempted to add a shop without a table!")
	end
	table.insert(PLUGIN.VehShops, dataTable)
end

nut.util.Include("sh_storage.lua")

function PLUGIN.GetCar( class )
	return PLUGIN.VehDataTable[class]
end

function PLUGIN.GetStorage( name )
	return PLUGIN.Storages[name] or PLUGIN.Storages["Downtown"]
end

if CLIENT then
	VehShopType = "CIV"
	local size = 16
	local border = 4
	local distance = size + border
	local PANEL = {}
	function PANEL:Init()
		self:SetPos(ScrW() * 0.375, ScrH() * 0.125)
		self:SetSize(ScrW() * nut.config.menuWidth, ScrH() * nut.config.menuHeight)
		self:MakePopup()
		self:SetTitle("Garage")

		local noticePanel = self:Add("nut_NoticePanel")
		noticePanel:Dock(TOP)
		noticePanel:DockMargin(0, 0, 0, 5)
		noticePanel:SetType(7)
		noticePanel:SetText("The house symbol means the vehicle is available at this storage, the world one means it's somewhere on the map.")

		local noticePanel = self:Add("nut_NoticePanel")
		noticePanel:Dock(TOP)
		noticePanel:DockMargin(0, 0, 0, 5)
		noticePanel:SetType(4)
		noticePanel:SetText("Select the vehicle of your choice and hit 'Take Out' / 'Store'")

		self.bg = self:Add("DIconLayout")
		self.bg:Dock(FILL)
		self.bg:DockMargin(0, 0, ScrW() * nut.config.menuWidth / 2, 0)
		self.bg:SetDrawBackground(true)

		self.list = self:Add("DIconLayout")
		self.list:Dock(FILL)
		self.list:DockMargin(0, 0, ScrW() * nut.config.menuWidth / 2, 0)
		self.list:SetDrawBackground(false)

		self.panel = self:Add("DPanel")
		self.panel:Dock(FILL)
		self.panel:DockMargin(ScrW() * nut.config.menuWidth / 2, 0, 0, 0)
		self.panel:SetDrawBackground(true)

		local preview = self.panel:Add("DCollapsibleCategory")
		preview:Dock(TOP)
		preview:SetLabel("Vehicle Model")

		self.model = vgui.Create("DModelPanel", preview)
		self.model:Dock(TOP)
		self.model:SetSize(ScrW() * nut.config.menuWidth / 2, ScrH() * nut.config.menuHeight / 3)
		self.model:SetCamPos(Vector(50, 200, 110))
		self.model:SetLookAt(Vector(0, 0, -10))

		local info = self.panel:Add("DCollapsibleCategory")
		info:Dock(TOP)
		info:SetLabel("Vehicle Info")

		self.info = vgui.Create("DLabel", info)
		self.info:Dock(TOP)
		self.info:DockMargin(5, 0, 0, 0)
		self.info:SetSize(400, 80)
		self.info:SetTextColor(Color(240, 240, 240))
		self.info:SetText("")

		self.give = self.panel:Add("DButton")
		self.give:Dock(BOTTOM)
		self.give:DockMargin(0, 5, 0, 0)
		self.give:SetDisabled(true)
		self.give:SetText("Give this vehicle to...")
		self.give.DoClick = function()
			if self.request then
				local dMenu = DermaMenu()

				for _, v in pairs(player.GetAll()) do
					if v:getChar() and v != LocalPlayer() then
						dMenu:AddOption(v:Name(), function()
							Derma_Query("Do you wish to send your "..PLUGIN.GetCar(LocalPlayer():getChar():getData("vehicles", {})[self.request[1]].class).name.." to "..v:Name().."?",
								"Confirmation...",
								"Yes",
								function()
									if IsValid(self) then
										self:Close()
									end
									netstream.Start("GiveVehicle", {self.request[1], v})
								end,
								"No", function()
									-- Nothing...
								end
							)
						end)
					end
				end

				dMenu:Open()
			end
		end

		self.button = self.panel:Add("DButton")
		self.button:Dock(BOTTOM)
		self.button:DockMargin(0, 5, 0, 0)
		self.button:SetDisabled(true)
		self.button:SetText("Select a Vehicle!")
		self.button.DoClick = function()
			if self.request then
				self:Close()
				netstream.Start("GarageRequest", {self.request[1], self.request[2]})
			end
		end

		local dist = 32768
		local currentStorage
		for k,v in pairs(PLUGIN.Storages) do
			local storageDist = v.pos:Distance(LocalPlayer():GetPos())
			if storageDist < dist then
				dist = storageDist
				currentStorage = k
			end
		end
		if dist > 300 then
			nut.util.Notify("No Storages In Range!", LocalPlayer())
			self:Close()
			return
		end

		for k,v in pairs(LocalPlayer():getChar():getData("vehicles", {})) do
			local data = PLUGIN.GetCar(v.class)
			local icon = self.list:Add("SpawnIcon")
			icon:SetModel(data.model, data.skin)
			icon.PaintOver = function(icon, w, h)
				surface.SetDrawColor(0, 0, 0, 45)
				surface.DrawOutlinedRect(1, 1, w - 2, h - 2)
				if v.onWorld or v.storage == currentStorage then
					surface.SetDrawColor(0, 0, 0, 50)
					surface.DrawRect(w - distance - 1, w - distance - 1, size + 2, size + 2)
					surface.SetDrawColor(255, 255, 255)
					if v.onWorld then
						surface.SetMaterial(Material("icon16/world.png"))
					else
						surface.SetMaterial(Material("icon16/house.png"))
					end
					surface.DrawTexturedRect(w - distance, w - distance, size, size)
				end
			end
			icon:SetTooltip(data.name)
			icon.DoClick = function()
				local hp = v.hp or 1000
				local text = "Name: "..data.name.."
Condition: "..hp.."/1000
Color: "..v.color.r..", "..v.color.g..", "..v.color.b.."
Fuel: "..v.fuel.."/100
Current Storage: "..v.storage or "N/A"
				self.info:SetText(text)
				self.model:SetModel(data.model)
				self.model.Entity:SetSkin(data.skin)
				self.model:SetColor(v.color)
				if v.onWorld or v.storage == currentStorage then
					self.request = {k, currentStorage}
					elseif v.onWorld then
						self.button:SetText("Store")
						elseif v.storage == currentStorage then
						self.button:SetText("Take Out")
						self.give:SetDisabled(false)
					end
					self.button:SetDisabled(false)
				else
					self.give:SetDisabled(true)
					self.button:SetDisabled(true)
					self.button:SetText("Select a Vehicle!")
				end
			end
		end
	end

	vgui.Register("nut_Garage", PANEL, "DFrame")

	local PANEL = {}
	function PANEL:Init()
		self:SetPos(ScrW() * 0.375, ScrH() * 0.125)
		self:SetSize(ScrW() * nut.config.menuWidth, ScrH() * nut.config.menuHeight)
		self:MakePopup()
		self:SetTitle("Vehicle Shop")

		local noticePanel = self:Add("nut_NoticePanel")
		noticePanel:Dock(TOP)
		noticePanel:DockMargin(0, 0, 0, 5)
		noticePanel:SetType(7)
		noticePanel:SetText("Coins means the vehicle is buyable, a V that you can sell it, an X that the vehicle isn't near the shop.")

		local noticePanel = self:Add("nut_NoticePanel")
		noticePanel:Dock(TOP)
		noticePanel:DockMargin(0, 0, 0, 5)
		noticePanel:SetType(4)
		noticePanel:SetText("Select the vehicle of your choice and hit 'Buy' / 'Sell'")

		local panel = self:Add("DPanel")
		panel:Dock(FILL)
		panel:DockMargin(0, 0, ScrW() * nut.config.menuWidth / 2, 0)
		panel:SetDrawBackground(false)

		self.bg = self:Add("DIconLayout")
		self.bg:Dock(FILL)
		self.bg:DockMargin(0, 0, ScrW() * nut.config.menuWidth / 2, 0)
		self.bg:SetDrawBackground(true)

		self.list = self:Add("DIconLayout")
		self.list:Dock(FILL)
		self.list:DockMargin(0, 0, ScrW() * nut.config.menuWidth / 2, 0)
		self.list:SetDrawBackground(false)

		self.panel = self:Add("DPanel")
		self.panel:Dock(FILL)
		self.panel:DockMargin(ScrW() * nut.config.menuWidth / 2, 0, 0, 0)
		self.panel:SetDrawBackground(true)

		local preview = self.panel:Add("DCollapsibleCategory")
		preview:Dock(TOP)
		preview:SetLabel("Vehicle Model")

		self.model = vgui.Create("DModelPanel", preview)
		self.model:Dock(TOP)
		self.model:SetSize(ScrW() * nut.config.menuWidth / 2, ScrH() * nut.config.menuHeight / 3)
		self.model:SetCamPos(Vector(50, 200, 110))
		self.model:SetLookAt(Vector(0, 0, -10))

		local info = self.panel:Add("DCollapsibleCategory")
		info:Dock(TOP)
		info:SetLabel("Vehicle Info")

		self.info = vgui.Create("DLabel", info)
		self.info:Dock(TOP)
		self.info:DockMargin(5, 0, 0, 0)
		self.info:SetSize(400, 60)
		self.info:SetTextColor(Color(240, 240, 240))
		self.info:SetText("NO DATA!")

		self.button = self.panel:Add("DButton")
		self.button:Dock(BOTTOM)
		self.button:DockMargin(0, 5, 0, 0)
		self.button:SetDisabled(true)
		self.button:SetText("Select a Vehicle!")
		self.button.DoClick = function()
			if self.request then
				self:Close()
				local color = self.color:GetColor()
				netstream.Start("VehShopRequest", {self.request[1], self.request[2], {r = color.r, g = color.g, b = color.b}})
			end
		end

		self.color = self.panel:Add("DColorMixer")
		self.color:Dock(FILL)
		self.color:SetPalette(true)
		self.color:SetAlphaBar(false)
		self.color:SetWangs(true)
		self.color:SetColor(Color(80, 80, 80))

		for k,v in pairs(PLUGIN.VehDataTable) do
			local data = PLUGIN.GetCar(k)
			if VehShopType == data.type then
				local icon = self.list:Add("SpawnIcon")
				icon:SetModel(data.model, data.skin)
				icon.PaintOver = function(icon, w, h)
					surface.SetDrawColor(0, 0, 0, 45)
					surface.DrawOutlinedRect(1, 1, w - 2, h - 2)
					surface.SetDrawColor(0, 0, 0, 50)
					surface.DrawRect(w - distance - 1, w - distance - 1, size + 2, size + 2)
					surface.SetDrawColor(255, 255, 255)
					surface.SetMaterial(Material("icon16/coins.png"))
					surface.DrawTexturedRect(w - distance, w - distance, size, size)
				end
				icon:SetTooltip(data.name)
				icon.DoClick = function()
					local text = "Name: "..data.name.."
Trunk Capacity: "..data.maxWeight.." kg
Price: "..nut.currency.GetName(data.price)
					self.request = {1, k}
					self.info:SetText(text)
					self.model:SetModel(data.model)
					self.model.Entity:SetSkin(data.skin)
					self.button:SetText("Buy")
					self.button:SetDisabled(false)
				end
			end
		end

		for k,v in pairs(LocalPlayer():getChar():getData("vehicles", {})) do
			local data = PLUGIN.GetCar(v.class)
			local icon = self.list:Add("SpawnIcon")
			icon:SetModel(data.model, data.skin)
			icon.PaintOver = function(icon, w, h)
				surface.SetDrawColor(0, 0, 0, 45)
				surface.DrawOutlinedRect(1, 1, w - 2, h - 2)
				surface.SetDrawColor(0, 0, 0, 50)
				surface.DrawRect(w - distance - 1, w - distance - 1, size + 2, size + 2)
				surface.SetDrawColor(255, 255, 255)
				surface.SetMaterial(Material("icon16/cross.png"))
				if v.onWorld then
					local veh = Entity(v.ent)
					if IsValid(veh) then
						if veh:GetPos():Distance(LocalPlayer():GetPos()) <= 700 then
							surface.SetMaterial(Material("icon16/tick.png"))
						end
					end
				end
				surface.DrawTexturedRect(w - distance, w - distance, size, size)
			end
			icon:SetTooltip(data.name)
			icon.DoClick = function()
				local text = "Name: "..data.name.."
Color: "..v.color.r..", "..v.color.g..", "..v.color.b.."
Fuel: "..v.fuel.."/100
Current Storage: "..v.storage or "N/A"
				self.info:SetText(text)
				self.model:SetModel(data.model)
				self.model.Entity:SetSkin(data.skin)
				self.model:SetColor(v.color)
				if v.onWorld then
					local veh = Entity(v.ent)
					if veh:GetPos():Distance(LocalPlayer():GetPos()) <= 700 then
						self.request = {2, tostring(k)}
						self.button:SetText("Sell")
						self.button:SetDisabled(false)
					else
						self.button:SetDisabled(true)
						self.button:SetText("Vehicle Too Far!")
					end
				else
					self.button:SetDisabled(true)
					self.button:SetText("Vehicle Too Far!")
				end
			end
		end
	end

	function PANEL:Think()
		if self.request then
			self.model:SetColor(self.color:GetColor())
		end
	end

	vgui.Register("nut_VehShop", PANEL, "DFrame")

	nut.bar.Add("fuel", {
		getValue = function()
			if (LocalPlayer():InVehicle()) then
				return LocalPlayer():GetVehicle():GetNWInt("fuel", 0)
			else
				return 0
			end
		end,
		color = Color(50, 50, 50)
	})

	nut.bar.Add("carHP", {
		getValue = function()
			if (LocalPlayer():InVehicle()) then
				return LocalPlayer():GetVehicle():Health() / 10
			else
				return 0
			end
		end,
		color = Color(230, 135, 50)
	})

	netstream.Hook("carColorMenu", function()
		local Frame = vgui.Create("DFrame")
		Frame:SetPos(0, 300)
		Frame:SetSize(300, 245)
		Frame:SetTitle("Car Paint")
		Frame:MakePopup()

		local Hint = vgui.Create("nut_NoticePanel", Frame)
		Hint:SetPos(10, 30)
		Hint:SetSize(280, 25)
		Hint:SetType(7)
		Hint:SetText("Pick the color of your car... Cost: 100 €")

		local Mixer = vgui.Create("DColorMixer", Frame)
		Mixer:SetPos(10, 60)
		Mixer:SetSize(280, 150)
		Mixer:SetPalette(true)
		Mixer:SetAlphaBar(false)
		Mixer:SetWangs(true)

		local Button = vgui.Create("DButton", Frame)
		Button:Dock(BOTTOM)
		Button:SetText("Paint!")
		function Button:DoClick()
			Frame:Close()
			netstream.Start("carColorSet", {red = Mixer:GetColor().r, green = Mixer:GetColor().g, blue = Mixer:GetColor().b})
		end
	end)
end



sv.plugin




local PLUGIN = PLUGIN

netstream.Hook("GarageRequest", function( ply, netTbl )
	local carID = netTbl[1]
	local storage = netTbl[2]
	local storageData = PLUGIN.GetStorage(storage)
	local customVehData = ply:getChar():getData("vehicles")
	local defaultVehData = PLUGIN.GetCar(customVehData[carID].class)
	if not customVehData then
		nut.util.Notify("ERROR: Couldn't retreive 'customVehData'! Go yell at Starfox64!", ply)
		return
	elseif not defaultVehData then
		nut.util.Notify("ERROR: Couldn't retreive 'defaultVehData'! Go yell at Starfox64!", ply)
		return
	elseif not storageData then
		nut.util.Notify("ERROR: Couldn't retreive 'storageData'! Go yell at Starfox64!", ply)
		return
	end
	if customVehData[carID].onWorld and customVehData[carID].ent then
		if IsValid(Entity(customVehData[carID].ent)) then
			local vehicle = Entity(customVehData[carID].ent)
			if vehicle.disabled then
				nut.util.Notify("Your vehicle is disabled!", ply)
				return
			end

			if storageData.spawnPos:Distance(vehicle:GetPos()) <= 300 then
				local newData = customVehData
				newData[carID].inv = vehicle.storage:GetNetVar("inv", {})
				newData[carID].money = vehicle.storage:GetNetVar("money", 0)
				newData[carID].fuel = math.Round(vehicle.fuel)
				newData[carID].color = vehicle:GetColor()
				newData[carID].storage = storage
				newData[carID].hp = vehicle:Health()
				newData[carID].onWorld = false
				newData[carID].ent = nil
				vehicle.storage:Remove()
				vehicle:Remove()
				table.RemoveByValue(ply.VehiclesOut, vehicle)
				ply:getChar():setData("vehicles", newData, ply, false)
				nut.util.AddLog(ply:Name().. " ( "..ply:RealName().." ) stored a "..customVehData[carID].class..".", LOG_FILTER_CONCOMMAND)
			else
				nut.util.Notify("Your vehicle is too far!", ply)
			end
		else
			nut.util.Notify("ERROR: This vehicle does not exist, reseting vehicle data. Please try again.")
			local newData = customVehData
			newData[carID].ent = nil
			newData[carID].onWorld = false
			ply:getChar():setData("vehicles", newData, ply, false)
		end
	elseif !customVehData[carID].onWorld and customVehData[carID].storage == storage then
		if customVehData[carID].ent then
			if IsValid(Entity(customVehData[carID].ent)) then
				Entity(customVehData[carID].ent):Remove()
			end
		end
		if ply.VehiclesOut then
			if table.Count(ply.VehiclesOut) + 1 > PLUGIN.maxVehiclesOut then
				nut.util.Notify("You cannot have more than "..PLUGIN.maxVehiclesOut.." vehicles out!", ply)
				return
			end
		end
		local vehicle = ents.Create("prop_vehicle_jeep")
		vehicle:SetModel(defaultVehData.model)
		vehicle:SetKeyValue("vehiclescript", defaultVehData.script)
		vehicle:SetPos(storageData.spawnPos)
		vehicle:SetAngles(storageData.spawnAng)
		vehicle:SetHealth(customVehData[carID].hp or 1000)
		vehicle:Spawn()
		vehicle.owner = ply
		vehicle:SetNetVar("owner", ply) -- To lazy to find where I'm using each of these ;)
		vehicle.fuel = customVehData[carID].fuel
		vehicle:SetColor(customVehData[carID].color or Color(255, 255, 255))
		vehicle.type = defaultVehData.type
		vehicle:SetSkin(defaultVehData.skin)
		vehicle.locked = false
		if defaultVehData.photon then
			vehicle.VehicleTable = list.Get("Vehicles")[defaultVehData.photon]
		end

		hook.Run("PlayerSpawnedVehicle", ply, vehicle) -- Passanger Mod

		local storage = ents.Create("nut_garage")
		storage:SetPos(vehicle:GetPos())
		storage:Spawn()
		storage:Activate()
		storage:SetModel("models/Gibs/HGIBS.mdl")
		storage:PhysicsInit(SOLID_NONE)
		storage:SetParent(vehicle)
		storage:SetColor(Color(0, 0, 0, 0))
		storage:SetRenderMode(RENDERMODE_TRANSALPHA)
		storage:SetNetVar("inv", customVehData[carID].inv)
		storage:SetNetVar("money", customVehData[carID].money)
		storage:SetNetVar("name", "Trunk")
		storage.itemID = "trunk"
		storage.Trunk = true
		storage:SetNetVar("max", defaultVehData.maxWeight)
		vehicle.storage = storage

		local newData = customVehData
		newData[carID].storage = "N/A"
		newData[carID].onWorld = true
		newData[carID].ent = vehicle:EntIndex()
		ply:getChar():setData("vehicles", newData, ply, false)

		if not ply.VehiclesOut then
			ply.VehiclesOut = {vehicle}
		else
			table.insert(ply.VehiclesOut, vehicle)
		end
		nut.util.AddLog(ply:Name().. " ( "..ply:RealName().." ) took out his "..customVehData[carID].class..".", LOG_FILTER_CONCOMMAND)
	end
end)

netstream.Hook("VehShopRequest", function( ply, netTbl )
	local type = netTbl[1]
	local vehID = netTbl[2]
	local color = netTbl[3]
	local ShopStorage = "DowntownMotors"
	local plyVehicles = ply:getChar():getData("vehicles", {})
	if type == 1 then -- Buy
		if table.Count(plyVehicles) >= PLUGIN.maxVehicles then
			nut.util.Notify("You have reached the maximum vehicles amount per character. ("..PLUGIN.maxVehicles..")", ply)
			return
		else


			local data = PLUGIN.GetCar(vehID)
			if ply:CanAfford(data.price) then
				local dist = 32768
				for k,v in pairs(PLUGIN.Storages) do
					local shopDist = v.pos:Distance(ply:GetPos())
					if shopDist < dist then
						dist = shopDist
						ShopStorage = k
					end
				end
				local carData = {}
				carData.class = vehID
				carData.color = Color(color.r, color.g, color.b)
				carData.fuel = 100
				carData.inv = {}
				carData.money = 0
				carData.storage = ShopStorage
				carData.onWorld = false
				carData.ent = nil
				local newData = plyVehicles
				table.insert(newData, carData)
				ply:getChar():setData("vehicles", newData, ply, false)
				ply:TakeMoney(data.price)
				nut.char.Save(ply)
				nut.util.Notify("You have successfully bought a "..data.name.." for "..nut.currency.GetName(data.price)..". It is now in the "..ShopStorage.." storage.", ply)
				nut.util.AddLog(ply:Name().. " ( "..ply:RealName().." ) bought a "..vehID..".", LOG_FILTER_CONCOMMAND)
			else
				nut.util.Notify("You do not have enough money!", ply)
				return
			end
		end
	elseif type == 2 then -- Sell
		vehID = tonumber(vehID)
		local data = plyVehicles[vehID]
		if data.onWorld then
			local veh = Entity(data.ent)
			if IsValid(veh) then
				if veh:GetPos():Distance(ply:GetPos()) <= 700 then
					veh.storage:Remove()
					veh:Remove()
					local carData = PLUGIN.GetCar(data.class)
					local sellPrice = math.Round(carData.price / 1.5) -- 75%
					ply:GiveMoney(sellPrice)
					newData = plyVehicles
					table.remove(newData, vehID)
					ply:getChar():setData("vehicles", newData, ply, false)
					nut.char.Save()
					nut.util.Notify("You have successfully sold your "..carData.name.." for "..nut.currency.GetName(sellPrice)..".", ply)
					nut.util.AddLog(ply:Name().. " ( "..ply:RealName().." ) sold his "..data.class..".", LOG_FILTER_CONCOMMAND)
				else
					nut.util.Notify("Your vehicle is too far away.", ply)
				end
			end
		else
			nut.util.Notify("Your vehicle must be out of your storage.", ply)
		end
	else -- ERROR
		nut.util.Notify("ERROR: No Type!", ply)
	end
end)

netstream.Hook("GiveVehicle", function( ply, netTbl )
	local vehID = netTbl[1]
	local target = netTbl[2]
	local car = ply:getChar():getData("vehicles", {})[vehID]
	local carName = PLUGIN.GetCar(car.class).name

	if target == ply then return end

	if car and not car.onWorld then
		if IsValid(target) and target:getChar() then
			local targetCars = target:getChar():getData("vehicles", {})
			local plyCars = ply:getChar():getData("vehicles", {})

			table.remove(plyCars, vehID)
			ply:getChar():setData("vehicles", plyCars)

			table.insert(targetCars, car)
			target:getChar():setData("vehicles", targetCars)

			nut.util.Notify("Your "..carName.." is now in "..target:Name().."'s garage.", ply)
			nut.util.Notify(ply:Name().." has sent a "..carName.." to your garage.", target)

			nut.util.AddLog(ply:Name().. " ( "..ply:RealName().." ) sent his "..carName.." to "..target:Name().." ( "..target:RealName().." )'s garage.", LOG_FILTER_CONCOMMAND)

			nut.char.Save(ply)
			nut.char.Save(target)
		else
			nut.util.Notify("ERROR: Target not found!", ply)
		end
	else
		nut.util.Notify("ERROR: Vehicle not found!", ply)
	end
end)

hook.Add("PlayerLoadedChar", "VehCharChange", function( ply )
	if ply.VehiclesOut then
		if table.Count(ply.VehiclesOut) > 1 then
			for k,v in pairs(player.GetAll()) do
				nut.util.Notify(ply:Name().."'s vehicles are being removed. Reason: Changing Character", v)
			end
			nut.util.AddLog(ply:Name().." ("..ply:SteamID()..") is changing character with vehicles on the world.", LOG_FILTER_MAJOR)
			for k,v in pairs(ply.VehiclesOut) do
				if IsValid(v.storage) then
					v.storage:Remove()
				end
				if IsValid(v) then
					v:Remove()
				end
			end
			table.Empty(ply.VehiclesOut)
		end
	end
	local vehicles = ply:getChar():getData("vehicles", {})
	for k, v in pairs(ply:getChar():getData("vehicles", {})) do
		local newData = v
		newData.onWorld = false
		newData.ent = nil
		if not v.storage or v.storage == "N/A" then
			newData.storage = "Downtown"
		end
		vehicles[k] = newData
	end
	ply:getChar():setData("vehicles", vehicles, ply, false)
end)

hook.Add("PlayerDisconnected", "VehiclesCleanup", function( ply )
	if ply.VehiclesOut then
		if table.Count(ply.VehiclesOut) > 0 then
			for k,v in pairs(player.GetAll()) do
				nut.util.Notify(ply:Name().."'s vehicles are being removed. Reason: Player Disconnected", v)
			end
			nut.util.AddLog(ply:Name().." ("..ply:SteamID()..") is disconnecting with vehicles on the world.", LOG_FILTER_MAJOR)
			for k,v in pairs(ply.VehiclesOut) do
				v.storage:Remove()
				v:Remove()
			end
		end
	end
end)

timer.Create("VehiclesAutoSave", 300, 0, function()
	for _,ply in pairs(player.GetAll()) do
		if ply.VehiclesOut then
			for k,v in pairs(ply:getChar():getData("vehicles", {})) do
				if v.onWorld and v.ent then
					local ent = Entity(v.ent)
					if IsValid(ent) then
						local newData = ply:getChar():getData("vehicles", {})
						if IsValid(ent.storage) then
							newData[k].inv = ent.storage:GetNetVar("inv", {})
							newData[k].money = ent.storage:GetNetVar("money", 0)
						end
						ply:getChar():setData("vehicles", newData, ply, false)
					end
				end
			end
		end
	end
end)

hook.Add("InitPostEntity", "SpawnGarageEntities", function()
	for k,v in pairs(PLUGIN.Storages) do
		local ent = ents.Create("nut_garage")
		ent:SetPos(v.pos)
		ent:SetAngles(v.ang)
		ent:SetMoveType(MOVETYPE_NONE)
		ent:Spawn()
		ent:Activate()
	end
	for k,v in pairs(PLUGIN.VehShops) do
		local vendor = ents.Create("npc_carvendor")
		vendor:SetPos(v.pos)
		vendor:SetAngles(v.ang)
		vendor.type = v.type
		vendor:SetModel(v.model)
		vendor:SetMoveType(MOVETYPE_NONE)
		vendor:Spawn()
		vendor:Activate()
	end	
end)

netstream.Hook("carColorSet", function( ply, color )
	if ply:GetMoney() >= 100 then
		ply:GetVehicle():SetColor(Color(color.red, color.green, color.blue))
		ply:SetMoney(ply:GetMoney() - 100)
		nut.util.Notify("You changed the color of your car for 100 €, put it back in your garage to save it!", ply)
	else
		nut.util.Notify("You do not have enough money! You need 100 € to change the color of your car.", ply)
	end
end)

timer.Create("FuelNetwork", 5, 0, function()
	for k, v in pairs(ents.GetAll()) do
		if v:GetClass() == "prop_vehicle_jeep" then
			if v.fuel then
				v:SetNWInt("fuel", v.fuel)
			end
		end
	end
end)

function PLUGIN.Honk( player, vehicle )
	if player:KeyDown( IN_ATTACK ) then
		if !vehicle.bool_honk then
			vehicle.bool_honk = true
			vehicle:EmitSound("horn.wav")
		end
	else
		if vehicle.bool_honk then
			vehicle.bool_honk = false
		end
	end
end

function PLUGIN.Tow( player, vehicle )
	if player:KeyDown( IN_ZOOM ) then
		if !vehicle.bool_tow then
			vehicle.bool_tow = true
			if vehicle.type == "TOW" then
				if not vehicle.tow then
					local traceData = {
						start = vehicle:GetPos(),
						endpos = vehicle:GetPos() + Angle(0, 0, 0):Forward() * 150,
						filter = vehicle
					}
					local trace = util.TraceLine(traceData)
					if trace.Entity then
						local target = trace.entity
						if target:IsVehicle() then
							local const = constraint.Rope(vehicle, target:EntIndex(), 0, 0, PLUGIN.TowTruckPos, PLUGIN.TowPos, PLUGIN.RopeLength, 0, 0, PLUGIN.RopeWidth, PLUGIN.RopeMaterial, false)
							if const then
								nut.util.Notify("Vehicle hooked!", player)
								vehicle.tow = target
							else
								nut.util.Notify("Hooking failed! (Constraints ERROR)", player)
							end
						end
					end
				else
					local removed = constraint.RemoveConstraints(vehicle, "Rope")
					if removed then
						vehicle.tow = nil
						nut.util.Notify("Vehicle released.", player)
					end
				end
			end
		end
	else
		if vehicle.bool_tow then
			vehicle.bool_tow = false
		end
	end
end

function PLUGIN:Think()
	for k, v in pairs( player.GetAll() ) do
		if v:InVehicle() then
			local vehicle = v:GetVehicle()
			if vehicle:IsValid() then
				local vel = vehicle:GetVelocity():Length()
				if vel > 0 then
					vehicle.fuel = math.Clamp( ( ( vehicle.fuel or 0 ) - vel/1000000 ), 0, 100 )
				end
				if not vehicle.fuel then vehicle.fuel = 0 end
				if vehicle.fuel <= 0 then
					local phys = vehicle:GetPhysicsObject()
					if phys:IsValid() then
						phys:SetVelocity( phys:GetVelocity()* -1 )
					end
				end
				if vehicle:GetClass() == "prop_vehicle_jeep" then
					PLUGIN.Honk(v, vehicle)
					PLUGIN.Tow(v, vehicle)
				end
			end
		end
	end
end





the part where the text is suppose to change and adds an icon




for k,v in pairs(LocalPlayer():getChar():getData("vehicles", {})) do
			local data = PLUGIN.GetCar(v.class)
			local icon = self.list:Add("SpawnIcon")
			icon:SetModel(data.model, data.skin)
			icon.PaintOver = function(icon, w, h)
				surface.SetDrawColor(0, 0, 0, 45)
				surface.DrawOutlinedRect(1, 1, w - 2, h - 2)
				if v.onWorld or v.storage == currentStorage then
					surface.SetDrawColor(0, 0, 0, 50)
					surface.DrawRect(w - distance - 1, w - distance - 1, size + 2, size + 2)
					surface.SetDrawColor(255, 255, 255)
					if v.onWorld then
						surface.SetMaterial(Material("icon16/world.png"))
					else
						surface.SetMaterial(Material("icon16/house.png"))
					end
					surface.DrawTexturedRect(w - distance, w - distance, size, size)
				end
			end
			icon:SetTooltip(data.name)
			icon.DoClick = function()
				local hp = v.hp or 1000
				local text = "Name: "..data.name.."
Condition: "..hp.."/1000
Color: "..v.color.r..", "..v.color.g..", "..v.color.b.."
Fuel: "..v.fuel.."/100
Current Storage: "..v.storage or "N/A"
				self.info:SetText(text)
				self.model:SetModel(data.model)
				self.model.Entity:SetSkin(data.skin)
				self.model:SetColor(v.color)
				if v.onWorld or v.storage == currentStorage then
					self.request = {k, currentStorage}
					elseif v.onWorld then
						self.button:SetText("Store")
						elseif v.storage == currentStorage then
						self.button:SetText("Take Out")
						self.give:SetDisabled(false)
					end
					self.button:SetDisabled(false)
				else
					self.give:SetDisabled(true)
					self.button:SetDisabled(true)
					self.button:SetText("Select a Vehicle!")
				end
			end
		end
	end