Guest User

Riddick - Translated from Polish to English language.

a guest
Aug 10th, 2011
1,210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 39.65 KB | None | 0 0
  1. #include                "a_samp"
  2.  
  3. #define NO_BALL         (403)
  4.  
  5. #define FULL_BALL       (0)
  6. #define HALF_BALL       (1)
  7.  
  8. #define WHITE           (14)
  9. #define BLACK           (15)
  10.  
  11. #define TABLE           (16)
  12. #define POLYGONS        (6)
  13.  
  14. forward Float:GetVectorAngle(obj, obj2);
  15. forward Float:GetVectorAngle_XY(Float:fx, Float:fy, Float:tx, Float:ty);
  16. forward Float:GetVectorDistance_PL(playerid, obj);
  17. forward Float:GetVectorDistance_OB(obj, obj2);
  18. forward Float:GetDistance(Float:fx, Float:fy, Float:tx, Float:ty);
  19. forward Float:GetDistancePointToLong(Float:px,Float:py, Float:px1,Float:py1, Float:px2,Float:py2);
  20.  
  21. forward OnEndBilliard();
  22. forward OnBallInHole(ballid);
  23. forward OnTimer();
  24. forward BallProperties();
  25. forward OnShowedTD(playerid);
  26.  
  27. enum GameEnum
  28. {
  29.     bool:Waiting,
  30.     bool:Running,
  31.     bool:WhiteInHole,
  32.     bool:BlackInHole,
  33.     Timer,
  34.     Timer2,
  35.     Player1,
  36.     Player2,
  37.     LastBall
  38. };
  39. new Game[GameEnum];
  40.  
  41. enum BallEnum
  42. {
  43.     ObjID,
  44.     Float:x,
  45.     Float:y,
  46.     Float:z,
  47.     Float:a,
  48.     Float:speed,
  49.     TouchID
  50. };
  51. new Ball[17][BallEnum];
  52.  
  53. enum EnumVertices
  54. {
  55.     Float:x,
  56.     Float:y
  57. };
  58. new Polygon[POLYGONS][2][EnumVertices];
  59.  
  60. enum PolygonInfo
  61. {
  62.     bool:Progress,
  63.     Vertices
  64. };
  65. new PolyResult[POLYGONS][PolygonInfo];
  66.  
  67. enum EnumPlayer
  68. {
  69.     bool:Sighting,
  70.     bool:AfterSighting,
  71.     bool:Turn,
  72.     BBall,
  73.     Points,
  74.     SelectLR,
  75.     SelectUD,
  76.     Float:a,
  77.     Text:T1,
  78.     Text:T2,
  79.     Text:T3,
  80.     Text:T4,
  81.     Text:T5,
  82.     Text:T6,
  83.     TDTimer
  84. };
  85. new Player[20][EnumPlayer];
  86.  
  87. new Float:Hole[6][4] =
  88. {
  89.     {2495.6413,-1670.6297, 2495.5415,-1670.7099}, // 1  12
  90.     {2496.4323,-1670.6297, 2496.5825,-1670.6398}, // 2  3
  91.     {2497.3632,-1670.6297, 2497.4433,-1670.7299}, // 4  5
  92.     {2497.4633,-1671.5506, 2497.3732,-1671.6607}, // 6  7
  93.     {2496.5725,-1671.6607, 2496.4323,-1671.6607}, // 8  9
  94.     {2495.6315,-1671.6607, 2495.5415,-1671.5606}  // 10 11
  95. };
  96.  
  97. new Char[2][] =
  98. {
  99.     {"(0)"},
  100.     {"(-)"}
  101. };
  102.  
  103. public OnFilterScriptInit()
  104. {
  105.     for(new i = 0; i < 20; i++)
  106.     {
  107.         Player[i][T1] = TextDrawCreate(481.000000,353.000000," ");
  108.         TextDrawUseBox(Player[i][T1],1);
  109.         TextDrawTextSize(Player[i][T1],602.000000,0.000000);
  110.         TextDrawLetterSize(Player[i][T1],0.359999,1.100000);
  111.         TextDrawSetShadow(Player[i][T1],1);
  112.         TextDrawColor(Player[i][T1],227275519);
  113.         TextDrawBoxColor(Player[i][T1],227275314);
  114.  
  115.         Player[i][T2] = TextDrawCreate(475.000000,344.000000," ");
  116.         TextDrawColor(Player[i][T2],4294967295);
  117.         TextDrawSetShadow(Player[i][T2],1);
  118.        
  119.         Player[i][T3] = TextDrawCreate(481.000000,313.000000," ");
  120.         TextDrawUseBox(Player[i][T3],1);
  121.         TextDrawTextSize(Player[i][T3],635.000000,0.000000);
  122.         TextDrawLetterSize(Player[i][T3],0.359999,1.100000);
  123.         TextDrawSetShadow(Player[i][T3],1);
  124.         TextDrawColor(Player[i][T3],227275519);
  125.         TextDrawBoxColor(Player[i][T3],227275314);
  126.  
  127.         Player[i][T4] = TextDrawCreate(475.000000,304.000000," ");
  128.         TextDrawColor(Player[i][T4],4294967295);
  129.         TextDrawSetShadow(Player[i][T4],1);
  130.        
  131.         Player[i][T5] = TextDrawCreate(481.000000,273.000000," ");
  132.         TextDrawUseBox(Player[i][T5],1);
  133.         TextDrawTextSize(Player[i][T5],635.000000,0.000000);
  134.         TextDrawLetterSize(Player[i][T5],0.359999,1.100000);
  135.         TextDrawSetShadow(Player[i][T5],1);
  136.         TextDrawColor(Player[i][T5],227275519);
  137.         TextDrawBoxColor(Player[i][T5],227275314);
  138.  
  139.         Player[i][T6] = TextDrawCreate(475.000000,264.000000," ");
  140.         TextDrawColor(Player[i][T6],4294967295);
  141.         TextDrawSetShadow(Player[i][T6],1);
  142.     }
  143.     return 1;
  144. }
  145.  
  146. public OnPlayerCommandText(playerid, cmdtext[])
  147. {
  148.     if(strcmp("/pool", cmdtext, true, 10) == 0)
  149.     {
  150.         SetPlayerPos(playerid,2499.3174,-1683.8401,13.4014);
  151.         return true;
  152.     }
  153.    
  154.     if (strcmp("/pool-start", cmdtext, true, 10) == 0)
  155.     {
  156.         if(Game[Waiting] == false && Game[Running] == false)
  157.         {
  158.             Game[Waiting] = true;
  159.             Game[Player1] = playerid;
  160.             Game[LastBall] = -1;
  161.             Player[playerid][Points] = 7;
  162.            
  163.             TextDrawSetString(Player[playerid][T1],"for the opponent...");
  164.             TextDrawShowForPlayer(playerid,Player[playerid][T1]);
  165.  
  166.             TextDrawSetString(Player[playerid][T2],"Waiting");
  167.             TextDrawShowForPlayer(playerid,Player[playerid][T2]);
  168.             GivePlayerWeapon(playerid,7,1);
  169.            
  170.             new name[24];
  171.             new str[100];
  172.             name = GetName(playerid);
  173.             format(str,sizeof(str),"%s waiting for the opponent. Type /pool-join, to compete with the host.",name);
  174.             for(new i = 0; i < 20; i++)
  175.             {
  176.                 if(IsPlayerConnected(i) == 1 && playerid != i)
  177.                 {
  178.                     TextDrawSetString(Player[i][T1],str);
  179.                     TextDrawShowForPlayer(i,Player[i][T1]);
  180.                    
  181.                     TextDrawSetString(Player[i][T2],"Pool");
  182.                     TextDrawShowForPlayer(i,Player[i][T2]);
  183.                 }
  184.                 Player[i][BBall] = NO_BALL;
  185.             }
  186.            
  187.             Ball[0][ObjID] = CreateObject(3100, 2497.0749511719, -1670.9591064453, 13.199293525696, 0, 0, 0); //CALA
  188.             Ball[1][ObjID] = CreateObject(3101, 2497.0034179688, -1671.01171875, 13.199293525696, 0, 0, 0); //CALA
  189.             Ball[2][ObjID] = CreateObject(3102, 2497.0034179688, -1671.1900634766, 13.199293525696, 0, 0, 0); //CALA
  190.             Ball[3][ObjID] = CreateObject(3103, 2496.8696289063, -1671.1865234375, 13.199293525696, 0, 0, 0); //CALA
  191.             Ball[4][ObjID] = CreateObject(3104, 2496.9370117188, -1671.0673828125, 13.199293525696, 0, 0, 0); //CALA
  192.             Ball[5][ObjID] = CreateObject(3105, 2497.072265625, -1671.2313232422, 13.199293525696, 0, 0, 0); //CALA
  193.             Ball[6][ObjID] = CreateObject(3002, 2496.8068847656, -1671.1413574219, 13.199293525696, 0, 0, 0); //CALA
  194.  
  195.             Ball[7][ObjID] = CreateObject(2995, 2496.8703613281, -1671.0987548828, 13.199293525696, 0, 0, 0); //POLOWKA
  196.             Ball[8][ObjID] = CreateObject(2996, 2497.0031738281, -1671.2750244141, 13.199293525696, 0, 0, 0); //POLOWKA
  197.             Ball[9][ObjID] = CreateObject(2997, 2497.0705566406, -1671.3179931641, 13.199293525696, 0, 0, 0); //POLOWKA
  198.             Ball[10][ObjID] = CreateObject(2998, 2497.0759277344, -1671.0457763672, 13.199293525696, 0, 0, 0); //POLOWKA
  199.             Ball[11][ObjID] = CreateObject(2999, 2497.0063476563, -1671.1011962891, 13.199293525696, 0, 0, 0); //POLOWKA
  200.             Ball[12][ObjID] = CreateObject(3000, 2497.0734863281, -1671.1456298828, 13.199293525696, 0, 0, 0); //POLOWKA
  201.             Ball[13][ObjID] = CreateObject(3001, 2496.9333496094, -1671.2292480469, 13.199293525696, 0, 0, 0); //POLOWKA
  202.  
  203.             Ball[WHITE][ObjID] = CreateObject(3003, 2495.8618164063, -1671.1704101563, 13.209293525696, 0, 0, 0); //Biala
  204.             Ball[BLACK][ObjID] = CreateObject(3106, 2496.9375, -1671.1451416016, 13.199293525696, 0, 0, 0); //Czarna
  205.             Ball[TABLE][ObjID] = CreateObject(2964, 2496.4970703125, -1671.1528320313, 12.265947036743, 0, 0, 0); //Stol
  206.  
  207.             CreatePolygon(2495.6413,-1670.6297, 2496.4323,-1670.6297);
  208.             CreatePolygon(2496.5825,-1670.6398, 2497.3632,-1670.6297);
  209.             CreatePolygon(2497.4433,-1670.7299, 2497.4633,-1671.5506);
  210.             CreatePolygon(2497.3732,-1671.6607, 2496.5725,-1671.6607);
  211.             CreatePolygon(2496.4323,-1671.6607, 2495.6315,-1671.6607);
  212.             CreatePolygon(2495.5415,-1671.5606, 2495.5415,-1670.7099);
  213.         }
  214.         return 1;
  215.     }
  216.    
  217.     if (strcmp("/stop", cmdtext, true, 10) == 0)
  218.     {
  219.         if(Game[Waiting] == true || Game[Running] == true)
  220.         {
  221.             KillTimer(Game[Timer]);
  222.             KillTimer(Game[Timer2]);
  223.             for(new i = 0; i < 17; i++)
  224.             {
  225.                 DestroyObject(Ball[i][ObjID]);
  226.             }
  227.            
  228.             if(Game[Waiting] == true)
  229.                 Game[Waiting] = false;
  230.                
  231.             if(Game[Running] == true)
  232.                 Game[Running] = false;
  233.                
  234.             Game[WhiteInHole] = false;
  235.             Game[BlackInHole] = false;
  236.                
  237.             Player[Game[Player1]][Sighting] = false;
  238.             TextDrawHideForPlayer(Game[Player1],Player[Game[Player1]][T1]);
  239.             TextDrawHideForPlayer(Game[Player1],Player[Game[Player1]][T2]);
  240.             TextDrawHideForPlayer(Game[Player1],Player[Game[Player1]][T3]);
  241.             TextDrawHideForPlayer(Game[Player1],Player[Game[Player1]][T4]);
  242.             TextDrawHideForPlayer(Game[Player1],Player[Game[Player1]][T5]);
  243.             TextDrawHideForPlayer(Game[Player1],Player[Game[Player1]][T6]);
  244.            
  245.             Player[Game[Player2]][Sighting] = false;
  246.             TextDrawHideForPlayer(Game[Player2],Player[Game[Player2]][T1]);
  247.             TextDrawHideForPlayer(Game[Player2],Player[Game[Player2]][T2]);
  248.             TextDrawHideForPlayer(Game[Player2],Player[Game[Player2]][T3]);
  249.             TextDrawHideForPlayer(Game[Player2],Player[Game[Player2]][T4]);
  250.             TextDrawHideForPlayer(Game[Player2],Player[Game[Player2]][T5]);
  251.             TextDrawHideForPlayer(Game[Player2],Player[Game[Player2]][T6]);
  252.         }
  253.         return true;
  254.     }
  255.    
  256.     if (strcmp("/pool-join", cmdtext, true, 10) == 0)
  257.     {
  258.         if(Game[Waiting] == true)
  259.         {
  260.             if(Game[Player1] != playerid)
  261.             {
  262.                 Game[Waiting] = false;
  263.                 Game[Running] = true;
  264.                 Game[Player2] = playerid;
  265.                 TextDrawHideForPlayer(playerid,Player[Game[Player1]][T1]);
  266.                 TextDrawHideForPlayer(playerid,Player[Game[Player1]][T2]);
  267.                
  268.                 new str[50];
  269.                 new name[24];
  270.                 GivePlayerWeapon(playerid,7,1);
  271.                
  272.                 new rand = random(2);
  273.                 if(rand == 0)
  274.                 {
  275.                     name = GetName(Game[Player1]);
  276.                     Player[Game[Player1]][Turn] = true;
  277.                     Player[Game[Player2]][Turn] = false;
  278.                 }
  279.                 else if(rand == 1)
  280.                 {
  281.                     name = GetName(Game[Player2]);
  282.                     Player[Game[Player1]][Turn] = false;
  283.                     Player[Game[Player2]][Turn] = true;
  284.                 }
  285.                
  286.                 for(new i = 0; i < 20; i++)
  287.                 {
  288.                     if(IsPlayerConnected(i) == 1 && Game[Player1] != i && Game[Player2] != i)
  289.                     {
  290.                         ShowMessage(i,"Pool","Failed to subscribe to the game. You can wait for the next round.");
  291.                     }
  292.                 }
  293.                    
  294.                 Player[playerid][Points] = 7;
  295.                 format(str,sizeof(str),"The gameplay begins by %s",name);
  296.                 ShowMessage(Game[Player1],"Gameplay",str);
  297.                 ShowMessage(Game[Player2],"Gameplay",str);
  298.                
  299.                 new string[80];
  300.                 format(string,sizeof(string),"%s %d~n~%s %d",GetName(Game[Player1]),Player[Game[Player1]][Points],GetName(Game[Player2]),Player[Game[Player2]][Points]);
  301.                 TextDrawSetString(Player[Game[Player1]][T3],string);
  302.                 TextDrawSetString(Player[Game[Player1]][T4],"Pool");
  303.                 TextDrawSetString(Player[Game[Player2]][T3],string);
  304.                 TextDrawSetString(Player[Game[Player2]][T4],"Pool");
  305.                
  306.                 TextDrawShowForPlayer(Game[Player1],Player[Game[Player1]][T3]);
  307.                 TextDrawShowForPlayer(Game[Player1],Player[Game[Player1]][T4]);
  308.                
  309.                 TextDrawShowForPlayer(Game[Player2],Player[Game[Player2]][T3]);
  310.                 TextDrawShowForPlayer(Game[Player2],Player[Game[Player2]][T4]);
  311.                
  312.                 for(new i = 0; i < 16; i++)
  313.                 {
  314.                     Ball[i][TouchID] = -1;
  315.                 }
  316.             }
  317.         }
  318.         return 1;
  319.     }
  320.     return 0;
  321. }
  322.  
  323. public OnEndBilliard()
  324. {
  325.     for(new i = 0; i < 17; i++)
  326.     {
  327.         DestroyObject(Ball[i][ObjID]);
  328.     }
  329.  
  330.     Game[Waiting] = false;
  331.     Game[Running] = false;
  332.     Game[WhiteInHole] = false;
  333.     Game[BlackInHole] = false;
  334.    
  335.     Player[Game[Player1]][Sighting] = false;
  336.     TextDrawHideForPlayer(Game[Player1],Player[Game[Player1]][T1]);
  337.     TextDrawHideForPlayer(Game[Player1],Player[Game[Player1]][T2]);
  338.     TextDrawHideForPlayer(Game[Player1],Player[Game[Player1]][T3]);
  339.     TextDrawHideForPlayer(Game[Player1],Player[Game[Player1]][T4]);
  340.     TextDrawHideForPlayer(Game[Player1],Player[Game[Player1]][T5]);
  341.     TextDrawHideForPlayer(Game[Player1],Player[Game[Player1]][T6]);
  342.    
  343.     Player[Game[Player2]][Sighting] = false;
  344.     TextDrawHideForPlayer(Game[Player2],Player[Game[Player2]][T1]);
  345.     TextDrawHideForPlayer(Game[Player2],Player[Game[Player2]][T2]);
  346.     TextDrawHideForPlayer(Game[Player2],Player[Game[Player2]][T3]);
  347.     TextDrawHideForPlayer(Game[Player2],Player[Game[Player2]][T4]);
  348.     TextDrawHideForPlayer(Game[Player2],Player[Game[Player2]][T5]);
  349.     TextDrawHideForPlayer(Game[Player2],Player[Game[Player2]][T6]);
  350. }
  351.  
  352. public OnBallInHole(ballid)
  353. {
  354.     if(ballid != WHITE)
  355.     {
  356.         DestroyObject(Ball[ballid][ObjID]);
  357.         Ball[ballid][speed] = 0;
  358.     }
  359.     else
  360.     {
  361.          Ball[WHITE][speed] = 0.2;
  362.          SetObjectPos(Ball[WHITE][ObjID],2495.8618164063, -1671.1704101563, 13.209293525696);
  363.          StopObject(Ball[WHITE][ObjID]);
  364.          Ball[WHITE][x] = 2495.8618164063;
  365.          Ball[WHITE][y] = -1671.1704101563;
  366.          Ball[WHITE][z] = 13.209293525696;
  367.     }
  368.          
  369.     Game[LastBall] = ballid;
  370.     for(new i = 0; i < 16; i++)
  371.     {
  372.         if(ballid == i)
  373.         {
  374.             if(ballid <= 6) //CALA
  375.             {
  376.                 if(Player[Game[Player1]][Turn] == true && Player[Game[Player1]][BBall] == NO_BALL)
  377.                 {
  378.                     Player[Game[Player1]][BBall] = FULL_BALL;
  379.                     Player[Game[Player2]][BBall] = HALF_BALL;
  380.                 }
  381.                 else if(Player[Game[Player2]][Turn] == true && Player[Game[Player2]][BBall] == NO_BALL)
  382.                 {
  383.                     Player[Game[Player1]][BBall] = HALF_BALL;
  384.                     Player[Game[Player2]][BBall] = FULL_BALL;
  385.                 }
  386.                
  387.                 if(Player[Game[Player1]][BBall] == FULL_BALL)
  388.                     Player[Game[Player1]][Points]--;
  389.                    
  390.                 else if(Player[Game[Player2]][BBall] == FULL_BALL)
  391.                     Player[Game[Player2]][Points]--;
  392.                
  393.             }
  394.                
  395.             else if(6 < ballid <= 13) //POLOWKA
  396.             {
  397.                 if(Player[Game[Player1]][Turn] == true && Player[Game[Player1]][BBall] == NO_BALL)
  398.                 {
  399.                     Player[Game[Player1]][BBall] = HALF_BALL;
  400.                     Player[Game[Player2]][BBall] = FULL_BALL;
  401.                 }
  402.                 else if(Player[Game[Player2]][Turn] == true && Player[Game[Player2]][BBall] == NO_BALL)
  403.                 {
  404.                     Player[Game[Player1]][BBall] = FULL_BALL;
  405.                     Player[Game[Player2]][BBall] = HALF_BALL;
  406.                 }
  407.                
  408.                 if(Player[Game[Player1]][BBall] == HALF_BALL)
  409.                     Player[Game[Player1]][Points]--;
  410.  
  411.                 else if(Player[Game[Player2]][BBall] == HALF_BALL)
  412.                     Player[Game[Player2]][Points]--;
  413.             }
  414.  
  415.             else if(ballid == WHITE)
  416.                 Game[WhiteInHole] = true;
  417.                
  418.             else if(ballid == BLACK)
  419.                 Game[BlackInHole] = true;
  420.  
  421.             break;
  422.         }
  423.     }
  424.     if(ballid != WHITE && ballid != BLACK)
  425.     {
  426.         new str[80];
  427.         format(str,sizeof(str),"%s %s %d~n~%s %s %d",GetName(Game[Player1]),Char[Player[Game[Player1]][BBall]],Player[Game[Player1]][Points], GetName(Game[Player2]),Char[Player[Game[Player2]][BBall]],Player[Game[Player2]][Points]);
  428.         TextDrawSetString(Player[Game[Player1]][T3],str);
  429.         TextDrawSetString(Player[Game[Player2]][T3],str);
  430.         TextDrawShowForPlayer(Game[Player1],Player[Game[Player1]][T3]);
  431.         TextDrawShowForPlayer(Game[Player2],Player[Game[Player2]][T3]);
  432.     }
  433. }
  434.  
  435. public BallProperties()
  436. {
  437.     for(new i = 0; i < 16; i++)
  438.     {
  439.         if(Ball[i][speed] > 0.1)
  440.         {
  441.             Ball[i][speed] = Ball[i][speed] / 1.4;
  442.             SetObjectSpeed(i,Ball[i][speed]);
  443.         }
  444.         else
  445.         {
  446.             Ball[i][speed] = 0;
  447.             StopObject(Ball[i][ObjID]);
  448.                
  449.             if(CheckAllBalls() == 1)
  450.             {
  451.                 KillTimer(Game[Timer]);
  452.                 KillTimer(Game[Timer2]);
  453.                
  454.                 if(Game[LastBall] != - 1)
  455.                 {
  456.                     if(Game[LastBall] <= 6) //CALA
  457.                     {
  458.                         if(Player[Game[Player1]][BBall] == FULL_BALL)
  459.                         {
  460.                             Player[Game[Player1]][Turn] = true;
  461.                             Player[Game[Player2]][Turn] = false;
  462.                         }
  463.                         else if(Player[Game[Player2]][BBall] == FULL_BALL)
  464.                         {
  465.                             Player[Game[Player1]][Turn] = false;
  466.                             Player[Game[Player2]][Turn] = true;
  467.                         }
  468.                     }
  469.                     else if(6 < Game[LastBall] <= 13) //POLOWKA
  470.                     {
  471.                         if(Player[Game[Player1]][BBall] == HALF_BALL)
  472.                         {
  473.                             Player[Game[Player1]][Turn] = true;
  474.                             Player[Game[Player2]][Turn] = false;
  475.                         }
  476.                         else if(Player[Game[Player2]][BBall] == HALF_BALL)
  477.                         {
  478.                             Player[Game[Player1]][Turn] = false;
  479.                             Player[Game[Player2]][Turn] = true;
  480.                         }
  481.                     }
  482.                 }
  483.                 else //Jezeli zadna bila nie wpadla
  484.                 {
  485.                     if(Player[Game[Player1]][Turn] == true)
  486.                     {
  487.                         Player[Game[Player1]][Turn] = false;
  488.                         Player[Game[Player2]][Turn] = true;
  489.                     }
  490.                     else if(Player[Game[Player2]][Turn] == true)
  491.                     {
  492.                         Player[Game[Player1]][Turn] = true;
  493.                         Player[Game[Player2]][Turn] = false;
  494.                     }
  495.                 }
  496.                
  497.                 TextDrawSetString(Player[Game[Player1]][T6],"Kolejka");
  498.                 TextDrawSetString(Player[Game[Player2]][T6],"Kolejka");
  499.                 TextDrawShowForPlayer(Game[Player1],Player[Game[Player1]][T6]);
  500.                 TextDrawShowForPlayer(Game[Player2],Player[Game[Player2]][T6]);
  501.                
  502.                 if(Game[BlackInHole] == false)
  503.                 {
  504.                     if(Game[WhiteInHole] == false)
  505.                     {
  506.                         if(Player[Game[Player1]][Turn] == true)
  507.                         {
  508.                             TextDrawSetString(Player[Game[Player1]][T5],GetName(Game[Player1]));
  509.                             TextDrawSetString(Player[Game[Player2]][T5],GetName(Game[Player1]));
  510.                         }
  511.                         else if(Player[Game[Player2]][Turn] == true)
  512.                         {
  513.                             TextDrawSetString(Player[Game[Player1]][T5],GetName(Game[Player2]));
  514.                             TextDrawSetString(Player[Game[Player2]][T5],GetName(Game[Player2]));
  515.                         }
  516.                     }
  517.                     else
  518.                     {
  519.                         if(Player[Game[Player1]][Turn] == true)
  520.                         {
  521.                             Player[Game[Player1]][Turn] = false;
  522.                             Player[Game[Player2]][Turn] = true;
  523.                             TextDrawSetString(Player[Game[Player1]][T5],GetName(Game[Player2]));
  524.                             TextDrawSetString(Player[Game[Player2]][T5],GetName(Game[Player2]));
  525.                         }
  526.                         else if(Player[Game[Player2]][Turn] == true)
  527.                         {
  528.                             Player[Game[Player1]][Turn] = true;
  529.                             Player[Game[Player2]][Turn] = false;
  530.                             TextDrawSetString(Player[Game[Player1]][T5],GetName(Game[Player1]));
  531.                             TextDrawSetString(Player[Game[Player2]][T5],GetName(Game[Player1]));
  532.                         }
  533.                         Game[WhiteInHole] = false;
  534.                         ShowMessage(Game[Player1],"Pool","Fell white ball");
  535.                         ShowMessage(Game[Player2],"Pool","Fell white ball");
  536.                     }
  537.                     TextDrawShowForPlayer(Game[Player1],Player[Game[Player1]][T5]);
  538.                     TextDrawShowForPlayer(Game[Player2],Player[Game[Player2]][T5]);
  539.                 }
  540.                 else
  541.                 {
  542.                     Game[Waiting] = true;
  543.  
  544.                     Player[Game[Player1]][Sighting] = false;
  545.                     Player[Game[Player2]][Sighting] = false;
  546.                     TextDrawHideForPlayer(Game[Player2],Player[Game[Player2]][T1]);
  547.                     TextDrawHideForPlayer(Game[Player2],Player[Game[Player2]][T2]);
  548.  
  549.                     TextDrawSetString(Player[Game[Player1]][T4],"Gameplay");
  550.                     TextDrawSetString(Player[Game[Player2]][T4],"Gameplay");
  551.                     TextDrawShowForPlayer(Game[Player1],Player[Game[Player1]][T4]);
  552.                     TextDrawShowForPlayer(Game[Player2],Player[Game[Player2]][T4]);
  553.  
  554.                     TextDrawSetString(Player[Game[Player1]][T3],"Fell black ball");
  555.                     TextDrawSetString(Player[Game[Player2]][T3],"Fell black ball");
  556.                     TextDrawShowForPlayer(Game[Player1],Player[Game[Player1]][T3]);
  557.                     TextDrawShowForPlayer(Game[Player2],Player[Game[Player2]][T3]);
  558.  
  559.                     TextDrawSetString(Player[Game[Player1]][T6],"Wins");
  560.                     TextDrawSetString(Player[Game[Player2]][T6],"Wins");
  561.                     TextDrawShowForPlayer(Game[Player1],Player[Game[Player1]][T6]);
  562.                     TextDrawShowForPlayer(Game[Player2],Player[Game[Player2]][T6]);
  563.                     if(Player[Game[Player1]][Points] == 0 || Player[Game[Player2]][Points] == 0)
  564.                     {
  565.                         if(Player[Game[Player1]][Turn] == true)
  566.                         {
  567.                             TextDrawSetString(Player[Game[Player1]][T5],GetName(Game[Player1]));
  568.                             TextDrawSetString(Player[Game[Player2]][T5],GetName(Game[Player1]));
  569.                         }
  570.                         else if(Player[Game[Player2]][Turn] == true)
  571.                         {
  572.                             TextDrawSetString(Player[Game[Player1]][T5],GetName(Game[Player2]));
  573.                             TextDrawSetString(Player[Game[Player2]][T5],GetName(Game[Player2]));
  574.                         }
  575.                     }
  576.                     else
  577.                     {
  578.                         if(Player[Game[Player1]][Turn] == true)
  579.                         {
  580.                             TextDrawSetString(Player[Game[Player1]][T5],GetName(Game[Player2]));
  581.                             TextDrawSetString(Player[Game[Player2]][T5],GetName(Game[Player2]));
  582.                         }
  583.                         else if(Player[Game[Player2]][Turn] == true)
  584.                         {
  585.                             TextDrawSetString(Player[Game[Player1]][T5],GetName(Game[Player1]));
  586.                             TextDrawSetString(Player[Game[Player2]][T5],GetName(Game[Player1]));
  587.                         }
  588.                     }
  589.                    
  590.                     Player[Game[Player1]][Turn] = false;
  591.                     Player[Game[Player2]][Turn] = false;
  592.                     Game[BlackInHole] = false;
  593.  
  594.                     TextDrawShowForPlayer(Game[Player1],Player[Game[Player1]][T5]);
  595.                     TextDrawShowForPlayer(Game[Player2],Player[Game[Player1]][T5]);
  596.  
  597.                     SetTimer("OnEndBilliard",10000,0);
  598.                 }
  599.                 Game[LastBall] = -1;
  600.                 break;
  601.             }
  602.         }
  603.     }
  604. }
  605.  
  606. public OnTimer()
  607. {
  608.     new temp[2];
  609.     for(new i = 0; i < 16; i++)
  610.     {
  611.         for(new j = 0; j < 16; j++)
  612.         {
  613.             if(i != j)
  614.             {
  615.                 if(GetVectorDistance_OB(Ball[i][ObjID],Ball[j][ObjID]) < 0.09)
  616.                 {
  617.                     if(Ball[i][TouchID] != j && Ball[j][TouchID] != i)
  618.                     {
  619.                         if(Ball[i][speed] > 0.1)
  620.                         {
  621.                             new Float:pos[6];
  622.                             GetObjectPos(Ball[i][ObjID],pos[0],pos[1],pos[2]);
  623.                             GetObjectPos(Ball[j][ObjID],pos[3],pos[4],pos[5]);
  624.                    
  625.                             Ball[j][TouchID] = i;
  626.                             Ball[i][TouchID] = j;
  627.                             temp[0] = i;
  628.                             temp[1] = j;
  629.                    
  630.                             Ball[j][a] = GetVectorAngle(Ball[i][ObjID],Ball[j][ObjID]);
  631.                    
  632.                             Ball[j][speed] = Ball[i][speed];
  633.                             if(Ball[i][speed] < 3)
  634.                             {
  635.                                 Ball[i][a] = GetVectorAngle(Ball[i][ObjID],Ball[j][ObjID]) + 180;
  636.                                 Ball[i][speed] = Ball[i][speed] / 1.15; //1.5
  637.                                 pos[0] += 5 * floatsin(-Ball[i][a],degrees); //(Ball[i][speed] / 1.1)
  638.                                 pos[1] += 5 * floatcos(-Ball[i][a],degrees); //(Ball[i][speed] / 1.1)
  639.                                 MoveObject(Ball[i][ObjID],pos[0],pos[1],pos[2],Ball[i][speed]);
  640.                             }
  641.                             else if(Ball[i][speed] >= 3)
  642.                             {
  643.                                 Ball[i][speed] = Ball[i][speed] / 1.15; //2
  644.                                 pos[0] += 5 * floatsin(-Ball[i][a],degrees); //Ball[i][speed] / 2) + random(25)
  645.                                 pos[1] += 5 * floatcos(-Ball[i][a],degrees); //Ball[i][speed] / 2) - random(25)
  646.                                 MoveObject(Ball[i][ObjID],pos[0],pos[1],pos[2],Ball[i][speed]);
  647.                             }
  648.  
  649.                             Ball[j][speed] = Ball[j][speed] / 1.1;
  650.                             pos[3] += 5 * floatsin(-Ball[j][a],degrees); //Ball[j][speed] / 1.3
  651.                             pos[4] += 5 * floatcos(-Ball[j][a],degrees); //Ball[j][speed] / 1.3
  652.                             MoveObject(Ball[j][ObjID],pos[3],pos[4],pos[5],Ball[j][speed]);
  653.                            
  654.                             Ball[i][x] = pos[0];
  655.                             Ball[i][y] = pos[1];
  656.                             Ball[i][z] = Ball[WHITE][z];
  657.                             Ball[j][x] = pos[3];
  658.                             Ball[j][y] = pos[4];
  659.                             Ball[j][z] = Ball[WHITE][z];
  660.                         }
  661.                     }
  662.                 }
  663.             }
  664.         }
  665.         new Float:pos[5];
  666.         GetObjectPos(Ball[i][ObjID],pos[0],pos[1],pos[2]);
  667.         for(new h = 0; h < 6; h++)
  668.         {
  669.             if(PointInLong(0.04,pos[0],pos[1],Hole[h][0],Hole[h][1],Hole[h][2],Hole[h][3]) == 1)
  670.             {
  671.                 CallRemoteFunction("OnBallInHole","d",i);
  672.                 break;
  673.             }
  674.         }
  675.         for(new k = 0; k < POLYGONS; k++)
  676.         {
  677.             if(PointInPolygon(pos[0],pos[1],k) == 1)
  678.             {
  679.                 new Float:tmp[4];
  680.                 tmp[0] = pos[0];
  681.                 tmp[1] = pos[1];
  682.                 tmp[2] = pos[0];
  683.                 tmp[3] = pos[1];
  684.                 pos[0] += floatsin(-Ball[i][a] + 180,degrees) / 5;
  685.                 pos[1] += floatcos(-Ball[i][a] + 180,degrees) / 5;
  686.                
  687.                 new Float:angle[2];
  688.                 angle[0] = GetVectorAngle_XY(tmp[0],tmp[1],Polygon[k][0][x],Polygon[k][0][y]);
  689.                 if(angle[0] > 0)
  690.                 {
  691.                     angle[1] = angle[0] + 180;
  692.                     if(angle[1] > 360)
  693.                         angle[1] = angle[1] - 360;
  694.                 }
  695.                 else
  696.                 {
  697.                     angle[1] = GetVectorAngle_XY(tmp[0],tmp[1],Polygon[k][0][x],Polygon[k][0][y]);
  698.                     angle[0] = angle[1] + 180;
  699.                     if(angle[0] > 360)
  700.                         angle[0] = angle[0] - 360;
  701.  
  702.                     if(angle[1] < 0)
  703.                         angle[1] = angle[0] + 180;
  704.                 }
  705.                
  706.                 new Float:stop = Ball[i][a] + 180;
  707.                 if(stop > 360)
  708.                     stop = stop - 360;
  709.                    
  710.                 if(angle[0] < angle[1])
  711.                 {
  712.                     if(angle[0] < stop < angle[1])
  713.                         angle[0] = angle[0] + 90;
  714.  
  715.                     else if(angle[1] < stop < 360 || 0 < stop < angle[0])
  716.                     {
  717.                         angle[0] = angle[1] + 90;
  718.                         if(angle[0] > 360)
  719.                             angle[0] = angle[0] - 360;
  720.                     }
  721.                 }
  722.                 else if(angle[0] > angle[1])
  723.                 {
  724.                     if(angle[0] > stop > angle[1])
  725.                         angle[0] = angle[1] + 90;
  726.  
  727.                     else if(angle[1] > stop > 0)
  728.                     {
  729.                         angle[0] = angle[1] - 90;
  730.                         if(angle[0] > 360)
  731.                             angle[0] = angle[0] - 360;
  732.                     }
  733.                     else if(360 > stop > angle[0])
  734.                     {
  735.                         angle[0] = angle[0] + 90;
  736.                         if(angle[0] > 360)
  737.                             angle[0] = angle[0] - 360;
  738.                     }
  739.                 }
  740.                
  741.                 new Float:sraka[2];
  742.                 sraka[0] = tmp[0];
  743.                 sraka[1] = tmp[1];
  744.                
  745.                 sraka[0] += floatsin(-angle[0],degrees) / 50;
  746.                 sraka[1] += floatcos(-angle[0],degrees) / 50;
  747.                
  748.                 tmp[0] += floatsin(-angle[0],degrees) / 7;
  749.                 tmp[1] += floatcos(-angle[0],degrees) / 7;
  750.                 SetObjectPos(Ball[i][ObjID],sraka[0],sraka[1],13.199293525696);
  751.                
  752.                 new Float:ang;
  753.                 new Float:dist;
  754.                 ang = GetVectorAngle_XY(pos[0],pos[1],tmp[0],tmp[1]);
  755.                 dist = GetDistance(pos[0],pos[1],tmp[0],tmp[1]);
  756.                
  757.                 pos[0] += (dist * floatsin(-ang,degrees)) * 2;
  758.                 pos[1] += (dist * floatcos(-ang,degrees)) * 2;
  759.                
  760.                
  761.                 new Float:ang2;
  762.                 ang2 = GetVectorAngle_XY(pos[0],pos[1],tmp[2],tmp[3]);
  763.                 ang2 = ang2 + 180;
  764.                
  765.                 tmp[2] += 5 * floatsin(-ang2,degrees);
  766.                 tmp[3] += 5 * floatcos(-ang2,degrees);
  767.                
  768.                 MoveObject(Ball[i][ObjID],tmp[2],tmp[3],13.199293525696,Ball[i][speed]);
  769.                 Ball[i][x] = tmp[2];
  770.                 Ball[i][y] = tmp[3];
  771.                 if(ang2 > 360)
  772.                     ang2 = ang2 - 360;
  773.  
  774.                 Ball[i][a] = ang2;
  775.                 break;
  776.             }
  777.         }
  778.     }
  779.     Ball[temp[0]][TouchID] = -1;
  780.     Ball[temp[1]][TouchID] = -1;
  781. }
  782.  
  783. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  784. {
  785.     if(newkeys & 128)
  786.     {
  787.         if(Player[playerid][Sighting] == false && CheckAllBalls() == 1 && Game[Running] == true && Player[playerid][Turn] == true)
  788.         {
  789.             new Float:dist = GetVectorDistance_PL(playerid,Ball[WHITE][ObjID]);
  790.             if(GetPlayerWeapon(playerid) == 7 && dist < 1.6)
  791.             {
  792.                 new Float:pos[7];
  793.                 GetObjectPos(Ball[WHITE][ObjID],pos[0],pos[1],pos[2]);
  794.                 GetPlayerPos(playerid,pos[3],pos[4],pos[5]);
  795.                 pos[6] = GetVectorAngle_XY(pos[3],pos[4],pos[0],pos[1]);
  796.                 Player[playerid][Sighting] = true;
  797.                 Player[playerid][AfterSighting] = true;
  798.                 Player[playerid][SelectLR] = 0;
  799.                 Player[playerid][SelectUD] = 5;
  800.                
  801.                 TextDrawSetString(Player[playerid][T2],"Predkosc");
  802.                 TextDrawShowForPlayer(playerid,Player[playerid][T2]);
  803.                
  804.                 TextDrawSetString(Player[playerid][T1],"60 cm~w~/s");
  805.                 TextDrawShowForPlayer(playerid,Player[playerid][T1]);
  806.                
  807.                 if(0.9 <= dist <= 1.2)
  808.                 {
  809.                     pos[3] += floatsin(-pos[6] + 180,degrees) * 0.3;
  810.                     pos[4] += floatcos(-pos[6] + 180,degrees) * 0.3;
  811.                 }
  812.                 else if(dist < 0.9)
  813.                 {
  814.                     pos[3] += floatsin(-pos[6] + 180,degrees) * 0.6;
  815.                     pos[4] += floatcos(-pos[6] + 180,degrees) * 0.6;
  816.                 }
  817.                 SetPlayerPos(playerid,pos[3],pos[4],pos[5]);
  818.                 SetPlayerFacingAngle(playerid,pos[6] - 2.2);
  819.                 Player[playerid][a] = pos[6] - 2.2;
  820.                
  821.                 pos[3] += floatsin(-pos[6] - 10,degrees) * 0.2;
  822.                 pos[4] += floatcos(-pos[6] - 10,degrees) * 0.2;
  823.                 SetPlayerCameraPos(playerid,pos[3],pos[4],pos[2] + 0.5);
  824.                 SetPlayerCameraLookAt(playerid,pos[0],pos[1],pos[2]);
  825.                 ApplyAnimation(playerid,"POOL","POOL_Med_Start",1,0,0,0,1,0,1);
  826.             }
  827.         }
  828.     }
  829.     else if(oldkeys & 128)
  830.     {
  831.         if(Player[playerid][AfterSighting] == true)
  832.         {
  833.             SetCameraBehindPlayer(playerid);
  834.             ApplyAnimation(playerid,"POOL","POOL_Med_Shot_O",4.1,0,1,1,1,1,1);
  835.            
  836.             TextDrawHideForPlayer(playerid,Player[playerid][T1]);
  837.             TextDrawHideForPlayer(playerid,Player[playerid][T2]);
  838.             Player[playerid][AfterSighting] = false;
  839.  
  840.             if(Player[playerid][Sighting] == true)
  841.                 Player[playerid][Sighting] = false;
  842.         }
  843.     }
  844.    
  845.     if(newkeys & KEY_FIRE)
  846.     {
  847.         if(Player[playerid][Sighting] == true)
  848.         {
  849.             new Float:pos[7];
  850.             GetObjectPos(Ball[WHITE][ObjID],pos[0],pos[1],pos[2]);
  851.            
  852.             Game[Timer] = SetTimer("OnTimer",10,1);
  853.             Game[Timer2] = SetTimer("BallProperties",200,1);
  854.            
  855.             TextDrawHideForPlayer(playerid,Player[playerid][T1]);
  856.             TextDrawHideForPlayer(playerid,Player[playerid][T2]);
  857.             Player[playerid][Sighting] = false;
  858.            
  859.             if(Player[playerid][a] > 360)
  860.                 Player[playerid][a] = Player[playerid][a] - 360;
  861.  
  862.             else if(Player[playerid][a] < 0)
  863.                 Player[playerid][a] = 360 + Player[playerid][a];
  864.            
  865.             Ball[WHITE][a] = Player[playerid][a];
  866.                    
  867.             pos[0] += 5 * floatsin(-Ball[WHITE][a],degrees);
  868.             pos[1] += 5 * floatcos(-Ball[WHITE][a],degrees);
  869.             Ball[WHITE][x] = pos[0];
  870.             Ball[WHITE][y] = pos[1];
  871.             Ball[WHITE][z] = pos[2];
  872.             Ball[WHITE][speed] = Player[playerid][SelectUD] / 1.5;
  873.            
  874.             new Float:pp[4];
  875.             GetPlayerPos(playerid,pp[0],pp[1],pp[2]);
  876.             GetPlayerFacingAngle(playerid,pp[3]);
  877.             pp[0] += floatsin(-pp[3] - 90,degrees) * 0.3;
  878.             pp[1] += floatcos(-pp[3] - 90,degrees) * 0.3;
  879.             SetPlayerPos(playerid,pp[0],pp[1],pp[2]);
  880.            
  881.             SetPlayerCameraPos(playerid,2496.4970703125, -1671.1528320313, 12.275947036743 + 5);
  882.             SetPlayerCameraLookAt(playerid,2496.4970703125, -1671.1528320313, 12.275947036743);
  883.             ApplyAnimation(playerid,"POOL","POOL_Med_Shot",4.1,0,1,1,1,1,1);
  884.         }
  885.     }
  886.     return 1;
  887. }
  888.  
  889. public OnPlayerUpdate(playerid)
  890. {
  891.     if(Player[playerid][Sighting] == true)
  892.     {
  893.         if(GetVectorDistance_PL(playerid,Ball[WHITE][ObjID]) < 1.6)
  894.         {
  895.             new key[3];
  896.             new Float:pos[3];
  897.             GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
  898.             GetPlayerKeys(playerid,key[0],key[1],key[2]);
  899.             if(key[2] == KEY_LEFT && Player[playerid][SelectLR] < 10)
  900.             {
  901.                 new Float:angle;
  902.                 new Float:angXY;
  903.                 GetPlayerFacingAngle(playerid,angle);
  904.                
  905.                 Player[playerid][SelectLR]++;
  906.            
  907.                 pos[0] += floatsin(-angle - 90,degrees) / 20;
  908.                 pos[1] += floatcos(-angle - 90,degrees) / 20;
  909.            
  910.                 new Float:dist = GetVectorDistance_PL(playerid,Ball[WHITE][ObjID]);
  911.                 new Float:pp[3];
  912.                 GetObjectPos(Ball[WHITE][ObjID],pp[0],pp[1],pp[2]);
  913.                 angXY = GetVectorAngle_XY(pos[0],pos[1],pp[0],pp[1]);
  914.            
  915.                 if(0.9 <= dist <= 1.2)
  916.                 {
  917.                     pos[0] += floatsin(-angXY + 180,degrees) * 0.3;
  918.                     pos[1] += floatcos(-angXY + 180,degrees) * 0.3;
  919.                 }
  920.                 else if(dist < 0.9)
  921.                 {
  922.                     pos[0] += floatsin(-angXY + 180,degrees) * 0.6;
  923.                     pos[1] += floatcos(-angXY + 180,degrees) * 0.6;
  924.                 }
  925.                 SetPlayerPos(playerid,pos[0],pos[1],pos[2]);
  926.                 SetPlayerFacingAngle(playerid,angXY - 2.2);
  927.                 Player[playerid][a] = angXY - 2.2;
  928.            
  929.                 pos[0] += floatsin(-angXY - 10,degrees) * 0.2;
  930.                 pos[1] += floatcos(-angXY - 10,degrees) * 0.2;
  931.                 SetPlayerCameraPos(playerid,pos[0],pos[1],pp[2] + 0.5);
  932.                 SetPlayerCameraLookAt(playerid,pp[0],pp[1],pp[2]);
  933.                 ApplyAnimation(playerid,"POOL","POOL_Med_Start",1,0,0,0,1,0,1);
  934.             }
  935.             else if(key[2] == KEY_RIGHT && Player[playerid][SelectLR] > -10)
  936.             {
  937.                 new Float:angle;
  938.                 new Float:angXY;
  939.                 GetPlayerFacingAngle(playerid,angle);
  940.  
  941.                 pos[0] += floatsin(-angle + 90,degrees) / 20;
  942.                 pos[1] += floatcos(-angle + 90,degrees) / 20;
  943.                
  944.                 Player[playerid][SelectLR]--;
  945.  
  946.                 new Float:dist = GetVectorDistance_PL(playerid,Ball[WHITE][ObjID]);
  947.                 new Float:pp[3];
  948.                 GetObjectPos(Ball[WHITE][ObjID],pp[0],pp[1],pp[2]);
  949.                 angXY = GetVectorAngle_XY(pos[0],pos[1],pp[0],pp[1]);
  950.            
  951.                 if(0.9 <= dist <= 1.2)
  952.                 {
  953.                     pos[0] += floatsin(-angXY + 180,degrees) * 0.3;
  954.                     pos[1] += floatcos(-angXY + 180,degrees) * 0.3;
  955.                 }
  956.                 else if(dist < 0.9)
  957.                 {
  958.                     pos[0] += floatsin(-angXY + 180,degrees) * 0.6;
  959.                     pos[1] += floatcos(-angXY + 180,degrees) * 0.6;
  960.                 }
  961.                 SetPlayerPos(playerid,pos[0],pos[1],pos[2]);
  962.                 SetPlayerFacingAngle(playerid,angXY - 2.2);
  963.                 Player[playerid][a] = angXY - 2.2;
  964.  
  965.                 pos[0] += floatsin(-angXY - 10,degrees) * 0.2;
  966.                 pos[1] += floatcos(-angXY - 10,degrees) * 0.2;
  967.                 SetPlayerCameraPos(playerid,pos[0],pos[1],pp[2] + 0.5);
  968.                 SetPlayerCameraLookAt(playerid,pp[0],pp[1],pp[2]);
  969.                 ApplyAnimation(playerid,"POOL","POOL_Med_Start",1,0,0,0,1,0,1);
  970.             }
  971.             else if(key[1] == KEY_UP || key[1] == KEY_DOWN)
  972.             {
  973.                 if(key[1] == KEY_UP && 0 < Player[playerid][SelectUD] < 8)
  974.                 {
  975.                     Player[playerid][SelectUD]++;
  976.                    
  977.                     if(Player[playerid][TDTimer] != 0)
  978.                     {
  979.                         KillTimer(Player[playerid][TDTimer]);
  980.                         Player[playerid][TDTimer] = 0;
  981.                     }
  982.  
  983.                     TextDrawSetString(Player[playerid][T2],"Predkosc");
  984.                     TextDrawShowForPlayer(playerid,Player[playerid][T2]);
  985.  
  986.                     new str[20];
  987.                     new length = (Player[playerid][SelectUD] / 2) * 30;
  988.                    
  989.                     if(length == 0)
  990.                         length = 15;
  991.                        
  992.                     format(str,sizeof(str),"%d cm~w~/s",length);
  993.                     TextDrawSetString(Player[playerid][T1],str);
  994.                     TextDrawShowForPlayer(playerid,Player[playerid][T1]);
  995.                 }
  996.                 else if(key[1] == KEY_DOWN && 1 < Player[playerid][SelectUD] <= 8)
  997.                 {
  998.                     Player[playerid][SelectUD]--;
  999.                    
  1000.                     if(Player[playerid][TDTimer] != 0)
  1001.                     {
  1002.                         KillTimer(Player[playerid][TDTimer]);
  1003.                         Player[playerid][TDTimer] = 0;
  1004.                     }
  1005.  
  1006.                     TextDrawSetString(Player[playerid][T2],"Predkosc");
  1007.                     TextDrawShowForPlayer(playerid,Player[playerid][T2]);
  1008.  
  1009.                     new str[20];
  1010.                     new length = (Player[playerid][SelectUD] / 2) * 30;
  1011.                    
  1012.                     if(length == 0)
  1013.                         length = 15;
  1014.                        
  1015.                     format(str,sizeof(str),"%d cm~w~/s",length);
  1016.                     TextDrawSetString(Player[playerid][T1],str);
  1017.                     TextDrawShowForPlayer(playerid,Player[playerid][T1]);
  1018.                 }
  1019.             }
  1020.         }
  1021.     }
  1022.     return 1;
  1023. }
  1024.  
  1025. public OnShowedTD(playerid)
  1026. {
  1027.     TextDrawHideForPlayer(playerid,Player[playerid][T1]);
  1028.     TextDrawHideForPlayer(playerid,Player[playerid][T2]);
  1029.     Player[playerid][TDTimer] = 0;
  1030. }
  1031.  
  1032. stock SetObjectSpeed(sysobj, Float:speedy)
  1033. {
  1034.     MoveObject(Ball[sysobj][ObjID],Ball[sysobj][x],Ball[sysobj][y],Ball[sysobj][z],speedy);
  1035. }
  1036.  
  1037. stock CheckAllBalls()
  1038. {
  1039.     for(new i = 0; i < 16; i++)
  1040.     {
  1041.         if(Ball[i][speed] != 0)
  1042.             return 0;
  1043.         else if(i == 15)
  1044.         {
  1045.             if(Ball[i][speed] == 0)
  1046.                 return 1;
  1047.         }
  1048.     }
  1049.     return 0;
  1050. }
  1051.  
  1052. stock Float:GetVectorAngle(obj, obj2)
  1053. {
  1054.     new Float:vector[3];
  1055.     new Float:pos[6];
  1056.     GetObjectPos(obj,pos[0],pos[1],pos[2]);
  1057.     GetObjectPos(obj2,pos[3],pos[4],pos[5]);
  1058.     vector[0] = pos[3] - pos[0];
  1059.     vector[1] = pos[4] - pos[1];
  1060.     vector[2] = atan(-(vector[0] / vector[1]));
  1061.     if(vector[1] < 0)
  1062.         vector[2] = vector[2] >= 180 ? vector[2] - 180 : vector[2] + 180;
  1063.        
  1064.     return vector[2];
  1065. }
  1066.  
  1067. stock Float:GetVectorAngle_XY(Float:fx, Float:fy, Float:tx, Float:ty)
  1068. {
  1069.     new Float:vector[3];
  1070.     vector[0] = tx - fx;
  1071.     vector[1] = ty - fy;
  1072.     vector[2] = atan(-(vector[0] / vector[1]));
  1073.     if(vector[1] < 0)
  1074.         vector[2] = vector[2] >= 180 ? vector[2] - 180 : vector[2] + 180;
  1075.  
  1076.     return vector[2];
  1077. }
  1078.  
  1079. stock Float:GetVectorDistance_PL(playerid, obj)
  1080. {
  1081.     new Float:pos[6];
  1082.     GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
  1083.     GetObjectPos(obj,pos[3],pos[4],pos[5]);
  1084.     return floatsqroot(floatpower(pos[3] - pos[0],2) + floatpower(pos[4] - pos[1],2) + floatpower(pos[5] - pos[2],2));
  1085. }
  1086.  
  1087. stock Float:GetVectorDistance_OB(obj, obj2)
  1088. {
  1089.     new Float:pos[6];
  1090.     GetObjectPos(obj,pos[0],pos[1],pos[2]);
  1091.     GetObjectPos(obj2,pos[3],pos[4],pos[5]);
  1092.     return floatsqroot(floatpower(pos[3] - pos[0],2) + floatpower(pos[4] - pos[1],2) + floatpower(pos[5] - pos[2],2));
  1093. }
  1094.  
  1095. stock Float:GetDistance(Float:fx, Float:fy, Float:tx, Float:ty)
  1096. {
  1097.     return floatsqroot(floatpower(tx - fx,2) + floatpower(ty - fy,2));
  1098. }
  1099.  
  1100. stock Float:GetDistancePointToLong(Float:px,Float:py, Float:px1,Float:py1, Float:px2,Float:py2)
  1101. {
  1102.     new Float:vec[3];
  1103.     vec[0] = GetDistance(px1,py1,px2,py2);
  1104.     if((vec[1] = GetDistance(px,py,px1,py1)) < vec[0] && (vec[2] = GetDistance(px,py,px2,py2)) < vec[0])
  1105.     {
  1106.         new Float:opt[2];
  1107.         opt[0] = (vec[0] + vec[1] + vec[2]) / 2;
  1108.         opt[1] = floatsqroot(opt[0] * (opt[0] - vec[0]) * (opt[0] - vec[1]) * (opt[0] - vec[2]));
  1109.         opt[1] = ((opt[1] * 2) / vec[0]);
  1110.         return opt[1];
  1111.     }
  1112.     return 0.0;
  1113. }
  1114.  
  1115.  
  1116. stock PointInLong(Float:size, Float:px,Float:py, Float:px1,Float:py1, Float:px2,Float:py2)
  1117. {
  1118.     new Float:vec[3];
  1119.     vec[0] = GetDistance(px1,py1,px2,py2);
  1120.     if((vec[1] = GetDistance(px,py,px1,py1)) < vec[0] && (vec[2] = GetDistance(px,py,px2,py2)) < vec[0])
  1121.     {
  1122.         new Float:opt[2];
  1123.         opt[0] = (vec[0] + vec[1] + vec[2]) / 2;
  1124.         opt[1] = floatsqroot(opt[0] * (opt[0] - vec[0]) * (opt[0] - vec[1]) * (opt[0] - vec[2]));
  1125.         opt[1] = ((opt[1] * 2) / vec[0]) * 2;
  1126.         if(opt[1] < size)
  1127.             return 1;
  1128.     }
  1129.     return 0;
  1130. }
  1131.  
  1132. stock CreatePolygon(Float:px1,Float:py1, Float:px2,Float:py2)
  1133. {
  1134.     for(new i = 0; i < POLYGONS; i++)
  1135.     {
  1136.         if(PolyResult[i][Progress] == false)
  1137.         {
  1138.             PolyResult[i][Progress] = true;
  1139.             PolyResult[i][Vertices] = 2;
  1140.  
  1141.             Polygon[i][0][x] = px1;
  1142.             Polygon[i][0][y] = py1;
  1143.  
  1144.             Polygon[i][1][x] = px2;
  1145.             Polygon[i][1][y] = py2;
  1146.             return i;
  1147.         }
  1148.     }
  1149.     return 0;
  1150. }
  1151.  
  1152. stock ShowMessage(playerid, message1[], message2[])
  1153. {
  1154.     if(Player[playerid][TDTimer] != 0)
  1155.     {
  1156.         KillTimer(Player[playerid][TDTimer]);
  1157.         Player[playerid][TDTimer] = 0;
  1158.     }
  1159.    
  1160.     TextDrawHideForPlayer(playerid,Player[playerid][T1]);
  1161.     TextDrawHideForPlayer(playerid,Player[playerid][T2]);
  1162.     TextDrawSetString(Player[playerid][T2],message1);
  1163.     TextDrawSetString(Player[playerid][T1],message2);
  1164.     TextDrawShowForPlayer(playerid,Player[playerid][T1]);
  1165.     TextDrawShowForPlayer(playerid,Player[playerid][T2]);
  1166.    
  1167.     new space;
  1168.     for(new i = 0; i < strlen(message2); i++)
  1169.     {
  1170.         if(message2[i] == ' ')
  1171.             space++;
  1172.     }
  1173.    
  1174.     if(space != 0)
  1175.         Player[playerid][TDTimer] = SetTimerEx("OnShowedTD",space * 3000,0,"d",playerid);
  1176.        
  1177.     else
  1178.         Player[playerid][TDTimer] = SetTimerEx("OnShowedTD",3000,0,"d",playerid);
  1179. }
  1180.  
  1181. stock PointInPolygon(Float:px, Float:py, polygonid)
  1182. {
  1183.     if(PolyResult[polygonid][Progress] == true)
  1184.     {
  1185.         for(new i = 0; i < PolyResult[polygonid][Vertices]; i++)
  1186.         {
  1187.             if(i == PolyResult[polygonid][Vertices] - 1)
  1188.             {
  1189.                 if(PointInLong(0.06,px,py,Polygon[polygonid][i][x],Polygon[polygonid][i][y],Polygon[polygonid][0][x],Polygon[polygonid][0][y]) == 1)
  1190.                     return 1;
  1191.             }
  1192.             else
  1193.             {
  1194.                 if(PointInLong(0.06,px,py,Polygon[polygonid][i][x],Polygon[polygonid][i][y],Polygon[polygonid][i + 1][x],Polygon[polygonid][i + 1][y]) == 1)
  1195.                     return 1;
  1196.             }
  1197.         }
  1198.     }
  1199.     return 0;
  1200. }
  1201.  
  1202. stock GetName(playerid)
  1203. {
  1204.     new name[24];
  1205.     GetPlayerName(playerid,name,24);
  1206.     return name;
  1207. }
  1208.  
  1209. stock Release()
  1210. {
  1211.     for(new i = 0; i < 20; i++)
  1212.     {
  1213.         TextDrawHideForPlayer(i,Player[i][T1]);
  1214.         TextDrawHideForPlayer(i,Player[i][T2]);
  1215.         TextDrawHideForPlayer(i,Player[i][T3]);
  1216.         TextDrawHideForPlayer(i,Player[i][T4]);
  1217.         TextDrawHideForPlayer(i,Player[i][T5]);
  1218.         TextDrawHideForPlayer(i,Player[i][T6]);
  1219.         TextDrawDestroy(Player[i][T1]);
  1220.         TextDrawDestroy(Player[i][T2]);
  1221.         TextDrawDestroy(Player[i][T3]);
  1222.         TextDrawDestroy(Player[i][T4]);
  1223.         TextDrawDestroy(Player[i][T5]);
  1224.         TextDrawDestroy(Player[i][T6]);
  1225.     }
  1226.     if(Game[Running] == true || Game[Waiting] == true)
  1227.     {
  1228.         KillTimer(Game[Timer]);
  1229.         KillTimer(Game[Timer2]);
  1230.         for(new i = 0; i < 17; i++)
  1231.         {
  1232.             DestroyObject(Ball[i][ObjID]);
  1233.         }
  1234.     }
  1235. }
Advertisement
Add Comment
Please, Sign In to add comment