Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.11 KB | None | 0 0
  1. local function OnCreateMoveMain(UserCmd)
  2.    
  3.     if Target ~= nil then
  4.         local LocalAngles = {UserCmd:GetViewAngles()}
  5.         local VecForward = {vector.Subtract( {Target:GetAbsOrigin()},  {LocalPlayer:GetAbsOrigin()} )}
  6.         local AimAngles = {vector.Angles( VecForward )}
  7.         local TargetSpeed = vector.Length(Target:GetPropFloat("localdata", "m_vecVelocity[0]"), Target:GetPropFloat("localdata", "m_vecVelocity[1]"), Target:GetPropFloat("localdata", "m_vecVelocity[2]"))
  8.        
  9.         if CrouchBlock then
  10.             UserCmd:SetForwardMove( ( (math.sin(math.rad(LocalAngles[2]) ) * VecForward[2]) + (math.cos(math.rad(LocalAngles[2]) ) * VecForward[1]) ) * 200 )
  11.             UserCmd:SetSideMove( ( (math.cos(math.rad(LocalAngles[2]) ) * -VecForward[2]) + (math.sin(math.rad(LocalAngles[2]) ) * VecForward[1]) ) * 200 )
  12.         else
  13.             local DiffYaw = AimAngles[2] - LocalAngles[2]
  14.  
  15.             if DiffYaw > 180 then
  16.                 DiffYaw = DiffYaw - 360
  17.             elseif DiffYaw < -180 then
  18.                 DiffYaw = DiffYaw + 360
  19.             end
  20.            
  21.             if DiffYaw > 0.001 then
  22.                 UserCmd:SetSideMove(-450)
  23.             elseif DiffYaw < -0.001 then
  24.                 UserCmd:SetSideMove(450)
  25.             end
  26.  
  27.         end
  28.        
  29.     end
  30.    
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement