October 24, 2019, 02:22 am

Author Topic: [E2][Release] Andre's Auto Door v1.0.0  (Read 1636 times)

Offline andreblue

  • Supporter
  • ByB Fanatic
  • *
  • Posts: 783
  • I got my zombie plan. Now do you have yours?
    • View Profile
    • Random ness here
[E2][Release] Andre's Auto Door v1.0.0
« on: August 28, 2016, 01:39 am »
So i needed a new auto door since i lost my old one, and i added some nice features to it that i think most lack
Features
  • Add via Name
  • Add via SteamID
  • ID to Name of those online
  • List Allowed chat command
  • Distance Set Command

Chat Commands(Do as the name states):
  • !add <player name | steam ID>
  • !remove<player name | steam ID>
  • !list
  • !dis <number in units>
  • !distance <number in units>

Simply reply if you run into issues.
Standard wiring of Fade to your fading door.

Code: [Select]
@name Auto Door
@inputs
@outputs Fade
@persist AllowedPlayers:table Distance
#Internal Vars
@persist [Owner Chip]:entity
@trigger

interval(250)

if(first() | dupefinished())
{
    function string string:steamID2Name()
    {
        local Plys = players()
        for(I=1, Plys:count())
        {
            if( This == Plys[I,entity]:steamID())
            {
                return Plys[I,entity]:name()
            }
        }
       
        return "Disconnected Player"
    }
    Owner = owner()
    Chip = entity()
    AllowedPlayers = table()
    AllowedPlayers[Owner:steamID(), number] = 1
    Distance = 50
    runOnChat(1)
}
if(clk())
{
    findInSphere(Chip:pos(), Distance)
    findClipToClass("player")
    findSortByDistance(Chip:pos())
    Found = findToArray()[1,entity]
    if(AllowedPlayers[Found:steamID(), number] == 1)
    {
        Fade = 1
    }
    else
    {
        Fade = 0
    }
}
if(chatClk(Owner))
{
    LS = Owner:lastSaid():lower():explode(" ")
    local ChatCmdDone = 0
    if(LS[1,string] == "!add" & LS[2,string])
    {
        if(LS[2,string]:upper():find("STEAM_"))
        {
            local ID = LS[2,string]:upper()
            if(!AllowedPlayers[ID, number] == 1)
            {
                AllowedPlayers[ID, number] = 1
                printColor(vec(0,128,128), "[E2 Door] ", vec(0,128,0), "Added ", vec(192,192,192), ID:steamID2Name()+"[", vec(256,256,256), ID, vec(128,128,128), "]")
            }
        }
        else
        {
            local Ply = findPlayerByName(LS[2,string])
            if(Ply:isValid() & Ply:isPlayer())
            {
                if(!AllowedPlayers[Ply:steamID(), number] == 1)
                {
                    AllowedPlayers[Ply:steamID(), number] = 1
                    printColor(vec(0,128,128), "[E2 Door] ", vec(0,128,0), "Added ", vec(192,192,192), Ply:name()+"[", vec(256,256,256), Ply:steamID(), vec(128,128,128), "]")
                }
            }
        }
        ChatCmdDone = 1
   
    }
    elseif(LS[1,string] == "!remove" & LS[2,string])
    {
        if(LS[2,string]:upper():find("STEAM_"))
        {
            local ID = LS[2,string]:upper()
            if(AllowedPlayers[ID, number] == 1)
            {
                AllowedPlayers[ID, number] = 0
                printColor(vec(0,128,128), "[E2 Door] ", vec(0,128,0), "Removed ", vec(192,192,192), ID:steamID2Name()+"[", vec(256,256,256), ID, vec(128,128,128), "]")
            }
            else
            {
                printColor(vec(0,128,128), "[E2 Door] ", vec(0,128,0), "This person is not on the door.")
            }
        }
        else
        {
            local Ply = findPlayerByName(LS[2,string])
            if(AllowedPlayers[Ply:steamID(), number] == 1)
            {
                AllowedPlayers[Ply:steamID(), number] = 0
                printColor(vec(0,128,128), "[E2 Door] ", vec(0,128,0), "Removed ", vec(192,192,192), Ply:name()+"[", vec(256,256,256), Ply:steamID(), vec(128,128,128), "]")
            }
            else
            {
                printColor(vec(0,128,128), "[E2 Door] ", vec(0,128,0), "This person is not on the door.")
            }
        }
        ChatCmdDone = 1
    }
    elseif(LS[1,string] == "!list")
    {
        foreach(ID, Allowed:number=AllowedPlayers)
        {
            printColor(vec(0,128,128), "[E2 Door] ", vec(192,192,192), "Listing Currently Allowed Players")
            if(Allowed)
            {
                printColor(vec(0,128,128), "[E2 Door] ", vec(192,192,192), ID:steamID2Name()+"[", vec(256,256,256), ID, vec(128,128,128), "]")
            }
        }
        ChatCmdDone = 1
    }
    elseif(LS[1,string] == "!distance" | LS[1,string] == "!dis" )
    {
        if(LS[2,string] & LS[2,string]:toNumber() != 0)
        {
            Distance = LS[2,string]:toNumber()
            printColor(vec(0,128,128), "[E2 Door] ", vec(0,128,0), "Set distance to ", vec(256,256,256), Distance)
        }
        ChatCmdDone = 1
    }
   
    if ( ChatCmdDone ){ hideChat(1) }
   
}



Offline Jelman

  • Super Admin
  • ByB Champion
  • *
  • Posts: 1678
    • View Profile
