Advertisement
Guest User

Untitled

a guest
Jul 28th, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. local MapData = {
  2.  
  3. Mapname = {
  4. {model="models/hunter/plates/plate.mdl", pos=Vector(0,0,0), ang=Angle(0,90,0)},
  5. {model="models/hunter/plates/plate.mdl", pos=Vector(100,0,-100), ang=Angle(22,35,15)},
  6. },
  7.  
  8. Maname = {
  9. {model="models/hunter/plates/plate.mdl", pos=Vector(0,0,0), ang=Angle(0,90,0)},
  10. {type="weapon_smg1", pos=Vector(100,0,-100), ang=Angle(22,35,15),}, --We can set a 'type' to spawn an entity instead of a physics prop
  11. },
  12.  
  13. }
  14.  
  15. local function AutospawnProps()
  16.  
  17. local mapName = game.GetMap() --Get the name of the map
  18. local mapData = MapData[mapName] --Check we have data for this map
  19.  
  20. if mapData then --If we have data for this map
  21.  
  22. --Loop through the stuff
  23. for _,v in pairs(mapData) do
  24.  
  25. --get the type of entity, or default to a physics prop
  26. local entType = v.type or "prop_physics"
  27. --spawn it
  28. local newEnt = ents.Create(entType)
  29. if v.model then newEnt:SetModel(v.model) end --set model
  30. if v.ang then newEnt:SetAngle(v.ang) end --set angle
  31. if v.pos then newEnt:SetPos(v.pos) end --set position
  32. newEnt:Spawn()
  33. newEnt:Activate()
  34.  
  35. end --End of for-loop
  36.  
  37. end --End of check for map data
  38.  
  39. end
  40.  
  41. hook.Add("InitPostEntity", "Autospawn Props On Load", AutospawnProps)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement