Advertisement
Guest User

Lua playerface

a guest
Mar 17th, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.13 KB | None | 0 0
  1. ---------------------------------------------------
  2. --                   Variables                   --
  3. ---------------------------------------------------
  4.  
  5. -- Script settings
  6. local Settings_Hotkey = VK_F12;
  7.  
  8. -- Event variables
  9. local Event_FaceTarget = nil;
  10. local Event_MoveToTarget = nil;
  11.  
  12. -- Script variables
  13. local Script_Started = false;
  14. local First_Start = false;
  15. local rP = 0;
  16.  
  17.  
  18. ---------------------------------------------------
  19. --                    Startup                    --
  20. ---------------------------------------------------
  21.  
  22. function Load()
  23.     Plus.PrintChat( "PlayerFace v1.0 loaded!" );
  24.     fFrame = Frame.Create( "", 200, 70, true );
  25.     bButton = Button.Create( fFrame, "Start", 10, 23, 180, 20 );
  26.     cbMoveToTarget = CheckBox.Create( fFrame, "", 175, 2, false);
  27.     lrPlayer = Label.Create( fFrame, "Rotation:" .. rP , 10, 2);
  28.     Label.Create( fFrame, "Auto Move", 108, 2);
  29.     Label.Create( fFrame, "::", 43, -28);
  30.     Event.RegisterFrameCallback( cbMtt, cbMoveToTarget, "OnClick");
  31.     Event.RegisterFrameCallback( cButton, bButton, "OnClick" );
  32.     Event.RegisterKeyCallback( OnToggleHotkey, Settings_Hotkey );
  33.     Event.RegisterTimerCallback( DisplayRotation, 5, true);
  34. end
  35.  
  36.  
  37. function Unload()
  38.     Event.RemoveTimerCallback( DisplayRotation );
  39.  
  40. end
  41.  
  42.  
  43. ---------------------------------------------------
  44. --                     Events                    --
  45. ---------------------------------------------------
  46.  
  47. function DisplayRotation( identifier, interval )
  48.     local rP = ObjectManager.GetActivePlayer():GetRotation();
  49.     lrPlayer:SetText( "Rotation:" .. string.sub(rP, 1, 4 ));
  50.  
  51. end
  52.  
  53.  
  54. function OnToggleHotkey( identifier, key )
  55.     if Script_Started == true then
  56.         Script_Started = false;
  57.         Event.RemoveTimerCallback( Event_FaceTarget );
  58.         bButton:SetText( "Start" );
  59.     else
  60.         Script_Started = true;
  61.         First_Start = true;
  62.         Event_FaceTarget = Event.RegisterTimerCallback( FaceTarget, 5, true );
  63.         bButton:SetText( "Stop" );
  64.  
  65.     end
  66. end
  67.  
  68.  
  69. function cbMtt( eventID, cbSender )
  70.     local cbMoveToCheck = cbMoveToTarget:GetChecked();
  71.  
  72.     if cbMoveToCheck == true then
  73.  
  74.         Event_MoveToTarget = Event.RegisterTimerCallback( MoveToTargetTimer, 600, true );
  75.     else
  76.  
  77.         Event.RemoveTimerCallback( Event_MoveToTarget );
  78.  
  79.     end
  80. end
  81.  
  82.  
  83. function MoveToTargetTimer( identifier, interval )
  84.     if Script_Started == false then
  85.         Event.RemoveTimerCallback( Event_MoveToTarget );
  86.         cbMoveToTarget:SetChecked( false );
  87.  
  88.         if First_Start == false then
  89.             Plus.PrintWarning( "Click Start Before Checking the Box." );
  90.         end
  91.     else
  92.         Script_Started = true;
  93.         Plus.SetHackState( "WallClimb", true );
  94.         local Target = ObjectManager.GetCurrentTarget();
  95.         local x,y,z = Target:GetLocation();
  96.         Player.MoveTo( x, y, z, 0);
  97.  
  98.     end
  99. end
  100.  
  101.  
  102. function cButton( eventID, button )
  103.     if Script_Started == true then
  104.         Script_Started = false;
  105.         Event.RemoveTimerCallback( Event_FaceTarget );
  106.         bButton:SetText( "Start" );
  107.     else
  108.         Script_Started = true;
  109.         First_Start = true;
  110.         Event_FaceTarget = Event.RegisterTimerCallback( FaceTarget, 5, true );
  111.         bButton:SetText( "Stop" );
  112.  
  113.     end
  114. end
  115.  
  116.  
  117. function FaceTarget( identifier, interval )
  118.     local Target = ObjectManager.GetCurrentTarget();
  119.     if Target == nil then
  120.         return;
  121.     end
  122.  
  123.     X,Y = Target:GetLocation();
  124.     Player.Face( X,Y );
  125.  
  126. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement