Exported Functions You can use the exported functions below to access/modify player money: GetMoney(Client player) - returns given player's money (data type: long) ChangeMoney(Client player, long amount) - changes given player's money by given amount (returns nothing) SetMoney(Client player, long amount) - sets given player's money to given amount (returns nothing) Settings (meta.xml) walletDB - Name of the database file. (Default: wallets.db) walletDefault - Starting money. (Default: 250) walletCap - Money cap. Don't go above 9007199254740991. (Default: 9000000000000000) walletInterval - Autosave interval in minutes, write 0 to disable. (Default: 5) walletSave - Save money after every operation. (not recommended) (Default: false) walletLog - Log money changes. (Default: false) Example Code: int ARMOR_PRICE = 250; [Command("armor")] public void CMD_BuyArmor(Client player) { if (API.exported.MoneyAPI.GetMoney(player) < ARMOR_PRICE) { API.sendChatMessageToPlayer(player, "You don't have enough money."); return; } API.exported.MoneyAPI.ChangeMoney(player, -ARMOR_PRICE); API.setPlayerArmor(player, 100); API.sendChatMessageToPlayer(player, "Bought body armor."); return; } Installation Drop the "MoneyAPI" folder in the archive to your server's "resources" folder, then add Code: <resource src="MoneyAPI" /> to your settings.xml. You can also use "/start MoneyAPI" command, enjoy!
Small Update - Changed the colors to be a bit more GTA Online like. - Changed the way autosave works. - Added a change display, it shows on screen for 3.5 seconds. (screenshot above) Download the attachment on the first post to update.
Code: [01:03:56] Starting MoneyAPI [01:03:57] Resource MoneyAPI started! [01:03:57] MoneyAPI Loaded [01:03:57] -> Database: wallets.db [01:03:57] -> Starting Money: $500 [01:03:57] -> Money Cap: $9.000.000.000.000.000 [01:03:57] -> Autosave: every 5 minutes [01:03:57] -> Save After Operation: Disabled [01:03:57] -> Logging: Enabled [01:03:57] EXCEPTION IN RESOURCE MoneyAPI INSIDE SCRIPTENGINE MoneyAPI [01:03:57] System.DllNotFoundException: SQLite.Interop.dll at (wrapper managed-to-native) System.Data.SQLite.UnsafeNativeMethods:sqlite3_config_none (System.Data.SQLite.SQLiteConfigOpsEnum) at System.Data.SQLite.SQLite3.StaticIsInitialized () [0x0001d] in <c22a89d6bc2c4c319c20c596506ca90a>:0 at System.Data.SQLite.SQLiteLog.Initialize () [0x00000] in <c22a89d6bc2c4c319c20c596506ca90a>:0 at System.Data.SQLite.SQLiteConnection..ctor (System.String connectionString, System.Boolean parseViaFramework) [0x00021] in <c22a89d6bc2c4c319c20c596506ca90a>:0 at System.Data.SQLite.SQLiteConnection..ctor (System.String connectionString) [0x00000] in <c22a89d6bc2c4c319c20c596506ca90a>:0 at (wrapper remoting-invoke-with-check) System.Data.SQLite.SQLiteConnection:.ctor (string) at MoneyAPI.MoneyAPI.MoneyAPI_Init () [0x00252] in <ce2d98293ce945dc8f32576ae5b0dc7d>:0 at GTANetworkServer.API.invokeResourceStart () [0x0000a] in <a8fe20d0070a4c9280bd6b8a9e0f0742>:0 at GTANetworkServer.ScriptingEngine.<InvokeResourceStart>b__28_0 () [0x0002b] in <a8fe20d0070a4c9280bd6b8a9e0f0742>:0 at GTANetworkServer.ScriptingEngine+<>c__DisplayClass23_0.<MainThreadLoop>b__0 (System.Object <p0>) [0x0000a] in <a8fe20d0070a4c9280bd6b8a9e0f0742>:0 [01:03:58] Resource CarinaeRoleplay started! [01:03:58] Started! Waiting for connections.