Darky

strcmp2zcmd.pwn

Mar 12th, 2013
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.48 KB | None | 0 0
  1. //______________________________________________________________________________
  2.  
  3. /*
  4.  
  5. To use this, you need to create one folder named "Converter" in scriptfiles and
  6.  
  7. two files named "input.cfg" and "output.cfg" in "Converter" folder.Then, paste
  8.  
  9. the strcmp command in "input.cfg", open the server, and in console, write
  10.  
  11. "convert".Then, verify the "output.cfg" file.There you will see the zcmd command
  12.  
  13. converted.Good luck!
  14.  
  15. */
  16.  
  17. //______________________________________________________________________________
  18.  
  19. #include                                                              " a_samp "
  20.  
  21. //______________________________________________________________________________
  22.  
  23. public OnRconCommand ( cmd [ ] )
  24.  
  25. {
  26.  
  27.     if ( !strcmp ( cmd , "convert" , true ) )
  28.    
  29.     {
  30.    
  31.         new
  32.  
  33.             File:inputfile = fopen ( "Converter/input.cfg" , io_read ) ;
  34.            
  35.         if ( inputfile )
  36.        
  37.         {
  38.        
  39.             new
  40.  
  41.                 inputline [   800   ] ;
  42.                
  43.             while ( fread ( inputfile , inputline ) )
  44.            
  45.             {
  46.            
  47.                 if ( strfind ( inputline , "strcmp" , true ) != -1 )
  48.                
  49.                 {
  50.                
  51.                     new
  52.  
  53.                         zcmdchar = -1 ;
  54.                        
  55.                     for ( new p ; p < strlen ( inputline ) ; p++ )
  56.                    
  57.                     {
  58.                    
  59.                         if ( inputline [ p ] == '/' )
  60.                        
  61.                         {
  62.                        
  63.                             zcmdchar = p ;
  64.                            
  65.                             break ;
  66.                            
  67.                         }
  68.                        
  69.                     }
  70.                    
  71.                     if ( zcmdchar != -1 && inputline [ zcmdchar + 1 ] != '/' )
  72.                    
  73.                     {
  74.                    
  75.                         new
  76.  
  77.                             File:output ;
  78.                            
  79.                         if ( !fexist ( "Converter/output.cfg" ) )
  80.  
  81.                         output = fopen ( "Converter/output.cfg" , io_write ) ;
  82.                        
  83.                         else output = fopen ( "Converter/output.cfg" , io_append ) ;
  84.                        
  85.                         if ( output )
  86.                        
  87.                         {
  88.                        
  89.                             new
  90.  
  91.                                 command [   32   ] ;
  92.                                
  93.                             format ( command , sizeof ( command ) , "%s" , inputline [ zcmdchar + 1 ] ) ;
  94.                            
  95.                             new
  96.  
  97.                                 end = strfind ( command , "\"" , true ) ;
  98.                                
  99.                             strdel ( command , end , strlen ( command ) ) ;
  100.                            
  101.                             new
  102.  
  103.                                 findbracket = strfind ( inputline , "{" , true , zcmdchar ) ;
  104.                                
  105.                             format ( inputline , sizeof ( inputline ) , "CMD:%s(playerid, params[])" , command ) ;
  106.                            
  107.                             if ( findbracket != -1 ) strins ( inputline , "\n{" , strlen ( inputline ) ) ;
  108.                            
  109.                             strins ( inputline , "\n" , strlen ( inputline ) ) ;
  110.                            
  111.                             fwrite ( output , inputline ) ;
  112.                            
  113.                             fclose ( output ) ;
  114.                            
  115.                             continue ;
  116.                            
  117.                         }
  118.                        
  119.                     }
  120.                    
  121.                 }
  122.                
  123.                 new
  124.  
  125.                     File:outputfile ;
  126.                    
  127.                 if ( !fexist ( "Converter/output.cfg" ) )
  128.  
  129.                 outputfile = fopen ( "Converter/output.cfg" , io_write ) ;
  130.                
  131.                 else outputfile = fopen ( "Converter/output.cfg" , io_append ) ;
  132.                
  133.                 if ( outputfile )
  134.                
  135.                 {
  136.                
  137.                     fwrite ( outputfile , inputline ) ;
  138.                    
  139.                     fclose ( outputfile ) ;
  140.                    
  141.                 }
  142.                
  143.             }
  144.            
  145.         }
  146.        
  147.     }
  148.    
  149.     return ( 1 ) ;
  150.    
  151. }
  152.  
  153. //______________________________________________________________________________
Advertisement
Add Comment
Please, Sign In to add comment