Skip to content

Commit

Permalink
Merge pull request #2 from robert4049/main
Browse files Browse the repository at this point in the history
fix: identity shared object and xplayer
  • Loading branch information
69u authored Dec 9, 2022
2 parents df2bca9 + 4247e1f commit 1da034f
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions server/main.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ESX = nil

AddEventHandler('onResourceStart', function(resourceName)
if (GetCurrentResourceName() ~= resourceName) then
return
Expand All @@ -17,6 +19,7 @@ AddEventHandler('onResourceStart', function(resourceName)
AddEventHandler('chatMessage', function(source, name, message)
local playerName
if config.identity then
local xPlayer = ESX.GetPlayerFromId(source)
playerName = xPlayer.getName()
else
playerName = GetPlayerName(source)
Expand All @@ -33,13 +36,16 @@ AddEventHandler('onResourceStart', function(resourceName)
CancelEvent()
end)
end
if config.identity then
ESX = exports["es_extended"]:getSharedObject()
end
end)

RegisterCommand('ooc', function(source, args, rawCommand)
local xPlayer = source
local playerName
local msg = rawCommand:sub(5)
if config.identity then
local xPlayer = ESX.GetPlayerFromId(source)
playerName = xPlayer.getName()
else
playerName = GetPlayerName(source)
Expand All @@ -51,10 +57,10 @@ RegisterCommand('ooc', function(source, args, rawCommand)
end, false)

RegisterCommand('me', function(source, args, rawCommand)
local xPlayer = source
local playerName
local msg = rawCommand:sub(4)
if config.identity then
local xPlayer = ESX.GetPlayerFromId(source)
playerName = xPlayer.getName()
else
playerName = GetPlayerName(source)
Expand All @@ -66,10 +72,10 @@ RegisterCommand('me', function(source, args, rawCommand)
end, false)

RegisterCommand('do', function(source, args, rawCommand)
local xPlayer = source
local playerName
local msg = rawCommand:sub(4)
if config.identity then
local xPlayer = ESX.GetPlayerFromId(source)
playerName = xPlayer.getName()
else
playerName = GetPlayerName(source)
Expand All @@ -81,10 +87,10 @@ RegisterCommand('do', function(source, args, rawCommand)
end, false)

RegisterCommand('news', function(source, args, rawCommand)
local xPlayer = source
local playerName
local msg = rawCommand:sub(5)
if config.identity then
local xPlayer = ESX.GetPlayerFromId(source)
playerName = xPlayer.getName()
else
playerName = GetPlayerName(source)
Expand All @@ -96,10 +102,10 @@ RegisterCommand('news', function(source, args, rawCommand)
end, false)

RegisterCommand('ad', function(source, args, rawCommand)
local xPlayer = source
local playerName
local msg = rawCommand:sub(4)
if config.identity then
local xPlayer = ESX.GetPlayerFromId(source)
playerName = xPlayer.getName()
else
playerName = GetPlayerName(source)
Expand All @@ -111,10 +117,10 @@ RegisterCommand('ad', function(source, args, rawCommand)
end, false)

RegisterCommand('twt', function(source, args, rawCommand)
local xPlayer = source
local playerName
local msg = rawCommand:sub(5)
if config.identity then
local xPlayer = ESX.GetPlayerFromId(source)
playerName = xPlayer.getName()
else
playerName = GetPlayerName(source)
Expand All @@ -126,10 +132,10 @@ RegisterCommand('twt', function(source, args, rawCommand)
end, false)

RegisterCommand('anon', function(source, args, rawCommand)
local xPlayer = source
local playerName
local msg = rawCommand:sub(5)
if config.identity then
local xPlayer = ESX.GetPlayerFromId(source)
playerName = xPlayer.getName()
else
playerName = GetPlayerName(source)
Expand Down

0 comments on commit 1da034f

Please sign in to comment.