|
| 1 | +#include <amxmodx> |
| 2 | +#include <ModularWallet> |
| 3 | +#include "MWallet/Utils" |
| 4 | + |
| 5 | +new const __TestPrint_template[] = "[MWallet-Test] %s => %.0f (#%d)"; |
| 6 | +#define TestPrint(%1,%2) \ |
| 7 | + client_print(%1, print_console, __TestPrint_template, fmt(%2), GetUserBalance(UserId), g_iUserSelectedCurrency[UserId]) |
| 8 | + |
| 9 | +#define GetUserBalance(%1) \ |
| 10 | + MWallet_Currency_Get(g_iUserSelectedCurrency[UserId], UserId) |
| 11 | + |
| 12 | +#pragma semicolon 1 |
| 13 | +#pragma compress 1 |
| 14 | + |
| 15 | +public stock const PluginName[] = "[MWallet] Test Commands"; |
| 16 | +public stock const PluginVersion[] = _MWALLET_VERSION; |
| 17 | +public stock const PluginAuthor[] = "ArKaNeMaN"; |
| 18 | +public stock const PluginURL[] = "t.me/arkaneman"; |
| 19 | +public stock const PluginDescription[] = "Some commands for testing Modular Wallet"; |
| 20 | + |
| 21 | +new T_Currency:g_iUserSelectedCurrency[MAX_PLAYERS + 1] = {Invalid_Currency, ...}; |
| 22 | + |
| 23 | +public MWallet_OnInited() { |
| 24 | + RegisterPluginByVars(); |
| 25 | + |
| 26 | + register_clcmd("mwallet_test_select", "@Cmd_Select"); |
| 27 | + register_clcmd("mwallet_test_get", "@Cmd_Get"); |
| 28 | + register_clcmd("mwallet_test_set", "@Cmd_Set"); |
| 29 | + register_clcmd("mwallet_test_credit", "@Cmd_Credit"); |
| 30 | + register_clcmd("mwallet_test_debit", "@Cmd_Debit"); |
| 31 | + register_clcmd("mwallet_test_enough", "@Cmd_Enough"); |
| 32 | +} |
| 33 | + |
| 34 | +@Cmd_Select(const UserId) { |
| 35 | + new sCurrencyName[MWALLET_CURRENCY_MAX_NAME_LEN]; |
| 36 | + read_argv(1, sCurrencyName, charsmax(sCurrencyName)); |
| 37 | + |
| 38 | + g_iUserSelectedCurrency[UserId] = MWallet_Currency_Find(sCurrencyName); |
| 39 | + |
| 40 | + if (g_iUserSelectedCurrency[UserId] == Invalid_Currency) { |
| 41 | + client_print(UserId, print_console, "[MWallet-Test] Currency `%s` not found.", sCurrencyName); |
| 42 | + } else { |
| 43 | + client_print(UserId, print_console, "[MWallet-Test] Select `%s` (#%d) currency.", sCurrencyName, g_iUserSelectedCurrency[UserId]); |
| 44 | + } |
| 45 | +} |
| 46 | + |
| 47 | +@Cmd_Get(const UserId) { |
| 48 | + TestPrint(UserId, "Get", GetUserBalance(UserId)); |
| 49 | +} |
| 50 | + |
| 51 | +@Cmd_Set(const UserId) { |
| 52 | + new Float:fAmount = read_argv_float(1); |
| 53 | + if (MWallet_Currency_Set(g_iUserSelectedCurrency[UserId], UserId, fAmount)) { |
| 54 | + TestPrint(UserId, "Set %.0f", fAmount); |
| 55 | + } else { |
| 56 | + TestPrint(UserId, "Can`t Set %.0f", fAmount); |
| 57 | + } |
| 58 | +} |
| 59 | + |
| 60 | +@Cmd_Credit(const UserId) { |
| 61 | + new Float:fAmount = read_argv_float(1); |
| 62 | + if (MWallet_Currency_Credit(g_iUserSelectedCurrency[UserId], UserId, fAmount)) { |
| 63 | + TestPrint(UserId, "Credit %.0f", fAmount); |
| 64 | + } else { |
| 65 | + TestPrint(UserId, "Can`t Credit %.0f", fAmount); |
| 66 | + } |
| 67 | +} |
| 68 | + |
| 69 | +@Cmd_Debit(const UserId) { |
| 70 | + new Float:fAmount = read_argv_float(1); |
| 71 | + if (MWallet_Currency_Debit(g_iUserSelectedCurrency[UserId], UserId, fAmount)) { |
| 72 | + TestPrint(UserId, "Debit %.0f", fAmount); |
| 73 | + } else { |
| 74 | + TestPrint(UserId, "Can`t Debit %.0f", fAmount); |
| 75 | + } |
| 76 | +} |
| 77 | + |
| 78 | +@Cmd_Enough(const UserId) { |
| 79 | + new Float:fAmount = read_argv_float(1); |
| 80 | + if (MWallet_Currency_IsEnough(g_iUserSelectedCurrency[UserId], UserId, fAmount)) { |
| 81 | + TestPrint(UserId, "Enough %.0f", fAmount); |
| 82 | + } else { |
| 83 | + TestPrint(UserId, "Not Enough %.0f", fAmount); |
| 84 | + } |
| 85 | +} |
0 commit comments