Cheesecaked

Magnet

Feb 23rd, 2021
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. @name Magnet
  2. @persist Table:table Array:array Range Stick Cooldown
  3. @model models/props_junk/PropaneCanister001a.mdl
  4.  
  5. if(first()){
  6. runOnTick(1)
  7.  
  8. Range = 510
  9. Stick = 30
  10.  
  11. Cooldown = 0
  12. }
  13.  
  14. findDisallowClass("wire_expression_2")
  15. findIncludeClass("prop_*")
  16. findIncludeClass("wire_*")
  17. findIncludeClass("npc_*")
  18. findInSphere(entity():boxCenterW(),2000)
  19. findSortByDistance(entity():boxCenterW())
  20.  
  21. Array = findToArray()
  22.  
  23. if(Cooldown == 0){
  24. for(P = 1,Array:count()){
  25. D = Array[P,entity]:boxCenterW():distance(entity():boxCenterW())
  26. if(D <= Range & Array[P,entity]:type() != entity():type() & Array[P,entity]:model() != ""){
  27. if(D >= Stick){
  28. V = entity():pos() - Array[P,entity]:pos()
  29. VV = vec(sqrt(V:x()^2),sqrt(V:y()^2),sqrt(V:z()^2)) / V
  30. Array[P,entity]:applyForce(VV * Array[P,entity]:mass() * ((Range - Stick - D )/(Range - Stick)*20))
  31. }
  32.  
  33. if(changed(D)){
  34. if(D <= Stick){
  35. Array[P,entity]:propFreeze(1)
  36. Array[P,entity]:parentTo(entity())
  37. Array[P,entity]:propNotSolid(1)
  38. Array[P,entity]:setAlpha(150)
  39. }
  40. }
  41. }
  42. }
  43. }
  44.  
  45. for(B = 1,players():count()){
  46. if(players()[B,entity]:aimEntity() == entity()){
  47. if(changed(players()[B,entity]:keyUse())){
  48. if(players()[B,entity]:keyUse()){
  49. Cooldown = 50
  50.  
  51. entity():propFreeze(0)
  52.  
  53. for(P = 1,Array:count()){
  54. D = Array[P,entity]:boxCenterW():distance(entity():boxCenterW())
  55. if(D <= Stick + 30 & Array[P,entity]:type() != entity():type()){
  56. Array[P,entity]:deparent()
  57. Array[P,entity]:propFreeze(1)
  58. Array[P,entity]:setPos(Array[P,entity]:pos() + vec(0,0,30))
  59. Array[P,entity]:propNotSolid(0)
  60. Array[P,entity]:setAlpha(255)
  61. }
  62. }
  63. }
  64. }
  65. }
  66. }
  67.  
  68. if(Cooldown > 0){
  69. Cooldown -= 1
  70. }
  71.  
  72. if(last()){
  73. for(P = 1,Array:count()){
  74. D = Array[P,entity]:boxCenterW():distance(entity():boxCenterW())
  75. if(D <= Stick){
  76. Array[P,entity]:deparent()
  77. Array[P,entity]:propNotSolid(0)
  78. Array[P,entity]:setAlpha(255)
  79. }
  80. }
  81. }
  82.  
Advertisement
Add Comment
Please, Sign In to add comment