Learn about and how to use common core client events!
RSGCore:Client:OnPlayerLoaded
Handles the player loading in after character selection
This event can be used as an event handler to trigger code because it signifies the player has successfully loaded into the server!
RegisterNetEvent('RSGCore:Client:OnPlayerLoaded', function()
print('Im a client and i just loaded into your server!')
end)
RSGCore:Client:OnPlayerUnload
Handles the player login out to character selection
This event can be used as an event handler to trigger code because it signifies the player has successfully unloaded or logged out of the server!
RegisterNetEvent('RSGCore:Client:OnPlayerUnload', function()
print('Im a client and i just logged out of your server!')
end)
RSG-Appearance:Client:OpenCreator
Handles the event that triggers when the "Create New Character" button is pressed.
This event it triggers as soon as the player selects the option to create a new character.
RegisterNetEvent('rsg-appearance:client:OpenCreator', function()
print('Im a client and i just logged out of your server!')
end)
RSG-Spawn:Client:NewPlayer
Handles the event triggered after the player creates their character.
Triggered after the player creates their character. This event is useful for executing actions or displaying UI elements immediately after a player has created their new character.
RegisterNetEvent('rsg-spawn:client:newplayer', function()
print('Im a client and i just logged out of your server!')
end)
RSGCore:Command:SpawnVehicle
Arguments = WagonName
Client example
-- /spawnveh chuckwagon000x
RegisterCommand('spawnveh', function(_, args)
local vehicle = RSGCore.Shared.Trim(args[1])
TriggerEvent('RSGCore:Command:SpawnVehicle', vehicle)
end)
-- This event can be used as an event handler to trigger code because it indicates that the players data has changed!
RegisterNetEvent('RSGCore:Player:SetPlayerData', function(val)
PlayerData = val
print(RSGCore.Debug(PlayerData))
end)
RSGCore:Notify
-- Arguments = message, type, length
Client Side Example
-- /testnotify This is my message, primary, 5000
RegisterCommand('testnotify', function(_, args)
local message = {}
for i=1, #args do
message[#message + 1] = args[i]
if string.match(args[i], ',') then
local text = table.concat(message, ' '):gsub(",", "")
local type = args[i + 1]:gsub(",", "")
local length = args[i + 2]
TriggerEvent('RSGCore:Notify', text, type, length)
break
end
end
end)
-- Using RSGCore's shared functions!
RegisterCommand('testnotify', function(_, args)
local message = RSGCore.Shared.SplitStr(table.concat(args, ' '), ",")
local text = message[1]
local type = RSGCore.Shared.Trim(message[2])
local length = tonumber(message[3])
TriggerEvent('RSGCore:Notify', text, type, length)
end)
Server Side example
-- /testnotify This is my message, primary, 5000
RegisterCommand('testnotify', function(source, args)
local message = {}
for i=1, #args do
message[#message + 1] = args[i]
if string.match(args[i], ',') then
local text = table.concat(message, ' '):gsub(",", "")
local type = args[i + 1]:gsub(",", "")
local length = args[i + 2]
TriggerClientEvent('RSGCore:Notify', source, text, type, length)
break
end
end
end)
-- Using RSGCore's shared functions!
RegisterCommand('testnotify', function(source, args)
local message = RSGCore.Shared.SplitStr(table.concat(args, ' '), ",")
local text = message[1]
local type = RSGCore.Shared.Trim(message[2])
local length = tonumber(message[3])
TriggerClientEvent('RSGCore:Notify', source, text, type, length)
end)
RSGCore:Client:UpdateObject
This event must be used as a handler when using Shared Exports because it refreshes the core object in your resource