Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name AutoFadeDoor
- @outputs Fade
- @persist Range PlayersAllowed:array Reset
- runOnChat(1)
- interval(500)
- if (first()) {
- Range = 40
- PlayersAllowed:insertEntity(1,entity():owner())
- function void chatCommands() {
- if (chatClk() && lastSpoke() == owner()) {
- LastSaid = lastSaid()
- if (LastSaid:sub(1,4) == "!add") {
- hideChat(1)
- if (findPlayerByName(LastSaid:sub(6)) != noentity()) {
- PlayersAllowed:insertEntity(1,findPlayerByName(LastSaid:sub(6)))
- printColor(vec(255,0,255),""+findPlayerByName(LastSaid:sub(6)):name(),vec(255,255,255)," is now able to use your doors!")
- }
- else {
- printColor(vec(255,0,0),"No one by that name was found!")
- }
- }
- if (LastSaid:sub(1,7) == "!remove") {
- hideChat(1)
- for (I=1, PlayersAllowed:count()) {
- if(PlayersAllowed[I,entity] == findPlayerByName(LastSaid:sub(9))) {
- PlayersAllowed:remove(I)
- printColor(vec(255,0,255),""+findPlayerByName(LastSaid:sub(9)):name(),vec(255,255,255)," is no longer allowed you use your doors!")
- }
- }
- }
- if (LastSaid:sub(1,5) == "!list") {
- hideChat(1)
- printColor(vec(0,255,255),"The following players are allowed to use your doors:")
- for(I=1, PlayersAllowed:count()) {
- printColor(vec(255,255,255),""+I+". ",vec(255,0,255),PlayersAllowed[I,entity]:name())
- }
- }
- }
- }
- function void doStuff() {
- Fade = 0
- Door = ioOutputEntities("Fade")
- for (I=1,PlayersAllowed:count()) {
- if (Door[1,entity]:pos():distance(PlayersAllowed[I,entity]:boxCenterW())<Range) {
- Fade = 1
- if (Reset == 0) {
- Reset = 1
- soundPlay(1,1,"doors/door_squeek1.wav")
- timer("reset",1000)
- }
- }
- }
- if (clk("reset")) {
- Reset = 0
- soundPlay(2,1,"doors/door_wood_close1.wav")
- }
- }
- }
- chatCommands()
- doStuff()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement