This documentation is for developers who are making scripts for JRS Core Framework
Export#
GetCore is a shared export that returns the core table containing all the getters and setters for JRS Core. some of the getters and setters are client side only and some are server side only.
Shared
GetCore#
returntableThe core table containing all the getters and setters.
local Core = exports.jrs_core:GetCore()Register Server Jobs#
Allowing you to only give correct jobs and grades to the players and to prevent them from using incorrect jobs and grades.
Server Side
RegisterJobs#
Register jobs to the server, this will be stored in config/jobs.lua file in jrs core then can be registered automatically using the RegisterJobs function or manually by adding the jobs to the lua file.
jobsDatatablerequiredjob data is a table with the following keys:
jobname:stringjob name as the key and the job data as the value.groups:arrayoptional, if you wish to set this job to only this group can give this job.privateJob:booleanif true, the job will be private no one can give this job.grades:tableonly add grades if you use grades[grade]:tablegrade number as the key and the grade data as the value.label:stringthe label of the gradeprivateGrade:booleanif true, the grade will be private no one can give this grade.
resourceNamestringrequiredThe resource name to register the jobs to for debug
local jobsData <const> = {
jobname = {
groups = {"admin"} -- optional, if you wish to set this job to only this group can give this job.
privateJob = true -- if true, the job will be private no one can give this job.
grades = { -- only add grades if you use grades
[1] = {
label = "Grade Label"
privateGrade = true -- if true, the grade will be private no one can give this grade.
}
}
}
}
if Core.RegisterJobs then
Core.RegisterJobs(jobsData, GetCurrentResourceName())
else
print("Core.RegisterJobs is not available update jrs core to the latest version")
endNotifications#
notifications can also accept -1 as duration to always stay on screen and to clear them you need to use UiFeedClearChannel
Shared
NotifyLeft#
titlestringrequiredThe title of the notification
subtitlestringrequiredThe subtitle of the notification
dictstringrequiredThe dictionary for the icon
iconstringrequiredThe icon name
durationnumberrequiredDuration in milliseconds
colorstringrequiredColor of the notification
Core.NotifyLeft("title", "subtitle", "dict", "icon", 4000, "color")NotifyTip#
titlestringrequiredThe title of the notification
durationnumberrequiredDuration in milliseconds
Core.NotifyTip("title", 4000)NotifyRightTip#
titlestringrequiredThe title of the notification
durationnumberrequiredDuration in milliseconds
Core.NotifyRightTip("title", 4000)NotifyObjective#
titlestringrequiredThe title of the notification
durationnumberrequiredDuration in milliseconds
Core.NotifyObjective("title", 4000)NotifyTop#
titlestringrequiredThe title of the notification
locationstringrequiredThe location to display
durationnumberrequiredDuration in milliseconds
Core.NotifyTop("title", "location", 4000)NotifySimpleTop#
titlestringrequiredThe title of the notification
subtitlestringrequiredThe subtitle of the notification
durationnumberrequiredDuration in milliseconds
Core.NotifySimpleTop("title", "subtitle", 4000)NotifyAvanced#
titlestringrequiredThe title of the notification
dictstringrequiredThe dictionary for the icon
iconstringrequiredThe icon name
colorstringrequiredColor of the notification
durationnumberrequiredDuration in milliseconds
qualitynumberrequiredenables the stars for quality like animal pelt stars
showQualitybooleanrequiredshows the quality of the notification
Core.NotifyAvanced("title", "dict", "icon", "color", 4000, quality, showQuality)NotifyCenter#
titlestringrequiredThe title of the notification
durationnumberrequiredDuration in milliseconds
Core.NotifyCenter("title", 4000)NotifyBottomRight#
titlestringrequiredThe title of the notification
durationnumberrequiredDuration in milliseconds
Core.NotifyBottomRight("title", 4000)NotifyFail#
titlestringrequiredThe title of the notification
subtitlestringrequiredThe subtitle of the notification
durationnumberrequiredDuration in milliseconds
Core.NotifyFail("title", "subtitle", 4000)NotifyDead#
titlestringrequiredThe title of the notification
audiorefstringrequiredThe audio reference
audionamestringrequiredThe audio name
durationnumberrequiredDuration in milliseconds
Core.NotifyDead("title", "audioref", "audioname", 4000)NotifyUpdate#
titlestringrequiredThe title of the notification
subtitlestringrequiredThe subtitle of the notification
durationnumberrequiredDuration in milliseconds
Core.NotifyUpdate("title", "subtitle", 4000)NotifyWarning#
titlestringrequiredThe title of the notification
subtitlestringrequiredThe subtitle of the notification
audiorefstringrequiredThe audio reference
audionamestringrequiredThe audio name
durationnumberrequiredDuration in milliseconds
Core.NotifyWarning("title", "subtitle", "audioref", "audioname", 4000)NotifyLeftRank#
titlestringrequiredThe title of the notification
subtitlestringrequiredThe subtitle of the notification
dictstringrequiredThe dictionary for the icon
iconstringrequiredThe icon name
durationnumberrequiredDuration in milliseconds
colorstringrequiredColor of the notification
Core.NotifyLeftRank("title", "subtitle", "dict", "icon", 4000, "color")NotifyOneSimpleTop#
titlestringrequiredThe title of the notification
durationnumberrequiredDuration in milliseconds
Core.NotifyOneSimpleTop("title", 4000)NotifyThreeSimpleTop#
titlestringrequiredThe title of the notification
descriptionstringrequiredThe description of the notification
second_descriptionstringrequiredThe second description of the notification
durationnumberrequiredDuration in milliseconds
Core.NotifyThreeSimpleTop("title","description","second_description", 4000)NotifyLeftInteractive#
titlestringrequiredThe title of the notification
subtitlestringrequiredThe subtitle of the notification
dictstringrequiredThe dictionary for the icon
iconstringrequiredThe icon name
durationnumberrequiredDuration in milliseconds or -1 for infinite
colorstringrequiredColor of the notification
Core.NotifyLeftInteractive("title", "subtitle", "dict", "icon", 4000, "color")NotifyTip#
sourceintegerrequiredThe player ID
titlestringrequiredThe title of the notification
durationintegerrequiredDuration in milliseconds
Core.NotifyTip(source, "title", 4000)NotifyLeft#
sourceintegerrequiredThe player ID
titlestringrequiredThe title of the notification
subtitlestringrequiredThe subtitle of the notification
dictstringrequiredThe dictionary for the icon
iconstringrequiredThe icon name
durationintegerrequiredDuration in milliseconds
colorstringrequiredColor of the notification
Core.NotifyLeft(source, "title", "subtitle", "dict", "icon", 4000, "color")NotifyRightTip#
sourceintegerrequiredThe player ID
titlestringrequiredThe title of the notification
durationintegerrequiredDuration in milliseconds
Core.NotifyRightTip(source, "title", 4000)NotifyObjective#
sourceintegerrequiredThe player ID
titlestringrequiredThe title of the notification
durationintegerrequiredDuration in milliseconds
Core.NotifyObjective(source, "title", 4000)NotifyTop#
sourceintegerrequiredThe player ID
titlestringrequiredThe title of the notification
locationstringrequiredThe location to display
durationintegerrequiredDuration in milliseconds
Core.NotifyTop(source, "title", "location", 4000)NotifySimpleTop#
sourceintegerrequiredThe player ID
titlestringrequiredThe title of the notification
subtitlestringrequiredThe subtitle of the notification
durationintegerrequiredDuration in milliseconds
Core.NotifySimpleTop(source, "title", "subtitle", 4000)NotifyAvanced#
sourceintegerrequiredThe player ID
titlestringrequiredThe title of the notification
dictstringrequiredThe dictionary for the icon
iconstringrequiredThe icon name
colorstringrequiredColor of the notification
durationintegerrequiredDuration in milliseconds
showQualitybooleanrequiredShow the quality of the notification
qualitynumberrequiredThe quality of the notification max 3
Core.NotifyAvanced(source, "title", "dict", "icon", "color",showQuality,quality, 4000)NotifyCenter#
sourceintegerrequiredThe player ID
titlestringrequiredThe title of the notification
durationintegerrequiredDuration in milliseconds
Core.NotifyCenter(source, "title", 4000)NotifyBottomRight#
sourceintegerrequiredThe player ID
titlestringrequiredThe title of the notification
durationintegerrequiredDuration in milliseconds
Core.NotifyBottomRight(source, "title", 4000)NotifyFail#
sourceintegerrequiredThe player ID
titlestringrequiredThe title of the notification
subtitlestringrequiredThe subtitle of the notification
durationintegerrequiredDuration in milliseconds
Core.NotifyFail(source, "title", "subtitle", 4000)NotifyDead#
sourceintegerrequiredThe player ID
titlestringrequiredThe title of the notification
audiorefstringrequiredThe audio reference
audionamestringrequiredThe audio name
durationintegerrequiredDuration in milliseconds
Core.NotifyDead(source, "title", "audioref", "audioname", 4000)NotifyUpdate#
sourceintegerrequiredThe player ID
titlestringrequiredThe title of the notification
subtitlestringrequiredThe subtitle of the notification
durationintegerrequiredDuration in milliseconds
Core.NotifyUpdate(source, "title", "subtitle", 4000)NotifyWarning#
sourceintegerrequiredThe player ID
titlestringrequiredThe title of the notification
subtitlestringrequiredThe subtitle of the notification
audiorefstringrequiredThe audio reference
audionamestringrequiredThe audio name
durationintegerrequiredDuration in milliseconds
Core.NotifyWarning(source, "title", "subtitle", "audioref", "audioname", 4000)NotifyLeftRank#
sourceintegerrequiredThe player ID
titlestringrequiredThe title of the notification
subtitlestringrequiredThe subtitle of the notification
dictstringrequiredThe dictionary for the icon
iconstringrequiredThe icon name
durationintegerrequiredDuration in milliseconds
colorstringrequiredColor of the notification
Core.NotifyLeftRank(source, "title", "subtitle", "dict", "icon", 4000, "color")NotifyOneSimpleTop#
sourceintegerrequiredThe player ID
titlestringrequiredThe title of the notification
durationintegerrequiredDuration in milliseconds
Core.NotifyOneSimpleTop(source, "title", 4000)NotifyThreeSimpleTop#
sourceintegerrequiredThe player ID
titlestringrequiredThe title of the notification
descriptionstringrequiredThe description of the notification
second_descriptionstringrequiredThe second description of the notification
durationintegerrequiredDuration in milliseconds
Core.NotifyThreeSimpleTop(source, "title","description","second_description", 4000)NotifyLeftInteractive#
sourceintegerrequiredThe player ID
titlestringrequiredThe title of the notification
subtitlestringrequiredThe subtitle of the notification
dictstringrequiredThe dictionary for the icon
iconstringrequiredThe icon name
durationintegerrequiredDuration in milliseconds or -1 for infinite
colorstringrequiredColor of the notification
Core.NotifyLeftInteractive(source, "title", "subtitle", "dict", "icon", 4000, "color")Characters#
Get the character data to access getters and setters
Server
getUsedCharacter#
sourceintegerrequiredThe player ID
local user = Core.getUser(source) --[[@as User]]
if not user then return end -- is player in session?
local character = user.getUsedCharacter --[[@as Character]]identifier#
returnstringThe unique identifier of the character
local identifier = character.identifiercharIdentifier#
returnstringThe unique character identifier
local charIdentifier = character.charIdentifiergroup#
returnstringThe group the character belongs to
local group = character.groupmultiJobs#
returntableThe multiJobs of the character
local multijobs = character.multiJobs
for _, job in pairs(multiJobs) do
print(job.job, job.grade, job.label)
endjob#
returnstringThe job of the character
local job = character.jobjobGrade#
returnintegerThe job grade of the character
local jobGrade = character.jobGradejobLabel#
returnstringThe job label of the character
local jobLabel = character.jobLabelmoney#
returnnumberThe amount of money the character has
local money = character.moneygold#
returnnumberThe amount of gold the character has
local gold = character.goldrol#
returnnumberThe amount of rol the character has
local rol = character.rolxp#
returnnumberThe amount of experience points the character has
local xp = character.xpfirstname#
returnstringThe first name of the character
local firstname = character.firstnamelastname#
returnstringThe last name of the character
local lastname = character.lastnamestatus#
returntableThe status of the character
local status = character.statuscoords#
returntableThe coordinates of the character
local coords = character.coordsisdead#
returnbooleanWhether the character is dead or not
local isDead = character.isdeadskin#
returntableThe skin details of the character
local skin = character.skincomps#
returntableThe component details of the character
local comps = character.compsage#
returnnumberThe age of the character
local age = character.agegender#
returnstringThe gender of the character
local gender = character.gendercharDescription#
returnstringThe description of the character
local charDescription = character.charDescriptionnickname#
returnstringThe nickname of the character
local nickname = character.nicknameinvCapacity#
returnnumberThe inventory capacity of the character
local invCapacity = character.invCapacityskills#
returntableThe skills of the character
local skills = character.skills
local skill = skills.Crafting
if not skill then return print("skill not found in core config or it doesn't exist") end
local skillExp = skill.Exp
local skillLevel = skill.LevelsetJob#
jobstringrequiredThe job name to set
flagbooleanIf true, the job change event won't be triggered
character.setJob("job", flag)setMultiJob#
Exists for compatibility only: it always returns false. Use exports.jrs_core:AddJob. Use the JRS equivalent from the JRS API page.
multijobs can be added to users and they can switch between them using the switch command in jrs core listen for job change events to know when the user switches jobs
jobstringrequiredThe job name to set
gradenumberrequiredThe job grade to set
labelstringrequiredThe job label to set
character.setMultiJob("job", 1, "label")removeMultiJob#
Exists for compatibility only: it always returns false. Use exports.jrs_core:RemoveJob. Use the JRS equivalent from the JRS API page.
jobstringrequiredThe job name to remove
character.removeMultiJob("job")getMultiJobsCount#
returnnumberThe number of multijobs the character has
local multiJobCount = character.getMultiJobsCount()setJobGrade#
gradenumberrequiredThe job grade to set
flagbooleanIf true, the job change event won't be triggered
character.setJobGrade(1, flag)setJobLabel#
labelstringrequiredThe job label to set
character.setJobLabel("Label")setGroup#
groupstringrequiredThe group to set
flagbooleanIf true, the group change event won't be triggered
character.setGroup("admin", false)setXp#
amountnumberrequiredSet the amount of XP of the character
character.setXp(5000)setFirstname#
firstnamestringrequiredSet the first name of the character
character.setFirstname("Sadie")setLastname#
lastnamestringrequiredSet the last name of the character
character.setLastname("Adler")addCurrency#
typenumberrequiredThe currency type (0 = money, 1 = gold, 2 = rol)
amountnumberrequiredThe amount to add to character
character.addCurrency(0, 1000)removeCurrency#
typenumberrequiredThe currency type (0 = money, 1 = gold, 2 = rol)
amountnumberrequiredThe amount to remove from character
character.removeCurrency(0, 1000)addXp#
amountnumberrequiredThe amount of XP to add
character.addXp(100)removeXp#
amountnumberrequiredThe amount of XP to remove
character.removeXp(100)updateInvCapacity#
Exists for compatibility only: it does nothing in JRS Core. Use the JRS equivalent from the JRS API page.
changenumberrequiredThe amount to change the inventory capacity by (can be positive or negative) its also incremental so 1000 will be 1000 + what you already have
character.updateInvCapacity(1) setSkills#
skillNamestringrequiredThe name of the skill to set, these skillNames will be in JRS Core config skills
valuenumberrequiredthe Exp value to be set to the skillName you passed values are incremental so 1000 exp will be 1000 + what you already have
character.setSkills("skillName", 10) -- skillname expUsers#
Get the user data to access getters and setters
getUser#
sourcenumberrequiredThe player ID
local user = Core.getUser(source) --[[@as User]]
if not user then return end -- is player in session?getUserByCharId#
charidnumberrequiredThe character ID
local user = Core.getUserByCharId(charid) --[[@as User]]getGroup#
returnstringThe user group (not character group)
local userGroup = user.getGroupsource#
returnintegerThe user's source (player ID)
local userSource = user.sourcemaxJobsAllowed#
returnnumberThe maximum number of jobs allowed for the user
local maxJobsAllowed = user.maxJobsAllowedWhitelist#
Server
getEntry#
identifierstringrequiredThe identifier of the whitelist entry
local data = Core.Whitelist.getEntry(identifier)
print(json.encode(data),{ident = true})Webhooks#
Shared
AddWebhook#
Exists for compatibility only: it does nothing on the client. Use the JRS equivalent from the JRS API page.
titlestringrequiredThe title of the webhook
webhookstringrequiredThe webhook link
descriptionstringrequiredThe description of the webhook
colornumberrequiredThe color of the webhook
namestringrequiredThe name of the webhook
logostringThe logo of the webhook
footerlogostringThe footerlogo of the webhook
avatarstringThe avatar of the webhook
Core.AddWebhook("title", "webhook", "description", 12345678, "name", "logo", "footerlogo", "avatar")Instancing#
Client
to add a players to different instances use his server id + instance number to add players to same instance use only the instanceNumber
local instanceNumber = 54123 -- any number
JRScore.instancePlayers(GetPlayerServerId(PlayerId())+ instanceNumber)remove players from instance
JRScore.instancePlayers(0)Player#
Available through core export
Server Side
when using these functions you will benefit of the event listeners OnPlayerDeath OnPlayerRevive OnPlayerRespawn
Heal#
sourceintegerrequiredThe player ID
Core.Player.Heal(source)Revive#
sourceintegerrequiredThe player ID
Core.Player.Revive(source)Respawn#
sourceintegerrequiredThe player ID
Core.Player.Respawn(source)Callbacks#
Callbacks are available through core export or single exports
if you need only the call back system
local ServerRPC = exports.jrs_core:ServerRpcCall() --[[@as ServerRPC]] -- for intellisenseTriggerAwait#
trigger a synchronous callback from client to server
namestringrequiredThe name of the callback
...anyThe parameters to pass to the callback
returnanyThe result of the callback
local result = Core.Callback.TriggerAwait(name,...)
print(result)TriggerAsync#
trigger an asynchronous callback from client to server
namestringrequiredThe name of the callback
...anyThe parameters to pass to the callback
returnanyThe result of the callback
Core.Callback.TriggerAsync(name, function(result)
print(result)
end, ...)Register#
register a callback on the server to receive a client callback
namestringrequiredThe name of the callback
callbackfunctionrequiredThe callback function
sourceintegerThe source of the callback
callbackfunctionThe callback function
...anyThe parameters to pass to the callback
returnanyThe result of the callback
Core.Callback.Register(name, function(source,callback,...)
callback(...)
end)if you need only the call back system
local ClientRPC = exports.jrs_core:ClientRpcCall() --[[@as ClientRPC]] -- for intellisenseTriggerAwait#
trigger a server to client callback synchronously
namestringrequiredThe name of the callback
sourceintegerThe source of the callback
...anyThe parameters to pass to the callback
returnanyThe result of the callback
local result = Core.Callback.TriggerAwait(name,source,...)
print(result)TriggerAsync#
trigger an asynchronous callback from client to server
namestringrequiredThe name of the callback
sourceintegerThe source of the callback
...anyThe parameters to pass to the callback
returnanyThe result of the callback
Core.Callback.TriggerAsync(name, source, function(result)
print(result)
end, ...)Register#
register a callback on the client to receive a server callback
namestringrequiredThe name of the callback
callbackfunctionrequiredThe callback function
...anyThe parameters to pass to the callback
returnanyThe result of the callback
Core.Callback.Register(name, function(callback,...)
callback(...)
end) Events#
Event Listeners to detect changes in the player state
when player job and group changes these events are triggered
Server Side
onGroupChange#
AddEventHandler("jrs:playerGroupChange",function(source, newgroup,oldgroup) end)onJobChange#
AddEventHandler("jrs:playerJobChange", function(source, newjob,oldjob) end)onJobGradeChange#
AddEventHandler("jrs:playerJobGradeChange",function(source, newjobgrade,oldjobgrade) end)onPlayerDeath#
when player dies this event is triggered
--CLIENT
AddEventHandler("jrs_core:Client:OnPlayerDeath",function(killerserverid,causeofdeath) end)
--SERVER
RegisterNetEvent("jrs_core:Server:OnPlayerDeath",function(killerserverid,causeofdeath) end)onPlayerRevive#
when player is revived through JRS Core export this event will trigger
--SERVER
AddEventHandler("jrs_core:Server:OnPlayerRevive",function(source)end)
--CLIENT
RegisterNetEvent("jrs_core:Client:OnPlayerRevive")onPlayerRespawn#
when player respawns through JRS Core export this event will trigger
--SERVER
AddEventHandler("jrs_core:Server:OnPlayerRespawn"function(source)end)
--CLIENT
RegisterNetEvent("jrs_core:Client:OnPlayerRespawn")onPlayerHeal#
when player is healed through JRS Core export this event will trigger
--SERVER
AddEventHandler("jrs_core:Server:OnPlayerHeal",function(source) end)
--CLIENT
RegisterNetEvent("jrs_core:Client:OnPlayerHeal")onSkillLevelChanged#
triggered when a skill (character skills, job levels) goes up or down
--SERVER
AddEventHandler("jrs_core:server:skillLevelChanged", function(source, skillName, newLevel, oldLevel) end)
--CLIENT
RegisterNetEvent("jrs_core:client:skillLevelChanged", function(skillName, newLevel, oldLevel) end)onCharacterReady#
triggered when the player selected a character and the character is fully loaded. This is the event to use instead of waiting on a spawn
--SERVER
AddEventHandler("jrs_core:server:characterReady", function(source, character) end)
--CLIENT
RegisterNetEvent("jrs_core:client:characterReady", function(charId) end)onCharacterUnloaded#
triggered when the character is unloaded (logout, character switch, disconnect)
--SERVER
AddEventHandler("jrs_core:server:characterUnloaded", function(source, previousCharacter, reason) end)
--CLIENT
RegisterNetEvent("jrs_core:client:characterUnloaded", function(reason) end)Dataview#
call dataview in your script fxmanifest
client_scripts {
'@jrs_core/client/dataview.lua'
}Statebags#
statebag getters that allow you to get the character data
Shared
IsInSession#
is player in session? this will return true when player choose his character
returnbooleanThe IsInSession of the character
LocalPlayer.state.IsInSessionFirstName#
get the first name of the character
returnstringThe first name of the character
LocalPlayer.state.Character.FirstNameLastName#
get the last name of the character
returnstringThe last name of the character
LocalPlayer.state.Character.LastNameJob#
get the job of the character
returnstringThe job of the character
LocalPlayer.state.Character.JobJobLabel#
get the job label of the character
returnstringThe job label of the character
LocalPlayer.state.Character.JobLabelGrade#
get the grade of the character
returnintegerThe grade of the character
LocalPlayer.state.Character.GradeGroup#
get the group of the character
returnstringThe group of the character
LocalPlayer.state.Character.GroupGender#
get the gender of the character
returnstringThe gender of the character
LocalPlayer.state.Character.GenderNickName#
get the nickname of the character
returnstringThe nickname of the character
LocalPlayer.state.Character.NickNameMoney#
get the money of the character
returnintegerThe money of the character
LocalPlayer.state.Character.MoneyGold#
get the gold of the character
returnintegerThe gold of the character
LocalPlayer.state.Character.GoldRol#
get the rol of the character
returnintegerThe rol of the character
LocalPlayer.state.Character.RolCharId#
get the charid of the character
returnintegerThe charid of the character
LocalPlayer.state.Character.CharIdIsInSession#
is player in session? this will return true when player choose his character
returnbooleanThe IsInSession of the character
Player(source).state.IsInSessionFirstName#
get the first name of the character
returnstringThe first name of the character
Player(source).state.Character.FirstNameLastName#
get the last name of the character
returnstringThe last name of the character
Player(source).state.Character.LastNameJob#
get the job of the character
returnstringThe job of the character
Player(source).state.Character.JobJobLabel#
get the job label of the character
returnstringThe job label of the character
Player(source).state.Character.JobLabelGrade#
get the grade of the character
returnintegerThe grade of the character
Player(source).state.Character.GradeGroup#
get the group of the character
returnstringThe group of the character
Player(source).state.Character.GroupGender#
get the gender of the character
returnstringThe gender of the character
Player(source).state.Character.GenderNickName#
get the nickname of the character
returnstringThe nickname of the character
Player(source).state.Character.NickNameMoney#
get the money of the character
returnintegerThe money of the character
Player(source).state.Character.MoneyGold#
get the gold of the character
returnintegerThe gold of the character
Player(source).state.Character.GoldRol#
get the rol of the character
returnintegerThe rol of the character
Player(source).state.Character.RolCharId#
get the charid of the character
returnintegerThe charid of the character
Player(source).state.Character.CharId