SlashPT

Mortar System

Nov 1st, 2011
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 12.87 KB | None | 0 0
  1. #define FILTERSCRIPT
  2. //==============================================================================
  3. #include <a_samp>
  4. #include <MapAndreas>
  5. #include <zcmd>
  6. #include <foreach>
  7. //==============================================================================
  8. #define INTERVAL 100 // Define timer's interval time , lower tick rates make faster movimentation while on camera screen...
  9. #define CallBack::%0(%1) forward %0 ( %1 ) ; public %0 ( %1 )
  10. #define FRONT 0
  11. #define BACK 1
  12. #define LEFT 2
  13. #define RIGHT 3
  14. //==============================================================================
  15. new
  16.     SentMortar [ MAX_PLAYERS ] = { -1 , ... } ,
  17.     Float:Coords [ 7 ] [ MAX_PLAYERS ] ,
  18.     MortarID [ MAX_OBJECTS ] [ 2 ] ,
  19.     Iterator:Mortar<MAX_PLAYERS>,
  20.     Shooting [ MAX_PLAYERS ] ,
  21.     Float:oCoords [ 3 ] ,
  22.     Text:Aim [ 11 ] ,
  23.     leftright ,
  24.     updown ,
  25.     keys ,
  26.     ii
  27. ;
  28. //==============================================================================
  29. public
  30.     OnFilterScriptInit ( )
  31. {
  32.     SetTimer ( "CheckControls" , INTERVAL , 1 ) ;
  33.     CreateTextDraws ( ) ;
  34.     return 1 ;
  35. }
  36. //==============================================================================
  37. public
  38.     OnFilterScriptExit ( )
  39. {
  40.     foreachex (Player , ii )
  41.     {
  42.         cmd_mortar ( ii , "\1" ) ;
  43.         TextDrawsForPlayer ( ii , 0 ) ;
  44.     }
  45.     for ( ii = 0 ; ii < sizeof ( Aim ) ; ii++ )
  46.     {
  47.         TextDrawDestroy ( Aim [ ii ] ) ;
  48.     }
  49.     return 1 ;
  50. }
  51. //==============================================================================
  52. public
  53.     OnPlayerDisconnect ( playerid , reason )
  54. {
  55.     if ( Shooting [ playerid ] == 1 )
  56.     {
  57.         Iter_Remove (Mortar , playerid ) ;
  58.         Shooting [ playerid ] = 0 ;
  59.     }
  60.     SentMortar [ playerid ] = -1 ;
  61.     return 1 ;
  62. }
  63. //==============================================================================
  64. public
  65.     OnPlayerCommandText ( playerid , cmdtext [ ] )
  66. {
  67.     return 0 ;
  68. }
  69. //==============================================================================
  70. public
  71.     OnPlayerKeyStateChange ( playerid , newkeys , oldkeys )
  72. {
  73.     if ( newkeys & KEY_WALK )
  74.     {
  75.         if ( SentMortar [ playerid ] == -1 )
  76.         {
  77.             SentMortar [ playerid ] = CreateObject ( 1252 , Coords [ 0 ] [ playerid ] , Coords [ 1 ] [ playerid ] , ( Coords [ 2 ] [ playerid ] + 20 ) , 90 , 0 , 0 , 200 ) ;
  78.             GetPointZPos ( Coords [ 0 ] [ playerid ] , Coords [ 1 ] [ playerid ] , Coords [ 6 ] [ playerid ] ) ;
  79.             MoveObject ( SentMortar [ playerid ] , Coords [ 0 ] [ playerid ] , Coords [ 1 ] [ playerid ] , Coords [ 6 ] [ playerid ] , 12 , 90 , 0 , 0 ) ;
  80.             MortarID [ SentMortar [ playerid ] ] [ 0 ] = 1 ;
  81.             MortarID [ SentMortar [ playerid ] ] [ 1 ] = playerid ;
  82.             SendClientMessage ( playerid , 0x0080FFFF , "> {FFFFFF}Fire in the hole !!!" ) ;
  83.         }
  84.     }
  85.     return 1 ;
  86. }
  87. //==============================================================================
  88. public
  89.     OnObjectMoved ( objectid )
  90. {
  91.     if ( MortarID [ objectid ] [ 0 ] == 1 )
  92.     {
  93.         GetObjectPos ( objectid , oCoords [ 0 ] , oCoords [ 1 ] , oCoords [ 2 ] ) ;
  94.         for ( ii = 0 ; ii < 2 ; ii++) // Making it absolutly deadly ( I think :D )
  95.         {
  96.             CreateExplosion ( oCoords [ 0 ] , oCoords [ 1 ] , oCoords [ 2 ] , 7 , 20 ) ;
  97.         }
  98.         SentMortar [ MortarID [ objectid ] [ 1 ] ] = -1 ;
  99.         MortarID [ objectid ] [ 0 ] = 0 ;
  100.         DestroyObject ( objectid ) ;
  101.     }
  102.     return 1 ;
  103. }
  104. //==============================================================================
  105. CallBack::CheckControls ( )
  106. {
  107.     foreachex (Mortar , ii )
  108.     {
  109.         GetPlayerKeys ( ii , keys , updown , leftright ) ;
  110.        
  111.         if ( updown == KEY_UP )
  112.         {
  113.             GetXY ( FRONT , Coords [ 0 ] [ ii ] , Coords [ 1 ] [ ii ] , Coords [ 3 ] [ ii ] , Coords [ 0 ] [ ii ] , Coords [ 1 ] [ ii ] ) ;
  114.             SetPlayerCameraPos ( ii , Coords [ 0 ] [ ii ] , Coords [ 1 ] [ ii ] , ( Coords [ 2 ] [ ii ] + 20 ) ) ;
  115.             SetPlayerCameraLookAt ( ii , Coords [ 0 ] [ ii ] , Coords [ 1 ] [ ii ] , Coords [ 2 ] [ ii ] ) ;
  116.             continue ;
  117.         }
  118.         else if ( updown == KEY_DOWN )
  119.         {
  120.             GetXY ( BACK , Coords [ 0 ] [ ii ] , Coords [ 1 ] [ ii ] , Coords [ 3 ] [ ii ] , Coords [ 0 ] [ ii ] , Coords [ 1 ] [ ii ] ) ;
  121.             SetPlayerCameraPos ( ii , Coords [ 0 ] [ ii ] , Coords [ 1 ] [ ii ] , ( Coords [ 2 ] [ ii ] + 20 ) ) ;
  122.             SetPlayerCameraLookAt ( ii , Coords [ 0 ] [ ii ] , Coords [ 1 ] [ ii ] , Coords [ 2 ] [ ii ] ) ;
  123.             continue ;
  124.         }
  125.         //======================================================================
  126.         if ( leftright == KEY_RIGHT )
  127.         {
  128.             GetXY ( RIGHT , Coords [ 0 ] [ ii ] , Coords [ 1 ] [ ii ] , Coords [ 3 ] [ ii ] , Coords [ 0 ] [ ii ] , Coords [ 1 ] [ ii ] ) ;
  129.             SetPlayerCameraPos ( ii , Coords [ 0 ] [ ii ] , Coords [ 1 ] [ ii ] , ( Coords [ 2 ] [ ii ] + 20 ) ) ;
  130.             SetPlayerCameraLookAt ( ii , Coords [ 0 ] [ ii ] , Coords [ 1 ] [ ii ] , Coords [ 2 ] [ ii ] ) ;
  131.             continue ;
  132.         }
  133.         else if ( leftright == KEY_LEFT )
  134.         {
  135.             GetXY ( LEFT , Coords [ 0 ] [ ii ] , Coords [ 1 ] [ ii ] , Coords [ 3 ] [ ii ] , Coords [ 0 ] [ ii ] , Coords [ 1 ] [ ii ] ) ;
  136.             SetPlayerCameraPos ( ii , Coords [ 0 ] [ ii ] , Coords [ 1 ] [ ii ] , ( Coords [ 2 ] [ ii ] + 20 ) ) ;
  137.             SetPlayerCameraLookAt ( ii , Coords [ 0 ] [ ii ] , Coords [ 1 ] [ ii ] , Coords [ 2 ] [ ii ] ) ;
  138.             continue ;
  139.         }
  140.     }
  141. }
  142. //==============================================================================
  143. cmd(mortar,playerid,params[])
  144. {
  145.     if ( Shooting [ playerid ] == 0 )
  146.     {
  147.         Coords [ 3 ] [ playerid ] = 0 ;
  148.         GetPlayerPos ( playerid , Coords [ 0 ] [ playerid ] , Coords [ 1 ] [ playerid ] , Coords [ 2 ] [ playerid ] ) ;
  149.         TogglePlayerControllable ( playerid , 0 ) ;
  150.         Iter_Add (Mortar , playerid ) ;
  151.         Shooting [ playerid ] = 1 ;
  152.         TextDrawsForPlayer ( playerid , 1 ) ;
  153.         SendClientMessage ( playerid , 0x0080FFFF , "> {FFFFFF}You are now using mortar aim !" ) ;
  154.         SetPlayerCameraPos ( playerid , Coords [ 0 ] [ playerid ] , Coords [ 1 ] [ playerid ] , ( Coords [ 2 ] [ playerid ] + 20 ) ) ;
  155.         SetPlayerCameraLookAt ( playerid , Coords [ 0 ] [ playerid ] , Coords [ 1 ] [ playerid ] , Coords [ 2 ] [ playerid ] ) ;
  156.     }
  157.     else
  158.     {
  159.         TogglePlayerControllable ( playerid , 1 ) ;
  160.         SetCameraBehindPlayer ( playerid ) ;
  161.         Iter_Remove (Mortar , playerid ) ;
  162.         Shooting [ playerid ] = 0 ;
  163.         TextDrawsForPlayer ( playerid , 0 ) ;
  164.         SendClientMessage ( playerid , 0x0080FFFF , "> {FFFFFF}You left mortar aim !" ) ;
  165.     }
  166.     return 1 ;
  167. }
  168. //==============================================================================
  169. stock
  170.     GetXY ( mode , Float:X , Float:Y , Float:Angle , &Float:return_x , &Float:return_y )
  171. {
  172.     if ( mode == FRONT )
  173.     {
  174.         return_x = X ;
  175.         return_y = Y ;
  176.         return_x += ( floatsin ( Angle , degrees ) * -0.5 ) ;
  177.         return_y -= ( floatcos ( Angle , degrees ) * -0.5 ) ;
  178.     }
  179.     if ( mode == BACK )
  180.     {
  181.         return_x = X ;
  182.         return_y = Y ;
  183.         return_x += ( floatsin ( Angle , degrees ) * 0.5 ) ;
  184.         return_y -= ( floatcos ( Angle , degrees ) * 0.5 ) ;
  185.     }
  186.     if ( mode == LEFT )
  187.     {
  188.         return_x = X ;
  189.         return_y = Y ;
  190.         return_x += ( floatsin ( ( Angle - 90 ) , degrees ) * 0.5 ) ;
  191.         return_y -= ( floatcos ( ( Angle - 90 ) , degrees ) * 0.5 ) ;
  192.     }
  193.     if ( mode == RIGHT )
  194.     {
  195.         return_x = X ;
  196.         return_y = Y ;
  197.         return_x += ( floatsin ( ( Angle + 90 ) , degrees ) * 0.5 ) ;
  198.         return_y -= ( floatcos ( ( Angle + 90 ) , degrees ) * 0.5 ) ;
  199.     }
  200. }
  201. //==============================================================================
  202. stock
  203.     CreateTextDraws ( )
  204. {
  205.     Aim [ 0 ] = TextDrawCreate ( 590.000000 , 215.000000 , "_" ) ;
  206.     TextDrawBackgroundColor ( Aim [ 0 ] , 255 ) ;
  207.     TextDrawFont ( Aim [ 0 ] , 2 ) ;
  208.     TextDrawLetterSize ( Aim [ 0 ] , 0.490000 , 0.000000 ) ;
  209.     TextDrawColor ( Aim [ 0 ] , -1 ) ;
  210.     TextDrawSetOutline ( Aim [ 0 ] , 0 ) ;
  211.     TextDrawSetProportional ( Aim [ 0 ] , 1 ) ;
  212.     TextDrawSetShadow ( Aim [ 0 ] , 1 ) ;
  213.     TextDrawUseBox ( Aim [ 0 ] , 1 ) ;
  214.     TextDrawBoxColor ( Aim [ 0 ] , 255 ) ;
  215.     TextDrawTextSize ( Aim [ 0 ] , 420.000000 , -6.000000 ) ;
  216.  
  217.     Aim [ 1 ] = TextDrawCreate ( 50.000000 , 215.000000 , "_" ) ;
  218.     TextDrawBackgroundColor ( Aim [ 1 ] , 255 ) ;
  219.     TextDrawFont ( Aim [ 1 ] , 2 ) ;
  220.     TextDrawLetterSize ( Aim [ 1 ] , 0.479999 , 0.000000 ) ;
  221.     TextDrawColor ( Aim [ 1 ] , -1 ) ;
  222.     TextDrawSetOutline ( Aim [ 1 ] , 0 ) ;
  223.     TextDrawSetProportional ( Aim [ 1 ] , 1 ) ;
  224.     TextDrawSetShadow ( Aim [ 1 ] , 1 ) ;
  225.     TextDrawUseBox ( Aim [ 1 ] , 1 ) ;
  226.     TextDrawBoxColor ( Aim [ 1 ] , 255 ) ;
  227.     TextDrawTextSize ( Aim [ 1 ] , 210.000000 , -6.000000 ) ;
  228.  
  229.     Aim [ 2 ] = TextDrawCreate ( 248.500000 , 161.000000 , "_" ) ;
  230.     TextDrawBackgroundColor ( Aim [ 2 ] , 255 ) ;
  231.     TextDrawFont ( Aim [ 2 ] , 1 ) ;
  232.     TextDrawLetterSize ( Aim [ 2 ] , 0.500000 , 0.199999 ) ;
  233.     TextDrawColor ( Aim [ 2 ] , -1 ) ;
  234.     TextDrawSetOutline ( Aim [ 2 ] , 0 ) ;
  235.     TextDrawSetProportional ( Aim [ 2 ] , 1 ) ;
  236.     TextDrawSetShadow ( Aim [ 2 ] , 1 ) ;
  237.     TextDrawUseBox ( Aim [ 2 ] , 1 ) ;
  238.     TextDrawBoxColor ( Aim [ 2 ] , 101 ) ;
  239.     TextDrawTextSize ( Aim [ 2 ] , 381.000000 , 0.000000 ) ;
  240.  
  241.     Aim [ 3 ] = TextDrawCreate ( 315.000000 , 19.000000 , "'" ) ;
  242.     TextDrawAlignment ( Aim [ 3 ] , 2 ) ;
  243.     TextDrawBackgroundColor ( Aim [ 3 ] , 255 ) ;
  244.     TextDrawFont ( Aim [ 3 ] , 0 ) ;
  245.     TextDrawLetterSize ( Aim [ 3 ] , 0.500000 , 39.000000 ) ;
  246.     TextDrawColor ( Aim [ 3 ] , -1 ) ;
  247.     TextDrawSetOutline ( Aim [ 3 ] , 0 ) ;
  248.     TextDrawSetProportional ( Aim [ 3 ] , 1 ) ;
  249.     TextDrawSetShadow ( Aim [ 3 ] , 0 ) ;
  250.  
  251.     Aim [ 4 ] = TextDrawCreate ( 315.000000 , 275.000000 , "'" ) ;
  252.     TextDrawAlignment ( Aim [ 4 ] , 2 ) ;
  253.     TextDrawBackgroundColor ( Aim [ 4 ] , 255 ) ;
  254.     TextDrawFont ( Aim [ 4 ] , 0 ) ;
  255.     TextDrawLetterSize ( Aim [ 4 ] , 0.500000 , 39.000000 ) ;
  256.     TextDrawColor ( Aim [ 4 ] , -1 ) ;
  257.     TextDrawSetOutline ( Aim [ 4 ] , 0 ) ;
  258.     TextDrawSetProportional ( Aim [ 4 ] , 1 ) ;
  259.     TextDrawSetShadow ( Aim [ 4 ] , 0 ) ;
  260.  
  261.     Aim [ 5 ] = TextDrawCreate ( 302.000000 , 193.000000 , "o" ) ;
  262.     TextDrawBackgroundColor ( Aim [ 5 ] , 255 ) ;
  263.     TextDrawFont ( Aim [ 5 ] , 2 ) ;
  264.     TextDrawLetterSize ( Aim [ 5 ] , 0.990000 , 4.000000 ) ;
  265.     TextDrawColor ( Aim [ 5 ] , 255 ) ;
  266.     TextDrawSetOutline ( Aim [ 5 ] , 0 ) ;
  267.     TextDrawSetProportional ( Aim [ 5 ] , 1 ) ;
  268.     TextDrawSetShadow ( Aim [ 5 ] , 0 ) ;
  269.  
  270.     Aim [ 6 ] = TextDrawCreate ( 283.000000 , 214.000000 , "_" ) ;
  271.     TextDrawBackgroundColor ( Aim [ 6 ] , 255 ) ;
  272.     TextDrawFont ( Aim [ 6 ] , 1 ) ;
  273.     TextDrawLetterSize ( Aim [ 6 ] , 0.500000 , -0.000000 ) ;
  274.     TextDrawColor ( Aim [ 6 ] , -16776961 ) ;
  275.     TextDrawSetOutline ( Aim [ 6 ] , 0 ) ;
  276.     TextDrawSetProportional ( Aim [ 6 ] , 1 ) ;
  277.     TextDrawSetShadow ( Aim [ 6 ] , 1 ) ;
  278.     TextDrawUseBox ( Aim [ 6 ] , 1 ) ;
  279.     TextDrawBoxColor ( Aim [ 6 ] , -16777116 ) ;
  280.     TextDrawTextSize ( Aim [ 6 ] , 300.000000 , 20.000000 ) ;
  281.  
  282.     Aim [ 7 ] = TextDrawCreate ( 373.000000 , 151.000000 , "_" ) ;
  283.     TextDrawBackgroundColor ( Aim [ 7 ] , 255 ) ;
  284.     TextDrawFont ( Aim [ 7 ] , 1 ) ;
  285.     TextDrawLetterSize ( Aim [ 7 ] , 0.590000 , 12.799999 ) ;
  286.     TextDrawColor ( Aim [ 7 ] , -1 ) ;
  287.     TextDrawSetOutline ( Aim [ 7 ] , 0 ) ;
  288.     TextDrawSetProportional ( Aim [ 7 ] , 1 ) ;
  289.     TextDrawSetShadow ( Aim [ 7 ] , 1 ) ;
  290.     TextDrawUseBox ( Aim [ 7 ] , 1 ) ;
  291.     TextDrawBoxColor ( Aim [ 7 ] , 101 ) ;
  292.     TextDrawTextSize ( Aim [ 7 ] , 367.000000 , -55.000000 ) ;
  293.  
  294.     Aim [ 8 ] = TextDrawCreate ( 248.500000 , 256.000000 , "_" ) ;
  295.     TextDrawBackgroundColor ( Aim [ 8 ] , 255 ) ;
  296.     TextDrawFont ( Aim [ 8 ] , 1 ) ;
  297.     TextDrawLetterSize ( Aim [ 8 ] , 0.500000 , 0.199999 ) ;
  298.     TextDrawColor ( Aim [ 8 ] , -1 ) ;
  299.     TextDrawSetOutline ( Aim [ 8 ] , 0 ) ;
  300.     TextDrawSetProportional ( Aim [ 8 ] , 1 ) ;
  301.     TextDrawSetShadow ( Aim [ 8 ] , 1 ) ;
  302.     TextDrawUseBox ( Aim [ 8 ] , 1 ) ;
  303.     TextDrawBoxColor ( Aim [ 8 ] , 101 ) ;
  304.     TextDrawTextSize ( Aim [ 8 ] , 381.000000 , 0.000000 ) ;
  305.  
  306.     Aim [ 9 ] = TextDrawCreate ( 262.000000 , 151.000000 , "_" ) ;
  307.     TextDrawBackgroundColor ( Aim [ 9 ] , 255 ) ;
  308.     TextDrawFont ( Aim [ 9 ] , 1 ) ;
  309.     TextDrawLetterSize ( Aim [ 9 ] , 0.590000 , 12.799999 ) ;
  310.     TextDrawColor ( Aim [ 9 ] , -1 ) ;
  311.     TextDrawSetOutline ( Aim [ 9 ] , 0 ) ;
  312.     TextDrawSetProportional ( Aim [ 9 ] , 1 ) ;
  313.     TextDrawSetShadow ( Aim [ 9 ] , 1 ) ;
  314.     TextDrawUseBox ( Aim [ 9 ] , 1 ) ;
  315.     TextDrawBoxColor ( Aim [ 9 ] , 101 ) ;
  316.     TextDrawTextSize ( Aim [ 9 ] , 256.000000 , -55.000000 ) ;
  317.  
  318.     Aim [ 10 ] = TextDrawCreate ( 331.000000 , 214.000000 , "_" ) ;
  319.     TextDrawBackgroundColor ( Aim [ 10 ] , 255 ) ;
  320.     TextDrawFont ( Aim [ 10 ] , 1 ) ;
  321.     TextDrawLetterSize ( Aim [ 10 ] , 0.500000 , -0.000000 ) ;
  322.     TextDrawColor ( Aim [ 10 ] , -16776961 ) ;
  323.     TextDrawSetOutline ( Aim [ 10 ] , 0 ) ;
  324.     TextDrawSetProportional ( Aim [ 10 ] , 1 ) ;
  325.     TextDrawSetShadow ( Aim [ 10 ] , 1 ) ;
  326.     TextDrawUseBox ( Aim [ 10 ] , 1 ) ;
  327.     TextDrawBoxColor ( Aim [ 10 ] , -16777116 ) ;
  328.     TextDrawTextSize ( Aim [ 10 ] , 349.000000 , 20.000000 ) ;
  329. }
  330. //==============================================================================
  331. stock
  332.     TextDrawsForPlayer ( playerid , mode )
  333. {
  334.     if ( mode == 1 )
  335.     {
  336.         for ( ii = 0 ; ii < sizeof ( Aim ) ; ii++ )
  337.         {
  338.             TextDrawShowForPlayer ( playerid , Aim [ ii ] ) ;
  339.         }
  340.     }
  341.     else
  342.     {
  343.         for ( ii = 0 ; ii < sizeof ( Aim ) ; ii++ )
  344.         {
  345.             TextDrawHideForPlayer ( playerid , Aim [ ii ] ) ;
  346.         }
  347.     }
  348. }
Advertisement
Add Comment
Please, Sign In to add comment