FoxHound

FoxPayDay_v4

Mar 7th, 2011
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.00 KB | None | 0 0
  1.         ////-/////-/////-/////-/////-/////-/////-/////-/////-/////-/////-/////-/////-//
  2.        //                        FOXHOUND'S EASY PAYDAY SCRIPT                      //
  3.       //                                  FoxPayDay!                               //
  4.      //                        COPYRIGHT BY FOXHOUND / PSPGAMER                   //
  5.     ////-/////-/////-/////-/////-/////-/////-/////-/////-/////-/////-/////-/////-//
  6.  
  7. #include <a_samp>
  8.  
  9. #pragma unused pdtimer
  10. #pragma unused FPD_ret_memcpy
  11.  
  12. //---------------------------< _-_-_-_-_ >---------------------------//
  13.       #define PayDaySaveDir "FoxPayDay/%s.fpd" //PayDay Data Save Directory
  14.       #define pdprotime 60                     //payday pro 60 minutes (minutes)
  15. //-------------------------------------------------------------------//
  16.  
  17. forward OnPlayerPayDay(playerid);
  18.  
  19. new pdtimer[MAX_PLAYERS],pdplus[MAX_PLAYERS];
  20.  
  21. #define SetPlayerPayDayTime(%1,%2) pdplus[%1] = %2
  22. forward GetPlayerPayDayTime(playerid);public GetPlayerPayDayTime(playerid) { return pdplus[playerid]; }
  23. #define StartPayDayTime(%1) pdtimer[%1] = SetTimerEx("pluspdtime",60000,1,"i",%1)
  24. #define StopPayDayTime(%1) KillTimer(pdtimer[%1])
  25. stock pluspdtime(playerid)
  26. {
  27.     new fpd_str_[64],fpd_pname_[MAX_PLAYER_NAME];
  28.     GetPlayerName(playerid,fpd_pname_,sizeof(fpd_pname_));
  29.     format(fpd_str_,sizeof(fpd_str_),PayDaySaveDir,fpd_pname_);
  30.     if(!FPD_dini_Exist(fpd_str_)) { FPD_dini_Create(fpd_str_); }
  31.     pdplus[playerid]+=1;
  32.     if(pdplus[playerid] >= pdprotime)
  33.     {
  34.         CallLocalFunction("OnPlayerPayDay","i",playerid);
  35.         pdplus[playerid] = 0;
  36.     }
  37.     FPD_dini_IntSet(fpd_str_,"PayDayTime",pdplus[playerid]);
  38. }
  39.  
  40. stock FPD_set(dest[],source[]) {
  41.     new count = strlen(source),i=0; for (i=0;i<count;i++) {
  42.         dest[i]=source[i]; }
  43.     dest[count]=0; }
  44. FPD_ret_memcpy(source[],index=0,numbytes) {
  45.     new tmp[255],i=0; tmp[0]=0; if (index>=strlen(source)) return tmp; if (numbytes+index>=strlen(source)) numbytes=strlen(source)-index; if (numbytes<=0) return tmp; for (i=index;i<numbytes+index;i++) {
  46.         tmp[i-index]=source[i]; if (source[i]==0) return tmp; }
  47.     tmp[numbytes]=0; return tmp; }
  48. stock FPD_equal(str1[],str2[],bool:ignorecase) { if (strlen(str1)!=strlen(str2)) return false; if (strcmp(str1,str2,ignorecase)==0) return true; return false; }
  49. stock FPD_StripNewLine(string[]) { new len = strlen(string); if (string[0]==0) return ; if ((string[len - 1] == '\n') || (string[len - 1] == '\r')) { string[len - 1] = 0; if (string[0]==0) return ; if ((string[len - 2] == '\n') || (string[len - 2] == '\r')) string[len - 2] = 0; } }
  50. stock FPD_dini_Exists(filename[]) { if (fexist(filename)) return true; return false; }
  51. stock FPD_dini_Create(filename[]) { new File:fhnd; if (fexist(filename)) return false; fhnd=fopen(filename,io_write); fclose(fhnd); return true; }
  52. stock FPD_dini_IntSet(filename[],key[],value) { new valuestring[255]; format(valuestring,sizeof(valuestring),"%d",value); return FPD_dini_Set(filename,key,valuestring); }
  53. stock FPD_dini_Set(filename[],key[],value[]) {
  54.     new File:fohnd, File:fwhnd; new bool:wasset=false; new tmpres[255]; if (key[0]==0) return false; format(tmpres,sizeof(tmpres),"%s.part",filename); fohnd=fopen(filename,io_read); if (!fohnd) return false; fremove(tmpres); fwhnd=fopen(tmpres,io_write); while (fread(fohnd,tmpres)) {
  55.         FPD_StripNewLine(tmpres); if ((!wasset)&&(FPD_equal(FPD_dini_PRIVATE_ExtractKey(tmpres),key,true))) { format(tmpres,sizeof(tmpres),"%s=%s",key,value); wasset=true; }
  56.         fwrite(fwhnd,tmpres); fwrite(fwhnd,"\r\n"); }
  57.     if (!wasset) { format(tmpres,sizeof(tmpres),"%s=%s",key,value); fwrite(fwhnd,tmpres); fwrite(fwhnd,"\r\n"); }
  58.     fclose(fohnd); fclose(fwhnd); format(tmpres,sizeof(tmpres),"%s.part",filename); if (fcopytextfile(tmpres,filename)) { return fremove(tmpres); }
  59.     return false; }
  60. stock FPD_dini_PRIVATE_ExtractKey(line[]) { new tmp[255]; tmp[0]=0; if (strfind(line,"=",true)==-1) return tmp; FPD_set(tmp,strlower(FPD_ret_memcpy(line,0,strfind(line,"=",true)))); return tmp; }
  61. stock FPD_dini_PRIVATE_ExtractValue(line[]) {
  62.     new tmp[255]; tmp[0]=0; if (strfind(line,"=",true)==-1) { return tmp; }
  63.     FPD_set(tmp,FPD_ret_memcpy(line,strfind(line,"=",true)+1,strlen(line))); return tmp; }
Advertisement
Add Comment
Please, Sign In to add comment