@name New Car
@inputs Pod:wirelink Chasis:entity 
@outputs MPH 
@persist 
@trigger 
runOnTick(1)

#Sounds And Visuals

MPH = toUnit("mph",entity():vel():length())

if (first()) {
    holoCreate(1)
    holoModel(1,"models/engines/v10med.mdl")
    holoColor(1,vec(0,255,63))
    holoPos(1,entity():isWeldedTo():pos())
    holoParent(1,entity())
    
    Base = entity():isWeldedTo()
}

local Seat = Pod["Entity",entity]
local Driver = Seat:driver()
local W = Driver:keyForward()
local A = Driver:keyLeft()
local S = Driver:keyBack()
local D = Driver:keyRight()
local R = Driver:keyReload()
local Mouse1 = Driver:keyAttack1()
local Mouse2 = Driver:keyAttack2()
local Shift = Driver:keySprint()
local Space = Driver:keyJump()
local Active = Driver:isPlayer()

if (changed(Active) & Active) {
    #soundPlay(1,0,"acf_engines/v8_dieselmedium2.wav")
    #soundPitch(1,80+MPH)
}

if (changed(Active) & !Active) {
    soundStop(1)
    holoAng(1,entity():isWeldedTo():angles()+ang(0,90,0))
}

if (Active) {
    holoAng(1,holoEntity(1):angles()#[+ang(0,0,randint(-0.1,0.1))]#)
    soundPitch(1,80 + (MPH * 2.5))
}

#Propulsion

Force=5
if(Chasis:vel():length()<100){
    Force=(-abs(Base:angVel()[2])+3500)*S-W
}

#Hand Break

if (Space) {
    #LWheel:propFreeze(1)
    #RWheel:propFreeze(1)
} else {
    #LWheel:propFreeze(0)
    #RWheel:propFreeze(0)
}

#Not Needed
