byted

h_INI

Apr 2nd, 2014
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.03 KB | None | 0 0
  1. // h_INI - Simples, porém util :D
  2. // Include super facil de se usar,funções:
  3. // h_Open("diretorio\arquivo.ini(.txt,etc)");
  4. // h_Write("texto ou numero");
  5. // h_Read();
  6. // h_Close();
  7. #include a_samp
  8.  
  9. #define MAX_STRING 128
  10. new bool:Open;
  11. new File: b;
  12.  
  13. stock h_Open(const file[MAX_STRING])
  14. {
  15.     if(Open == true) return 0;
  16.     Open = true;
  17.     b = fopen(file, io_readwrite);
  18.     for(new i; i < 1; i++) if(b) continue;
  19.     return 1;
  20. }
  21.  
  22. stock h_Write(const string[MAX_STRING])
  23. {
  24.     if(Open == false) return 0;
  25.     new str[128];
  26.     format(str,sizeof(str),"%s \r",string);
  27.     fwrite(b,str);
  28.     return 1;
  29. }
  30.  
  31. stock h_Read()
  32. {
  33.     new str[128];
  34.     fread(b,str);
  35.     return str;
  36. }
  37.  
  38. stock h_Close()
  39. {
  40.     if(Open == false) return 0;
  41.     fclose(b);
  42.     Open = false;
  43.     return 1;
  44. }
  45.  
  46. /* TESTE DE VELOCIDADE E EXEMPLO: 1ms entre 0ms
  47. main()
  48. {
  49.     new tick;
  50.     tick=GetTickCount();
  51.     h_Open("player.ini");
  52.     h_Write("Byted bonito");
  53.     h_Close();
  54.     h_Open("player.info");
  55.     printf("%s",h_Read());
  56.     h_Close();
  57.     printf("%d ms",GetTickCount()-tick);
  58. }
  59. */
Advertisement
Add Comment
Please, Sign In to add comment