Advertisement
Guest User

Untitled

a guest
Apr 16th, 2011
926
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.34 KB | None | 0 0
  1. /*////////////////////////////////////////////////////////////////////////////////
  2.  
  3.                      _ ____        _____          __  __
  4.                     (_)  _ \ ___  |_   _|__  __ _|  \/  |
  5.                     | | |_) / __|   | |/ _ \/ _` | |\/| |
  6.                     | |  __/\__ \   | |  __/ (_| | |  | |
  7.                     |_|_|   |___/   |_|\___|\__,_|_|  |_|
  8.  
  9.                         Intelligent Programming Style ®
  10.                        
  11.                          ____________________________
  12.                           www.ips-team.blogspot.com
  13.                          www.ips-team.forumeiros.com
  14.                          ____________________________
  15.                          
  16.                          Created By DraKiNs & SlashPT
  17.                          Thanks to [iPs]TeaM and Jhony
  18.  
  19. */////////////////////////////////////////////////////////////////////////////////
  20.  
  21.  
  22. //========= [ Configs of Read/Write Files ] ====================================
  23.  
  24. #define maxtag      (00128)
  25. #define maxfile     (99999)
  26. #define maxname     (00064)
  27.  
  28. //==========[ Defines Funnctions ] =============================================
  29.  
  30. #define Fini_Exists             fexist
  31. #define Fini_GetFloat(%0)       floatstr(Fini_GetStr(%0))
  32.  
  33. //========= [ Variables of Set/Get Ini ] =======================================
  34.  
  35. new
  36.     iSource,
  37.     zNormal1,
  38.     fStr[maxtag],
  39.     fTag[maxtag],
  40.     fFile[maxfile],
  41.     File:zFopenFile,
  42.     fName[maxname],
  43.     sSeting[24];
  44.  
  45. //===========[ Functions of Fini ]==============================================
  46.  
  47. stock   Fini_OpenFile(fname[])
  48. {
  49.     zFopenFile = fopen(fname,io_read);
  50.     while(fread(zFopenFile,fStr)) strins(fFile,fStr,strlen(fFile),maxfile);
  51.     fclose(zFopenFile);
  52.     return format(fName,maxname,"%s",fname);
  53. }
  54.  
  55. stock   Fini_SaveFile()
  56. {
  57.     fremove(fName);
  58.     zFopenFile = fopen(fName,io_write);
  59.     fwrite(zFopenFile,fFile);
  60.     return fclose(zFopenFile);
  61. }
  62.  
  63. stock   Fini_CloseFile()
  64. {
  65.     fFile[0x0] = '\0';
  66.     return fName[0x0] = '\0';
  67. }
  68.  
  69. stock   Fini_GetStr(ftag[])
  70. {
  71.     format(fTag, maxtag, "%s=", ftag);
  72.     iSource = strfind(fFile, fTag, false) + 0x1;
  73.     strmid(fTag, fFile, iSource + strlen(fTag) - 0x1, strfind(fFile, "\n", false, iSource));
  74.     return fTag;
  75. }
  76.  
  77. stock   Fini_SetStr(ftag[],fstr[])
  78. {
  79.     format(fTag,maxtag, "%s=", ftag);
  80.     zNormal1 = strfind(fFile,fTag, true);
  81.     if(zNormal1 != -1)
  82.     {
  83.         strdel(fFile,zNormal1-1, strfind(fFile, "\n", false,zNormal1));
  84.         format(fTag,maxtag, "%s=%s\r\n",ftag,fstr);
  85.         strins(fFile, fTag, strlen(fFile));
  86.     }
  87.     else
  88.     {
  89.         format(fTag,maxtag, "%s=%s\r\n",ftag,fstr);
  90.         strins(fFile,fTag, strlen(fFile));
  91.     }
  92.     return true;
  93. }
  94.  
  95. stock   Fini_Create(nFile[])
  96. {
  97.     if(Fini_Exists(nFile)) return false;
  98.     zFopenFile = fopen(nFile,io_write);
  99.     return fclose(zFopenFile);
  100. }
  101.  
  102. stock   Fini_SetVal(ftag[],fval)
  103. {
  104.     format(sSeting,maxtag,"%d",fval);
  105.     return Fini_SetStr(ftag,sSeting);
  106. }
  107.  
  108. stock   Fini_SetFloat(ftag[],Float:fval)
  109. {
  110.     format(sSeting,maxtag,"%f",fval);
  111.     return Fini_SetStr(ftag,sSeting);
  112. }
  113.  
  114. stock   Fini_SetBool(ftag[],bool:fval)
  115. {
  116.     format(sSeting,maxtag,"%d",fval);
  117.     return Fini_SetStr(ftag,sSeting);
  118. }
  119.  
  120. stock   Fini_IsSet(ftag[])
  121. {
  122.     format(fTag,maxtag,"%s=%s",ftag,Fini_GetStr(ftag));
  123.     zNormal1 = strfind(fFile,ftag,true);
  124.     if(zNormal1 != -1) return true;
  125.     return false;
  126. }
  127.  
  128. stock   Fini_GetBool(ftag[])
  129. {
  130.     return  bool:strval(Fini_GetStr(ftag));
  131. }  
  132.  
  133. stock   Fini_GetValue(ftag[])
  134. {
  135.     return strval(Fini_GetStr(ftag));
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement