@name Croco's House E2
@persist Couchbuy Ang:angle Money Array:array Sinkbuy Stovebuy Amount Tablebuy Money2 MPbuy
@persist  E:entity  Max G:entity MP:entity
@persist Chat:array  Y  Ents:array Ent:entity
@model models/hunter/plates/plate5x5.mdl
E = entity()
E:setAlpha(0)
Y = 0

runOnTick(1) 
runOnChat(1)
if(first()){
Money  = 10000
Print = 1

hint("Welcome to Sims in Gmod!",10)
hint("Made By Crocopotomuslion!",10)
hint("Say /money to see your money",10)
hint("Say /buyhelp to see whats for sale!",10)
hint("Say /helpme to See these again!",10)

#floor
holoCreate(1)
holoModel(1,"hqsquare")
holoScale(1,vec(20,20,0.2))
holoMaterial(1,"models/props_c17/furniturefabric002a")

#ceiling
holoCreate(2)
holoModel(2,"hqsquare")
holoScale(2,vec(20,20,0.2))
holoMaterial(2,"models/props_debris/plasterwall034a")
holoPos(2, entity():pos()+vec(0,0,220))

#Wall1
holoCreate(3)
holoModel(3,"hqsquare")
holoScale(3,vec(0.4,20,20))
holoMaterial(3,"phoenix_storms/metalfloor_2-3")
holoPos(3, entity():pos()+vec(0,118,100))
holoAng(3,ang(0,90,0))

#Wall2
holoCreate(4)
holoModel(4,"hqsquare")
holoScale(4,vec(0.4,20,20))
holoMaterial(4,"phoenix_storms/metalfloor_2-3")
holoPos(4, entity():pos()+vec(0,-118,100))
holoAng(4,ang(0,90,0))

#Wall3
holoCreate(5)
holoModel(5,"hqsquare")
holoScale(5,vec(0.4,20,20))
holoMaterial(5,"phoenix_storms/metalfloor_2-3")
holoPos(5, entity():pos()+vec(118,0,100))
holoAng(5,ang(0,180,0))

#wall4
holoCreate(6)
holoModel(6,"hqsquare")
holoScale(6,vec(0.4,20,20))
holoMaterial(6,"phoenix_storms/metalfloor_2-3")
holoPos(6, entity():pos()+vec(-118,0,100))
holoAng(6,ang(0,180,0))

holoCreate(7)
holoModel(7,"models/props_c17/door01_left.mdl")
holoScale(7,vec(5,1,1))
holoPos(7, entity():pos()+vec(-118,25,55))
holoAng(7,ang(0,180,0))

    holoCreate(8)
    holoModel(8,"models/props_c17/FurnitureCouch001a.mdl")
Couchbuy = 0 

    holoCreate(9)
    holoModel(9,"models/props_c17/FurnitureSink001a.mdl")
Sinkbuy = 0

    holoCreate(10)
    holoModel(10,"models/props_c17/furnitureStove001a.mdl")
Stovebuy = 0

    holoCreate(11)
    holoModel(11,"models/props_c17/FurnitureTable001a.mdl")
Tablebuy = 0

    holoCreate(12)
    holoModel(12,"models/props_c17/consolebox05a.mdl")
MPbuy = 0

Amount == 1000
}

#####################
#####-BUILDINGS-#####
#####################
Money2 = randint(1,300)

timer("money",20000)
if(clk("money")){Money = Money + Money2
    print("PayDay!" + " You Took home" + " " + Money2 +  " " + "Dollars!")}


Me = owner()
if(Couchbuy == 1){
       if(Money > 0){
    Ang = (Me:eyeTrace():hitNormal():toAngle() + ang(-90,0,180)):setYaw((Me:aimPos() - Me:pos() ):toAngle():yaw())
    holoPos(8, Me:aimPos()+vec(0,0,35))
holoAng(8, Ang)}
    if(Me:aimPos():distance(Me:pos()) >= 150){ 
        holoAlpha(8,0)}else{
        holoAlpha(8, 175)
        if(Me:keyAttack1()){
          if(Couchbuy == 1){
            Pos = Me:aimPos()
           E = propSpawn("models/props_c17/FurnitureCouch001a.mdl",owner():aimPos()+vec(0,0,25),1)
        E:setAng(Ang)
            Couchbuy = 0
            holoPos(8,vec(9999,9999,9999))
}}}}
if(Couchbuy == 0){holoPos(8,vec(9999,9999,9999))}

if(Sinkbuy == 1){
    if(Money > 0){
    Ang = (Me:eyeTrace():hitNormal():toAngle() + ang(-90,0,180)):setYaw((Me:aimPos() - Me:pos() ):toAngle():yaw())
    holoPos(9, Me:aimPos()+vec(0,0,35))
holoAng(9, Ang)}
    if(Me:aimPos():distance(Me:pos()) >= 150){ 
        holoAlpha(9,0)}else{
        holoAlpha(9, 175)
        if(Me:keyAttack1()){
          if(Sinkbuy == 1){
            Pos = Me:aimPos()
           E = propSpawn("models/props_c17/FurnitureSink001a.mdl",owner():aimPos()+vec(0,0,25),1)
        E:setAng(Ang)
            Sinkbuy = 0
            holoPos(9,vec(9999,9999,9999))
}}}}
if(Sinkbuy == 0){holoPos(9,vec(9999,9999,9999))}



if(Stovebuy == 1){
    Ang = (Me:eyeTrace():hitNormal():toAngle() + ang(-90,0,180)):setYaw((Me:aimPos() - Me:pos() ):toAngle():yaw())
    holoPos(10, Me:aimPos()+vec(0,0,35))
holoAng(10, Ang)}
    if(Me:aimPos():distance(Me:pos()) >= 150){ 
        holoAlpha(10,0)}else{
        holoAlpha(10, 175)
        if(Me:keyAttack1()){
          if(Stovebuy == 1){
            Pos = Me:aimPos()
           E = propSpawn("models/props_c17/furnitureStove001a.mdl",owner():aimPos()+vec(0,0,25),1)
        E:setAng(Ang)
            Stovebuy = 0
            holoPos(10,vec(9999,9999,9999))
}}}
if(Stovebuy == 0){holoPos(10,vec(9999,9999,9999))}


if(Tablebuy == 1){
    Ang = (Me:eyeTrace():hitNormal():toAngle() + ang(-90,0,180)):setYaw((Me:aimPos() - Me:pos() ):toAngle():yaw())
    holoPos(11, Me:aimPos()+vec(0,0,35))
holoAng(11, Ang)}
    if(Me:aimPos():distance(Me:pos()) >= 150){ 
        holoAlpha(11,0)}else{
        holoAlpha(11, 175)
        if(Me:keyAttack1()){
          if(Tablebuy == 1){
            Pos = Me:aimPos()
           E = propSpawn("models/props_c17/FurnitureTable001a.mdl",owner():aimPos()+vec(0,0,25),1)
        E:setAng(Ang)
            Tablebuy = 0
            holoPos(11,vec(9999,9999,9999))
}}}
if(Tablebuy == 0){holoPos(11,vec(9999,9999,9999))}


if(MPbuy == 1){
    Ang = (Me:eyeTrace():hitNormal():toAngle() + ang(-90,0,180)):setYaw((Me:aimPos() - Me:pos() ):toAngle():yaw())
    holoPos(12, Me:aimPos()+vec(0,0,35))
holoAng(12, Ang)}
    if(Me:aimPos():distance(Me:pos()) >= 150){ 
        holoAlpha(12,0)}else{
    holoAlpha(12, 175)}
        if(Me:keyAttack1()){
          if(MPbuy == 1){
            Pos = Me:aimPos()
           MP = propSpawn("models/props_c17/consolebox05a.mdl",owner():aimPos()+vec(0,0,25),0)
        MP:setAng(Ang)
            MPbuy = 0
            holoPos(12,vec(9999,9999,9999))
            Print = 0
}}
if(MPbuy == 0){holoPos(12,vec(9999,9999,9999))}



if (chatClk(owner())) {
    Array = owner():lastSaid():lower():explode(" ")   
    if (Array[1,string] == "/money") {
    hideChat(1)
print("You have " + Money + "$")}

    if (Array[1,string] == "/helpme") {
        hideChat(1)
print("Say /money to see your money")
print("Say /buyhelp to see whats for sale!")
print("Say /helpme to See these again!")}

    if (Array[1,string] == "/buy-couch") {
        hideChat(1)
    Couchbuy = 1
    Amount = 400
    Money = Money - Amount
    print("You have bought a couch for 400$")
    holoAlpha(8,175)
    }
    
       if (Array[1,string] == "/buy-sink") {
        hideChat(1)
    Sinkbuy = 1
    Amount = 300
    Money = Money - Amount
    print("You have bought a sink for 300$")
    holoAlpha(9,175)
    }

    
       if (Array[1,string] == "/buy-stove") {
        hideChat(1)
    Stovebuy = 1
    Amount = 600
    Money = Money - Amount
    print("You have bought a stove for 600$")
    holoAlpha(10,175)
    }
       if (Array[1,string] == "/buy-table") {
        hideChat(1)
    Tablebuy = 1
    Amount = 200
    Money = Money - Amount
    print("You have bought a table for 200$")
    holoAlpha(11,175)
    }
    

       if (Array[1,string] == "/buy-money-printer") {
        hideChat(1)
    MPbuy = 1
    Amount = 1000
    Money = Money - Amount
    print("You have bought a Money Printer for 1000$")
    holoAlpha(12,175)
    }

       if (Array[1,string] == "/buyhelp") {
        hideChat(1)
 print("/buy-couch - 400$")
 print("/buy-sink  - 300$")
 print("/buy-stove - 600$")
 print("/buy-table - 200$")
 print("/buy-money-printer - 1000$")
    }




}



if(Print == 0){
    timer("print",20000)}

if(clk("print")){
    if(Max < 1){
    G = propSpawn("models/props/cs_assault/Money.mdl",MP:toWorld(vec(20,0,5)),Ang,1)
Y++
Max++
}}
timer("check",100)
Distance = 250
Result = ""
Times = 100
Damage = 20
if (clk("check")) {
    findInSphere(G:pos(), Distance)
    Array = findToArray()
    for(I=1,Array:count()) {
        if(Array[I,entity]:isPlayer()) {
            if(Array[I,entity]:isAlive()) {
                if (Result != "whip") {                  
 P = findClosest(entity():pos())
    Use = P:keyUse()
    Hp = " 10"
    Name=P:name()
    if(Use==1){
Ents[Y,entity] = G
Y = 0
Max = 0
Ents:propDelete()
print("You picked up 120$")
Money = Money + 120

}}}}}}

