Advertisement
balou27

sv_randomplacement

Jul 12th, 2020
1,402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.13 KB | None | 0 0
  1. local GM = GM or GAMEMODE
  2.  
  3. local function Spawn_SlashGen()
  4.     if GM.MAP.Goal then --If we have data for this map
  5.         for k, v in pairs( GM.MAP.Goal ) do
  6.  
  7.             if (v == GM.MAP.Goal.Jerrican) then
  8.                 nbEntToSpawn = 3 *  math.ceil( (#player.GetAll() / 3) )
  9.             else
  10.                 nbEntToSpawn = 0
  11.             end
  12.  
  13.             while (nbEntToSpawn >= 0) do
  14.                 w = table.Random(v)
  15.  
  16.                 if !w.spw then
  17.                     --get the type of entity
  18.                     local entType = w.type
  19.                     --spawn it
  20.                     local newEnt = ents.Create(entType)
  21.                     if w.model then newEnt:SetModel(w.model) end --set model
  22.                     if w.ang then newEnt:SetAngles(w.ang) end --set angle
  23.                     if w.pos then newEnt:SetPos(w.pos) end --set position
  24.                     newEnt:Spawn()
  25.  
  26.                     newEnt:Activate()
  27.  
  28.                     w.spw = true
  29.                 end
  30.                 nbEntToSpawn = nbEntToSpawn -1
  31.             end
  32.         end
  33.     end
  34. end
  35. hook.Add( "sls_round_PostStart", "Slasher Generator Spawn", Spawn_SlashGen )
  36.  
  37. hook.Add( "sls_round_PreStart", "sls_ReinitObjectives", function( ply, text, public )
  38.     if GM.MAP.Goal then --If we have data for this map
  39.         for k, v in pairs( GM.MAP.Goal ) do
  40.             for m, w in pairs( v ) do
  41.                 w.spw = false
  42.             end
  43.         end
  44.     end
  45. end )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement