RodneyFrancalim

Dashcam em viaturas

Aug 31st, 2014
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.34 KB | None | 0 0
  1. #include    <a_samp>
  2. #include    <zcmd>
  3. #include    <sscanf2>
  4.  
  5. native IsValidVehicle(vehicleid);
  6.  
  7. new
  8.     pViaturaCamera[ MAX_PLAYERS ],
  9.     pInt[ MAX_PLAYERS ],
  10.     pVW[ MAX_PLAYERS ],
  11.     Float:pPos[ MAX_PLAYERS ][ 4 ]
  12. ;
  13.  
  14. new
  15.     PlayerText:dashcamdatahora,
  16.     PlayerText:dashcamcamera
  17. ;
  18.  
  19. public OnFilterScriptInit()
  20. {
  21.     print( "\n\n\n" );
  22.     print( "*****************************************************" );
  23.     print( "*                                                   *" );
  24.     print( "* FS de dashcam nas viaturas. Por: Rodney Francalim *" );
  25.     print( "*                                                   *" );
  26.     print( "*     [[[ Não remova os créditos, obrigado. ]]]     *" );
  27.     print( "*                                                   *" );
  28.     print( "*****************************************************" );
  29.     print( "\n\n\n" );
  30.  
  31.     SetTimer( "TempoServidor", 1000, true );
  32.  
  33.     return 1;
  34. }
  35.  
  36. public OnFilterScriptExit()
  37. {
  38.     return 1;
  39. }
  40.  
  41. public OnPlayerRequestClass( playerid, classid )
  42. {
  43.     return 1;
  44. }
  45.  
  46. public OnPlayerConnect( playerid )
  47. {
  48.     pViaturaCamera[ playerid ] = 0;
  49.  
  50.     dashcamdatahora = CreatePlayerTextDraw( playerid, 40.000000, 350.000000, "" );
  51.     PlayerTextDrawBackgroundColor( playerid, dashcamdatahora, 255 );
  52.     PlayerTextDrawFont( playerid, dashcamdatahora, 2 );
  53.     PlayerTextDrawLetterSize( playerid,dashcamdatahora, 1.000000, 4.000000 );
  54.     PlayerTextDrawColor( playerid, dashcamdatahora, -86 );
  55.     PlayerTextDrawSetOutline( playerid, dashcamdatahora, 1 );
  56.     PlayerTextDrawSetProportional( playerid, dashcamdatahora, 1 );
  57.     PlayerTextDrawSetSelectable( playerid, dashcamdatahora, 0 );
  58.  
  59.     dashcamcamera = CreatePlayerTextDraw( playerid, 600.000000, 350.000000, "" );
  60.     PlayerTextDrawAlignment( playerid, dashcamcamera, 3 );
  61.     PlayerTextDrawBackgroundColor( playerid, dashcamcamera, 255 );
  62.     PlayerTextDrawFont( playerid, dashcamcamera, 2 );
  63.     PlayerTextDrawLetterSize( playerid, dashcamcamera, 1.000000, 4.000000 );
  64.     PlayerTextDrawColor( playerid, dashcamcamera, -86 );
  65.     PlayerTextDrawSetOutline( playerid, dashcamcamera, 1 );
  66.     PlayerTextDrawSetProportional( playerid, dashcamcamera, 1 );
  67.     PlayerTextDrawSetSelectable( playerid, dashcamcamera, 0 );
  68.  
  69.     PlayerTextDrawHide( playerid, dashcamdatahora );
  70.     PlayerTextDrawHide( playerid, dashcamcamera );
  71.  
  72.     return 1;
  73. }
  74.  
  75. public OnPlayerDisconnect( playerid, reason )
  76. {
  77.     if( pViaturaCamera[ playerid ] > 0 )
  78.         DestroyObject( pViaturaCamera[ playerid ]);
  79.  
  80.     return 1;
  81. }
  82.  
  83. public OnPlayerSpawn( playerid )
  84. {
  85.     SendClientMessage( playerid, -1, "Este servidor usa o {FF0000}FS {000000}'{FFFFFF}viaturas com dashcam{000000}' {FF8040}v0.1b{FFFFFF}. Por: {0000FF}Rodney Francalim" );
  86.     return 1;
  87. }
  88.  
  89. CMD:sv( playerid, params[]) return cmd_specviatura( playerid, params );
  90. CMD:specviatura( playerid, params[])
  91. {
  92.     if( sscanf( params, "d", params[ 0 ])) return SendClientMessage( playerid, 0xFFFF00AA, "USE: /specviatura [CAMERA]" );
  93.     if( !EUmaViatura( params[ 0 ]) && params[ 0 ] != 0 ) return SendClientMessage( playerid, 0xFF0000AA, "Este veículo não existe, ou não é uma viatura!" );
  94.     if( params[ 0 ] != 0 )
  95.     {
  96.         new
  97.             str[ 64 ],
  98.             Float:vAng,
  99.             vVW
  100.         ;
  101.  
  102.         if( pViaturaCamera[ playerid ] != 0 )
  103.             DestroyObject( pViaturaCamera[ playerid ]);
  104.         else
  105.         {
  106.             SendClientMessage( playerid, -1, "CENTRAL: Logando no sistema, aguarde..." );
  107.             TogglePlayerSpectating( playerid, true );
  108.             GetPlayerPos( playerid, pPos[ playerid ][ 0 ], pPos[ playerid ][ 1 ], pPos[ playerid ][ 2 ]);
  109.             GetPlayerFacingAngle( playerid, pPos[ playerid ][ 3 ]);
  110.             pInt[ playerid ] = GetPlayerInterior( playerid );
  111.             pVW[ playerid ] = GetPlayerVirtualWorld( playerid );
  112.         }
  113.  
  114.         GetVehicleZAngle( params[ 0 ], vAng );
  115.         vVW = GetVehicleVirtualWorld( params[ 0 ]);
  116.         SetPlayerFacingAngle( playerid, vAng );
  117.         SetPlayerVirtualWorld( playerid, vVW );
  118.         SetCameraBehindPlayer( playerid );
  119.  
  120.         PlayerSpectateVehicle( playerid, params[ 0 ]);
  121.         pViaturaCamera[ playerid ] = CreateObject( 19300, 0, 0, 0, 0, 0, 0 );
  122.         AttachObjectToVehicle( pViaturaCamera[ playerid ], params[ 0 ], 0, 1, 0.5, 0, 0, 0 );
  123.         AttachCameraToObject( playerid, pViaturaCamera[ playerid ]);
  124.  
  125.         format( str, sizeof( str ), "CAM %d", params[ 0 ]);
  126.         PlayerTextDrawSetString( playerid, dashcamcamera, str );
  127.         PlayerTextDrawShow( playerid, dashcamcamera );
  128.     }
  129.     else
  130.     {
  131.         if( pViaturaCamera[ playerid ] != 0 )
  132.         {
  133.             DestroyObject( pViaturaCamera[ playerid ]);
  134.             pViaturaCamera[ playerid ] = 0;
  135.  
  136.             TogglePlayerSpectating( playerid, false );
  137.             SetPlayerPos( playerid, pPos[ playerid ][ 0 ], pPos[ playerid ][ 1 ], pPos[ playerid ][ 2 ]);
  138.             SetPlayerFacingAngle( playerid, pPos[ playerid ][ 3 ]);
  139.             SetPlayerInterior( playerid, pInt[ playerid ]);
  140.             SetPlayerVirtualWorld( playerid, pVW[ playerid ]);
  141.             SetCameraBehindPlayer( playerid );
  142.  
  143.             PlayerTextDrawHide( playerid, dashcamdatahora );
  144.             PlayerTextDrawHide( playerid, dashcamcamera );
  145.  
  146.             SendClientMessage( playerid, -1, "CENTRAL: Você deslogou do sistema de câmeras." );
  147.         }
  148.         else return SendClientMessage( playerid, 0xFF0000AA, "CENTRAL: Você não estava logado no sistema de câmeras." );
  149.     }
  150.  
  151.     return 1;
  152. }
  153.  
  154. stock EUmaViatura( vehicleid )
  155. {
  156.     if( !IsValidVehicle( vehicleid )) return false;
  157.  
  158.     if( GetVehicleModel( vehicleid ) == 596 || GetVehicleModel( vehicleid ) == 597 || GetVehicleModel( vehicleid ) == 598 )
  159.         return true;
  160.  
  161.     return false;
  162. }
  163.  
  164. forward TempoServidor();
  165. public TempoServidor()
  166. {
  167.     new
  168.         t[ 6 ],
  169.         str[ 32 ]
  170.     ;
  171.  
  172.     gettime( t[ 3 ], t[ 4 ], t[ 5 ]);
  173.     getdate( t[ 2 ], t[ 1 ], t[ 0 ]);
  174.  
  175.     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" ));
  176.     for( new p = 0; p < MAX_PLAYERS; ++p )
  177.     {
  178.         if( pViaturaCamera[ p ] != 0 )
  179.         {
  180.             PlayerTextDrawSetString( p, dashcamdatahora, str );
  181.             PlayerTextDrawShow( p, dashcamdatahora );
  182.         }
  183.     }
  184.  
  185.     return 1;
  186. }
Advertisement
Add Comment
Please, Sign In to add comment