Installation Guide

Step 1: SQL Modifications

You must execute the SQL code to set up the necessary database tables.

Instructions

  1. Open your database management tool (e.g., phpMyAdmin or HeidiSQL).

  2. Select Your Database.

  3. Run the following SQL query in your database to create the required table:

CREATE TABLE `moon_loans` (
	`id` INT(11) NOT NULL AUTO_INCREMENT,
	`license` VARCHAR(50) NULL DEFAULT NULL COLLATE 'utf8mb3_general_ci',
	`citizenid` VARCHAR(50) NULL DEFAULT NULL COLLATE 'utf8mb3_general_ci',
	`loanamount` INT(11) NOT NULL DEFAULT '0',
	`loanperiod` INT(11) NOT NULL DEFAULT '0',
	`moneydrawn` INT(1) NOT NULL DEFAULT '0',
	`fullname` VARCHAR(100) NOT NULL DEFAULT '' COLLATE 'utf8mb3_general_ci',
	`creditscore` INT(11) NOT NULL DEFAULT '0',
	`numPaymentsMade` INT(11) NOT NULL DEFAULT '0',
	PRIMARY KEY (`id`) USING BTREE,
	INDEX `citizenid` (`citizenid`) USING BTREE,
	INDEX `license` (`license`) USING BTREE
)
COLLATE='utf8mb3_general_ci'
ENGINE=InnoDB
AUTO_INCREMENT=0
;

CREATE TABLE `moon_loans_requests` (
	`id` INT(11) NOT NULL AUTO_INCREMENT,
	`license` VARCHAR(50) NULL DEFAULT NULL COLLATE 'utf8mb3_general_ci',
	`citizenid` VARCHAR(50) NULL DEFAULT NULL COLLATE 'utf8mb3_general_ci',
	`loanamount` INT(11) NOT NULL DEFAULT '0',
	`loanperiod` INT(11) NOT NULL DEFAULT '0',
	`status` INT(1) NOT NULL DEFAULT '0',
	`fullname` VARCHAR(100) NOT NULL DEFAULT '' COLLATE 'utf8mb3_general_ci',
	`creditscore` INT(11) NOT NULL DEFAULT '0',
	PRIMARY KEY (`id`) USING BTREE,
	INDEX `citizenid` (`citizenid`) USING BTREE,
	INDEX `license` (`license`) USING BTREE
)
COLLATE='utf8mb3_general_ci'
ENGINE=InnoDB
AUTO_INCREMENT=0
;

CREATE TABLE `credit_score_history` (
	`id` INT(11) NOT NULL AUTO_INCREMENT,
	`citizenid` VARCHAR(50) NOT NULL COLLATE 'utf8mb4_general_ci',
	`change_amount` INT(11) NOT NULL,
	`reason` VARCHAR(255) NOT NULL COLLATE 'utf8mb4_general_ci',
	`created_at` TIMESTAMP NOT NULL DEFAULT current_timestamp(),
	PRIMARY KEY (`id`) USING BTREE,
	INDEX `citizenid` (`citizenid`) USING BTREE
)
COLLATE='utf8mb4_general_ci'
ENGINE=InnoDB
AUTO_INCREMENT=0
;

Step 2: Update Player Metadata

qb-core/server/player.lua
PlayerData.metadata['creditscore'] = PlayerData.metadata['creditscore'] or 400

Step 3: Banker Job Integration

If you want to integrate the banker job, set Config.ApproveSystem to true. Add the following job definition to qb-core/shared/jobs:

['banker'] = {
    label = 'Pacific Bank',
    defaultDuty = true,
    offDutyPay = false,
    grades = {
        ['0'] = {
            name = 'Clerk',
            payment = 50
        },
        ['1'] = {
            name = 'Asst. Manager',
            payment = 50
        },
        ['2'] = {
            name = 'Manager',
            isboss = true,
            payment = 50
        },
    },
},

Step 4: Configure the Script

Adjust the settings in the Moon Loans config file to match your server’s economy and loan requirements.


Step 5: Commands

  • /getcreditscore [id]: Retrieve a player's credit score.

  • /setcreditscore [id] [amount]: Set a player's credit score.

  • /addcreditscore [id] [amount]: Add to a player's credit score.

  • /reducecreditscore [id] [amount]: Reduce a player's credit score.


Moon Loans is designed to provide a realistic and immersive loan system for your server. Customize the loan settings to fit your economy and enhance your players' roleplaying experience with credit management, loan applications, and banker jobs.

Last updated