Advertisement
TheDenVxUA

Untitled

Aug 6th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.94 KB | None | 0 0
  1. --[[CreateConVar( "dv_spawnamount", "10", FCVAR_ARCHIVE, "How much DV to spawn?" )
  2. CreateConVar( "dv_spawnrestrictcat", "", FCVAR_ARCHIVE, "Write here name of category you want to spawn vehicles" )
  3. 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'")
  4. 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" )
  5. ]]
  6.  
  7. CreateConVar( "dv_spawnamount", "5", FCVAR_ARCHIVE, "How much DV to spawn?" )
  8.  
  9. local SpawnTableInfo = {
  10.     Colors = {
  11.     Color(255, 223, 127, 255),
  12.     Color(127, 111, 63, 255),
  13.     Color(109, 109, 109, 255),
  14.     Color(0, 0, 0, 255),
  15.     Color(127, 0, 0, 255),
  16.     Color(255, 191, 0, 255),
  17.     Color(72, 72, 72, 255),
  18.     Color(127, 95, 0, 255),
  19.     Color(200, 200, 200, 255)
  20.     }, -- {Color(127,0,0), Color(0,255)},
  21.     WhiteList = {
  22.     ["crsk_chevrolet_caprice_1993"] = true,
  23.     ["chev_tahoe_lw"] = true,
  24.     ["crsk_mitsubishi_lancer_evo_ix"] = true,
  25.     ["trueno"] = true
  26.     }, -- {"dk_vehicle", "dk_vehicle3", "blabla"}
  27.  
  28. }
  29.  
  30.  
  31.  
  32. local DVSTable = {}
  33. local dvd = DecentVehicleDestination
  34. local function SpawnDVS()
  35.     local wps = dvd.Waypoints
  36.     if not wps or table.Count(wps) <= 5 then return end
  37.     local amount = GetConVar("dv_spawnamount"):GetInt()
  38.     if amount == 0 then return end
  39.     if table.Count(wps) <= amount then
  40.         amount = math.floor(amount/2)
  41.         error("Too much vehicles to spawn!")
  42.     end
  43.  
  44.     local allowed = {}
  45.     local vehicles = list.Get("Vehicles")
  46.     print("Checking for allowed vehicles...")
  47.     for k, v in pairs(vehicles) do
  48.         if v.Category == "Chairs" or k == "Pod" or k == "Airboat" then print("Skipped boat and seats") continue end
  49.         if not SpawnTableInfo.WhiteList[k] then print("Skipped "..k.." because of whitelist") continue end
  50.         print("Adding", k)
  51.         table.insert(allowed, k)
  52.     end
  53.  
  54.     if #allowed == 0 then
  55.         print("Can't spawn vehicle for DV because there no allowed vehicles")
  56.         print("Check next lines, maybe you wrote something wrong?:")
  57.         print("Vehicle whitelist:", table.concat(SpawnTableInfo.WhiteList, ", "))
  58.         print("END")
  59.         return
  60.     end
  61.  
  62.     for i=1, amount do
  63.         local rand = math.random(1, table.Count(wps))
  64.         while DVSTable[rand] do
  65.             rand = math.random(1, table.Count(wps))
  66.         end
  67.         local waypoint = wps[rand]
  68.  
  69.         local class = allowed[math.random(1, #allowed)]
  70.         local lst = vehicles[class]
  71.  
  72.         local car = ents.Create("prop_vehicle_jeep")
  73.         car:SetModel(lst.Model)
  74.         car:SetPos(waypoint.Target+Vector(0,0,50))
  75.         car:SetAngles(Angle(0,0,0))
  76.         car:SetKeyValue("vehiclescript",lst.KeyValues.vehiclescript)
  77.         car:SetVehicleClass( class )
  78.         car:SetColor(HSVToColor( math.random(0,360), 1, 1 ))
  79.         car:Spawn()
  80.         car:Activate()
  81.         if table.Count(SpawnTableInfo.Colors) > 0 then
  82.             car:SetColor(SpawnTableInfo.Colors[math.random(0.3, table.Count(SpawnTableInfo.Colors))])
  83.         end
  84.  
  85.         local dv = ents.Create("npc_decentvehicle")
  86.         dv:SetPos(car:GetPos())
  87.         dv:Spawn()
  88.  
  89.         DVSTable[rand] = car
  90.  
  91.         print("[DecentVehicle Spawner] Created", class)
  92.     end
  93. end
  94.  
  95. hook.Add("InitPostEntity", "SpawnDecentVehicles", SpawnDVS)
  96.  
  97. concommand.Add("dv_respawnvehicles", function()
  98.     for k, ent in ipairs(DVSTable) do
  99.         if not IsValid(ent) then continue end
  100.         ent:Remove()
  101.     end
  102.     SpawnDVS()
  103. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement