1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. GTA Network forum is now in archive mode.

MoneyAPI

Discussion in 'Scripts' started by rootcause, Mar 22, 2017.

  1. rootcause

    rootcause Member

    Messages:
    18
    Likes Received:
    63
    Joined:
    Jan 2, 2017

    [​IMG]

    [​IMG]

    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!
     

    Attached Files:

    Last edited: Jun 4, 2017
    Xenius, Meinhof, Colm and 5 others like this.
  2. Max_Andolini

    Max_Andolini New Member

    Messages:
    3
    Likes Received:
    0
    Joined:
    Dec 29, 2016
  3. SkyLaGer

    SkyLaGer Member

    Messages:
    19
    Likes Received:
    3
    Joined:
    Feb 20, 2017
    Ooooo yeees. Thx happy~~
     
    « Joseph » likes this.
  4. Trust37

    Trust37 Well-Known Member

    Messages:
    181
    Likes Received:
    49
    Joined:
    Sep 6, 2016
    That is pretty awesome.
     
  5. Electro957

    Electro957 Member

    Messages:
    27
    Likes Received:
    0
    Joined:
    Dec 29, 2016
    how i can give money to players?
     
  6. Electro957

    Electro957 Member

    Messages:
    27
    Likes Received:
    0
    Joined:
    Dec 29, 2016
    how can i give money to players?
     
  7. DurtyFree

    DurtyFree New Member

    Messages:
    0
    Likes Received:
    0
    Joined:
    Oct 30, 2016
    ChangeMoney(Client player, long amount)
    or
    SetMoney(Client player, long amount)
     
  8. Electro957

    Electro957 Member

    Messages:
    27
    Likes Received:
    0
    Joined:
    Dec 29, 2016
    i dont understand where does i need to type ChangeMoney??
     
  9. Nikguin04

    Nikguin04 New Member

    Messages:
    1
    Likes Received:
    0
    Joined:
    Apr 15, 2017
    it says for me the .dll is outdated?
     
  10. rootcause

    rootcause Member

    Messages:
    18
    Likes Received:
    63
    Joined:
    Jan 2, 2017
    [​IMG]

    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.
     
    Meinhof likes this.
  11. lRoberth

    lRoberth Member

    Messages:
    13
    Likes Received:
    1
    Joined:
    Apr 10, 2017
    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.
    
     

Share This Page