Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[CreateConVar( "dv_spawnamount", "10", FCVAR_ARCHIVE, "How much DV to spawn?" )
- CreateConVar( "dv_spawnrestrictcat", "", FCVAR_ARCHIVE, "Write here name of category you want to spawn vehicles" )
- CreateConVar( "dv_whitelistVehicle", "trueno crsk_chevrolet_caprice_1993 chev_tahoe_lw merc_sprinter_boxtruck_lw", FCVAR_ARCHIVE, "Write here classes of cars to spawn.Example: 'dk_vehicle1 dv_vehicle2 vehicle3 veh4 kek lol'")
- CreateConVar( "dv_colors", '[ {"r":127.0,"g":111.0,"b":63.0,"a":255.0}, {"r":109,"g":109.0,"b":109.0,"a":255.0}, {"r":0,"g":0.0,"b":0.0,"a":255.0}, {"r":255,"g":0.0,"b":0.0,"a":255.0}, {"r":255,"g":191.0,"b":0.0,"a":255.0}, {"r":200,"g":200.0,"b":200.0,"a":255.0}, {"r":191,"g":255.0,"b":127.0,"a":255.0}, {"r":127,"g":95.0,"b":0.0,"a":255.0}, {"r":72,"g":72.0,"b":72.0,"a":255.0} ]', FCVAR_ARCHIVE, "Write here name of category you want to spawn vehicles" )
- ]]
- CreateConVar( "dv_spawnamount", "10", FCVAR_ARCHIVE, "How much DV to spawn?" )
- local SpawnTableInfo = {
- Colors = {
- Color(255, 255, 255, 255),
- --[[Color(255, 223, 127, 255),
- Color(99, 0, 0, 255),
- Color(64, 64, 64, 255),
- Color(69, 94, 138, 255),
- Color(90, 90, 90, 255),
- Color(127, 111, 63, 255),
- Color(109, 109, 109, 255),
- Color(0, 0, 0, 255),
- Color(0, 0, 0, 255),
- Color(127, 0, 0, 255),
- Color(255, 191, 0, 255),
- Color(72, 72, 72, 255),
- Color(72, 72, 72, 255),
- Color(127, 95, 0, 255),
- Color(200, 200, 200, 255)]]
- }, -- {Color(127,0,0), Color(0,255)},
- WhiteList = {
- ["forney_consumer_aspire"] = true,
- ["forney_consumer_explorer"] = true,
- ["forney_consumer_explorereb"] = true,
- ["forney_consumer_sunfire"] = true,
- ["forney_consumer_voyager"] = true,
- ["forney_consumer_maxima"] = true,
- ["forney_consumer_sierra"] = true,
- ["forney_consumer_canopy"] = true,
- --["priustdm"] = true,
- --["sm_fordmond17"] = true,
- --["chev_impala_09"] = true,
- --["fusionroy"] = true,
- --["transittdm"] = true,
- --["gmc_savana_lw"] = true,
- --["gmc_yukon_lw"] = true,
- --["crsk_chevrolet_caprice_1993"] = true,
- --["speed3tdm"] = true,
- --["chargersrt8tdm"] = true,
- --["priustdm"] = true,
- --["sublegrs90tdm"] = true,
- --["bmw_x5_48i_lw"] = true,
- --["m3e92tdm"] = true,
- --["trueno"] = true
- }, -- {"dk_vehicle", "dk_vehicle3", "blabla"}
- }
- local DVSTable = {}
- local dvd = DecentVehicleDestination
- local function SpawnDVS()
- local wps = dvd.Waypoints
- if not wps or table.Count(wps) <= 5 then return end
- local amount = GetConVar("dv_spawnamount"):GetInt()
- if amount == 0 then return end
- if table.Count(wps) <= amount then
- amount = math.floor(amount/2)
- error("Too much vehicles to spawn!")
- end
- local allowed = {}
- local vehicles = list.Get("Vehicles")
- print("Checking for allowed vehicles...")
- for k, v in pairs(vehicles) do
- if v.Category == "Chairs" or k == "Pod" or k == "Airboat" then print("Skipped boat and seats") continue end
- if not SpawnTableInfo.WhiteList[k] then print("Skipped "..k.." because of whitelist") continue end
- print("Adding", k)
- table.insert(allowed, k)
- end
- if #allowed == 0 then
- print("Can't spawn vehicle for DV because there no allowed vehicles")
- print("Check next lines, maybe you wrote something wrong?:")
- print("Vehicle whitelist:", table.concat(SpawnTableInfo.WhiteList, ", "))
- print("END")
- return
- end
- for i=1, amount do
- local rand = math.random(1, table.Count(wps))
- while DVSTable[rand] do
- rand = math.random(1, table.Count(wps))
- end
- local waypoint = wps[rand]
- local class = allowed[math.random(1, #allowed)]
- local lst = vehicles[class]
- local car = ents.Create("prop_vehicle_jeep")
- car:SetModel(lst.Model)
- car:SetBodyGroups = {
- { 0, 0 }, -- Body
- { 1, 1 }, -- Wheels
- { 2, 1 }, -- clamped1
- { 3, 0 }, -- clamped2
- { 4, 0 }, -- clamped3
- { 5, 0 }, -- clamped4
- { 6, 0 }, -- clamped5
- }
- car:SetSkin( math.random( 0, car:SkinCount() ) )
- car:SetPos(waypoint.Target+Vector(0,0,50))
- car:SetAngles(Angle(0,0,0))
- car:SetKeyValue("vehiclescript",lst.KeyValues.vehiclescript)
- car:SetVehicleClass( class )
- car:SetColor(HSVToColor( math.random(0,360), 1, 1 ))
- car:Spawn()
- car:Activate()
- if table.Count(SpawnTableInfo.Colors) > 0 then
- MsgC(SpawnTableInfo.Colors[math.random(1, table.Count(SpawnTableInfo.Colors))], "[DecentVehicle Spawner] ", color_white, "Detected colors\n")
- car:SetColor(SpawnTableInfo.Colors[math.random(1, table.Count(SpawnTableInfo.Colors))])
- end
- local dv = ents.Create("npc_decentvehicle")
- dv:SetPos(waypoint.Target+Vector(0,0,50))
- dv:Spawn()
- DVSTable[rand] = car
- print("[DecentVehicle Spawner] Created", class)
- end
- end
- local PlayerJoined
- hook.Add("PlayerInitialSpawn", "SpawnDecentVehicles", function()
- if PlayerJoined then return end
- SpawnDVS()
- PlayerJoined = true
- end)
- concommand.Add("dv_respawnvehicles", function()
- for k, ent in pairs(DVSTable) do
- if not IsValid(ent) then continue end
- ent:Remove()
- end
- SpawnDVS()
- end)
- --[[hook.Add( "Decent Vehicle: Drive", "Idle reduction", function( self )
- self.v:VC_setHealth(self.v:VC_getHealthMax())
- end )]]
- hook.Add("Decent Vehicle: Drive", "Blablablabl", function(self)
- if not self.v.VC_getHealth or not self.v.VC_getHealthMax or not self.v.VC_repairFull_Admin then return end
- if self.v:VC_getHealth() <= self.v:VC_getHealthMax() then
- self.v:VC_repairFull_Admin()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement