Advertisement
RodneyFrancalim

Dashcam in cop's vehicle

Sep 1st, 2014
1,110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include    <a_samp>
  2. #include    <zcmd>
  3. #include    <sscanf2>
  4.  
  5.  
  6. new
  7.     pCopVehCam[ MAX_PLAYERS ],
  8.     pInt[ MAX_PLAYERS ],
  9.     pVW[ MAX_PLAYERS ],
  10.     Float:pPos[ MAX_PLAYERS ][ 4 ]
  11. ;
  12.  
  13. new
  14.     PlayerText:dashcamdatetime,
  15.     PlayerText:dashcamcam
  16. ;
  17.  
  18. public OnFilterScriptInit()
  19. {
  20.     print( "\n\n\n" );
  21.     print( "*****************************************************" );
  22.     print( "*                                                   *" );
  23.     print( "*  Dashcam's cop vehicle FS. By: Rodney Francalim   *" );
  24.     print( "*                                                   *" );
  25.     print( "*     [[[ Don't remove the credits, thanks. ]]]     *" );
  26.     print( "*                                                   *" );
  27.     print( "*****************************************************" );
  28.     print( "\n\n\n" );
  29.  
  30.     SetTimer( "ServerTime", 1000, true );
  31.  
  32.     return 1;
  33. }
  34.  
  35. public OnFilterScriptExit()
  36. {
  37.     return 1;
  38. }
  39.  
  40. public OnPlayerRequestClass( playerid, classid )
  41. {
  42.     return 1;
  43. }
  44.  
  45. public OnPlayerConnect( playerid )
  46. {
  47.     pCopVehCam[ playerid ] = 0;
  48.  
  49.     dashcamdatetime = CreatePlayerTextDraw( playerid, 40.000000, 350.000000, "" );
  50.     PlayerTextDrawBackgroundColor( playerid, dashcamdatetime, 255 );
  51.     PlayerTextDrawFont( playerid, dashcamdatetime, 2 );
  52.     PlayerTextDrawLetterSize( playerid, dashcamdatetime, 1.000000, 4.000000 );
  53.     PlayerTextDrawColor( playerid, dashcamdatetime, -86 );
  54.     PlayerTextDrawSetOutline( playerid, dashcamdatetime, 1 );
  55.     PlayerTextDrawSetProportional( playerid, dashcamdatetime, 1 );
  56.     PlayerTextDrawSetSelectable( playerid, dashcamdatetime, 0 );
  57.  
  58.     dashcamcam = CreatePlayerTextDraw( playerid, 600.000000, 350.000000, "" );
  59.     PlayerTextDrawAlignment( playerid, dashcamcam, 3 );
  60.     PlayerTextDrawBackgroundColor( playerid, dashcamcam, 255 );
  61.     PlayerTextDrawFont( playerid, dashcamcam, 2 );
  62.     PlayerTextDrawLetterSize( playerid, dashcamcam, 1.000000, 4.000000 );
  63.     PlayerTextDrawColor( playerid, dashcamcam, -86 );
  64.     PlayerTextDrawSetOutline( playerid, dashcamcam, 1 );
  65.     PlayerTextDrawSetProportional( playerid, dashcamcam, 1 );
  66.     PlayerTextDrawSetSelectable( playerid, dashcamcam, 0 );
  67.  
  68.     PlayerTextDrawHide( playerid, dashcamdatetime );
  69.     PlayerTextDrawHide( playerid, dashcamcam );
  70.  
  71.     return 1;
  72. }
  73.  
  74. public OnPlayerDisconnect( playerid, reason )
  75. {
  76.     if( pCopVehCam[ playerid ] > 0 )
  77.         DestroyObject( pCopVehCam[ playerid ]);
  78.  
  79.     return 1;
  80. }
  81.  
  82. public OnPlayerSpawn( playerid )
  83. {
  84.     SendClientMessage( playerid, -1, "This server uses the {000000}'{FFFFFF}Dashcam's cop vehicle{000000}' {FF0000}FS {FF8040}v0.1b{FFFFFF}. By: {0000FF}Rodney Francalim" );
  85.     return 1;
  86. }
  87.  
  88. CMD:scv( playerid, params[]) return cmd_speccopveh( playerid, params );
  89. CMD:speccopveh( playerid, params[])
  90. {
  91.     if( sscanf( params, "d", params[ 0 ])) return SendClientMessage( playerid, 0xFFFF00AA, "USE: /speccopveh [CAMERA]" );
  92.     if( !IsACopVeh( params[ 0 ]) && params[ 0 ] != 0 ) return SendClientMessage( playerid, 0xFF0000AA, "This vehicle doesn't exist, or isn't a cop vehicle!" );
  93.     if( params[ 0 ] != 0 )
  94.     {
  95.         new
  96.             str[ 64 ],
  97.             Float:vAng,
  98.             vVW
  99.         ;
  100.  
  101.         if( pCopVehCam[ playerid ] != 0 )
  102.             DestroyObject( pCopVehCam[ playerid ]);
  103.         else
  104.         {
  105.             SendClientMessage( playerid, -1, "CENTRAL: Logging on system, wait..." );
  106.             TogglePlayerSpectating( playerid, true );
  107.             GetPlayerPos( playerid, pPos[ playerid ][ 0 ], pPos[ playerid ][ 1 ], pPos[ playerid ][ 2 ]);
  108.             GetPlayerFacingAngle( playerid, pPos[ playerid ][ 3 ]);
  109.             pInt[ playerid ] = GetPlayerInterior( playerid );
  110.             pVW[ playerid ] = GetPlayerVirtualWorld( playerid );
  111.         }
  112.  
  113.         GetVehicleZAngle( params[ 0 ], vAng );
  114.         vVW = GetVehicleVirtualWorld( params[ 0 ]);
  115.         SetPlayerFacingAngle( playerid, vAng );
  116.         SetPlayerVirtualWorld( playerid, vVW );
  117.         SetCameraBehindPlayer( playerid );
  118.  
  119.         PlayerSpectateVehicle( playerid, params[ 0 ]);
  120.         pCopVehCam[ playerid ] = CreateObject( 19300, 0, 0, 0, 0, 0, 0 );
  121.         AttachObjectToVehicle( pCopVehCam[ playerid ], params[ 0 ], 0, 1, 0.5, 0, 0, 0 );
  122.         AttachCameraToObject( playerid, pCopVehCam[ playerid ]);
  123.  
  124.         format( str, sizeof( str ), "CAM %d", params[ 0 ]);
  125.         PlayerTextDrawSetString( playerid, dashcamcam, str );
  126.         PlayerTextDrawShow( playerid, dashcamcam );
  127.     }
  128.     else
  129.     {
  130.         if( pCopVehCam[ playerid ] != 0 )
  131.         {
  132.             DestroyObject( pCopVehCam[ playerid ]);
  133.             pCopVehCam[ playerid ] = 0;
  134.  
  135.             TogglePlayerSpectating( playerid, false );
  136.             SetPlayerPos( playerid, pPos[ playerid ][ 0 ], pPos[ playerid ][ 1 ], pPos[ playerid ][ 2 ]);
  137.             SetPlayerFacingAngle( playerid, pPos[ playerid ][ 3 ]);
  138.             SetPlayerInterior( playerid, pInt[ playerid ]);
  139.             SetPlayerVirtualWorld( playerid, pVW[ playerid ]);
  140.             SetCameraBehindPlayer( playerid );
  141.  
  142.             PlayerTextDrawHide( playerid, dashcamdatetime );
  143.             PlayerTextDrawHide( playerid, dashcamcam );
  144.  
  145.             SendClientMessage( playerid, -1, "CENTRAL: You shutted down the system." );
  146.         }
  147.         else return SendClientMessage( playerid, 0xFF0000AA, "CENTRAL: You weren't logged on cam's system." );
  148.     }
  149.  
  150.     return 1;
  151. }
  152.  
  153. stock IsACopVeh( vehicleid )
  154. {
  155.     if( GetVehicleModel( vehicleid ) == 596 || GetVehicleModel( vehicleid ) == 597 || GetVehicleModel( vehicleid ) == 598 )
  156.         return true;
  157.  
  158.     return false;
  159. }
  160.  
  161. forward ServerTime();
  162. public ServerTime()
  163. {
  164.     new
  165.         t[ 6 ],
  166.         str[ 32 ]
  167.     ;
  168.  
  169.     gettime( t[ 3 ], t[ 4 ], t[ 5 ]);
  170.     getdate( t[ 2 ], t[ 1 ], t[ 0 ]);
  171.  
  172.     format( str, sizeof( str ), "%02d/%02d/%d~n~%02d:%02d %s", t[ 1 ], t[ 0 ], t[ 2 ], t[ 3 ], t[ 4 ], t[ 3 ] >= 12 ? ( "PM" ) : ( "AM" ));
  173.     for( new p = 0; p < MAX_PLAYERS; ++p )
  174.     {
  175.         if( pCopVehCam[ p ] != 0 )
  176.         {
  177.             PlayerTextDrawSetString( p, dashcamdatetime, str );
  178.             PlayerTextDrawShow( p, dashcamdatetime );
  179.         }
  180.     }
  181.  
  182.     return 1;
  183. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement