Advertisement
RodneyFrancalim

Dashcam em viaturas - v0.2b

Sep 3rd, 2014
1,483
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. #define     DIALOG_DASHCAMS (9999) // Mude o número em caso de conflito
  7.  
  8.  
  9. new
  10.     pViaturaCamera[ MAX_PLAYERS ],
  11.     pInt[ MAX_PLAYERS ],
  12.     pVW[ MAX_PLAYERS ],
  13.     pListaDashcams[ MAX_PLAYERS ][ 11 ],
  14.     Float:pPos[ MAX_PLAYERS ][ 4 ]
  15. ;
  16.  
  17. new
  18.     PlayerText:dashcamdatahora,
  19.     PlayerText:dashcamcamera
  20. ;
  21.  
  22. public OnFilterScriptInit()
  23. {
  24.     print( "\n\n\n" );
  25.     print( "*****************************************************" );
  26.     print( "*                                                   *" );
  27.     print( "* FS de dashcam nas viaturas. Por: Rodney Francalim *" );
  28.     print( "*                                                   *" );
  29.     print( "*     [[[ Não remova os créditos, obrigado. ]]]     *" );
  30.     print( "*                                                   *" );
  31.     print( "*****************************************************" );
  32.     print( "\n\n\n" );
  33.  
  34.     SetTimer( "TempoServidor", 1000, true );
  35.  
  36.     return 1;
  37. }
  38.  
  39. public OnFilterScriptExit()
  40. {
  41.     return 1;
  42. }
  43.  
  44. public OnPlayerRequestClass( playerid, classid )
  45. {
  46.     return 1;
  47. }
  48.  
  49. public OnPlayerConnect( playerid )
  50. {
  51.     pViaturaCamera[ playerid ] = 0;
  52.     pListaDashcams[ playerid ][ 10 ] = 1;
  53.  
  54.     dashcamdatahora = CreatePlayerTextDraw( playerid, 40.000000, 350.000000, "" );
  55.     PlayerTextDrawBackgroundColor( playerid, dashcamdatahora, 255 );
  56.     PlayerTextDrawFont( playerid, dashcamdatahora, 2 );
  57.     PlayerTextDrawLetterSize( playerid,dashcamdatahora, 1.000000, 4.000000 );
  58.     PlayerTextDrawColor( playerid, dashcamdatahora, -86 );
  59.     PlayerTextDrawSetOutline( playerid, dashcamdatahora, 1 );
  60.     PlayerTextDrawSetProportional( playerid, dashcamdatahora, 1 );
  61.     PlayerTextDrawSetSelectable( playerid, dashcamdatahora, 0 );
  62.  
  63.     dashcamcamera = CreatePlayerTextDraw( playerid, 600.000000, 350.000000, "" );
  64.     PlayerTextDrawAlignment( playerid, dashcamcamera, 3 );
  65.     PlayerTextDrawBackgroundColor( playerid, dashcamcamera, 255 );
  66.     PlayerTextDrawFont( playerid, dashcamcamera, 2 );
  67.     PlayerTextDrawLetterSize( playerid, dashcamcamera, 1.000000, 4.000000 );
  68.     PlayerTextDrawColor( playerid, dashcamcamera, -86 );
  69.     PlayerTextDrawSetOutline( playerid, dashcamcamera, 1 );
  70.     PlayerTextDrawSetProportional( playerid, dashcamcamera, 1 );
  71.     PlayerTextDrawSetSelectable( playerid, dashcamcamera, 0 );
  72.  
  73.     PlayerTextDrawHide( playerid, dashcamdatahora );
  74.     PlayerTextDrawHide( playerid, dashcamcamera );
  75.  
  76.     return 1;
  77. }
  78.  
  79. public OnPlayerDisconnect( playerid, reason )
  80. {
  81.     if( pViaturaCamera[ playerid ] > 0 )
  82.         DestroyObject( pViaturaCamera[ playerid ]);
  83.  
  84.     return 1;
  85. }
  86.  
  87. public OnPlayerSpawn( playerid )
  88. {
  89.     SendClientMessage( playerid, -1, "Este servidor usa o {FF0000}FS {000000}'{FFFFFF}viaturas com dashcam{000000}' {FF8040}v0.2b{FFFFFF}. Por: {0000FF}Rodney Francalim" );
  90.  
  91.     return 1;
  92. }
  93.  
  94. CMD:sv( playerid ) return cmd_specviatura( playerid );
  95. CMD:specviatura( playerid )
  96. {
  97.     new
  98.         str[ 150 ],
  99.         strd[ 12 ],
  100.         celula = -1
  101.     ;
  102.  
  103.     for( new i = pListaDashcams[ playerid ][ 10 ]; i <= MAX_VEHICLES; ++i )
  104.     {
  105.         if( EUmaViatura( i ))
  106.         {
  107.             pListaDashcams[ playerid ][ ++celula ] = i;
  108.             if( celula >= 10 )
  109.             {
  110.                 strcat( str, "Próxima >>" );
  111.                 break;
  112.             }
  113.             else
  114.             {
  115.                 format( strd, sizeof( strd ), "CAM %d\n", i );
  116.                 strcat( str, strd );
  117.             }
  118.         }
  119.     }
  120.     ShowPlayerDialog( playerid, DIALOG_DASHCAMS, DIALOG_STYLE_LIST, "Sistema de dashcams", str, "Escolher", "Deslogar" );
  121.     return 1;
  122. }
  123.  
  124. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  125. {
  126.     switch( dialogid )
  127.     {
  128.         case DIALOG_DASHCAMS:
  129.         {
  130.             if( response )
  131.             {
  132.                 switch( listitem )
  133.                 {
  134.                     case 0 .. 9:
  135.                     {
  136.                         new
  137.                             str[ 64 ],
  138.                             Float:vAng,
  139.                             vVW,
  140.                             vehicleid = pListaDashcams[ playerid ][ listitem ]
  141.                         ;
  142.  
  143.                         pListaDashcams[ playerid ][ 10 ] = pListaDashcams[ playerid ][ 0 ];
  144.  
  145.                         if( pViaturaCamera[ playerid ] != 0 )
  146.                             DestroyObject( pViaturaCamera[ playerid ]);
  147.                         else
  148.                         {
  149.                             SendClientMessage( playerid, -1, "CENTRAL: Logando no sistema, aguarde..." );
  150.                             TogglePlayerSpectating( playerid, true );
  151.                             GetPlayerPos( playerid, pPos[ playerid ][ 0 ], pPos[ playerid ][ 1 ], pPos[ playerid ][ 2 ]);
  152.                             GetPlayerFacingAngle( playerid, pPos[ playerid ][ 3 ]);
  153.                             pInt[ playerid ] = GetPlayerInterior( playerid );
  154.                             pVW[ playerid ] = GetPlayerVirtualWorld( playerid );
  155.                         }
  156.  
  157.                         GetVehicleZAngle( vehicleid, vAng );
  158.                         vVW = GetVehicleVirtualWorld( vehicleid );
  159.                         SetPlayerFacingAngle( playerid, vAng );
  160.                         SetPlayerVirtualWorld( playerid, vVW );
  161.                         SetCameraBehindPlayer( playerid );
  162.  
  163.                         PlayerSpectateVehicle( playerid, vehicleid );
  164.                         pViaturaCamera[ playerid ] = CreateObject( 19300, 0, 0, 0, 0, 0, 0 );
  165.                         DashCamPos( pViaturaCamera[ playerid ], vehicleid );
  166.                         AttachCameraToObject( playerid, pViaturaCamera[ playerid ]);
  167.  
  168.                         format( str, sizeof( str ), "CAM %d", vehicleid );
  169.                         PlayerTextDrawSetString( playerid, dashcamcamera, str );
  170.                         PlayerTextDrawShow( playerid, dashcamcamera );
  171.                     }
  172.                     case 10:
  173.                     {
  174.                         cmd_sv( playerid );
  175.                     }
  176.                 }
  177.             }
  178.             else
  179.             {
  180.                 pListaDashcams[ playerid ][ 10 ] = 1;
  181.  
  182.                 if( pViaturaCamera[ playerid ] != 0 )
  183.                 {
  184.                     TogglePlayerSpectating( playerid, false );
  185.                     DestroyObject( pViaturaCamera[ playerid ]);
  186.                     pViaturaCamera[ playerid ] = 0;
  187.  
  188.                     SetPlayerPos( playerid, pPos[ playerid ][ 0 ], pPos[ playerid ][ 1 ], pPos[ playerid ][ 2 ]);
  189.                     SetPlayerFacingAngle( playerid, pPos[ playerid ][ 3 ]);
  190.                     SetPlayerInterior( playerid, pInt[ playerid ]);
  191.                     SetPlayerVirtualWorld( playerid, pVW[ playerid ]);
  192.                     SetCameraBehindPlayer( playerid );
  193.  
  194.                     PlayerTextDrawHide( playerid, dashcamdatahora );
  195.                     PlayerTextDrawHide( playerid, dashcamcamera );
  196.  
  197.                     SendClientMessage( playerid, -1, "CENTRAL: Você deslogou do sistema de câmeras." );
  198.                 }
  199.                 else
  200.                     SendClientMessage( playerid, 0xFF0000AA, "CENTRAL: Você não estava logado no sistema de câmeras." );
  201.             }
  202.         }
  203.     }
  204. }
  205.  
  206. stock DashCamPos( objectid, vehicleid )
  207. {
  208.     if( GetVehicleModel( vehicleid ) == 427 )
  209.         return AttachObjectToVehicle( objectid, vehicleid, 0, 1.65, 0.9, 0, 0, 0 );
  210.     else if( GetVehicleModel( vehicleid ) == 490 )
  211.         return AttachObjectToVehicle( objectid, vehicleid, 0, 1.3, 0.7, 0, 0, 0 );
  212.     else if( GetVehicleModel( vehicleid ) == 596 || GetVehicleModel( vehicleid ) == 597 || GetVehicleModel( vehicleid ) == 598 )
  213.         return AttachObjectToVehicle( objectid, vehicleid, 0, 1, 0.5, 0, 0, 0 );
  214.     else if( GetVehicleModel( vehicleid ) == 599 )
  215.         return AttachObjectToVehicle( objectid, vehicleid, 0, 0.85, 0.75, 0, 0, 0 );
  216.     else
  217.         return AttachObjectToVehicle( objectid, vehicleid, 0, 0, 0, 0, 0, 0 );
  218. }
  219.  
  220. stock EUmaViatura( vehicleid )
  221. {
  222.     if( GetVehicleModel( vehicleid ) == 427 || GetVehicleModel( vehicleid ) == 490 || GetVehicleModel( vehicleid ) == 596 ||
  223.         GetVehicleModel( vehicleid ) == 597 || GetVehicleModel( vehicleid ) == 598 || GetVehicleModel( vehicleid ) == 599 )
  224.         return true;
  225.  
  226.     return false;
  227. }
  228.  
  229. forward TempoServidor();
  230. public TempoServidor()
  231. {
  232.     new
  233.         t[ 6 ],
  234.         str[ 32 ]
  235.     ;
  236.  
  237.     gettime( t[ 3 ], t[ 4 ], t[ 5 ]);
  238.     getdate( t[ 2 ], t[ 1 ], t[ 0 ]);
  239.  
  240.     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" ));
  241.     for( new p = 0; p < MAX_PLAYERS; ++p )
  242.     {
  243.         if( pViaturaCamera[ p ] != 0 )
  244.         {
  245.             PlayerTextDrawSetString( p, dashcamdatahora, str );
  246.             PlayerTextDrawShow( p, dashcamdatahora );
  247.         }
  248.     }
  249.  
  250.     return 1;
  251. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement