Garry's Mod

Garry's Mod

Not enough ratings
A bitcoins system
   
Award
Favorite
Favorited
Unfavorite
Content Type: Addon
Addon Type: Server content
Addon Tags: Roleplay, Realism
File Size
Posted
4.863 MB
4 Aug, 2024 @ 1:35am
1 Change Note ( view )

Subscribe to download
A bitcoins system

Description
My bitcoins system from 3 years ago, should be all working though.
You can use it all you want, just dont steal credits for it.

I'd HIGHLY suggest extracting the addon and modifying the config located in lua/bitcoins_system/sh/config.lua

Features SQLite support for logging.

Features:
A panel where players can see their wallet key, amount of bitcoins and the price of it!
An entity which shows the current price of bitcoin and the last change!
Players can buy, sell and/or transfer their bitcoins to a key of another player, you're never sure who are you sending the bitcoins to!
This addon uses SQLite for storing player's info, no MySql for now.
Most of the features are highly customizable and the addon is made in the way so developers have as much freedom with it!
Support for CODE BLUE's bitminers (bitcoins in the bitminer will be the same price as in the addon)
A set of commands to use the addon!
A bunch of hooks for you to make custom features!
An user-friendly admin panel as well as console commands!
Commands:
bitcoins_logs - Displays logs (Admins by default)
bitcoins_clearlogs - Clears logs from the addon (Superadmin by default)
bitcoins_stats - Shows statistics from online and offline players (Admin by default)
bitcoins_add ("target key", amount) - Adds a specific amount of bitcoins to a player (Superadmin by default)
bitcoins_remove ("target key", amount) - Subtracts a specific amount of bitcoins from a player (Superadmin by default)
bitcoins_reload - Reloads the addon server-side (works only from console, players can reload the script client-side if they are superadmin)
bitcoins - Opens up the bitcoin menu

Functions:

Player:AddBitcoins(amount)
Player:SellBitcoins(amount)
Player:BuyBitcoins(amount)
BITSInflateDeflate() - Sets a new randomized price for the bitcoin (if you want to make your own function that triggers this, you can disable triggering this every fixed interval in the config) (ignores cooldowns)
Player:SubtractBitcoins(amount)
Player:GenerateKey() - Generates a new key for a player
Player:TransferBitcoins(key,amount) - Transfers bitcoins to a specific key that matches a player
BITUpdateValue(currentprice,difference) - Updates the value of bitcoin (difference variable is by how much the price should change, if you want to change the price from 500 to 400 you should set this variable to -100)
GetPlyFromBITKey(key) - Returns the player as an object that matches the key
Hooks:

"bitupdate",old,new - Ran when bitcoin changes price by the function BITSInflateDeflate (new value is by how much the price changed)
"bitsold", player, amount - Ran after bitcoins were sold
"bitbought",player,amount - Ran after bitcoins were bought
"bitnewkey",player,key - Ran after generating a new key for a player
"bittrans",player,target,amount - Ran after transfering bitcoins, target returns the player as an object
"BITConfigLoaded" - Ran after loading the config
"bitsremovedadmin",admin, target, amount - Ran after removing bitcoins with commands
"bitsaddedadmin",admin, target, amount - Ran after adding bitcoins with commands
"bitschangeddb",admin,steamid changed,bitcoins - Ran after changing the players database for bitcoins
Values:

bits.value - Holds the current value for a bitcoin
Player.bitkey - Holds the player's current key
Player.bitsamount - Holds the player's current bitcoins


Changing the price should use the function BITUpdateValue()
SQLite uses tables "bitcoins_players" and "bitcoins_value", first one holds steamids and amount of bitcoins, latter holds the current bitcoin value and the fluctuate value