Git Product home page Git Product logo

moneydb's Introduction

MoneyDB casino collection

A collection of scripts useful for running StarfallEx-based casinos. Includes MoneyDB, which allows for the management of money on servers that do not have their own money system.

Warning

The gambling machines in this repository do not use cryptographically secure random number generation, and are intended for entertainment purposes only. Don't use fake money you particularly care about, and definitely don't use any form of real money or anything that can be exchanged for real money. There are only a limited number of extremely basic sanity and security checks, and they should not be depended upon.

Additionally, the backend code is not well written and the API is not well designed, and there are known bugs that may cause crashes, corruption of the MoneyDB database, or crazy values. Machines should be monitored and babysat to ensure everything is working fine, since they tend to act up sometimes.

Usage (user)

  1. git clone https://github.com/x4fx77x4f/moneydb.git
  2. ln -s "$(realpath moneydb)" ~/.steam/steam/steamapps/common/GarrysMod/garrysmod/data/starfall/casino
  3. Flash casino/moneydb/init.lua to a chip
  4. Flash casino/atm/init.lua to another chip and connect a screen to it (recommended but not required)
  5. Flash any MoneyDB compatible code to another chip (such as casino/poker/init.lua)

Usage (developer)

I have included sample code here. Additionally, see moneydb/init_demo.lua, the MoneyDB source code, as well as the source code of the ATM and poker machine.

--@server
--@include casino/moneydb/sv_lib.lua
require('casino/moneydb/sv_lib.lua')
assert(moneydb.init(), "could not find host")
moneydb.getBalance(owner(), function(success, balance)
	print(string.format("Your balance: $%d", balance))
end)

The balance is a signed integer that has a bit width that is implementation defined, and stored in MDB_MONEY_WIDTH. It is important that you always use that constant rather than just assuming that it will stay the same, as corruption can occur if the wrong width is used. Constants are defined in moneydb/sh_constants.lua.

API

Entity or nil host = moneydb.init(Player or nil owner of host)

Looks for and finds any MoneyDB host chips owned by the provided owner, or the owner of the current chip if not specified. If a host is found, moneydb.host is set to it and it is returned. Otherwise, nil is returned.

void moneydb.onInit(function callback, Player or nil owner of host)

Similar to moneydb.init, but asynchronous. The callback will be called with a single parameter of true once a host is found. If no host is found, it will keep trying indefinitely.

void moneydb.increaseBalance(Player or string entity or SteamID, number amount, function callback)

Increases the player's balance by a certain amount. The callback will be called with a single boolean parameter that is either true or false depending on whether the operation succeeded.

void moneydb.decreaseBalance(Player or string entity or SteamID, number amount, function callback)

Decreases the player's balance by a certain amount. The callback will be called with a single boolean parameter that is either true or false depending on whether the operation succeeded.

void moneydb.transferMoney(Player or string source, Player or string destination, number amount, function callback)

Decreases the source player's balance by a certain amount, and increase's the destination player's balance by the same amount. The callback will be called with a single boolean parameter that is either true or false depending on whether the operation succeeded.

void moneydb.getBalance(Player or string entity or SteamID, function callback)

Gets the player's balance. The callback will be called with a boolean parameter that is either true or false depending on whether the operation succeeded, and a number parameter corresponding to the player's balance.

void moneydb.setBalance(Player or string entity or SteamID, number amount, function callback)

Sets the player's balance. The callback will be called with a single boolean parameter that is either true or false depending on whether the operation succeeded.

number index = moneydb.addToQueue(function callback, number action, varargs parameters)

For internal use only. Manually injects an action into the queue. You should not use numbers directly as they are implementation defined, instead you should use the constants starting with MDB_ACTION_. Needed parameters vary depending on the action.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.