Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FILTERSCRIPT
- #include <a_samp>
- #include <zcmd>
- #include <dini>
- #define COLOR_WHITE 0xffffffff
- #define COLOR_LIGHTGREEN 0x00ff00ff
- //Colores Pawno Generados por PawnoGen v0.2 by Shoock
- #pragma tabsize 0
- new archivo[256];
- public OnFilterScriptInit()
- {
- print("-----------------------------------------");
- print("----------Bank System by rooT.----------");
- print("-----------------------------------------");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- CMD:depositar(playerid, params[])
- {
- new dinero, string[128];
- if(sscanf(params, "d", dinero)) return SendClientMessage(playerid, COLOR_WHITE, "USO: /depositar <cantidad>");
- if(!sscanf(params, "d", dinero))
- {
- if(GetPlayerMoney(playerid) < dinero) return SendClientMessage(playerid, COLOR_LIGHTGREEN, "No tienes ese dinero!");
- if(GetPlayerMoney(playerid) >= dinero)
- {
- new pname[MAX_PLAYER_NAME];
- GetPlayerName(playerid, pname, sizeof(pname));
- format(archivo, sizeof(archivo), "Banco/%s.txt", pname);
- if(dini_Exists(archivo))
- {
- dini_IntSet(archivo, "Saldo", dini_Int(archivo, "Saldo") +dinero);
- }
- else if(!dini_Exists(archivo))
- {
- dini_Create(archivo);
- dini_IntSet(archivo, "Saldo", dinero);
- }
- format(string, sizeof(string), "|- Banco -| Depositaste %d, tu saldo actual es %d", dinero, dini_Int(archivo, "Saldo"));
- SendClientMessage(playerid, COLOR_LIGHTGREEN, string);
- GivePlayerMoney(playerid, -dinero);
- }
- }
- return 1;
- }
- CMD:retirar(playerid, params[])
- {
- new dinero, string[128];
- if(sscanf(params, "d", dinero)) return SendClientMessage(playerid, COLOR_WHITE, "USO: /retirar <cantidad>");
- if(!sscanf(params, "d", dinero))
- {
- new pname[MAX_PLAYER_NAME];
- GetPlayerName(playerid, pname, sizeof(pname));
- format(archivo, sizeof(archivo), "Banco/%s.txt", pname);
- if(dini_Exists(archivo))
- {
- if(dini_Int(archivo, "Saldo") < dinero) return SendClientMessage(playerid, COLOR_LIGHTGREEN, "No tienes esa cantidad de dinero en el banco!");
- else if(dini_Int(archivo, "Saldo") >= dinero)
- {
- GivePlayerMoney(playerid, dinero);
- dini_IntSet(archivo, "Saldo", dini_Int(archivo, "Saldo") -dinero);
- format(string, sizeof(string), "|- Banco -| Retiraste %d, tu saldo actual es %d", dinero, dini_Int(archivo, "Saldo"));
- SendClientMessage(playerid, COLOR_LIGHTGREEN, string);
- }
- }
- else if(!dini_Exists(archivo))
- {
- SendClientMessage(playerid, COLOR_LIGHTGREEN, "|- Banco -| No tienes cuenta en el banco!");
- }
- }
- return 1;
- }
- CMD:saldo(playerid, params[])
- {
- new pname[MAX_PLAYER_NAME];
- GetPlayerName(playerid, pname, sizeof(pname));
- format(archivo, sizeof(archivo), "Banco/%s.txt", pname);
- if(dini_Exists(archivo))
- {
- new string[128];
- format(string, sizeof(string), "|- Banco -| Tu saldo actual es %d", dini_Int(archivo, "Saldo"));
- SendClientMessage(playerid, COLOR_LIGHTGREEN, string);
- }
- else if(!dini_Exists(archivo))
- {
- SendClientMessage(playerid, COLOR_LIGHTGREEN, "|- Banco -| No tienes cuenta en el banco!");
- }
- return 1;
- }
- CMD:banco(playerid, params[])
- {
- SendClientMessage(playerid, COLOR_LIGHTGREEN, "Comandos del banco:");
- SendClientMessage(playerid, COLOR_LIGHTGREEN, "/depositar <cantidad>: Deposita X cantidad de dinero.");
- SendClientMessage(playerid, COLOR_LIGHTGREEN, "/retirar <cantidad>: Retira X cantidad de dinero.");
- SendClientMessage(playerid, COLOR_LIGHTGREEN, "/saldo: Para ver tu saldo en el banco");
- return 1;
- }
- //------------------------------Sscanf-----------------------------------------
- stock sscanf(string[], format[], {Float,_}:...)
- {
- new
- formatPos = 0,
- stringPos = 0,
- paramPos = 2,
- paramCount = numargs();
- while (paramPos < paramCount && string[stringPos])
- {
- switch (format[formatPos++])
- {
- case '\0':
- {
- return 0;
- }
- case 'i', 'd':
- {
- new
- neg = 1,
- num = 0,
- ch = string[stringPos];
- if (ch == '-')
- {
- neg = -1;
- ch = string[++stringPos];
- }
- do
- {
- stringPos++;
- if (ch >= '0' && ch <= '9')
- {
- num = (num * 10) + (ch - '0');
- }
- else
- {
- return 1;
- }
- }
- while ((ch = string[stringPos]) && ch != ' ');
- setarg(paramPos, 0, num * neg);
- }
- case 'h', 'x':
- {
- new
- ch,
- num = 0;
- while ((ch = string[stringPos++]))
- {
- switch (ch)
- {
- case 'x', 'X':
- {
- num = 0;
- continue;
- }
- case '0' .. '9':
- {
- num = (num << 4) | (ch - '0');
- }
- case 'a' .. 'f':
- {
- num = (num << 4) | (ch - ('a' - 10));
- }
- case 'A' .. 'F':
- {
- num = (num << 4) | (ch - ('A' - 10));
- }
- case ' ':
- {
- break;
- }
- default:
- {
- return 1;
- }
- }
- }
- setarg(paramPos, 0, num);
- }
- case 'c':
- {
- setarg(paramPos, 0, string[stringPos++]);
- }
- case 'f':
- {
- new tmp[25];
- strmid(tmp, string, stringPos, stringPos+sizeof(tmp)-2);
- setarg(paramPos, 0, _:floatstr(tmp));
- }
- case 's', 'z':
- {
- new
- i = 0,
- ch;
- if (format[formatPos])
- {
- while ((ch = string[stringPos++]) && ch != ' ')
- {
- setarg(paramPos, i++, ch);
- }
- if (!i) return 1;
- }
- else
- {
- while ((ch = string[stringPos++]))
- {
- setarg(paramPos, i++, ch);
- }
- }
- stringPos--;
- setarg(paramPos, i, '\0');
- }
- default:
- {
- continue;
- }
- }
- while (string[stringPos] && string[stringPos] != ' ')
- {
- stringPos++;
- }
- while (string[stringPos] == ' ')
- {
- stringPos++;
- }
- paramPos++;
- }
- while (format[formatPos] == 'z') formatPos++;
- return format[formatPos];
- }
- //---------------------Fin Sscanff--------------------
Advertisement
Add Comment
Please, Sign In to add comment