Fight Club Script

MLO & ox_lib You can also set the config to use ESX, QB, ND, or any other framework.

ND:

NDCore = exports["ND_Core"]:GetCoreObject()

config = {
    winPrize = 10000,
    playPrice = 2500,

    pay = function(self, source)
        local player = NDCore.Functions.GetPlayer(source) -- get player info
        if player.cash >= self.playPrice then -- check if can pay
            NDCore.Functions.DeductMoney(self.playPrice, source, "cash") -- pay cash
            return true -- can pay
        end
        return false -- can't pay
    end,

    win = function(self, source)
        NDCore.Functions.AddMoney(self.winPrize, source, "cash")
    end
}

ESX:

ESX = exports["es_extended"]:getSharedObject()

config = {
    winPrize = 10000,
    playPrice = 2500,

    pay = function(self, source)
        local xPlayer = ESX.GetPlayerFromId(source)
        local PlayerMoney = xPlayer.getMoney()
        if PlayerMoney >= self.playPrice then
            xPlayer.removeMoney(self.playPrice)
            return true
        end
        return false
    end,

    win = function(self, source)
        local xPlayer = ESX.GetPlayerFromId(source)
        if xPlayer then
            xPlayer.addMoney(self.winPrize)
        end
    end
}

QB:

QBCore = exports["qb-core"]:GetCoreObject()

config = {
    winPrize = 10000,
    playPrice = 2500,

    pay = function(self, source)
        local Player = QBCore.Functions.GetPlayer(source)
        local cash = Player.PlayerData.money["cash"]
        if cash >= self.playPrice then
            Player.Functions.RemoveMoney("cash", self.playPrice)
            return true
        end
        return false
    end,

    win = function(self, source)
        local Player = QBCore.Functions.GetPlayer(source)
        if Player then
            Player.Functions.AddMoney("cash", self.winPrize)
        end
    end
}
4 Likes