Death-Gm

DCoins

Apr 2nd, 2014
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. #if defined _DCoins_included
  2. #endinput
  3. #endif
  4. #define _DCoins_included
  5.  
  6. #if ( !defined pasta )
  7. #error local para Guardadar Dados não definido , exemple: #define pasta "local"
  8. #endif
  9.  
  10. new File:Arquivo;
  11. new coin[MAX_PLAYERS];
  12.  
  13. stock SetPlayerCents(playerid, coins) return coin[playerid] = coins;
  14. stock GivePlayerCents(playerid, coins) return coin[playerid] += coins;
  15. stock ResetPlayerCents(playerid) return coin[playerid] = 0;
  16. stock GetPlayerCents(playerid) return coin[playerid];
  17.  
  18. stock SaveCents(playerid) {
  19. new st[128], nm[MAX_PLAYER_NAME];
  20. GetPlayerName(playerid, nm, MAX_PLAYER_NAME);
  21. format(st, sizeof(st), "%s/%s.ini", pasta, nm);
  22. Arquivo = fopen(st, io_append);
  23. if(Arquivo) {
  24. fremove(st);
  25. fclose(Arquivo);
  26. Arquivo = fopen(st, io_write);
  27. new e[500];
  28. format(e, sizeof(e), "%d", coin[playerid]);
  29. fwrite(Arquivo, e);
  30. fclose(Arquivo);
  31. }
  32. return 1;
  33. }
  34.  
  35. stock LoadCents(playerid) {
  36. new st[128],
  37. nm[MAX_PLAYER_NAME],
  38. bool:Exist;
  39.  
  40.  
  41. GetPlayerName(playerid, nm, MAX_PLAYER_NAME);
  42.  
  43. format(st, sizeof(st), "%s/%s.ini", pasta, nm);
  44.  
  45. Arquivo = fopen(st, io_append);
  46.  
  47. if(Arquivo) Exist = true;
  48. else Exist = false;
  49. if(Exist == true) {
  50. new str[500];
  51. Arquivo = fopen(st, io_read);
  52. fread(Arquivo, str);
  53. new valor = strval(str);
  54. coin[playerid] = valor;
  55. fclose(Arquivo);
  56. } else {
  57. Arquivo = fopen(st, io_write);
  58. fwrite(Arquivo, "0");
  59. fclose(Arquivo);
  60. }
  61. return 1;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment