Advertisement
Guest User

Vietnam slide

a guest
Jul 9th, 2017
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.45 KB | None | 0 0
  1. enum CSlideSettings
  2. {
  3.     CrouchDelay        = 1.0,
  4.     Radius             = 0.8,
  5.     Interval           = 16,
  6.     MaximumDuration    = 2400
  7. }
  8.  
  9. SqPlayer.newmember("LastAction", [SqPlayerAction.None, SqPlayerAction.None]);
  10. SqPlayer.newmember("LastCrouchTime", 0.0);
  11. SqPlayer.newmember("CrouchDelay", 1e+6);
  12. SqPlayer.newmember("Sliding", false);
  13. SqPlayer.newmember("SlideTerminateTask", null);
  14. SqPlayer.newmember("SlideCreated", 0);
  15.  
  16. SqCore.On().PlayerAction.Connect(function (player, oldaction, newaction)
  17. {
  18.     if (player.Sliding == false)
  19.     {
  20.         if
  21.         (
  22.             oldaction == SqPlayerAction.Shooting &&
  23.             newaction == SqPlayerAction.Normal &&
  24.             player.Crouched == true &&
  25.             player.CrouchDelay < CSlideSettings.CrouchDelay &&
  26.             player.LastAction[0] == SqPlayerAction.Normal &&
  27.             player.LastAction[1] == SqPlayerAction.Shooting
  28.         )
  29.         {
  30.             player.SetAnimation(206, 15);
  31.  
  32.             player.SlideTerminateTask = player.MakeTask(function ()
  33.             {
  34.                 player.SlideTerminateTask.Terminate();
  35.  
  36.                 player.SlideTerminateTask    = null;
  37.                 player.Sliding               = false;
  38.             }, CSlideSettings.MaximumDuration, 1);
  39.  
  40.             player.Sliding = true;
  41.         }
  42.     }
  43.  
  44.     player.LastAction        = [oldaction, newaction];
  45. });
  46.  
  47. SqCore.On().PlayerCrouching.Connect(function (player, iscrouching)
  48. {
  49.     player.CrouchDelay       = clock() - player.LastCrouchTime;
  50.     player.LastCrouchTime    = clock();
  51. });
  52.  
  53. SqCore.On().PlayerGameKeys.Connect(function (player, lastkeys, newkeys)
  54. {
  55.     if (player.Sliding == true)
  56.     {
  57.         if (!(newkeys & 32768))
  58.         {
  59.             player.SlideTerminateTask.Terminate();
  60.  
  61.             player.SlideTerminateTask    = null;
  62.             player.Sliding               = false;
  63.         }
  64.     }
  65. });
  66.  
  67. SqCore.On().ScriptLoaded.Connect(function ()
  68. {
  69.     SqRoutine(this, function ()
  70.     {
  71.         SqForeach.Player.Active(this, function (player)
  72.         {
  73.             if (player.Sliding == true)
  74.             {
  75.                 player.SetAnimation(206, 15);
  76.  
  77.                 local trueangle = player.Angle + (PI * 0.5);
  78.                 player.Position = Vector3(CSlideSettings.Radius * cos(trueangle) + player.Position.X, CSlideSettings.Radius * sin(trueangle) + player.Position.Y, player.Position.Z);
  79.             }
  80.         });
  81.     }, CSlideSettings.Interval, 0);
  82. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement