Introduction

  • The shared file inside rsg-core contains all the information for your jobs, vehicles, items & more! You will spend a lot of time in this file configuring everything to your exact specifications. Jenkins hashes are used frequently, you can find more information on those here

Utility

  • Found in rsg-core/shared/main.lua
RSGShared = RSGShared or {}

local StringCharset = {}
local NumberCharset = {}

RSGShared.StarterItems = {
    bread = { amount = 5, item = 'bread' },
    water = { amount = 5, item = 'water' },
}

for i = 48, 57 do NumberCharset[#NumberCharset + 1] = string.char(i) end
for i = 65, 90 do StringCharset[#StringCharset + 1] = string.char(i) end
for i = 97, 122 do StringCharset[#StringCharset + 1] = string.char(i) end

function RSGShared.RandomStr(length)
    if length <= 0 then return '' end
    return RSGShared.RandomStr(length - 1) .. StringCharset[math.random(1, #StringCharset)]
end

function RSGShared.RandomInt(length)
    if length <= 0 then return '' end
    return RSGShared.RandomInt(length - 1) .. NumberCharset[math.random(1, #NumberCharset)]
end

function RSGShared.SplitStr(str, delimiter)
    local result = {}
    local from = 1
    local delim_from, delim_to = string.find(str, delimiter, from)
    while delim_from do
        result[#result + 1] = string.sub(str, from, delim_from - 1)
        from = delim_to + 1
        delim_from, delim_to = string.find(str, delimiter, from)
    end
    result[#result + 1] = string.sub(str, from)
    return result
end

function RSGShared.Trim(value)
    if not value then return nil end
    return (string.gsub(value, '^%s*(.-)%s*$', '%1'))
end

function RSGShared.FirstToUpper(value)
    if not value then return nil end
    return (value:gsub("^%l", string.upper))
end

function RSGShared.Round(value, numDecimalPlaces)
    if not numDecimalPlaces then return math.floor(value + 0.5) end
    local power = 10 ^ numDecimalPlaces
    return math.floor((value * power) + 0.5) / (power)
end

function RSGShared.ChangeVehicleExtra(vehicle, extra, enable)
    if DoesExtraExist(vehicle, extra) then
        if enable then
            SetVehicleExtra(vehicle, extra, false)
            if not IsVehicleExtraTurnedOn(vehicle, extra) then
                RSGShared.ChangeVehicleExtra(vehicle, extra, enable)
            end
        else
            SetVehicleExtra(vehicle, extra, true)
            if IsVehicleExtraTurnedOn(vehicle, extra) then
                RSGShared.ChangeVehicleExtra(vehicle, extra, enable)
            end
        end
    end
end

function RSGShared.SetDefaultVehicleExtras(vehicle, config)
    -- Clear Extras
    for i = 1, 20 do
        if DoesExtraExist(vehicle, i) then
            SetVehicleExtra(vehicle, i, 1)
        end
    end

    for id, enabled in pairs(config) do
        RSGShared.ChangeVehicleExtra(vehicle, tonumber(id), type(enabled) == 'boolean' and enabled or true)
    end
end

Items

  • Found in rsg-core/shared/items.lua
RSGShared.Items = {
    bread      = { 
        name = 'bread',     -- Actual item name for spawning/giving/removing      
        label = 'Bread',    -- Label of item that is shown in inventory slot        
        weight = 100,       -- How much the items weighs
        type = 'item',      -- What type the item is (ex: item, weapon)
        image = 'consumable_bread_roll.png',-- This item image that is found in rsg-inventory/html/images (must be same name as ['name'] from above)          
        unique = false, -- Is the item unique (true|false) - Cannot be stacked & accepts item info to be assigned
        useable = true, -- Is the item useable (true|false) - Must still be registered as useable
        shouldClose = true, -- Should the item close the inventory on use (true|false)
        description = 'Bread Roll' },-- Description of time in inventory
    }

Jobs

  • Found in rsg-core/shared/jobs.luaa
RSGShared = RSGShared or {}
RSGShared.ForceJobDefaultDutyAtLogin = true -- true: Force duty state to jobdefaultDuty | false: set duty state from database last saved
RSGShared.Jobs = {

    unemployed = {              -- job name (string)
        label = 'Civilian',     -- job label (string)
        defaultDuty = true,     -- enable/disable player being auto clocked-in (bool)
        offDutyPay = false,     -- enable/disable player being paid offduty (bool)
        grades = {
            ['0'] = {            -- job grade (string)
             name = 'Freelancer',-- job grade name (string)
             payment =  3        -- paycheck amount (number)
              },
        },
    },
    vallaw = {
        label = 'Valentine Law Enforcement',
        type = 'leo',
        defaultDuty = false,
        offDutyPay = false,
        grades = {
            ['0'] = { name = 'Recruit', payment = 10 },
            ['1'] = { name = 'Deputy', payment = 25 },
            ['2'] = { name = 'Sheriff',
             isboss = true,       -- set this grade as a boss=true to access boss menu
             payment = 50 },
        },
    },
}

Vehicles

  • Found in rsg-core/shared/vehicles.lua
RSGShared = RSGShared or {}
RSGShared.Vehicles = RSGShared.Vehicles or {}

local Vehicles = {

    CART01 = {                   -- Cart model/spawn name (string)
        name = 'Wooden Cart 1',  -- Desired name/label for the cart (string)
        brand = '?',             -- The brand of cart (string)
        model = 'CART01',        -- Cart model/spawn name (string)
        price = 10,              -- How much the cart costs at the stable (number)
        category = 'carts',      -- The category the vehicle will display in at the stable (string)
        hash = '-824257932',     -- Vehicle model number 
        shop = 'cart',           -- The desired shop the cart is available for sale at (string)
    },
}

for i = 1, #Vehicles do
    RSGShared.Vehicles[Vehicles[i].model] = {
        spawncode = Vehicles[i].model,
        name = Vehicles[i].name,
        brand = Vehicles[i].brand,
        model = Vehicles[i].model,
        price = Vehicles[i].price,
        category = Vehicles[i].category,
        hash = joaat(Vehicles[i].model),
        type = Vehicles[i].type,
        shop = Vehicles[i].shop
    }
end

Gangs

  • Found in rsg-core/shared/gangs.lua
RSGShared = RSGShared or {}
RSGShared.Gangs = {
    none = {
        label = 'No Gang',
        grades = {
            ['0'] = {
                name = 'Unaffiliated'
            }
        }
    },
    odriscoll = {              -- grade name (string)
		label = 'O Driscoll Boys',  -- Label of the gang (string)
		grades = {
            ['0'] = {  -- grade (number)
                name = 'Recruit'
            },
			['1'] = {
                name = 'Enforcer'  -- Label of the gang grade (string)
            },
			['2'] = {
                name = 'Shot Caller'
            },
			['3'] = {
                name = 'Boss',
				isboss = true   -- set this grade as a boss to access gang menu
            },
        },
    }
}

Weapons

  • Found in rsg-core/shared/weapons.lua

Weapons are added in shared/items.lua as well!

RSGShared = RSGShared or {}
RSGShared.Weapons = {
    -- revolver
	[`weapon_revolver_cattleman`] = {        -- Weapon hash 
		 name = 'weapon_revolver_cattleman', -- Actual item name for spawning/giving/removing         
		 label = 'Cattleman Revolver',       -- Label of item that is shown in inventory slot      
		 weapontype = 'Revolver',     		 -- What type the item is (ex: revolver, shotgun)
		 ammotype = 'AMMO_REVOLVER',         -- What type of ammo the item uses
		 damagereason = 'Placeholder' 		 -- What type of damage the item does
		}
	}