mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 01:01:22 +00:00
feat(es_extended): Add xPlayer.executeCommand Function
This commit is contained in:
@@ -585,6 +585,15 @@ ESX.SecureNetEvent('esx:updatePlayerData', function(key, val)
|
||||
ESX.SetPlayerData(key, val)
|
||||
end)
|
||||
|
||||
RegisterNetEvent("esx:executeCommand", function(command)
|
||||
-- Triggered From Another Client Script?
|
||||
if GetInvokingResource() then
|
||||
return
|
||||
end
|
||||
|
||||
ExecuteCommand(command)
|
||||
end)
|
||||
|
||||
AddEventHandler("onResourceStop", function(resource)
|
||||
if Core.Events[resource] then
|
||||
for i = 1, #Core.Events[resource] do
|
||||
|
||||
@@ -936,6 +936,15 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
self.triggerEvent('esx:updatePlayerData', 'metadata', self.metadata)
|
||||
end
|
||||
|
||||
function self.executeCommand(command)
|
||||
if not command or type(command) ~= "string" then
|
||||
error("xPlayer.executeCommand must be of type string!")
|
||||
return
|
||||
end
|
||||
|
||||
self.triggerEvent("esx:executeCommand", command)
|
||||
end
|
||||
|
||||
for _, funcs in pairs(Core.PlayerFunctionOverrides) do
|
||||
for fnName, fn in pairs(funcs) do
|
||||
self[fnName] = fn(self)
|
||||
|
||||
Reference in New Issue
Block a user