Exports // Triggers
EXPORTS Lua code examples for Client Side
local myjobs = exports["sfjob"]:getMyJobs()
print(myjobs) -- return table e.g: { [1] = { ["name"] = Burger Shot,["workname"] = burgershot,["position"] = 10,} ,[2] = { ["name"] = Bean Machine,["workname"] = beanmachine,["position"] = 10,} ,}
local myjob = exports["sfjob"]:getActiveJob()
print(myjob) -- return string e.g: "farm"
local myjobgrade = exports["sfjob"]:getActiveJobGrade()
print(myjobgrade) -- return number e.g: 0
local job_name = "burgershot"
local id_cash = 1
exports["sfjob"]:cashRegister(job_name, id_cash) -- open cash register for employees and customers
local job_name = "burgershot"
local id_tray = 1
exports["sfjob"]:orderTray(job_name, id_tray) -- open tray for employees and customers
local job_name = "burgershot"
local displayname = "Stash Main"
local id_stash = 1
local places = 50
local weight = 100000
local grade = 1
exports["sfjob"]:openStash(job_name, displayname, id_stash, places, weight, grade) -- Opening the cupboard/fridge with things.
TriggerEvent("nuifix") -- if the NUI breaks.
EXPORTS Lua code examples for Server Side
local player_jobs = exports["sfjob"]:getJobsFromSource(source)
print(player_jobs) -- return table e.g: { [1] = { ["workname"] = burgershot,["position"] = 10,["name"] = Burger Shot,} ,[2] = { ["workname"] = beanmachine,["position"] = 10,["name"] = Bean Machine,} ,}
local player_job, player_grade = exports["sfjob"]:getJobFromSource(source)
print(player_job) -- return active job for player
print(player_grade) -- return grade active job for player
local player_id = "char1:00000000000"
local player_job, player_grade = exports["sfjob"]:getJobFromId(player_id)
print(player_job) -- return active job for player
print(player_grade) -- return grade active job for player
local job_name = "unemployed" -- or "burgershot" or anything else. when set to "unemployed", it will exclude you from your current job.
local result = exports["sfjob"]:setActiveJob(job_name, source) -- sets the active job for the player, return true or false
local job_name = "burgershot"
local nameJob = exports["sfjob"]:getJobName(job_name)
print(nameJob) -- return e.g.: "Burger Shot"
local job_name = "burgershot"
local src_data = 11 -- server id of the player you want to hire
local result = exports["sfjob"]:addNewJob(source, job_name, src_data) -- hire an employee, if src_data is empty hire yourself
print(result) -- return true or false(if hiring was unsuccessful)
local job_name = "burgershot"
local id_player = "char1:0000000000" -- the id of the player you want to fire.(not server id)
local new_position = 2 -- e.g.
exports["sfjob"]:updatePosition(job_name, id_player, new_position) -- change player rank, all fields must be filled. return true or false
local job_name = "burgershot"
local id_player = "char1:0000000000" -- the id of the player you want to fire.(not server id)
exports["sfjob"]:dropFromJob(source, job_name, id_player) -- dismiss an employee, if id_player is left blank you will fire yourself. return true or false
local job_name = "police"
local count = exports["sfjob"]:countPlayersInJob(job_name)
print(count) -- returns the number of people actively working
local stash_id = "police-armory"
local add_slots = 50
local add_weight = 100000
exports["sfjob"]:setCustomStash(stash_id, add_slots, add_weight)
local job_name = "burgershot"
local id_player = "char1:1234567"
local new_position = 10
local result = exports["sfjob"]:updatePosition(job_name, id_player, new_position)
print(result) -- return true or false
-- increasing the employee limit (current limit + 4)
local job_name = "burgershot"
local what = "maxlimit"
local data = 4
local result = exports["sfjob"]:changeDataSettingsJob(job_name, what, data)
print(result) -- return true or false
-- saving the purchased/received update for the indicated company
local job_name = "burgershot"
local what = "updates"
local data = 4 -- id update'u
local result = exports["sfjob"]:changeDataSettingsJob(job_name, what, data)
print(result) -- return true or false
-- change in remuneration for a given rank in a given company
local job_name = "burgershot"
local what = "money"
local data = {}
data.position = 10 -- id rank
data.permissions = {} -- data must always be in the table
local result = exports["sfjob"]:changeDataSettingsJob(job_name, what, data)
print(result) -- return true or false
-- adding a product/set for a given company
local job_name = "burgershot"
local what = "addProduct"
local data = {}
data.kit_name = "Big Kit" -- set name or item id
data.kit_price = 100 -- price of the set/product
data.kit_products = {} -- data must always be in the table, if the table is empty, kit_name must contain the item id
local productList = {}
productList.product = "burger"
productList.amount = 1
table.insert(data.kit_products, productList)
local result = exports["sfjob"]:changeDataSettingsJob(job_name, what, data)
print(result) -- return true or false
-- deleting a product/kit for a given company
local job_name = "burgershot"
local what = "removeProduct"
local data = 3 -- product/set id
local result = exports["sfjob"]:changeDataSettingsJob(job_name, what, data)
print(result) -- return true or false
-- receiving the current employee limit from the indicated company
local job_name = "burgershot"
local what = "maxlimit"
local result = exports["sfjob"]:getDataSettingsJob(job_name, what)
print(result) -- return number (e.g.: 6) or false
-- receiving purchased/received upgrades from the indicated company
local job_name = "burgershot"
local what = "updates"
local result = exports["sfjob"]:getDataSettingsJob(job_name, what)
print(result) -- return table or false
-- receiving data of all employees from the indicated company
local job_name = "burgershot"
local what = "jobs_players"
local result = exports["sfjob"]:getDataSettingsJob(job_name, what)
print(result) -- return table or false
-- receiving data of all ranks from the indicated company
local job_name = "burgershot"
local what = "jobs_products"
local result = exports["sfjob"]:getDataSettingsJob(job_name, what)
print(result) -- return table or false
-- receiving information whether the specified company pays remuneration in the bank - if so returns true.
local job_name = "burgershot"
local what = "withdrawalFromBankInfo"
local result = exports["sfjob"]:getDataSettingsJob(job_name, what)
print(result) -- return true or false
-- receiving information whether the cost of remuneration is covered by the company (return true) or the server (return false)
local job_name = "burgershot"
local what = "withdrawalFromCompanyAccount"
local result = exports["sfjob"]:getDataSettingsJob(job_name, what)
print(result) -- return true or false
-- receiving information about the salary for a particular rank in the company
local job_name = "burgershot"
local what = "money"
local position = 10
local result = exports["sfjob"]:getDataSettingsJob(job_name, what, position)
print(result) -- return number (e.g.: 100) or false
-- receiving information about the rights of a particular rank in the company
local job_name = "burgershot"
local what = "permissions"
local position = 10
local result = exports["sfjob"]:getDataSettingsJob(job_name, what, position)
print(result) -- return number (e.g.: 100) or false
-- changing player data in the other column. e.g.: you can save the badge number here
local job_name = "burgershot"
local what = "other"
local id_player = "char1:123456789"
local data = {} -- always table with data
local result = exports["sfjob"]:changeDataPlayerJob(job_name, what, id_player, data)
print(result) -- return true or false
-- receiving all player data from the indicated company
local job_name = "burgershot"
local player_id = "char1:123456"
local result = exports["sfjob"]:getDataPlayerJob(job_name, player_id)
print(result) -- return table with data or false
-- paying the player's salary from the indicated company if payment from the bank is disabled
local src = source -- source of the person who pays the bonuses
local job_name = "burgershot"
local player_id = "char1:123456"
local result = exports["sfjob"]:payoutBonus(job_name, player_id, src)
print(result) -- return true or false
-- resetting employee working hours for a given company
local job_name = "burgershot"
local result = exports["sfjob"]:resetTimework(job_name)
print(result) -- return true or false
-- generating player data from jobs to excel
local job_name = "burgershot"
local webook = "https://discord.com/api/webhooks/"
local options = { name=true, position=true, worktime=true, worktime_all=true, date_creation=true, unit=true, badge=true, specializations=true, stats=true, }
exports["sfjob"]:generateExcel(job_name, webhook, options)
-- saving players stats in job
local source = 1
local job_name = "burgershot"
local type_stats = "cleaning" -- type of statistics
local amount = 1 -- quantity to be added (+1)
exports["sfjob"]:setStats(source, job_name, type_stats, amount)
Event Handler for collecting paycheck in bank:
AddEventHandler('sfjob:infoPaycheck', function(source, money, workname)
print("Player "..source.." received $"..money.." from his job as a "..workname)
end)
Last updated