Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #if defined _DCoins_included
- #endinput
- #endif
- #define _DCoins_included
- #if ( !defined pasta )
- #error local para Guardadar Dados não definido , exemple: #define pasta "local"
- #endif
- new File:Arquivo;
- new coin[MAX_PLAYERS];
- stock SetPlayerCents(playerid, coins) return coin[playerid] = coins;
- stock GivePlayerCents(playerid, coins) return coin[playerid] += coins;
- stock ResetPlayerCents(playerid) return coin[playerid] = 0;
- stock GetPlayerCents(playerid) return coin[playerid];
- stock SaveCents(playerid) {
- new st[128], nm[MAX_PLAYER_NAME];
- GetPlayerName(playerid, nm, MAX_PLAYER_NAME);
- format(st, sizeof(st), "%s/%s.ini", pasta, nm);
- Arquivo = fopen(st, io_append);
- if(Arquivo) {
- fremove(st);
- fclose(Arquivo);
- Arquivo = fopen(st, io_write);
- new e[500];
- format(e, sizeof(e), "%d", coin[playerid]);
- fwrite(Arquivo, e);
- fclose(Arquivo);
- }
- return 1;
- }
- stock LoadCents(playerid) {
- new st[128],
- nm[MAX_PLAYER_NAME],
- bool:Exist;
- GetPlayerName(playerid, nm, MAX_PLAYER_NAME);
- format(st, sizeof(st), "%s/%s.ini", pasta, nm);
- Arquivo = fopen(st, io_append);
- if(Arquivo) Exist = true;
- else Exist = false;
- if(Exist == true) {
- new str[500];
- Arquivo = fopen(st, io_read);
- fread(Arquivo, str);
- new valor = strval(str);
- coin[playerid] = valor;
- fclose(Arquivo);
- } else {
- Arquivo = fopen(st, io_write);
- fwrite(Arquivo, "0");
- fclose(Arquivo);
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment