Home Showcase
Welcome to the new Diaspora forums, please let us know if you see anything broken! Notice: Some users may need to reupload their avatars due to an issue during forum setup!

Omnitool

KatelynKatelyn Registered, Administrator Posts: 171
edited May 2011 in Showcase #1
This is a tool that I am currently developing. It currently only has admin simulating commands, have a look.


It also features changing the alias of every command in the chip. Some of the commands are conflicting with ulx though.
@name Omnitool
@persist Zoom Minzoom Maxzoom Zoomrate 
@persist Bear Elev X Y Z Pointer
@persist [Date, Command, Return]:string
@persist
@persist
@persist [Target]:entity
@persist 
@persist [Ranger]:ranger
@persist [G]:gtable
@persist [Chat, Btarget, Players]:array
@persist [Master]:table

#[
Omni-tool set
Version [Beta 0.2] Build 2
5/15/2011

Created by: Katelyn E. Sullivan
3/21/2011

Aim:      Consta135
Yahoo:    Consta135@ymail.com
Live:     Katelyn135@live.com
E-mail:   Katelyn135@gmail.com
]#

if (first() | dupefinished())
{
    runOnFile(1)
    runOnChat(1)
    runOnTick(1)
    

    G = gTable("Omnitool")
    if (G["Count", number] > 0)
    {
        printColor(vec(255,0,0), "You already have an omni-tool chip spawned.")
        selfDestruct()
    }
    elseif (fileCanLoad())
    {
        fileLoad("KateKollection/Omnitool.txt")
        G["Count", number] = G["Count", number] + 1
        printColor(vec(0,255,255), "Omni-tool loading...")
        runOnLast(1)
    }
    else
    {
        printColor(vec(255,0,0), "File can not be loaded at this moment. Please respaste your omni-tool.")
        selfDestruct()
    }
    
    Target = owner()
    
    Minzoom = 100
    Maxzoom = 3000
    Zoom = (Maxzoom - Minzoom) / 8
    Zoomrate = Maxzoom / 2000
    rangerPersist(1)
    rangerHitEntities(0)
    rangerHitWater(0)
    rangerIgnoreWorld(0)
    
    entity():setSolid(0)
    entity():setAlpha(0)  
    entity():setPosition(randvec(-16500, 16500))
    
    findByClass("player")
    Players = findToArray()
}
if (last())
{
    G["Count", number] =  G["Count", number] - 1
}
if (fileClk())
{
    Date = "Omnilog" + toString(time("year") + time("month") + time("day"))
    if (fileStatus() == _FILE_OK)
    {
        Master = glonDecodeTable(fileRead())
    }
    else
    {
        A = array()
        B = table()
        C = table()
        Alias = table()
        
        
   
        B["test", string] = "test"

        B["teleport", string] = "teleport"
        B["tele", string] = "teleport"
        B["tp", string] = "teleport"

        B["bring", string] = "bring"
        B["brng", string] = "bring"
        
        B["goto", string] = "goto"
        B["go", string] = "goto"

        B["spectate", string] = "spectate"
        B["spec", string] = "spectate"

        B["hide", string] = "hide"

        B["alias", string] = "alias"
        
        D = table()
        D["index", string] = "color"
        
        B["color", table] = D:clone()

        B["designator", string] = "?"
        
        C["alias", table] = B:clone()
        
        B:clear()

        B["error", vector] = vec(255, 0, 0)
        B["notification", vector] = vec(0, 128, 255)
        B["target", vector] = vec(255, 128, 0)
        B["queryerror", vector] = vec(255, 0, 128)
        B["input", vector] = vec(0, 0, 255)
        
        
        C["colors", table] = B:clone()
        Master["cmd", table] = C:clone()
        
        fileWrite("KateKollection/Omnitool.txt", glonEncode(Master))
        
        printColor(Master["cmd", table]["colors", table]["error", vector], "There was a problem loading your configuration file. If this is your first time running this, disregard this message. !Help for more information.")
    }
}

if (chatClk(owner()) & lastSaid()[1] == Master["cmd", table]["alias", table]["designator", string] & lastSaid()[2] != "")
{
    Cmd = lastSaid():trim():lower():explode(" ")
    Cmd[1, string] = Cmd[1, string]:sub(2)
    if (Master["cmd", table]["alias", table]:exists(Cmd[1, string]))
    {
        Cmd[1, string] = Master["cmd", table]["alias", table][Cmd[1, string], string]
    }
    else
    {
        printColor(Master["cmd", table]["colors", table]["queryerror", vector], "The command \"", Master["cmd", table]["colors", table]["input", vector], Cmd[1, string], Master["cmd", table]["colors", table]["queryerror", vector], "\" does not exist.")
    }
    
    
    if (Cmd[1, string] == "test")
    {
        print("Success")    
    }
    
    
#Command Teleport#
    if (Cmd[1, string] == "teleport")
    {
        if (Cmd[2, string]:length() > 0)
        {
            findByClass("Player")
            findClipToName(Cmd[2, string])
            
            Results = findToArray()
            if (Results:count() == 1)
            { 
                if (find():trusts(owner()))
                {
                    printColor(Master["cmd", table]["colors", table]["notification", vector], "Teleporting ", Master["cmd", table]["colors", table]["input", vector], find():name(), Master["cmd", table]["colors", table]["notification", vector], " to ", Master["cmd", table]["colors", table]["input", vector], owner():aimPos():toString())   
                    find():setPosition(owner():aimPos() + vec(0,0,50))
                }
                else
                {
                    printColor(Master["cmd", table]["colors", table]["queryerror", vector], "Player ", Master["cmd", table]["colors", table]["input", vector], find():name(), Master["cmd", table]["colors", table]["queryerror", vector], " does not trust you. Have them add you to their Prop Protection.")
                }
            }
            elseif (Results:count() > 1)
            {
                Return = ""
                for (K = 1, Results:count())
                {
                    Return = Return + Results[K, entity]:name() + "\n"
                }
                printColor(Master["cmd", table]["colors", table]["queryerror", vector], "Multiple results returned\n", Master["cmd", table]["colors", table]["input", vector], Return)
            }
            else
            {
                printColor(Master["cmd", table]["colors", table]["queryerror", vector], "No results found for phrase: ", Master["cmd", table]["colors", table]["input", vector], Cmd[2, string])
            }
        }
        else
        {
            printColor(Master["cmd", table]["colors", table]["notification", vector], "Teleporting ", Master["cmd", table]["colors", table]["input", vector], "self", Master["cmd", table]["colors", table]["notification", vector], " to ", Master["cmd", table]["colors", table]["input", vector], owner():aimPos():toString())   
            owner():setPosition(owner():aimPos() + vec(0,0,50))
        }
    }
    
#Command Goto#
    if (Cmd[1, string] == "goto")
    {
        if (Cmd[2, string]:length() > 0)
        {
            findByClass("Player")
            findClipToName(Cmd[2, string])
            
            Results = findToArray()
            if (Results:count() == 1)
            { 
                printColor(Master["cmd", table]["colors", table]["notification", vector], "Teleporting to ", Master["cmd", table]["colors", table]["input", vector], find():name())   
                owner():setPosition(find():pos() + vec(randint(50, 100), randint(50, 100), 50))
            }
            elseif (Results:count() > 1)
            {
                Return = ""
                for (K = 1, Results:count())
                {
                    Return = Return + Results[K, entity]:name() + "\n"
                }
                printColor(Master["cmd", table]["colors", table]["queryerror", vector], "Multiple results returned\n", Master["cmd", table]["colors", table]["input", vector], Return)
            }
            else
            {
                printColor(Master["cmd", table]["colors", table]["queryerror", vector], "No results found for phrase: ", Master["cmd", table]["colors", table]["input", vector], Cmd[2, string])
            }
        }
        else
        {
            printColor(Master["cmd", table]["colors", table]["queryerror", vector], "You need to specify someone to teleport to.")
        }
    }
    
#Command Bring#
    if (Cmd[1, string] == "bring")
    {
        if (Cmd[2, string]:length() > 0)
        {
            findByClass("Player")
            findClipToName(Cmd[2, string])
            
            Results = findToArray()
            if (Results:count() == 1)
            { 
                Target = find()
                if (Cmd[3, string]:length() > 0)
                {
                    timer("bring", 50)
                    
                }
                else
                {
                    if (find():trusts(owner()))
                    {
                        printColor(Master["cmd", table]["colors", table]["notification", vector], "Bringing ", Master["cmd", table]["colors", table]["input", vector], find():name(), Master["cmd", table]["colors", table]["notification", vector], " to ", Master["cmd", table]["colors", table]["input", vector], "self")   
                        Target:setPosition(owner():pos() + vec(randint(50, 100), randint(50, 100), 50))
                        Target = owner()
                    }
                    else
                    {
                        printColor(Master["cmd", table]["colors", table]["queryerror", vector], "Player ", Master["cmd", table]["colors", table]["input", vector], find():name(), Master["cmd", table]["colors", table]["queryerror", vector], " does not trust you. Have them add you to their Prop Protection.")
                    }
                }
            }
            elseif (Results:count() > 1)
            {
                Return = ""
                for (K = 1, Results:count())
                {
                    Return = Return + Results[K, entity]:name() + "\n"
                }
                printColor(Master["cmd", table]["colors", table]["queryerror", vector], "Multiple results returned for first phrase\n", Master["cmd", table]["colors", table]["input", vector], Return)
            }
            else
            {
                printColor(Master["cmd", table]["colors", table]["queryerror", vector], "No results found for first phrase: ", Master["cmd", table]["colors", table]["input", vector], Cmd[2, string])
            }
        }
        else
        {
            printColor(Master["cmd", table]["colors", table]["queryerror", vector], "You need to specify someone to teleport to.")
        }
    }
    
#Command Spectate#
    if (Cmd[1, string] == "spectate")
    {
        lastSpoke():setAlpha(0)
        

        if (Cmd[2, string]:length() > 0)
        {
            findByClass("Player")
            findClipToName(Cmd[2, string])
            
            Results = findToArray()
            if (Results:count() == 1)
            {
                Target = find()   
                printColor(Master["cmd", table]["colors", table]["notification", vector], "Spectating ", Master["cmd", table]["colors", table]["input", vector], find():name())   
                Master["spectate", number] = 1
            }
            elseif (Results:count() > 1)
            {
                Return = ""
                for (K = 1, Results:count())
                {
                    Return = Return + Results[K, entity]:name() + "\n"
                }
                printColor(Master["cmd", table]["colors", table]["queryerror", vector], "Multiple results returned\n", Master["cmd", table]["colors", table]["input", vector], Return)
            }
            else
            {
                printColor(Master["cmd", table]["colors", table]["queryerror", vector], "No results found for phrase: ", Master["cmd", table]["colors", table]["input", vector], Cmd[2, string])
            }
            
            for (K = 1, Players:count())
            {
                if (Players[K, entity] == Target)
                {
                    Pointer = K
                }
            }
        }
        elseif (Master["spectate", number])
        {
            Master["spectate", number] = 0
            printColor(Master["cmd", table]["colors", table]["notification", vector], "No longer spectating ", Master["cmd", table]["colors", table]["input", vector], Target:name())
            owner():setAlpha(255)
            Target = owner()
            hudRemoveElement(211)
            
            Zoom = (Maxzoom - Minzoom) / 8
            owner():setView(0, vec(), ang())
        }
    }
    
#Command Hide#
    if (Cmd[1, string] == "hide")
    {
        if (Cmd[2, string] == "1" | Cmd[2, string] == "on")
        {
            entity():setSolid(0)
            entity():setAlpha(0)
            
            Master["hide", number] = 1
            
            entity():setPosition(randvec(-16500, 16500))
            printColor(Master["cmd", table]["colors", table]["input", vector], "Hiding ", Master["cmd", table]["colors", table]["notification", vector], "the chip")
        }
        elseif (Cmd[2, string] == "0" | Cmd[2, string] == "off")
        {
            entity():setSolid(1)
            entity():setAlpha(255)
            
            Master["hide", number] = 0
            
            entity():setPosition(owner():aimPos())
            printColor(Master["cmd", table]["colors", table]["input", vector], "Unhiding ", Master["cmd", table]["colors", table]["notification", vector], "the chip")
        }
        elseif (Cmd[2, string] == "")
        {
            if (Master["hide", number] == 0)
            {
                entity():setSolid(0)
                entity():setAlpha(0)
                
                Master["hide", number] = 1
                
                entity():setPosition(randvec(-16500, 16500))
                printColor(Master["cmd", table]["colors", table]["input", vector], "Hiding ", Master["cmd", table]["colors", table]["notification", vector], "the chip")
            }
            else
            {
                entity():setSolid(1)
                entity():setAlpha(255)
                
                Master["hide", number] = 0
                
                entity():setPosition(owner():aimPos())
                printColor(Master["cmd", table]["colors", table]["input", vector], "Unhiding ", Master["cmd", table]["colors", table]["notification", vector], "the chip")

            }
        }            
    }
    
    #alias
    if (Cmd[1, string] == "alias")
    {
        Reg = Cmd:clone()
        Reg:shift()
        Reg:shift()
        
        Level = Master["cmd", table]["alias", table]
        
        if (Reg:count() > 1)
        {
            for (I = 1, Reg:count() - 1)
            {
                Level = Level[Reg[I, string], table]
            }
        }
    
        if (Level:exists(Cmd[2, string]))
        {
            if (Level:exists(Cmd[3, string]))
            {
                Level[Cmd[2, string], string] = Level[Cmd[3, string], string]
                fileWrite("KateKollection/Omnitool.txt", glonEncode(Master))
                printColor(Master["cmd", table]["colors", table]["notification", vector], "Replacing alias \"", Master["cmd", table]["colors", table]["input", vector], Cmd[2, string], Master["cmd", table]["colors", table]["notification", vector], "\" with command \"", Master["cmd", table]["colors", table]["input", vector], Cmd[3, string], Master["cmd", table]["colors", table]["notification", vector], "\"")
                
            }
            else
            {
                printColor(Master["cmd", table]["colors", table]["queryerror", vector], "The command \"", Master["cmd", table]["colors", table]["input", vector], Cmd[3, string], Master["cmd", table]["colors", table]["queryerror", vector], "\" does not exist.")
            }
        }
        else
        {
            if (Level:exists(Cmd[3, string]))
            {
                Level[Cmd[2, string], string] = Level[Cmd[3, string], string]
                fileWrite("KateKollection/Omnitool.txt", glonEncode(Master))
                printColor(Master["cmd", table]["colors", table]["notification", vector], "Creating alias \"", Master["cmd", table]["colors", table]["input", vector], Cmd[2, string], Master["cmd", table]["colors", table]["notification", vector], "\" for command \"", Master["cmd", table]["colors", table]["input", vector], Cmd[3, string], Master["cmd", table]["colors", table]["notification", vector],"\"")
                
            }
            else
            {
                printColor(Master["cmd", table]["colors", table]["queryerror", vector], "The command \"", Master["cmd", table]["colors", table]["input", vector], Cmd[3, string], Master["cmd", table]["colors", table]["queryerror", vector], "\" does not exist.")
            }
        }
    }
    
    
    hideChat(1)  
}


if (Master["spectate", number])
{
    Zoom = Zoom + ((owner():keyJump() - owner():keyDuck()) * Zoomrate)
    Zoom = clamp(Zoom, Minzoom, Maxzoom)
    Bear = owner():eyeAngles():yaw()
    Elev = owner():eyeAngles():pitch() + 90
    X = Zoom * cos(Bear) * sin(Elev)
    Y = Zoom * sin(Bear) * sin(Elev)
    Z = Zoom * cos(Elev)
    if (Zoom != Minzoom)
    {
        if (((Target:pos() + vec(0,0,30)) - vec(X, Y, Z)):isInWorld())
        {
            owner():setView(1, (Target:pos() + vec(0,0,30)) - vec(X, Y, Z), ang(Elev - 90, Bear, 0))
        }
        else
        {
            Ranger = rangerOffset(Target:pos() + vec(0,0,30), (Target:pos() + vec(0,0,30)) - vec(X, Y, Z))
            owner():setView(1, Ranger:position(), ang(Elev - 90, Bear, 0))
        }
    }
    else
    {
        owner():setView(1, Target:pos() + vec(0,0,65), Target:eyeAngles())
    }
    
    if (changed(owner():keyForward()) & owner():keyForward())
    {
        Pointer = (Pointer == Players:count() ? 1 : Pointer + 1)
        Target = Players[Pointer, entity]
    }
    if (changed(owner():keyBack()) & owner():keyBack())
    {
        Pointer = (Pointer == 1 ? Players:count() : Pointer - 1)
        Target = Players[Pointer, entity]
    }
    hudDrawText(211, "Spectating " + Target:name(), 50, 10, vec(222, 122, 122), 255, 1, 0.3)
    if (changed(owner():keyReload()) & owner():keyReload())
    {
        Master["spectate", number] = 0
        printColor(Master["cmd", table]["colors", table]["notification", vector], "No longer spectating ", Master["cmd", table]["colors", table]["input", vector], Target:name())
        owner():setAlpha(255)
        
        hudRemoveElement(211)
        
        Zoom = (Maxzoom - Minzoom) / 8
        owner():setView(0, vec(), ang())
        
        printColor(Master["cmd", table]["colors", table]["notification", vector], "Teleporting to ", Master["cmd", table]["colors", table]["input", vector], Players[Pointer, entity]:name())   
        owner():setPosition((Target:pos() + vec(0,0,30)) - vec(X, Y, Z))
        Target = owner()
    }
    
    

}
if (clk("bring"))
{
    findByClass("Player")
    findClipToName(Cmd[3, string])
    Results = findToArray()
    if (Results:count() == 1)
    {
        if (find():trusts(owner()))
        {
            printColor(vec(255,255,0), "Bringing ", vec(255, 0, 0), Target:name(), vec(255,255,0), " to ", vec(255,0,0), find():name())   
            Target:setPosition(find():pos() + vec(randint(50, 100), randint(50, 100), 50))
        }
        else
        {
            printColor(Master["cmd", table]["colors", table]["queryerror", vector], "Player ", Master["cmd", table]["colors", table]["input", vector], find():name(), Master["cmd", table]["colors", table]["queryerror", vector], " does not trust you. Have them add you to their Prop Protection.")
        }
    }
    elseif (Results:count() > 1)
    {
        Return = ""
        for (K = 1, Results:count())
        {
            Return = Return + Results[K, entity]:name() + "\n"
        }
        printColor(vec(255,255,0), "Multiple results returned for second phrase\n", vec(255,0,0), Return)
    }
    else
    {
        printColor(vec(255,255,0), "No results found for second phrase: ", vec(255,0,0), Cmd[2, string])
    }
    Target = owner()
}

if (changed(numPlayers()))
{
    findByClass("player")
    
    Players = findToArray()
    if (Pointer > Players:count())
    {
        Pointer = Players:count()
    }
}

Comments

  • Nielk1Nielk1 Registered, Administrator Posts: 252
    That is why all my commands by E2 start with ? isntead of !. I started that way way way back with the asgard teleporter that mirrored all the non-easy-as-hell-to-minge admin teleport commands. Though I open my chips to all to use then I place them if they are like that (I restrict parts of them) so I guess that means both ! and ? are sort of taken...

    I can try to find my function simulating chip pair if you are interested. Was basically 1 chip did the calling and the other had all the functions that took params off global tables and such.
  • KatelynKatelyn Registered, Administrator Posts: 171
    A quick update on the status of this chip. I've developed a very very nice way to do command customization dependent arguments (IE Select Sphere 1024)[Red being an argument of the command Select] It actually supports an infinite number of dependent arguments.

    I have renewed interest in this project, so be expecting an update soon.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file