Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2015
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. @name AutoFadeDoor
  2. @outputs Fade
  3. @persist Range PlayersAllowed:array Reset
  4.  
  5. runOnChat(1)
  6. interval(500)
  7.  
  8. if (first()) {
  9. Range = 40
  10.  
  11. PlayersAllowed:insertEntity(1,entity():owner())
  12. function void chatCommands() {
  13. if (chatClk() && lastSpoke() == owner()) {
  14. LastSaid = lastSaid()
  15. if (LastSaid:sub(1,4) == "!add") {
  16. hideChat(1)
  17. if (findPlayerByName(LastSaid:sub(6)) != noentity()) {
  18. PlayersAllowed:insertEntity(1,findPlayerByName(LastSaid:sub(6)))
  19. printColor(vec(255,0,255),""+findPlayerByName(LastSaid:sub(6)):name(),vec(255,255,255)," is now able to use your doors!")
  20. }
  21. else {
  22. printColor(vec(255,0,0),"No one by that name was found!")
  23. }
  24. }
  25. if (LastSaid:sub(1,7) == "!remove") {
  26. hideChat(1)
  27. for (I=1, PlayersAllowed:count()) {
  28. if(PlayersAllowed[I,entity] == findPlayerByName(LastSaid:sub(9))) {
  29. PlayersAllowed:remove(I)
  30. printColor(vec(255,0,255),""+findPlayerByName(LastSaid:sub(9)):name(),vec(255,255,255)," is no longer allowed you use your doors!")
  31. }
  32. }
  33. }
  34. if (LastSaid:sub(1,5) == "!list") {
  35. hideChat(1)
  36. printColor(vec(0,255,255),"The following players are allowed to use your doors:")
  37. for(I=1, PlayersAllowed:count()) {
  38. printColor(vec(255,255,255),""+I+". ",vec(255,0,255),PlayersAllowed[I,entity]:name())
  39. }
  40. }
  41. }
  42.  
  43. }
  44. function void doStuff() {
  45. Fade = 0
  46. Door = ioOutputEntities("Fade")
  47. for (I=1,PlayersAllowed:count()) {
  48. if (Door[1,entity]:pos():distance(PlayersAllowed[I,entity]:boxCenterW())<Range) {
  49. Fade = 1
  50. if (Reset == 0) {
  51. Reset = 1
  52. soundPlay(1,1,"doors/door_squeek1.wav")
  53. timer("reset",1000)
  54. }
  55. }
  56. }
  57. if (clk("reset")) {
  58. Reset = 0
  59. soundPlay(2,1,"doors/door_wood_close1.wav")
  60. }
  61. }
  62. }
  63.  
  64. chatCommands()
  65. doStuff()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement