Giter Site home page Giter Site logo

keep-paycheck's Introduction

Dependencies

Preview

Installation

  • if you are using qb-menu and don't want to use keep-menu :(
  • set Confing.menu to 'qb-menu'

Step 0:

  • import sql.sql in your database
  • make sure keep-menu is already installed
  • ensure keep-paycheck after qb-core and keep-menu
  • make sure scirpt's name is correct (keep-paycheck)
ensure qb-core
...
ensure keep-menu
...
ensure keep-paycheck

Step 1 (Redirect qb-core's paychecks to scirpt):

  • edit qb-core/server/functions.lua (make sure you already have a backup of this file)
  • replace code at PaycheckInterval() to
function PaycheckInterval()
    if next(QBCore.Players) then
        for _, Player in pairs(QBCore.Players) do
            if Player then
                local payment = Player.PlayerData.job.payment
                local citizenid = Player.PlayerData.citizenid

                if Player.PlayerData.job and payment > 0 and (QBShared.Jobs[Player.PlayerData.job.name].offDutyPay or Player.PlayerData.job.onduty) then
                    if QBCore.Config.Money.PayCheckSociety then
                        local account = exports['qb-management']:GetAccount(Player.PlayerData.job.name)
                        if account ~= 0 then -- Checks if player is employed by a society
                            if account < payment then -- Checks if company has enough money to pay society
                                TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('error.company_too_poor'), 'error')
                            else
                                TriggerEvent('keep-paycheck:server:AddMoneyToPayCheck', citizenid,payment,Player.PlayerData.job.name)
                                exports['qb-management']:RemoveMoney(Player.PlayerData.job.name, payment)
                            end
                        else
                            TriggerEvent('keep-paycheck:server:AddMoneyToPayCheck', citizenid,payment,Player.PlayerData.job.name)
                        end
                    else
                        TriggerEvent('keep-paycheck:server:AddMoneyToPayCheck', citizenid,payment,Player.PlayerData.job.name)
                    end
                end
            end
        end
    end
    SetTimeout(QBCore.Config.Money.PayCheckTimeOut * (60 * 1000), PaycheckInterval)
end

Redirect external scirpts payment method to keep-paycheck

  • to redirect their payments first find all AddMoney functions that resposible for payments.
Player.Functions.AddMoney('cash/bank', amount)
  • then replace them with keep-paycheck payment event
local payment = money -- how much money player should recive in their accounts
local citizenid = Player.PlayerData.citizenid
local from = Player.PlayerData.job.name -- job name / shown as 'from' in transaction history

TriggerEvent('keep-paycheck:server:AddMoneyToPayCheck', citizenid, payment , from)

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.