Advertisement
Guest User

Untitled

a guest
Jul 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.58 KB | None | 0 0
  1. --[[
  2. ____ ____ _ _ _
  3. | _ \ _ __ ___ _ __ | _ \ _ __ ___ | |_ ___ ___ | |_ (_) ___ _ __
  4. | |_) | | '__| / _ \ | '_ \ | |_) | | '__| / _ \ | __| / _ \ / __| | __| | | / _ \ | '_ \
  5. | __/ | | | (_) | | |_) | | __/ | | | (_) | | |_ | __/ | (__ | |_ | | | (_) | | | | |
  6. |_| |_| \___/ | .__/ |_| |_| \___/ \__| \___| \___| \__| |_| \___/ |_| |_|
  7. |_|
  8. ]]--
  9.  
  10. --------------------
  11. // Prop Blacklist
  12. --------------------
  13.  
  14. hook.Add("PlayerSpawnedProp", "OsirisPropBlacklist", function(ply, mdl, ent)
  15. if OSIRIS_PP_CONFIG.PropBlacklist then
  16. if table.HasValue( OSIRIS_PP_CONFIG.PropBlacklistModels, ent:GetModel() ) then
  17. ent:Remove()
  18. ply:ChatPrint(OSIRIS_PP_CONFIG.PropBlacklistMessage)
  19. else
  20. return
  21. end
  22. end
  23. end)
  24.  
  25. --------------------
  26. // Prop Count
  27. --------------------
  28.  
  29. hook.Add("PlayerSpawnProp", "OsirisPropCount", function(ply)
  30. if OSIRIS_PP_CONFIG.PropCount then
  31. if ply:GetCount( "props" ) >= OSIRIS_PP_CONFIG.PropSpawnLimit and !ply.OnTimer then
  32. if OSIRIS_PP_CONFIG.CaughtMessage then
  33. ply:ChatPrint( OSIRIS_PP_CONFIG.PropSpawnCooldownInitialNotification )
  34. for k, v in pairs(player.GetAll()) do
  35. for i = 1, 1 do
  36. v:ChatPrint( string.format( OSIRIS_PP_CONFIG.PropSpawnCaught, ply:Name() ) )
  37. end
  38. end
  39. ply.OnTimer = true
  40. timer.Simple(OSIRIS_PP_CONFIG.PropSpawnTimer, function()
  41. ply.OnTimer = false
  42. ply:ChatPrint( OSIRIS_PP_CONFIG.PropSpawnCooldownInactiveNotification )
  43. end)
  44. else
  45. ply:ChatPrint( OSIRIS_PP_CONFIG.PropSpawnCooldownInitialNotification )
  46. ply.OnTimer = true
  47. timer.Simple(OSIRIS_PP_CONFIG.PropSpawnTimer, function()
  48. ply.OnTimer = false
  49. ply:ChatPrint( OSIRIS_PP_CONFIG.PropSpawnCooldownInactiveNotification )
  50. end)
  51. end
  52. end
  53. if ply.OnTimer then
  54. if OSIRIS_PP_CONFIG.RemoveProps then
  55. for _,ent in pairs(ents.FindByClass("prop_physics")) do
  56. ent:Remove()
  57. end
  58. ply:ChatPrint( OSIRIS_PP_CONFIG.PropSpawnCooldownActiveNotification )
  59. --ply:ChatPrint( OSIRIS_PP_CONFIG.PropRemovealMessage )
  60. return false
  61. else
  62. ply:ChatPrint( OSIRIS_PP_CONFIG.PropSpawnCooldownActiveNotification )
  63. return false
  64. end
  65. end
  66. else
  67. return
  68. end
  69. end)
  70.  
  71. --------------------
  72. // Prop Collide
  73. --------------------
  74.  
  75. local IsValid = IsValid
  76. local props = {
  77. prop_physics = true,
  78. prop_physics_multiplayer = true,
  79. prop_dynamic = true,
  80. prop_physics_override = true,
  81. prop_dynamic_override = true
  82. }
  83. local function HandleCollision(self, coldata)
  84. if not IsValid(self) or not IsValid(coldata.HitEntity) then return end
  85. if not props[coldata.HitEntity:GetClass()] then return end
  86. local pos = coldata.HitPos
  87. local td = util.TraceLine({
  88. start = pos,
  89. ["end"] = pos,
  90. filter = self,
  91. })
  92. if not IsValid(td.Entity) or td.Entity != self then return end
  93. td = util.TraceLine({
  94. start = pos,
  95. ["end"] = pos,
  96. filter = coldata.HitEntity,
  97. })
  98. if not IsValid(td.Entity) or td.Entity != coldata.HitEntity then return end
  99. timer.Simple(0, function()
  100.  
  101. constraint.NoCollide(td.Entity, coldata.HitEntity, 0, 0 )
  102.  
  103. end)
  104. end
  105.  
  106. hook.Add("PlayerSpawnedProp", "OsirisPropCollision", function(ply, mdl, ent)
  107. if OSIRIS_PP_CONFIG.PropCollosionProtection then
  108. ent:AddCallback("PhysicsCollide", HandleCollision)
  109. else
  110. return
  111. end
  112. end)
  113.  
  114. --------------------
  115. // Unfreeze All
  116. --------------------
  117.  
  118. hook.Add("CanPlayerUnfreeze", "OsirisUnfreeze", function(ply, ent, phys)
  119. if OSIRIS_PP_CONFIG.DisableUnfreezeAll then
  120. return false
  121. end
  122. end)
  123.  
  124. --------------------
  125. // Prop Ghosting
  126. --------------------
  127.  
  128. hook.Add("PlayerSpawnedProp", "OsirisPropGhosting", function(ply, model, ent)
  129. if OSIRIS_PP_CONFIG.EnableSpawnPropGhosted == true then
  130. ent:SetMaterial("models/props_combine/com_shield001a")
  131. ent:SetCollisionGroup(COLLISION_GROUP_DEBRIS)
  132. end
  133. end)
  134.  
  135. --------------------
  136. // Physgun Ghosting
  137. --------------------
  138.  
  139. --{ Physgun Pickup }--
  140.  
  141. hook.Add("PhysgunPickup", "OsirisNoCollideOnPickup", function(ply, ent)
  142. if OSIRIS_PP_CONFIG.EnablePropFreezing == true then
  143. if ent:GetCollisionGroup() == COLLISION_GROUP_DEBRIS then
  144. return
  145. end
  146. ent:SetCollisionGroup(COLLISION_GROUP_DEBRIS)
  147. ent:SetMaterial("models/props_combine/com_shield001a")
  148. else
  149. retrun ""
  150. end
  151. end)
  152.  
  153. --{ Freeze Prop In Player }--
  154.  
  155. hook.Add("PhysgunDrop", "OsirisNoCollideNearPlayer", function(ply, ent)
  156. if OSIRIS_PP_CONFIG.EnablePropFreezing == true then
  157. for _,v in pairs(ents.GetAll()) do
  158. for _,ply in pairs(player.GetAll()) do
  159. if v:GetClass() == "prop_physics"and ply:GetPos():Distance(v:GetPos()) < 100 then
  160. ent:SetCollisionGroup(COLLISION_GROUP_DEBRIS)
  161. ent:SetMaterial("models/props_combine/com_shield001a")
  162. ply:ChatPrint(OSIRIS_PP_CONFIG.PropFreezingMessage)
  163. else
  164. ent:SetCollisionGroup(0)
  165. ent:SetMaterial("")
  166. ent:GetPhysicsObject():EnableMotion(false)
  167. end
  168. end
  169. end
  170. else
  171. return
  172. end
  173. end)
  174.  
  175. --{ Freeze on Drop }--
  176.  
  177. hook.Add("PhysgunDrop", "OsirisFreezeOnDrop", function(ply, ent)
  178. if OSIRIS_PP_CONFIG.EnablePropFreezingOnDrop then
  179. for _,v in pairs(ents.GetAll()) do
  180. for _,ply in pairs(player.GetAll()) do
  181. if v:GetClass() == "prop_physics"and ply:GetPos():Distance(v:GetPos()) < 100 then
  182. ent:SetCollisionGroup(COLLISION_GROUP_DEBRIS)
  183. ent:SetMaterial("models/props_combine/com_shield001a")
  184. return
  185. end
  186. end
  187. end
  188. if OSIRIS_PP_CONFIG.EnablePropFrozenMessage == true then
  189. ply:ChatPrint(OSIRIS_PP_CONFIG.PropFrozenMessage)
  190. end
  191. ent:SetCollisionGroup(0)
  192. ent:SetMaterial("")
  193. ent:GetPhysicsObject():EnableMotion(false)
  194. else
  195. return
  196. end
  197. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement