@name EGP Auto Buttons
@inputs EGP:wirelink User:entity 
@outputs Data:table Time Distance
@persist O:entity Distance Hit Entity:entity
@trigger User  R:ranger

It = owner()
Play = players()

interval(0)
runOnChat(0)

if (It:lastSaid() == "!Dev") {
    It:setModel("models/player/p2_chell.mdl")
    It:give("weapon_lordi_wep_minigun")
It:give("weapon_lordi_wep_xm1014")
It:give("weapon_lordi_wep_xm1014")
It:give("weapon_lordi_wep_ump")
It:give("weapon_lordi_wep_tmp")
It:give("weapon_lordi_wep_mp5")
It:give("weapon_lordi_wep_m249")
It:give("weapon_physgun")
It:give("gmod_tool")
It:give("weapon_medkit")
It:give("weapon_rpg")
It:give("manhack_welder")
It:give("remotecontroller")
It:give("blink_swep")
It:give("laserpointer")

}





###SET E2 COLOR###
setColor(0,255,0)
##################
#if(first()|dupefinished()){
#if(owner():steamID() != "STEAM_0:0:69686717"){
#        soundPlay(3, 12, "/buttons/weapon_cant_buy.wav")
#        entity():propNotSolid(1)
#        print("SORRY, THIS IS NOT YOUR E2 or DUPE.. YOU HAVE TAKEN IT WITHOUT PERMISSION")
#        selfDestructAll()
#    }
#}


if( dupefinished() ){ reset() }


if(first())
{
    runOnTick(1)
    O = owner()
    
    EGP:egpClear()
    
    Dist = 30
    
    Hue = 200
    
    function number getID( N )
    {   
        
        return EGP:egpNumObjects() + N
    }
    
    function number getID( N )
    {
        return EGP:egpNumObjects() + N
    }
    function number makeButton( S1:string, V1:vector2, V2:vector2, V3:vector, S2:string )
    {
        Type = S1:lower()
        ID = getID( 1 )
        
        if( Type == "box" )
        {
            EGP:egpBox( ID, V1, V2 )
        }
        elseif( Type == "circle" )
        {
            EGP:egpCircle( ID, V1, V2 )
        }
        
        EGP:egpText( getID(1), S2, vec2(0,0) )
        EGP:egpSize( getID(0), 40 )
        EGP:egpAlign( getID(0), 1, 1 )
        EGP:egpParent( getID(0), ID )
        EGP:egpColor( getID(0), vec() )
        
        Data[ Type[ 1 ] + ID, string ] = S2
        EGP:egpColor( ID, V3 )
        
        return ID
    }
    function number isInRange( N, S1:string )
    {
        R_Pos = EGP:egpPos( N )
        R_Size = EGP:egpSize( N ) / ( S1 == "c" ?: 2 )
        return inrange( EGP:egpCursor(User), R_Pos - R_Size, R_Pos + R_Size )
    }
    
    ## Start creating here...
        # makeButton( Type, Position, Size, Color, Text / Function )
    
    makeButton( "box", vec2( 256.25, 50 ), vec2( 490.5, 75 ), vec( 0, 255, 255 ), "Buy Car" )
    makeButton( "box", vec2( 256.25, 150 ), vec2( 490.5, 75), vec( 0, 255, 255 ), "Auto Master" )
    makeButton( "box", vec2( 256.25, 250 ), vec2( 490.5, 75), vec( 0, 255, 255 ), "TEST"),(O:give("weapon_lordi_wep_awp"))
    makeButton( "box", vec2( 256.25, 350 ), vec2( 490.5, 75), vec( 0, 255, 255 ), "" )
    makeButton( "box", vec2( 256.25, 450 ), vec2( 490.5, 75), vec( 0, 255, 255 ), "" )
#    EGP:egpText( getID(1), "AK47", vec2(16,30) )
#    EGP:egpSize( getID(0), 40 )
#    EGP:egpColor( getID(0), vec(0,0,0))
#    EGP:egpText( getID(1), "AUG", vec2(20,130) )
#    EGP:egpSize( getID(0), 40 )
#    EGP:egpColor( getID(0), vec(0,0,0))
#    EGP:egpText( getID(1), "AWP", vec2(20,230) )
#    EGP:egpSize( getID(0), 40 )
#    EGP:egpColor( getID(0), vec(0,0,0))
#    EGP:egpText( getID(1), "Deagle", vec2(15,330) )
#    EGP:egpSize( getID(0), 30 )
#    EGP:egpColor( getID(0), vec(0,0,0))
#    EGP:egpText( getID(1), "Duel", vec2(30,420) )
#    EGP:egpSize( getID(0), 25 )
#    EGP:egpColor( getID(0), vec(0,0,0))
#    EGP:egpText( getID(1), "Berettas", vec2(15,450) )
#    EGP:egpSize( getID(0), 25 )
#    EGP:egpColor( getID(0), vec(0,0,0))
#    EGP:egpText( getID(1), "Famas", vec2(145,30) )
#    EGP:egpSize( getID(0), 30 )
#    EGP:egpColor( getID(0), vec(0,0,0))
#    EGP:egpText( getID(1), "Five", vec2(160,120) )
#    EGP:egpSize( getID(0), 30 )
#    EGP:egpColor( getID(0), vec(0,0,0))
#    EGP:egpText( getID(1), "Seven", vec2(150,145) )
#    EGP:egpSize( getID(0), 30 )
#    EGP:egpColor( getID(0), vec(0,0,0))
#    EGP:egpText( getID(1), "G3", vec2(165,230) )
#    EGP:egpSize( getID(0), 40 )
#    EGP:egpColor( getID(0), vec(0,0,0))
#    EGP:egpText( getID(1), "Glock", vec2(145,330) )
#    EGP:egpSize( getID(0), 35 )
#    EGP:egpColor( getID(0), vec(0,0,0))
    
}

if( ~User & User & curtime() - Time >= 3)
{
    #print( curtime() - Time )
    foreach( K, V:string = Data )
    {
        Tmp_ID = K:sub( 2, -1 ):toNumber()
        if( isInRange( Tmp_ID, K[ 1 ] ))
        {
            #print( V )
            switch( V )
            {
                default,break
                
                case "Buy Car",
printColor(vec(0,255,0),"Someone want's a car")
hint("Someone wants a car!",20)
soundPlay(1,1,"SuitRecharge.Start")
                break
                
                case "Auto Master",

printColor(vec(255,0,0),"Somone needs the Auto Master")
                break
                
                case "TEST",

printColor(vec(0,255,0),"ON")
                break
                
                case "Iris - OFF",

printColor(vec(255,0,0),"Iris - OFF")
                break
                
                case "Good Job",

printColor(vec(0,255,0),"Keep up the good work!")
                break
                
                
}
}
}
}
    
