This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Smart Opener

By: a guest on Feb 27th, 2012  |  syntax: None  |  size: 6.01 KB  |  views: 24  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. @name Smart Opener
  2. @inputs S:wirelink
  3. @outputs Door
  4. @persist [P Distance A]:array Target:entity D Z
  5. @persist Color:vector
  6. @trigger
  7.  
  8.  
  9. interval(500)
  10.  
  11.  
  12. if (first())
  13. {
  14.     # Run On Chat
  15.     runOnChat(1)
  16.    
  17.    
  18.    
  19.     #Distance
  20.     D = 50
  21.    
  22.     # Clear Screen
  23.     S:writeString("Auto Door Opener -            ",0,0,1000,Color,0)
  24.     S:writeString("                              ",0,1,1000,Color,0)
  25.     S:writeString("                              ",0,2,1000,Color,0)
  26.     S:writeString("                              ",0,3,1000,Color,0)
  27.     S:writeString("                              ",0,4,1000,Color,0)
  28.     S:writeString("                              ",0,5,1000,Color,0)
  29.     S:writeString("                              ",0,6,1000,Color,0)
  30.     S:writeString("                              ",0,7,1000,Color,0)
  31.     S:writeString("                              ",0,8,1000,Color,0)
  32.     S:writeString("                              ",0,9,1000,Color,0)
  33.     S:writeString("                              ",0,10,1000,Color,0)
  34.     S:writeString("                              ",0,11,1000,Color,0)
  35.     S:writeString("                              ",0,12,1000,Color,0)
  36.     S:writeString("                              ",0,13,1000,Color,0)
  37.     S:writeString("                              ",0,14,1000,Color,0)
  38.     S:writeString("                              ",0,15,1000,Color,0)
  39.     S:writeString("                              ",0,16,1000,Color,0)
  40.     S:writeString("                              ",0,17,1000,Color,0)
  41.    
  42.     # Hints
  43.  
  44. }
  45.  
  46.  
  47.  
  48.  
  49. if (changed(P:count()) | changed(Door))
  50. {
  51.    
  52.     # Clear Screen
  53.     S:writeString("Auto Door Opener -            ",0,0,1000,Color,0)
  54.     S:writeString("                              ",0,1,1000,Color,0)
  55.     S:writeString("                              ",0,2,1000,Color,0)
  56.     S:writeString("                              ",0,3,1000,Color,0)
  57.     S:writeString("                              ",0,4,1000,Color,0)
  58.     S:writeString("                              ",0,5,1000,Color,0)
  59.     S:writeString("                              ",0,6,1000,Color,0)
  60.     S:writeString("                              ",0,7,1000,Color,0)
  61.     S:writeString("                              ",0,8,1000,Color,0)
  62.     S:writeString("                              ",0,9,1000,Color,0)
  63.     S:writeString("                              ",0,10,1000,Color,0)
  64.     S:writeString("                              ",0,11,1000,Color,0)
  65.     S:writeString("                              ",0,12,1000,Color,0)
  66.     S:writeString("                              ",0,13,1000,Color,0)
  67.     S:writeString("                              ",0,14,1000,Color,0)
  68.     S:writeString("                              ",0,15,1000,Color,0)
  69.     S:writeString("                              ",0,16,1000,Color,0)
  70.     S:writeString("                              ",0,17,1000,Color,0)
  71.    
  72.     # Update Allowed Players
  73.     for (X=1,P:count())
  74.     {
  75.         E2 = P[X,entity]
  76.         S:writeString(""+E2:name(),0,X,1000,Color,0)
  77.         if (P:count() >= 1)
  78.         {
  79.             S:writeString("Players Allowed: " + P:count() + "                     ",0,17,1000,Color,0)
  80.         }
  81.     }  
  82. }
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89. # If Owner Talks
  90. if (chatClk(owner()))
  91. {
  92.     # Chat String
  93.     Str = owner():lastSaid():explode(" ")
  94.  
  95.  
  96.     if(Str[1,string]=="!add")
  97.     {
  98.         TP = findPlayerByName(Str[2,string])
  99.         if(TP:isPlayer())
  100.         {
  101.             Target = TP
  102.             P:pushEntity(TP)
  103.         }
  104.        
  105.     }
  106.    
  107.     if(Str[1,string]=="!remove" | Str[1,string]=="!remove")
  108.     {
  109.         TP = findPlayerByName(Str[2,string])
  110.         if(TP:isPlayer())
  111.         {
  112.             while(Z < 20)
  113.             {
  114.                 if(TP == P[Z,entity])
  115.                 {
  116.                     P:remove(Z)
  117.                 }
  118.                 Z++
  119.             }
  120.         }
  121.         Z = 0
  122.     }
  123. }
  124.  
  125.  
  126. # Update Allowed Player Distance
  127. Distance1 = round(((entity():pos() - P[1,entity]:pos()):length()))
  128. Distance2 = round(((entity():pos() - P[2,entity]:pos()):length()))
  129. Distance3 = round(((entity():pos() - P[3,entity]:pos()):length()))
  130. Distance4 = round(((entity():pos() - P[4,entity]:pos()):length()))
  131. Distance5 = round(((entity():pos() - P[5,entity]:pos()):length()))
  132. Distance6 = round(((entity():pos() - P[6,entity]:pos()):length()))
  133. Distance7 = round(((entity():pos() - P[7,entity]:pos()):length()))
  134. Distance8 = round(((entity():pos() - P[8,entity]:pos()):length()))
  135. Distance9 = round(((entity():pos() - P[9,entity]:pos()):length()))
  136. Distance10 = round(((entity():pos() - P[10,entity]:pos()):length()))
  137.  
  138.  
  139. # Open Door For Allowed / Update Screen
  140. if(Distance1<D){Door = 1 Color = teamColor(P[1,entity]:team()) S:writeString("Auto Door Opener - OPEN       ",0,0,1000,Color,0)}
  141. elseif(Distance2<D){Door = 1 Color = teamColor(P[2,entity]:team()) S:writeString("Auto Door Opener - OPEN       ",0,0,1000,Color,0)}
  142. elseif(Distance3<D){Door = 1 Color = teamColor(P[3,entity]:team()) S:writeString("Auto Door Opener - OPEN       ",0,0,1000,Color,0)}
  143. elseif(Distance4<D){Door = 1 Color = teamColor(P[4,entity]:team()) S:writeString("Auto Door Opener - OPEN       ",0,0,1000,Color,0)}
  144. elseif(Distance5<D){Door = 1 Color = teamColor(P[5,entity]:team()) S:writeString("Auto Door Opener - OPEN       ",0,0,1000,Color,0)}
  145. elseif(Distance6<D){Door = 1 Color = teamColor(P[6,entity]:team()) S:writeString("Auto Door Opener - OPEN       ",0,0,1000,Color,0)}
  146. elseif(Distance7<D){Door = 1 Color = teamColor(P[7,entity]:team()) S:writeString("Auto Door Opener - OPEN       ",0,0,1000,Color,0)}
  147. elseif(Distance8<D){Door = 1 Color = teamColor(P[8,entity]:team()) S:writeString("Auto Door Opener - OPEN       ",0,0,1000,Color,0)}
  148. elseif(Distance9<D){Door = 1 Color = teamColor(P[9,entity]:team()) S:writeString("Auto Door Opener - OPEN       ",0,0,1000,Color,0)}
  149. elseif(Distance10<D){Door = 1 Color = teamColor(P[10,entity]:team()) S:writeString("Auto Door Opener - OPEN       ",0,0,1000,Color,0)}
  150. else{Door = 0 Color = vec(0,0,0) S:writeString("Auto Door Opener - CLOSED     ",0,0,1000,Color,0)}
clone this paste RAW Paste Data