Re: [E2][Release] Andre's Auto Door v1.0.0
« Reply #1 on: August 28, 2016, 02:08 am »
doesnt auto set the name of the e2 to the owner, bad e2






His Grace Snoop of House Dogg, first in his name; Kushleesi; The Unblazed; Brother of Green Dragon Sativas; embarks on a quest to reclaim Weedsteros

Offline andreblue

  • Supporter
  • ByB Fanatic
  • *
  • Posts: 783
  • I got my zombie plan. Now do you have yours?
    • View Profile
    • Random ness here
Re: [E2][Release] Andre's Auto Door v1.0.0
« Reply #2 on: August 28, 2016, 03:11 am »
doesnt auto set the name of the e2 to the owner, bad e2
Well here is v 1.0.1
Changelist:
Jelman is an ass
Code: [Select]
@name Auto Door
@inputs
@outputs Fade
@persist AllowedPlayers:table Distance
#Internal Vars
@persist [Owner Chip]:entity
@trigger

interval(250)

if(first() | dupefinished())
{
    function string string:steamID2Name()
    {
        local Plys = players()
        for(I=1, Plys:count())
        {
            if( This == Plys[I,entity]:steamID())
            {
                return Plys[I,entity]:name()
            }
        }
       
        return "Disconnected Player"
    }
    Owner = owner()
    Chip = entity()
    AllowedPlayers = table()
    AllowedPlayers[Owner:steamID(), number] = 1
    Distance = 50
    runOnChat(1)
    if(Owner:steamID() == "STEAM_0:1:39329367"){setName("smeg Boi's E2 Door")}else{setName(Owner:name() + "'s Auto Door")}
}
if(clk())
{
    findInSphere(Chip:pos(), Distance)
    findClipToClass("player")
    findSortByDistance(Chip:pos())
    Found = findToArray()[1,entity]
    if(AllowedPlayers[Found:steamID(), number] == 1)
    {
        Fade = 1
    }
    else
    {
        Fade = 0
    }
}
if(chatClk(Owner))
{
    LS = Owner:lastSaid():lower():explode(" ")
    local ChatCmdDone = 0
    if(LS[1,string] == "!add" & LS[2,string])
    {
        if(LS[2,string]:upper():find("STEAM_"))
        {
            local ID = LS[2,string]:upper()
            if(!AllowedPlayers[ID, number] == 1)
            {
                AllowedPlayers[ID, number] = 1
                printColor(vec(0,128,128), "[E2 Door] ", vec(0,128,0), "Added ", vec(192,192,192), ID:steamID2Name()+"[", vec(256,256,256), ID, vec(128,128,128), "]")
            }
        }
        else
        {
            local Ply = findPlayerByName(LS[2,string])
            if(Ply:isValid() & Ply:isPlayer())
            {
                if(!AllowedPlayers[Ply:steamID(), number] == 1)
                {
                    AllowedPlayers[Ply:steamID(), number] = 1
                    printColor(vec(0,128,128), "[E2 Door] ", vec(0,128,0), "Added ", vec(192,192,192), Ply:name()+"[", vec(256,256,256), Ply:steamID(), vec(128,128,128), "]")
                }
            }
        }
        ChatCmdDone = 1
   
    }
    elseif(LS[1,string] == "!remove" & LS[2,string])
    {
        if(LS[2,string]:upper():find("STEAM_"))
        {
            local ID = LS[2,string]:upper()
            if(AllowedPlayers[ID, number] == 1)
            {
                AllowedPlayers[ID, number] = 0
                printColor(vec(0,128,128), "[E2 Door] ", vec(0,128,0), "Removed ", vec(192,192,192), ID:steamID2Name()+"[", vec(256,256,256), ID, vec(128,128,128), "]")
            }
            else
            {
                printColor(vec(0,128,128), "[E2 Door] ", vec(0,128,0), "This person is not on the door.")
            }
        }
        else
        {
            local Ply = findPlayerByName(LS[2,string])
            if(AllowedPlayers[Ply:steamID(), number] == 1)
            {
                AllowedPlayers[Ply:steamID(), number] = 0
                printColor(vec(0,128,128), "[E2 Door] ", vec(0,128,0), "Removed ", vec(192,192,192), Ply:name()+"[", vec(256,256,256), Ply:steamID(), vec(128,128,128), "]")
            }
            else
            {
                printColor(vec(0,128,128), "[E2 Door] ", vec(0,128,0), "This person is not on the door.")
            }
        }
        ChatCmdDone = 1
    }
    elseif(LS[1,string] == "!list")
    {
        foreach(ID, Allowed:number=AllowedPlayers)
        {
            printColor(vec(0,128,128), "[E2 Door] ", vec(192,192,192), "Listing Currently Allowed Players")
            if(Allowed)
            {
                printColor(vec(0,128,128), "[E2 Door] ", vec(192,192,192), ID:steamID2Name()+"[", vec(256,256,256), ID, vec(128,128,128), "]")
            }
        }
        ChatCmdDone = 1
    }
    elseif(LS[1,string] == "!distance" | LS[1,string] == "!dis" )
    {
        if(LS[2,string] & LS[2,string]:toNumber() != 0)
        {
            Distance = LS[2,string]:toNumber()
            printColor(vec(0,128,128), "[E2 Door] ", vec(0,128,0), "Set distance to ", vec(256,256,256), Distance)
        }
        ChatCmdDone = 1
    }
   
    if ( ChatCmdDone ){ hideChat(1) }
   
}