HUD
Functions

Car Dealer: CD get Info

Get all VCMod data related to this car dealer.

Used in: VCMod Main addon.

Shared Entity Car Dealer:VC_CD_getInfo()

Returns

1. Integer Car dealers ID.

2. String Car dealers name.

3. String Car dealers model.

4. Table Car dealers data. This only works severside!. This includes all VCMod data assosiated with it, including vehicle data.

Example

// Compatibility with: https://www.gmodstore.com/scripts/view/4270

local allowedsecondarygroups = {
	"donator",
	"donator+",
}

hook.Add("VC_CD_canUse", "VC_SecondaryRank", function(NPC, ply)
	local ID, name, model, data = NPC:VC_CD_getInfo()
	local secUserGroup = ply.GetSecondaryUserGroup and ply:GetSecondaryUserGroup()

	if name == "VIP Car Dealer" and secUserGroup and !table.HasValue(allowedsecondarygroups, secUserGroup) then
		print("Insufficient Group Permissions")
		return false
	end
end)


// Print out first car dealers data
concommand.Add("VC_CD_getInfo", function()
	local NPC = ents.FindByClass("vc_npc_cardealer")[1]

	if IsValid(NPC) then
		local ID, name, model, data = ply:VC_CD_getInfo()

		print("Car dealer information: ID - "..ID..", name - "..name..", model - "..model..".")

		local countVeh = table.Count(data.Vehicles or {}) //Count how many vehicles are sold through this vehicle
		print("This car dealers sells "..countVeh.." vehicles.")
	else
		print("No car dealers spawned.")
	end
end)
Page modified:
...2018-11-02 09:24:36