Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name Magnet
- @persist Table:table Array:array Range Stick Cooldown
- @model models/props_junk/PropaneCanister001a.mdl
- if(first()){
- runOnTick(1)
- Range = 510
- Stick = 30
- Cooldown = 0
- }
- findDisallowClass("wire_expression_2")
- findIncludeClass("prop_*")
- findIncludeClass("wire_*")
- findIncludeClass("npc_*")
- findInSphere(entity():boxCenterW(),2000)
- findSortByDistance(entity():boxCenterW())
- Array = findToArray()
- if(Cooldown == 0){
- for(P = 1,Array:count()){
- D = Array[P,entity]:boxCenterW():distance(entity():boxCenterW())
- if(D <= Range & Array[P,entity]:type() != entity():type() & Array[P,entity]:model() != ""){
- if(D >= Stick){
- V = entity():pos() - Array[P,entity]:pos()
- VV = vec(sqrt(V:x()^2),sqrt(V:y()^2),sqrt(V:z()^2)) / V
- Array[P,entity]:applyForce(VV * Array[P,entity]:mass() * ((Range - Stick - D )/(Range - Stick)*20))
- }
- if(changed(D)){
- if(D <= Stick){
- Array[P,entity]:propFreeze(1)
- Array[P,entity]:parentTo(entity())
- Array[P,entity]:propNotSolid(1)
- Array[P,entity]:setAlpha(150)
- }
- }
- }
- }
- }
- for(B = 1,players():count()){
- if(players()[B,entity]:aimEntity() == entity()){
- if(changed(players()[B,entity]:keyUse())){
- if(players()[B,entity]:keyUse()){
- Cooldown = 50
- entity():propFreeze(0)
- for(P = 1,Array:count()){
- D = Array[P,entity]:boxCenterW():distance(entity():boxCenterW())
- if(D <= Stick + 30 & Array[P,entity]:type() != entity():type()){
- Array[P,entity]:deparent()
- Array[P,entity]:propFreeze(1)
- Array[P,entity]:setPos(Array[P,entity]:pos() + vec(0,0,30))
- Array[P,entity]:propNotSolid(0)
- Array[P,entity]:setAlpha(255)
- }
- }
- }
- }
- }
- }
- if(Cooldown > 0){
- Cooldown -= 1
- }
- if(last()){
- for(P = 1,Array:count()){
- D = Array[P,entity]:boxCenterW():distance(entity():boxCenterW())
- if(D <= Stick){
- Array[P,entity]:deparent()
- Array[P,entity]:propNotSolid(0)
- Array[P,entity]:setAlpha(255)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment