Advertisement
Guest User

Untitled

a guest
Apr 6th, 2010
1,181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.38 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define END_BALL_STEP 16
  4. #define DIALOG_HELP 1024
  5.  
  6. //=====================BasketBall===============================================
  7. //==============================================================================
  8. new BMode[3] = {0, 1, -1};
  9. new Float: StartBallPos[3] = {2317.3474,-1515.4139,24.7};
  10. new Float: BBP[2] = {2316.8721,-1514.9233};
  11. new BallStep;
  12. new CanJump[MAX_PLAYERS];
  13. new Float: BallSteps[2];
  14. new Float: ZBallPos[END_BALL_STEP] =
  15. {0.6, 0.65, 0.7, 0.35, 0.30, 0.25, 0.2, 0.15,
  16. -0.15, -0.25, -0.2, -0.3, -0.35, -0.7, -0.65, -0.6};
  17. new Float: BallDown[8] = {-2.8, 2.1, -2.1, 1.5, -1.5, 0.7, -0.7, 0.0};
  18. new Float: BallSide[10] = {1.8, -1.97, -2.6, 1.0, -1.0, 0.75, -0.75, 0.3, -0.3, 0.0};
  19. new Mode;
  20. new Float: BallPos[3];
  21. new Ball;
  22. new BallOn = -1;
  23. new AnimTime;
  24. //==============================================================================
  25.  
  26. forward AnimStop();
  27.  
  28. main ()
  29. {
  30.  
  31. }
  32.  
  33. public OnFilterScriptInit()
  34. {
  35.     return 1;
  36. }
  37.  
  38. public OnFilterScriptExit()
  39. {
  40.     return 1;
  41. }
  42.  
  43. ReturnBall()
  44. {
  45.     DestroyObject(Ball);
  46.     Ball = CreateObject(2114, StartBallPos[0], StartBallPos[1], StartBallPos[2], 0,0,0);
  47.     BallPos[0] = StartBallPos[0];
  48.     BallPos[1] = StartBallPos[1];
  49.     BallPos[2] = StartBallPos[2];
  50.     CanJump[BallOn] = 0;
  51.     BallOn = -1;
  52. }
  53.  
  54. public OnPlayerDisconnect(playerid)
  55. {
  56.     if (BallOn == playerid)
  57.     {
  58.         ReturnBall();
  59.     }
  60.     return 1;
  61. }
  62.  
  63. public AnimStop()
  64. {
  65.     TogglePlayerControllable(BallOn, 1);
  66.     AttachObjectToPlayer(Ball, BallOn, 0.3, 0.5, 0, 0,0,0);
  67.     ApplyAnimation(BallOn, "BSKTBALL", "BBALL_Jump_Shot_O", 4, 0, 0, 0, 1, 500);
  68.     CanJump[BallOn] = 1;
  69.     KillTimer(AnimTime);
  70. }
  71.  
  72. public OnGameModeInit()
  73. {
  74.     Ball = CreateObject(2114, StartBallPos[0], StartBallPos[1], StartBallPos[2], 0,0,0);
  75.     BallPos[0] = StartBallPos[0];
  76.     BallPos[1] = StartBallPos[1];
  77.     BallPos[2] = StartBallPos[2];
  78.     return 1;
  79. }
  80.  
  81. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  82. {
  83.     if (newkeys & KEY_SPRINT && // Åñëè íàæàòà êëàâèøà SHIFT
  84.     !IsPlayerInAnyVehicle(playerid) && // È èãðîê íå â àâòîìîáèëå
  85.     IsPlayerInRangeOfPoint(playerid, 10, 2316.5007,-1520.9408,25.3438) && // Íàõîäèòñÿ íà èãðîâîé ïëîùàäêå
  86.     CanJump[playerid] == 1) // Ìîæåò êèäàòü
  87.     {
  88.         new Float: x, Float: y, Float: z;
  89.         GetPlayerPos(playerid, x,y,z);
  90.         SetPlayerPos(playerid, x,y,25.3438);
  91.         DestroyObject(Ball);
  92.         Ball = CreateObject(2114, x,y,24.9438, 0,0,0);
  93.         new Float: dX = BBP[0] - x;
  94.         new Float: dY = BBP[1] - y;
  95.         new Float: PlayerAlpha = atan2(dX, dY);
  96.         new RandomModeRange;
  97.         new Float: ay, Float: BallSpeed;
  98.         SetPlayerFacingAngle(playerid, -PlayerAlpha);
  99.         if (floatabs(BBP[0] - x) < 3 && floatabs(BBP[1] - y) < 3)
  100.         {
  101.             ay = 0.5;
  102.             RandomModeRange = 1; // Ïîïàäàíèå â êîëüöî 100 %
  103.             SetPlayerPos(playerid, BBP[0], BBP[1]+0.2, 25.3438);
  104.             SetPlayerFacingAngle(playerid, -PlayerAlpha);
  105.             ApplyAnimation(playerid, "BSKTBALL", "BBALL_Dnk", 4, 0, 1, 1, 1, 1000);
  106.             BallSpeed = 5.3;
  107.         }
  108.         else
  109.         {
  110.             ay = 0.2;
  111.             RandomModeRange = 3; // Ïîïàäàíèå â êîëüöî 30 %
  112.             ApplyAnimation(playerid, "BSKTBALL", "BBALL_Jump_Shot", 7, 0, 2, 2, 1, 1000);
  113.             BallSpeed = 2.8;
  114.         }
  115.  
  116.         BallStep = 0;
  117.         BallSteps[0] = (BBP[0] - x) / END_BALL_STEP;
  118.         BallSteps[1] = (BBP[1] - y) / END_BALL_STEP;
  119.         CanJump[playerid] = 0;
  120.         MoveObject(Ball, x, y+ay, 27.3438, BallSpeed);
  121.         Mode = BMode[random(RandomModeRange)];
  122.     }
  123.     return 1;
  124. }
  125.  
  126. public OnPlayerUpdate(playerid)
  127. {
  128.     if (IsPlayerInRangeOfPoint(playerid, 10, 2316.5007,-1520.9408,25.3438))
  129.     {
  130.         if (IsPlayerInRangeOfPoint(playerid, 1, BallPos[0], BallPos[1], BallPos[2]) && BallOn == -1)
  131.         {
  132.             TogglePlayerControllable(playerid, 0);
  133.             new Float: x, Float: y, Float: z;
  134.             GetObjectPos(Ball, x,y,z);
  135.             SetPlayerPos(playerid, x,y-0.4,z);
  136.             SetPlayerFacingAngle(playerid, 0);
  137.             ApplyAnimation(playerid, "BSKTBALL", "BBALL_pickup", 4, 0,1,1,1,1500);
  138.             BallOn = playerid;
  139.             AnimTime = SetTimer("AnimStop", 1500, true);
  140.             return 1;
  141.         }
  142.     }
  143.  
  144.     else
  145.     {
  146.         if (CanJump[playerid])
  147.         {
  148.             ReturnBall();
  149.             return 1;
  150.         }
  151.     }
  152.     return 1;
  153. }
  154.  
  155. public OnObjectMoved(objectid)
  156. {
  157.     if (objectid == Ball)
  158.     {
  159.         new Float: x, Float: y, Float: z;
  160.         GetObjectPos(objectid, x,y,z);
  161.  
  162.         new n = END_BALL_STEP;
  163.         if (BallStep >= n)
  164.         {
  165.             new b;
  166.             if (!Mode) b = 8; else b = 10;
  167.             if (BallStep == n + b)
  168.             {
  169.                 BallPos[0] = x;
  170.                 BallPos[1] = y;
  171.                 BallPos[2] = z;
  172.                 CanJump[BallOn] = 0;
  173.                 ApplyAnimation(BallOn, "BSKTBALL", "BBALL_Jump_Shot_O", 4, 0, 0, 0, 1, 100);
  174.                 BallOn = -1;
  175.             }
  176.             else
  177.             {
  178.                 if (!Mode)
  179.                 {
  180.                     GameTextForPlayer(BallOn, "~g~+1", 3000, 6);
  181.                     new Float: a = BallDown[BallStep - n];
  182.                     MoveObject(objectid, x,y,z + a, 8-a);
  183.                     BallStep++;
  184.                 }
  185.                 else
  186.                 {
  187.                     new Float: a = BallSide[BallStep - n];
  188.                     MoveObject(objectid, x+0.15*Mode, y - 0.08, z + a, 8-a);
  189.                     BallStep++;
  190.                 }
  191.             }
  192.         }
  193.         MoveObject(objectid, x+BallSteps[0], y+BallSteps[1], z+ZBallPos[BallStep], 7.65);
  194.         BallStep++;
  195.     }
  196.     return 1;
  197. }
  198.  
  199. public OnPlayerCommandText(playerid, cmdtext[])
  200. {
  201.     if (strcmp(cmdtext, "/basket", true) == 0)
  202.     {
  203.         SetPlayerPos(playerid, 2316.5007,-1520.9408,25.3438);
  204.         return 1;
  205.     }
  206.     return 0;
  207. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement