@name Keylogger
@outputs
@inputs Reset
@persist Victim:entity X Y X1 Y1 BeingPushed Code:string First:string Second:string Third:string Fourth:string Lasthit:string Combined:string Cracked
#by Sarteka
interval(10)

if (Reset){reset()}

if (owner():aimEntity():type():find("sent_keypad")){Victim = owner():aimEntity():owner()}


if (Victim:aimEntity():type():find("sent_keypad")) {
    E = Victim:aimEntity()
    Size = E:boxSize()
    Width = Size:y()/2
    Height = Size:z()/2
    GPS1 = E:massCenter() + E:up()*Height - E:right()*Width
    GPS2 = E:massCenter() + E:up()*Height + E:right()*Width
    GPS3 = E:massCenter() - E:up()*Height + E:right()*Width
    Input = Victim:aimPos() - GPS2
    T1 = GPS1 - GPS2
    T2 = GPS3 - GPS2
    TX = clamp(Input:dot(T1) / (T1:length()^2),-1,1)
    TY = clamp(Input:dot(T2) / (T2:length()^2),-1,1)
    X = floor(TX*512) #0 - 512
    Y = floor(TY*512) #0 - 512
}
else {
    X = Y = 0
}

if ( !BeingPushed & X & Y & Victim:keyUse()) 
{X1 = X , Y1 = Y , BeingPushed = 1

if (X1>88  & X1<176 & Y1>256 & Y1<311){Code = "1"}
if (X1>210 & X1<305 & Y1>256 & Y1<311){Code = "2"}
if (X1>334 & X1<431 & Y1>256 & Y1<311){Code = "3"}
if (X1>88  & X1<176 & Y1>326 & Y1<382){Code = "4"}
if (X1>210 & X1<305 & Y1>326 & Y1<382){Code = "5"}
if (X1>334 & X1<431 & Y1>326 & Y1<382){Code = "6"}
if (X1>88  & X1<176 & Y1>402 & Y1<455){Code = "7"}
if (X1>210 & X1<305 & Y1>402 & Y1<455){Code = "8"}
if (X1>334 & X1<431 & Y1>402 & Y1<455){Code = "9"}
if (X1>281 & X1<431 & Y1>187 & Y1<241){Code = "Enter"}
if (X1>88  & X1<234 & Y1>185 & Y1<240){Code = "Cancel"}

First = Second , Second = Third , Third = Fourth , Fourth = Lasthit , Lasthit = Code
}

if (BeingPushed & !Victim:keyUse()){hint(Code,50) , BeingPushed = 0}

if (Lasthit == "Enter" & !Cracked){
Combined = "The password is " + First + Second + Third + Fourth
hint(Combined,50)
print(Combined)
Cracked = 1
}