Advertisement
RaFaeLs

## SA:MP RL_FILES plugin v1.2.4 ##

Jan 29th, 2013
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.97 KB | None | 0 0
  1. /*
  2.  *                              rl_files 0.1.2
  3.  *        All right reserved! © By: RaFaeL
  4.  *
  5.  * Owner                : RaFaeL
  6.  * Time                 : 28.01.2013
  7.  *
  8.  * Thanks to:
  9.  *                      RaFaeL                           - Scripting, PAWN
  10.  *                      Kyosaur                          - How to build plugin
  11.  *                      SA:MP Team past, present, future - SA:MP.
  12.  *
  13.  *
  14.  * Functions:
  15.  *          fcheck(dir[], idx) - Check if file exist by idx
  16.  *          fnum(dir[]) - Return how much files in dir
  17.  *          fname(dir[], idx, souce[], len = sizeof(souce)) - Return the file name by idx
  18.  *          fprint(dir[]) - Print all files in dir
  19.  *          fend(file[], len = sizeof(file)) - Delete the file .(dot)
  20.  *
  21.  * CallBacks:
  22.  *          None.
  23.  *
  24.  * Update:
  25.  *      28.01.2013:
  26.  *          Other:              - First Release
  27.  *                              - Bug fixed
  28.  *      29.01.2013:
  29.  *          Functions:          - fend(file[], len = sizeof(file))
  30.  *                              -
  31.  *
  32.  *          Other:
  33.  *                              - fnum(dir[]) changed to PAWN scripted function
  34.  *                              - No meter if "." or "" directory
  35.  *
  36.  */
  37.  
  38. #if defined rl_files
  39.     #error files is already defined!
  40. #endif
  41. #define rl_files
  42.  
  43.  
  44. #define MAX_FILE_NAME    64
  45. #define NULL_DIR         "."
  46. #define PRINT_FORMAT "%s/%s",dir,file
  47.  
  48. native fname(dir[], idx, souce[], len = sizeof(souce));
  49.  
  50. stock fprint(dir[]) {
  51.     new
  52.         idx,
  53.         file[MAX_FILE_NAME];
  54.     while(fname(dir, idx, file)) {
  55.         printf(PRINT_FORMAT);
  56.         idx++;
  57.     }
  58.     return 1;
  59. }
  60.  
  61. stock fnum(dir[]) {
  62.     new
  63.         idx,
  64.         file[MAX_FILE_NAME];
  65.     while(fname(dir, idx, file)) {
  66.         idx++;
  67.     }
  68.     return idx;
  69. }
  70.  
  71. stock fcheck(dir[], idx) {
  72.     new
  73.         file[MAX_FILE_NAME];
  74.     if(!fname(dir, idx, file))
  75.         return 0;
  76.     return 1;
  77. }
  78.  
  79. stock fend(file[], len = sizeof(file)) {
  80.     new
  81.         ret[MAX_FILE_NAME];
  82.     strcat((ret[0] = EOS, ret), file);
  83.     strdel(ret, strfind(ret, ".", true), len);
  84.     return ret;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement