This commit is contained in:
Mycroft
2021-05-03 20:04:39 +01:00
parent c4add91157
commit 9212219d46
8 changed files with 91 additions and 141 deletions
+8 -49
View File
@@ -1,29 +1,19 @@
local isPaused, isDead, pickups = false, false, {}
if Config.UseKashacters then
RegisterNetEvent('esx:kashloaded')
AddEventHandler('esx:kashloaded', function()
TriggerServerEvent('esx:onPlayerJoined')
end)
else
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if NetworkIsPlayerActive(PlayerId()) then
while NetworkIsPlayerActive(PlayerId()) do
Citizen.Wait(5)
TriggerServerEvent('esx:onPlayerJoined')
break
end
end
end)
end
RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(playerData)
ESX.PlayerLoaded = true
ESX.PlayerData = playerData
if not Config.UseKashacters then
if GetEntityModel(PlayerPedId()) == GetHashKey('PLAYER_ZERO') then
local defaultModel = GetHashKey('a_m_y_stbla_02')
@@ -41,7 +31,6 @@ AddEventHandler('esx:playerLoaded', function(playerData)
FreezeEntityPosition(PlayerPedId(), true)
end
-- enable PVP
if Config.EnablePVP then
@@ -72,33 +61,6 @@ end
})
end
if Config.UseKashacters then
--[[
ESX.Game.Teleport(PlayerPedId(), {
x = playerData.coords.x,
y = playerData.coords.y,
z = playerData.coords.z + 0.25,
heading = playerData.coords.heading
}, function()
end)
]]--
TriggerServerEvent('esx:onPlayerSpawn')
TriggerEvent('esx:onPlayerSpawn')
TriggerEvent('playerSpawned') -- compatibility with old scripts, will be removed soon
TriggerEvent('esx:restoreLoadout')
Citizen.Wait(0)
ShutdownLoadingScreen()
FreezeEntityPosition(PlayerPedId(), false)
DoScreenFadeIn(0)
StartServerSyncLoops()
else
ESX.Game.Teleport(PlayerPedId(), {
x = playerData.coords.x,
y = playerData.coords.y,
z = playerData.coords.z + 0.25,
heading = playerData.coords.heading
}, function()
TriggerServerEvent('esx:onPlayerSpawn')
TriggerEvent('esx:onPlayerSpawn')
TriggerEvent('playerSpawned') -- compatibility with old scripts, will be removed soon
@@ -110,8 +72,6 @@ end
FreezeEntityPosition(PlayerPedId(), false)
DoScreenFadeIn(10000)
StartServerSyncLoops()
end)
end
TriggerEvent('esx:loadingScreenOff')
end)
@@ -281,7 +241,7 @@ AddEventHandler('esx:setJob', function(Job)
grade_label = Job.grade_label
})
end
ESX.SetPlayerData(job, Job)
ESX.SetPlayerData("job", Job)
end)
RegisterNetEvent('esx:spawnVehicle')
@@ -422,7 +382,7 @@ function StartServerSyncLoops()
-- keep track of ammo
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
Citizen.Wait(1000)
if isDead then
Citizen.Wait(500)
@@ -447,7 +407,7 @@ function StartServerSyncLoops()
local previousCoords = vector3(ESX.PlayerData.coords.x, ESX.PlayerData.coords.y, ESX.PlayerData.coords.z)
while true do
Citizen.Wait(1000)
Citizen.Wait(1500)
local playerPed = PlayerPedId()
if DoesEntityExist(playerPed) then
@@ -467,7 +427,7 @@ end
Citizen.CreateThread(function()
while Config.EnableDefaultInventory do
Citizen.Wait(0)
Citizen.Wait(9)
if IsControlJustReleased(0, 289) then
if IsInputDisabled(0) and not isDead and not ESX.UI.Menu.IsOpen('default', 'es_extended', 'inventory') then
@@ -477,7 +437,6 @@ Citizen.CreateThread(function()
end
end)
-- Pickups
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
@@ -549,4 +508,4 @@ AddEventHandler("esx:tpm", function()
else
TriggerEvent('chatMessage', "No Waypoint Set")
end
end)
end)
+1 -1
View File
@@ -2,7 +2,7 @@ Citizen.CreateThread(function()
local isDead = false
while true do
Citizen.Wait(0)
Citizen.Wait(150)
local player = PlayerId()
if NetworkIsPlayerActive(player) then
+6 -6
View File
@@ -5,7 +5,7 @@ function ESX.Streaming.RequestModel(modelHash, cb)
RequestModel(modelHash)
while not HasModelLoaded(modelHash) do
Citizen.Wait(1)
Citizen.Wait(4)
end
end
@@ -19,7 +19,7 @@ function ESX.Streaming.RequestStreamedTextureDict(textureDict, cb)
RequestStreamedTextureDict(textureDict)
while not HasStreamedTextureDictLoaded(textureDict) do
Citizen.Wait(1)
Citizen.Wait(4)
end
end
@@ -33,7 +33,7 @@ function ESX.Streaming.RequestNamedPtfxAsset(assetName, cb)
RequestNamedPtfxAsset(assetName)
while not HasNamedPtfxAssetLoaded(assetName) do
Citizen.Wait(1)
Citizen.Wait(4)
end
end
@@ -47,7 +47,7 @@ function ESX.Streaming.RequestAnimSet(animSet, cb)
RequestAnimSet(animSet)
while not HasAnimSetLoaded(animSet) do
Citizen.Wait(1)
Citizen.Wait(4)
end
end
@@ -61,7 +61,7 @@ function ESX.Streaming.RequestAnimDict(animDict, cb)
RequestAnimDict(animDict)
while not HasAnimDictLoaded(animDict) do
Citizen.Wait(1)
Citizen.Wait(4)
end
end
@@ -75,7 +75,7 @@ function ESX.Streaming.RequestWeaponAsset(weaponHash, cb)
RequestWeaponAsset(weaponHash)
while not HasWeaponAssetLoaded(weaponHash) do
Citizen.Wait(1)
Citizen.Wait(4)
end
end
-3
View File
@@ -16,8 +16,5 @@ Config.PaycheckInterval = 7 * 60000 -- how often to recieve pay checks in
Config.EnableDebug = false -- Use Debug options?
Config.EnableDefaultInventory = true -- Display the default Inventory ( F2 )
Config.EnableWantedLevel = false -- Use Normal GTA wanted Level?
Config.DisableSuperadmin = true -- Disable the use of superadmin
Config.EnablePVP = true -- Allow Player to player combat
Config.UseMulticharacter = false -- WIP, ADDS multicharacter features
Config.UseKashacters = true
+36 -28
View File
@@ -1,4 +1,4 @@
local crash = false
ESX.RegisterCommand('setcoords', 'admin', function(xPlayer, args, showError)
xPlayer.setCoords({x = args.x, y = args.y, z = args.z})
end, false, {help = _U('command_setcoords'), validate = true, arguments = {
@@ -20,13 +20,14 @@ end, true, {help = _U('command_setjob'), validate = true, arguments = {
}})
ESX.RegisterCommand('car', 'admin', function(xPlayer, args, showError)
if not args.car then args.car = "baller2" end
if not args.car then args.car = "Mower" end
xPlayer.triggerEvent('esx:spawnVehicle', args.car)
end, false, {help = _U('command_car'), validate = false, arguments = {
{name = 'car', help = _U('command_car_car'), type = 'any'}
}})
ESX.RegisterCommand({'cardel', 'dv'}, 'admin', function(xPlayer, args, showError)
if not args.car then args.car = "bus" end
xPlayer.triggerEvent('esx:deleteVehicle', args.radius)
end, false, {help = _U('command_cardel'), validate = false, arguments = {
{name = 'radius', help = _U('command_cardel_radius'), type = 'any'}
@@ -51,9 +52,7 @@ ESX.RegisterCommand('giveaccountmoney', 'admin', function(xPlayer, args, showErr
showError(_U('command_giveaccountmoney_invalid'))
end
end, true, {help = _U('command_giveaccountmoney'), validate = true, arguments = {
{name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'},
{name = 'account', help = _U('command_giveaccountmoney_account'), type = 'string'},
{name = 'amount', help = _U('command_giveaccountmoney_amount'), type = 'number'}
{name = 'weather', help = _U('command_giveaccountmoney_account'), type = 'string'},
}})
ESX.RegisterCommand('giveitem', 'admin', function(xPlayer, args, showError)
@@ -126,7 +125,7 @@ end, true, {help = _U('command_clearloadout'), validate = true, arguments = {
ESX.RegisterCommand('setgroup', 'admin', function(xPlayer, args, showError)
if not args.playerId then args.playerId = xPlayer.source end
if Config.DisableSuperadmin and args.group == "superadmin" then args.group = "admin" end
if args.group == "superadmin" then args.group = "admin" end
args.playerId.setGroup(args.group)
end, true, {help = _U('command_setgroup'), validate = true, arguments = {
{name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'},
@@ -143,12 +142,34 @@ ESX.RegisterCommand('saveall', 'admin', function(xPlayer, args, showError)
ESX.SavePlayers()
end, true, {help = _U('command_saveall')})
ESX.RegisterCommand('currentgroup', {"user", "admin"}, function(xPlayer, args, showError)
print("You are currently: ".. xPlayer.getGroup())
ESX.RegisterCommand('group', {"user", "admin"}, function(xPlayer, args, showError)
print(xPlayer.getName()..", You are currently: ^5".. xPlayer.getGroup())
end, true)
ESX.RegisterCommand('getcoords', "admin", function(xPlayer, args, showError)
print("".. xPlayer.getName().. ": ".. xPlayer.getCoords(true))
ESX.RegisterCommand('job', {"user", "admin"}, function(xPlayer, args, showError)
print(xPlayer.getName()..", You are currently: ^5".. xPlayer.getJob().name.. "^0 - ^5".. xPlayer.getJob().grade_label)
end, true)
ESX.RegisterCommand('info', {"user", "admin"}, function(xPlayer, args, showError)
local job = xPlayer.getJob().name
local jobgrade = xPlayer.getJob().grade_name
print("2ID : ^5"..xPlayer.source.." ^0| ^2Name:^5"..xPlayer.getName().." ^0 | ^2Group:^5"..xPlayer.getGroup().."^0 | ^2Job:^5".. job.."")
end, true)
ESX.RegisterCommand('coords', "admin", function(xPlayer, args, showError)
print("".. xPlayer.getName().. ": ^5".. xPlayer.getCoords(true))
end, true)
ESX.RegisterCommand('sv_restart', "admin", function(xPlayer, args, showError)
Citizen.CreateThread(function()
ESX.SavePlayers()
for _, playerId in ipairs(GetPlayers()) do
DropPlayer(playerId, "Server Restart")
end
crash = true
while crash do
end
end)
end, true)
ESX.RegisterCommand('tpm', "admin", function(xPlayer, args, showError)
@@ -156,37 +177,24 @@ ESX.RegisterCommand('tpm', "admin", function(xPlayer, args, showError)
end, true)
ESX.RegisterCommand('goto', "admin", function(xPlayer, args, showError)
local xTarget = ESX.GetPlayerFromId(args.playerId)
if xTarget then
local targetCoords = xTarget.getCoords()
local targetCoords = args.playerId.getCoords()
xPlayer.setCoords(targetCoords)
xPlayer.TriggerEvent("chatMessage", "Successfully Teleported")
else
xPlayer.TriggerEvent("chatMessage", "ERROR: Player Not Online!")
end
end, true, {help = _U('goto'), validate = true, arguments = {
{name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'}
}})
ESX.RegisterCommand('bring', "admin", function(xPlayer, args, showError)
local xTarget = ESX.GetPlayerFromId(args.playerId)
if xTarget then
local playerCoords = xPlayer.getCoords()
xTarget.setCoords(playerCoords)
xPlayer.TriggerEvent("chatMessage", "Successfully Brought Player")
else
xPlayer.TriggerEvent("chatMessage", "ERROR: Player Not Online!")
end
args.playerId.setCoords(playerCoords)
end, true, {help = _U('goto'), validate = true, arguments = {
{name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'}
}})
ESX.RegisterCommand('getplayers', "admin", function(xPlayer, args, showError)
ESX.RegisterCommand('players', "admin", function(xPlayer, args, showError)
local xAll = ESX.GetPlayers()
print("^2"..#xAll.." ^3online player(s)^0")
print("^5"..#xAll.." ^2online player(s)^0")
for i=1, #xAll, 1 do
local xPlayer = ESX.GetPlayerFromId(xAll[i])
print("^4[ ^2ID : ^3"..xPlayer.source.." ^0| ^2Name : ^3"..xPlayer.getName().." ^0 | ^2Group : ^3"..xPlayer.getGroup().." ^4]^0\n")
print("^1[ ^2ID : ^5"..xPlayer.source.." ^0| ^2Name : ^5"..xPlayer.getName().." ^0 | ^2Group : ^5"..xPlayer.getGroup().." ^0 | ^2Identifier : ^5".. xPlayer.identifier .."^1]^0\n")
end
end, true)
-9
View File
@@ -284,12 +284,3 @@ ESX.DoesJobExist = function(job, grade)
return false
end
ESX.GetPlayerIdentifier = function(playerId)
local identifiers = GetPlayerIdentifiers(playerId)
for _,id in ipairs(identifiers) do
if id:find(Config.IdentifierPrefix) then
return id:gsub(string.format("%s:","licence"),"")
end
end
end
+39 -44
View File
@@ -10,31 +10,17 @@ AddEventHandler('esx:onPlayerJoined', function()
end
end)
if Config.UseMulticharacter then
AddEventHandler("esx:overwriteIdentifierMethod",function(ref)
ESX.GetPlayerIdentifier = ref
end)
end
function onPlayerJoined(playerId)
local identifier
if Config.UseMulticharacter then
local identifier = ESX.GetPlayerIdentifier(playerId)
else
for k,v in ipairs(GetPlayerIdentifiers(playerId)) do
if string.match(v, 'license:') then
if Config.UseKashacters then
identifier = v
break
else
identifier = string.sub(v, 9)
break
end
end
for k,v in ipairs(GetPlayerIdentifiers(playerId)) do
if string.match(v, 'license:') then
identifier = string.sub(v, 9)
break
end
end
if identifier then
if ESX.GetPlayerFromIdentifier(identifier) then
DropPlayer(playerId, ('there was an error loading your character!\nError code: identifier-active-ingame\n\nThis error is caused by a player on this server who has the same identifier as you have. Make sure you are not playing on the same Rockstar account.\n\nYour Rockstar identifier: %s'):format(identifier))
@@ -52,7 +38,7 @@ function onPlayerJoined(playerId)
end
if IsPlayerAceAllowed(playerId, "command") then
print(('[es_extended] [^2INFO^7] The player id %s just connected for the first time and will be given the admin group due to ace permissions.'):format(playerId))
print(('[es_extended] ^5[INFO] ^0 Player ^5%s ^0Has been granted admin permissions via ^5Ace Perms.'):format(playerId))
defaultGroup = "admin"
else
defaultGroup = "user"
@@ -78,22 +64,13 @@ AddEventHandler('playerConnecting', function(name, setCallback, deferrals)
local playerId, identifier = source
Citizen.Wait(100)
if Config.UseMulticharacter then
local identifier = ESX.GetPlayerIdentifier(playerId)
else
for k,v in ipairs(GetPlayerIdentifiers(playerId)) do
if string.match(v, 'license:') then
if Config.UseKashacters then
identifier = v
break
else
identifier = string.sub(v, 9)
break
end
identifier = string.sub(v, 9)
break
end
end
end
if identifier then
if ESX.GetPlayerFromIdentifier(identifier) then
@@ -202,7 +179,11 @@ function loadESXPlayer(identifier, playerId)
-- Group
if result[1].group then
userData.group = result[1].group
if result[1].group == "superadmin" then
userData.group = "admin"
else
userData.group = result[1].group
end
else
userData.group = 'user'
end
@@ -244,7 +225,6 @@ function loadESXPlayer(identifier, playerId)
Async.parallel(tasks, function(results)
local xPlayer = CreateExtendedPlayer(playerId, identifier, userData.group, userData.accounts, userData.inventory, userData.weight, userData.job, userData.loadout, userData.playerName, userData.coords)
ESX.Players[playerId] = xPlayer
TriggerEvent('esx:playerLoaded', playerId, xPlayer)
xPlayer.triggerEvent('esx:playerLoaded', {
accounts = xPlayer.getAccounts(),
@@ -259,7 +239,7 @@ function loadESXPlayer(identifier, playerId)
xPlayer.triggerEvent('esx:createMissingPickups', ESX.Pickups)
xPlayer.triggerEvent('esx:registerSuggestions', ESX.RegisteredCommands)
print(('[es_extended] [^2INFO^7] A player with name "%s^7" has connected to the server with assigned player id %s'):format(xPlayer.getName(), playerId))
print(('[es_extended] ^5[INFO]^0 Player ^5"%s" ^0has connected to the server. ID: ^5%s'):format(xPlayer.getName(), playerId))
end)
end
@@ -537,23 +517,24 @@ end)
Citizen.CreateThread(
function()
local vRaw = LoadResourceFile(GetCurrentResourceName(), 'version.json')
if vRaw and config.versionCheck then
if vRaw then
local v = json.decode(vRaw)
PerformHttpRequest(
'https://raw.githubusercontent.com/Mycroft-Studios/es_extended/legacy/version.json',
'https://raw.githubusercontent.com/esx-framework/es_extended/legacy/version.json',
function(code, res, headers)
if code == 200 then
local rv = json.decode(res)
if rv.version ~= v.version then
if rv.version == v.version then
if rv.commit ~= v.commit then
print(
([[
^1-------------------------------------------------------
URGENT: YOUR ES-EXTENDED IS OUTDATATED!!!
COMMIT UPDATE: %s AVAILABLE
CHANGELOG: %s
-------------------------------------------------------
^1----------------------------------------------------------------------
^1URGENT: YOUR ES-EXTENDED IS OUTDATATED!!!
^1COMMIT UPDATE: ^5%s AVAILABLE
^1DOWNLOAD:^5 https://github.com/esx-framework/es_extended/tree/legacy
^1CHANGELOG:^5 %s
^1-----------------------------------------------------------------------
]]):format(
rv.commit,
rv.changelog
@@ -570,12 +551,26 @@ CHANGELOG: %s
^5CHANGELOG:^0 %s
^8-------------------------------------------------------
]]):format(
rv.version
rv.version,
rv.commit,
rv.changelog
)
)
end
else
print(
([[
^1-------------------------------------------------------
URGENT: YOUR ES-EXTENDED IS OUTDATATED!!!
VERSION: %s AVAILABLE
CHANGELOG: %s
-------------------------------------------------------
]]):format(
rv.commit,
rv.changelog
)
)
end
else
print('ERROR: Es-Extended unable to check version')
+1 -1
View File
@@ -1,5 +1,5 @@
{
"version": "legacy",
"commit" : "1.4",
"commit" : "1.1.5",
"changelog": "Performance Improvements; Config Updates; Bug Fixes"
}