Author
Message
Veteran Member
12-27-2014
, 23:07
LookAtPoint || LookAtClient [TF2/Possibly Other Games]
#1
Some functions that can be used to make a client look basically anywhere you tell them to. Not sure if it has been posted before, but I thought this might be helpful to some people.
Spoiler
PHP Code:
stock LookAtClient ( any : client , any : target ){
new Float : angles [ 3 ], Float : clientEyes [ 3 ], Float : targetEyes [ 3 ], Float : resultant [ 3 ];
GetClientEyePosition ( client , clientEyes );
GetClientEyePosition ( target , targetEyes );
MakeVectorFromPoints ( targetEyes , clientEyes , resultant );
GetVectorAngles ( resultant , angles );
if( angles [ 0 ] >= 270 ){
angles [ 0 ] -= 270 ;
angles [ 0 ] = ( 90 - angles [ 0 ]);
}else{
if( angles [ 0 ] <= 90 ){
angles [ 0 ] *= - 1 ;
}
}
angles [ 1 ] -= 180 ;
TeleportEntity ( client , NULL_VECTOR , angles , NULL_VECTOR );
}
stock LookAtPoint ( any : client , Float : point [ 3 ]){
new Float : angles [ 3 ], Float : clientEyes [ 3 ], Float : resultant [ 3 ];
GetClientEyePosition ( client , clientEyes );
MakeVectorFromPoints ( point , clientEyes , resultant );
GetVectorAngles ( resultant , angles );
if( angles [ 0 ] >= 270 ){
angles [ 0 ] -= 270 ;
angles [ 0 ] = ( 90 - angles [ 0 ]);
}else{
if( angles [ 0 ] <= 90 ){
angles [ 0 ] *= - 1 ;
}
}
angles [ 1 ] -= 180 ;
TeleportEntity ( client , NULL_VECTOR , angles , NULL_VECTOR );
}