mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-02 03:08:52 +00:00
@@ -43,9 +43,7 @@ ESX was initially developed by Gizz back in 2017 for his friend as the were crea
|
||||
|
||||
```
|
||||
cd resources
|
||||
git clone https://github.com/esx-framework/es_extended.git
|
||||
cd es_extended
|
||||
git checkout legacy
|
||||
git clone https://github.com/esx-framework/es_extended.git --branch legacy
|
||||
git clone https://github.com/ESX-Org/esx_menu_default [esx]/[ui]/esx_menu_default
|
||||
git clone https://github.com/ESX-Org/esx_menu_dialog [esx]/[ui]/esx_menu_dialog
|
||||
git clone https://github.com/ESX-Org/esx_menu_list [esx]/[ui]/esx_menu_list
|
||||
@@ -93,7 +91,7 @@ start esx_menu_dialog
|
||||
|
||||
es_extended - ESX framework for FiveM
|
||||
|
||||
Copyright (C) 2015-2020 Jérémie N'gadi
|
||||
Copyright (C) 2015-2021 Jérémie N'gadi
|
||||
|
||||
This program Is free software: you can redistribute it And/Or modify it under the terms Of the GNU General Public License As published by the Free Software Foundation, either version 3 Of the License, Or (at your option) any later version.
|
||||
|
||||
|
||||
+15
-23
@@ -729,31 +729,23 @@ ESX.Game.SetVehicleProperties = function(vehicle, props)
|
||||
end
|
||||
end
|
||||
|
||||
ESX.Game.Utils.DrawText3D = function(coords, text, size, font)
|
||||
coords = vector3(coords.x, coords.y, coords.z)
|
||||
ESX.Game.Utils.DrawText3D = function(coords, text, scale, font)
|
||||
local vector = type(coords) == "vector3" and coords or vec(coords.x, coords.y, coords.z)
|
||||
|
||||
local camCoords = GetGameplayCamCoords()
|
||||
local distance = #(coords - camCoords)
|
||||
if not scale then scale = 0.35 end
|
||||
if not font then font = 4 end
|
||||
|
||||
if not size then size = 1 end
|
||||
if not font then font = 0 end
|
||||
|
||||
local scale = (size / distance) * 2
|
||||
local fov = (1 / GetGameplayCamFov()) * 100
|
||||
scale = scale * fov
|
||||
|
||||
SetTextScale(0.0 * scale, 0.55 * scale)
|
||||
SetTextScale(scale, scale)
|
||||
SetTextFont(font)
|
||||
SetTextColour(255, 255, 255, 255)
|
||||
SetTextDropshadow(0, 0, 0, 0, 255)
|
||||
SetTextDropShadow()
|
||||
SetTextOutline()
|
||||
SetTextProportional(1)
|
||||
SetTextColour(255, 255, 255, 215)
|
||||
SetTextEntry('STRING')
|
||||
SetTextCentre(true)
|
||||
|
||||
SetDrawOrigin(coords, 0)
|
||||
BeginTextCommandDisplayText('STRING')
|
||||
AddTextComponentSubstringPlayerName(text)
|
||||
EndTextCommandDisplayText(0.0, 0.0)
|
||||
AddTextComponentString(text)
|
||||
SetDrawOrigin(vector.xyz, 0)
|
||||
DrawText(0.0, 0.0)
|
||||
local factor = string.len(text) / 370
|
||||
DrawRect(0.0, 0.0 + 0.0125, 0.017 + factor, 0.03, 0, 0, 0, 75)
|
||||
ClearDrawOrigin()
|
||||
end
|
||||
|
||||
@@ -763,7 +755,7 @@ ESX.ShowInventory = function()
|
||||
|
||||
for k,v in pairs(ESX.PlayerData.accounts) do
|
||||
if v.money > 0 then
|
||||
local formattedMoney = _U('locale_currency', ESX.Math.GroupDigits(v.money))
|
||||
local formattedMoney = _U('locale_currency', ESX.Math.GroupDigits(v.money))
|
||||
local canDrop = v.name ~= 'bank'
|
||||
|
||||
table.insert(elements, {
|
||||
@@ -776,7 +768,7 @@ ESX.ShowInventory = function()
|
||||
canRemove = canDrop
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for k,v in ipairs(ESX.PlayerData.inventory) do
|
||||
if v.count > 0 then
|
||||
|
||||
+133
-23
@@ -1,22 +1,20 @@
|
||||
local isPaused, isDead, pickups = false, false, {}
|
||||
|
||||
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)
|
||||
|
||||
|
||||
RegisterNetEvent('esx:playerLoaded')
|
||||
AddEventHandler('esx:playerLoaded', function(playerData)
|
||||
ESX.PlayerLoaded = true
|
||||
ESX.PlayerData = playerData
|
||||
|
||||
-- check if player is coming from loading screen
|
||||
|
||||
if GetEntityModel(PlayerPedId()) == GetHashKey('PLAYER_ZERO') then
|
||||
local defaultModel = GetHashKey('a_m_y_stbla_02')
|
||||
RequestModel(defaultModel)
|
||||
@@ -31,16 +29,19 @@ AddEventHandler('esx:playerLoaded', function(playerData)
|
||||
SetModelAsNoLongerNeeded(defaultModel)
|
||||
end
|
||||
|
||||
-- freeze the player
|
||||
|
||||
FreezeEntityPosition(PlayerPedId(), true)
|
||||
|
||||
-- enable PVP
|
||||
SetCanAttackFriendly(PlayerPedId(), true, false)
|
||||
NetworkSetFriendlyFireOption(true)
|
||||
|
||||
if Config.EnablePVP then
|
||||
SetCanAttackFriendly(PlayerPedId(), true, false)
|
||||
NetworkSetFriendlyFireOption(true)
|
||||
end
|
||||
-- disable wanted level
|
||||
if not Config.EnableWantedLevel then
|
||||
ClearPlayerWantedLevel(PlayerId())
|
||||
SetMaxWantedLevel(0)
|
||||
end
|
||||
|
||||
if Config.EnableHud then
|
||||
for k,v in ipairs(playerData.accounts) do
|
||||
@@ -176,11 +177,6 @@ AddEventHandler('esx:removeInventoryItem', function(item, count, showNotificatio
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:setJob')
|
||||
AddEventHandler('esx:setJob', function(job)
|
||||
ESX.PlayerData.job = job
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:addWeapon')
|
||||
AddEventHandler('esx:addWeapon', function(weaponName, ammo)
|
||||
local playerPed = PlayerPedId()
|
||||
@@ -245,13 +241,14 @@ AddEventHandler('esx:teleport', function(coords)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:setJob')
|
||||
AddEventHandler('esx:setJob', function(job)
|
||||
AddEventHandler('esx:setJob', function(Job)
|
||||
if Config.EnableHud then
|
||||
ESX.UI.HUD.UpdateElement('job', {
|
||||
job_label = job.label,
|
||||
grade_label = job.grade_label
|
||||
job_label = Job.label,
|
||||
grade_label = Job.grade_label
|
||||
})
|
||||
end
|
||||
ESX.SetPlayerData("job", Job)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:spawnVehicle')
|
||||
@@ -392,7 +389,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)
|
||||
@@ -417,7 +414,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
|
||||
@@ -436,8 +433,8 @@ function StartServerSyncLoops()
|
||||
end
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(0)
|
||||
while Config.EnableDefaultInventory do
|
||||
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
|
||||
@@ -447,7 +444,6 @@ Citizen.CreateThread(function()
|
||||
end
|
||||
end)
|
||||
|
||||
-- Pickups
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(0)
|
||||
@@ -495,3 +491,117 @@ Citizen.CreateThread(function()
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
----- Admin commnads from esx_adminplus
|
||||
|
||||
RegisterNetEvent("esx:tpm")
|
||||
AddEventHandler("esx:tpm", function()
|
||||
local WaypointHandle = GetFirstBlipInfoId(8)
|
||||
if DoesBlipExist(WaypointHandle) then
|
||||
local waypointCoords = GetBlipInfoIdCoord(WaypointHandle)
|
||||
|
||||
for height = 1, 1000 do
|
||||
SetPedCoordsKeepVehicle(PlayerPedId(), waypointCoords["x"], waypointCoords["y"], height + 0.0)
|
||||
|
||||
local foundGround, zPos = GetGroundZFor_3dCoord(waypointCoords["x"], waypointCoords["y"], height + 0.0)
|
||||
|
||||
if foundGround then
|
||||
SetPedCoordsKeepVehicle(PlayerPedId(), waypointCoords["x"], waypointCoords["y"], height + 0.0)
|
||||
|
||||
break
|
||||
end
|
||||
|
||||
Citizen.Wait(5)
|
||||
end
|
||||
TriggerEvent('chatMessage', "Successfully Teleported")
|
||||
else
|
||||
TriggerEvent('chatMessage', "No Waypoint Set")
|
||||
end
|
||||
end)
|
||||
|
||||
local noclip = false
|
||||
RegisterNetEvent("esx:noclip")
|
||||
AddEventHandler("esx:noclip", function(input)
|
||||
local player = PlayerId()
|
||||
local ped = PlayerPedId
|
||||
|
||||
local msg = "disabled"
|
||||
if(noclip == false)then
|
||||
noclip_pos = GetEntityCoords(PlayerPedId(), false)
|
||||
end
|
||||
|
||||
noclip = not noclip
|
||||
|
||||
if(noclip)then
|
||||
msg = "enabled"
|
||||
end
|
||||
|
||||
TriggerEvent("chatMessage", "Noclip has been ^2^*" .. msg)
|
||||
end)
|
||||
|
||||
local heading = 0
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(0)
|
||||
|
||||
if(noclip)then
|
||||
SetEntityCoordsNoOffset(PlayerPedId(), noclip_pos.x, noclip_pos.y, noclip_pos.z, 0, 0, 0)
|
||||
|
||||
if(IsControlPressed(1, 34))then
|
||||
heading = heading + 1.5
|
||||
if(heading > 360)then
|
||||
heading = 0
|
||||
end
|
||||
|
||||
SetEntityHeading(PlayerPedId(), heading)
|
||||
end
|
||||
|
||||
if(IsControlPressed(1, 9))then
|
||||
heading = heading - 1.5
|
||||
if(heading < 0)then
|
||||
heading = 360
|
||||
end
|
||||
|
||||
SetEntityHeading(PlayerPedId(), heading)
|
||||
end
|
||||
|
||||
if(IsControlPressed(1, 8))then
|
||||
noclip_pos = GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 1.0, 0.0)
|
||||
end
|
||||
|
||||
if(IsControlPressed(1, 32))then
|
||||
noclip_pos = GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, -1.0, 0.0)
|
||||
end
|
||||
|
||||
if(IsControlPressed(1, 27))then
|
||||
noclip_pos = GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 0.0, 1.0)
|
||||
end
|
||||
|
||||
if(IsControlPressed(1, 173))then
|
||||
noclip_pos = GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 0.0, -1.0)
|
||||
end
|
||||
else
|
||||
Citizen.Wait(200)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent("esx:killPlayer")
|
||||
AddEventHandler("esx:killPlayer", function()
|
||||
SetEntityHealth(PlayerPedId(), 0)
|
||||
end)
|
||||
|
||||
RegisterNetEvent("esx:freezePlayer")
|
||||
AddEventHandler("esx:freezePlayer", function(input)
|
||||
local player = PlayerId()
|
||||
local ped = PlayerPedId()
|
||||
if input == 'freeze' then
|
||||
SetEntityCollision(ped, false)
|
||||
FreezeEntityPosition(ped, true)
|
||||
SetPlayerInvincible(player, true)
|
||||
elseif input == 'unfreeze' then
|
||||
SetEntityCollision(ped, true)
|
||||
FreezeEntityPosition(ped, false)
|
||||
SetPlayerInvincible(player, false)
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
+10
-6
@@ -7,10 +7,14 @@ Config.Accounts = {
|
||||
money = _U('account_money')
|
||||
}
|
||||
|
||||
Config.StartingAccountMoney = {bank = 50000}
|
||||
Config.StartingAccountMoney = {bank = 50000}
|
||||
|
||||
Config.EnableSocietyPayouts = false -- pay from the society account that the player is employed at? Requirement: esx_society
|
||||
Config.EnableHud = true -- enable the default hud? Display current job and accounts (black, bank & cash)
|
||||
Config.MaxWeight = 24 -- the max inventory weight without backpack
|
||||
Config.PaycheckInterval = 7 * 60000 -- how often to recieve pay checks in milliseconds
|
||||
Config.EnableDebug = false -- Use Debug options?
|
||||
Config.EnableDefaultInventory = true -- Display the default Inventory ( F2 )
|
||||
Config.EnableWantedLevel = false -- Use Normal GTA wanted Level?
|
||||
Config.EnablePVP = true -- Allow Player to player combat
|
||||
|
||||
Config.EnableSocietyPayouts = false -- pay from the society account that the player is employed at? Requirement: esx_society
|
||||
Config.EnableHud = true -- enable the default hud? Display current job and accounts (black, bank & cash)
|
||||
Config.MaxWeight = 24 -- the max inventory weight without backpack
|
||||
Config.PaycheckInterval = 7 * 60000 -- how often to recieve pay checks in milliseconds
|
||||
Config.EnableDebug = false
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ CREATE DATABASE IF NOT EXISTS `es_extended`;
|
||||
USE `es_extended`;
|
||||
|
||||
CREATE TABLE `users` (
|
||||
`identifier` VARCHAR(40) NOT NULL,
|
||||
`identifier` VARCHAR(64) NOT NULL,
|
||||
`accounts` LONGTEXT NULL DEFAULT NULL,
|
||||
`group` VARCHAR(50) NULL DEFAULT 'user',
|
||||
`inventory` LONGTEXT NULL DEFAULT NULL,
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ game 'gta5'
|
||||
|
||||
description 'ES Extended'
|
||||
|
||||
version '1.2.0'
|
||||
version 'legacy'
|
||||
|
||||
server_scripts {
|
||||
'@async/async.lua',
|
||||
|
||||
+94
-3
@@ -1,3 +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 = {
|
||||
@@ -19,12 +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
|
||||
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.radius then args.radius = 4 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'}
|
||||
@@ -66,7 +69,7 @@ ESX.RegisterCommand('giveweapon', 'admin', function(xPlayer, args, showError)
|
||||
if args.playerId.hasWeapon(args.weapon) then
|
||||
showError(_U('command_giveweapon_hasalready'))
|
||||
else
|
||||
xPlayer.addWeapon(args.weapon, args.ammo)
|
||||
args.playerId.addWeapon(args.weapon, args.ammo)
|
||||
end
|
||||
end, true, {help = _U('command_giveweapon'), validate = true, arguments = {
|
||||
{name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'},
|
||||
@@ -79,10 +82,10 @@ ESX.RegisterCommand('giveweaponcomponent', 'admin', function(xPlayer, args, show
|
||||
local component = ESX.GetWeaponComponent(args.weaponName, args.componentName)
|
||||
|
||||
if component then
|
||||
if xPlayer.hasWeaponComponent(args.weaponName, args.componentName) then
|
||||
if args.playerId.hasWeaponComponent(args.weaponName, args.componentName) then
|
||||
showError(_U('command_giveweaponcomponent_hasalready'))
|
||||
else
|
||||
xPlayer.addWeaponComponent(args.weaponName, args.componentName)
|
||||
args.playerId.addWeaponComponent(args.weaponName, args.componentName)
|
||||
end
|
||||
else
|
||||
showError(_U('command_giveweaponcomponent_invalid'))
|
||||
@@ -123,6 +126,8 @@ 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 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'},
|
||||
@@ -138,3 +143,89 @@ end, true, {help = _U('command_save'), validate = true, arguments = {
|
||||
ESX.RegisterCommand('saveall', 'admin', function(xPlayer, args, showError)
|
||||
ESX.SavePlayers()
|
||||
end, true, {help = _U('command_saveall')})
|
||||
|
||||
ESX.RegisterCommand('group', {"user", "admin"}, function(xPlayer, args, showError)
|
||||
print(xPlayer.getName()..", You are currently: ^5".. xPlayer.getGroup())
|
||||
end, 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
|
||||
print('[^5es_extended^0] ^2[INFO] ^1 Server Restarting, Please Wait :)')
|
||||
crash = true
|
||||
while crash do
|
||||
end
|
||||
end)
|
||||
end, true)
|
||||
|
||||
ESX.RegisterCommand('tpm', "admin", function(xPlayer, args, showError)
|
||||
xPlayer.triggerEvent("esx:tpm")
|
||||
end, true)
|
||||
|
||||
ESX.RegisterCommand('goto', "admin", function(xPlayer, args, showError)
|
||||
local targetCoords = args.playerId.getCoords()
|
||||
xPlayer.setCoords(targetCoords)
|
||||
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 playerCoords = xPlayer.getCoords()
|
||||
args.playerId.setCoords(playerCoords)
|
||||
end, true, {help = _U('bring'), validate = true, arguments = {
|
||||
{name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'}
|
||||
}})
|
||||
|
||||
ESX.RegisterCommand('kill', "admin", function(xPlayer, args, showError)
|
||||
args.playerId.triggerEvent('esx:killPlayer')
|
||||
end, true, {help = _U('kill'), validate = true, arguments = {
|
||||
{name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'}
|
||||
}})
|
||||
|
||||
ESX.RegisterCommand('freeze', "admin", function(xPlayer, args, showError)
|
||||
args.playerId.triggerEvent('esx:freezePlayer', "freeze")
|
||||
end, true, {help = _U('kill'), validate = true, arguments = {
|
||||
{name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'}
|
||||
}})
|
||||
|
||||
ESX.RegisterCommand('unfreeze', "admin", function(xPlayer, args, showError)
|
||||
args.playerId.triggerEvent('esx:freezePlayer', "unfreeze")
|
||||
end, true, {help = _U('kill'), validate = true, arguments = {
|
||||
{name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'}
|
||||
}})
|
||||
|
||||
ESX.RegisterCommand('reviveall', "admin", function(xPlayer, args, showError)
|
||||
for _, playerId in ipairs(GetPlayers()) do
|
||||
TriggerClientEvent('esx_ambulancejob:revive', playerId)
|
||||
end
|
||||
end, false)
|
||||
|
||||
ESX.RegisterCommand("noclip", 'admin', function(xPlayer, args, showError)
|
||||
xPlayer.triggerEvent('esx:noclip')
|
||||
end, false)
|
||||
|
||||
ESX.RegisterCommand('players', "admin", function(xPlayer, args, showError)
|
||||
local xAll = ESX.GetPlayers()
|
||||
print("^5"..#xAll.." ^2online player(s)^0")
|
||||
for i=1, #xAll, 1 do
|
||||
local xPlayer = ESX.GetPlayerFromId(xAll[i])
|
||||
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)
|
||||
|
||||
+4
-4
@@ -41,26 +41,26 @@ MySQL.ready(function()
|
||||
if ESX.Jobs[v.job_name] then
|
||||
ESX.Jobs[v.job_name].grades[tostring(v.grade)] = v
|
||||
else
|
||||
print(('[es_extended] [^3WARNING^7] Ignoring job grades for "%s" due to missing job'):format(v.job_name))
|
||||
print(('[^5es_extended^0] [^3WARNING^7] Ignoring job grades for ^5"%s"^0 due to missing job'):format(v.job_name))
|
||||
end
|
||||
end
|
||||
|
||||
for k2,v2 in pairs(ESX.Jobs) do
|
||||
if ESX.Table.SizeOf(v2.grades) == 0 then
|
||||
ESX.Jobs[v2.name] = nil
|
||||
print(('[es_extended] [^3WARNING^7] Ignoring job "%s" due to no job grades found'):format(v2.name))
|
||||
print(('[^5es_extended^0] [^3WARNING^7] Ignoring job ^5"%s"^0due to no job grades found'):format(v2.name))
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
print('[es_extended] [^2INFO^7] ESX developed by ESX-Org has been initialized')
|
||||
print('[^5es_extended^0] [^2INFO^7] ESX ^5Legacy^0 initialized')
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx:clientLog')
|
||||
AddEventHandler('esx:clientLog', function(msg)
|
||||
if Config.EnableDebug then
|
||||
print(('[es_extended] [^2TRACE^7] %s^7'):format(msg))
|
||||
print(('[^5es_extended^0] [^2TRACE^7] %s^7'):format(msg))
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
ESX.Trace = function(msg)
|
||||
if Config.EnableDebug then
|
||||
print(('[es_extended] [^2TRACE^7] %s^7'):format(msg))
|
||||
print(('[^5es_extended^0] [^2TRACE^7] %s^7'):format(msg))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,7 +30,7 @@ ESX.RegisterCommand = function(name, group, cb, allowConsole, suggestion)
|
||||
end
|
||||
|
||||
if ESX.RegisteredCommands[name] then
|
||||
print(('[es_extended] [^3WARNING^7] An command "%s" is already registered, overriding command'):format(name))
|
||||
print(('[^5es_extended^0] [^3WARNING^7] Command ^5"%s" already registered, overriding command'):format(name))
|
||||
|
||||
if ESX.RegisteredCommands[name].suggestion then
|
||||
TriggerClientEvent('chat:removeSuggestion', -1, ('/%s'):format(name))
|
||||
@@ -50,7 +50,7 @@ ESX.RegisterCommand = function(name, group, cb, allowConsole, suggestion)
|
||||
local command = ESX.RegisteredCommands[name]
|
||||
|
||||
if not command.allowConsole and playerId == 0 then
|
||||
print(('[es_extended] [^3WARNING^7] %s'):format(_U('commanderror_console')))
|
||||
print(('[^5es_extended^0] [^3WARNING^7] ^5%s'):format(_U('commanderror_console')))
|
||||
else
|
||||
local xPlayer, error = ESX.GetPlayerFromId(playerId), nil
|
||||
|
||||
@@ -122,14 +122,14 @@ ESX.RegisterCommand = function(name, group, cb, allowConsole, suggestion)
|
||||
|
||||
if error then
|
||||
if playerId == 0 then
|
||||
print(('[es_extended] [^3WARNING^7] %s^7'):format(error))
|
||||
print(('[^5es_extended^0] [^3WARNING^7] %s^7'):format(error))
|
||||
else
|
||||
xPlayer.triggerEvent('chat:addMessage', {args = {'^1SYSTEM', error}})
|
||||
end
|
||||
else
|
||||
cb(xPlayer or false, args, function(msg)
|
||||
if playerId == 0 then
|
||||
print(('[es_extended] [^3WARNING^7] %s^7'):format(msg))
|
||||
print(('[^5es_extended^0] [^3WARNING^7] %s^7'):format(msg))
|
||||
else
|
||||
xPlayer.triggerEvent('chat:addMessage', {args = {'^1SYSTEM', msg}})
|
||||
end
|
||||
@@ -159,7 +159,7 @@ ESX.TriggerServerCallback = function(name, requestId, source, cb, ...)
|
||||
if ESX.ServerCallbacks[name] then
|
||||
ESX.ServerCallbacks[name](source, cb, ...)
|
||||
else
|
||||
print(('[es_extended] [^3WARNING^7] Server callback "%s" does not exist. Make sure that the server sided file really is loading, an error in that file might cause it to not load.'):format(name))
|
||||
print(('[^5es_extended^0] [^3WARNING^7] Server callback ^5"%s"^0 does not exist. ^1Please Check The Server File for Errors!'):format(name))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -182,7 +182,7 @@ ESX.SavePlayer = function(xPlayer, cb)
|
||||
end)
|
||||
|
||||
Async.parallel(asyncTasks, function(results)
|
||||
print(('[es_extended] [^2INFO^7] Saved player "%s^7"'):format(xPlayer.getName()))
|
||||
print(('[^5es_extended^0] [^2INFO^7] Saved player ^5"%s^7"'):format(xPlayer.getName()))
|
||||
|
||||
if cb then
|
||||
cb()
|
||||
@@ -201,7 +201,7 @@ ESX.SavePlayers = function(cb)
|
||||
end
|
||||
|
||||
Async.parallelLimit(asyncTasks, 8, function(results)
|
||||
print(('[es_extended] [^2INFO^7] Saved %s player(s)'):format(#xPlayers))
|
||||
print(('[^5es_extended^0] [^2INFO^7] Saved ^5%s^0 player(s)'):format(#xPlayers))
|
||||
if cb then
|
||||
cb()
|
||||
end
|
||||
|
||||
+97
-14
@@ -1,6 +1,6 @@
|
||||
Citizen.CreateThread(function()
|
||||
SetMapName('San Andreas')
|
||||
SetGameType('Roleplay')
|
||||
SetGameType('ESX Roleplay')
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:onPlayerJoined')
|
||||
@@ -20,6 +20,7 @@ function onPlayerJoined(playerId)
|
||||
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))
|
||||
@@ -37,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(('[^5es_extended^0] ^2[INFO] ^0 Player ^5%s ^0Has been granted admin permissions via ^5Ace Perms.^7'):format(playerId))
|
||||
defaultGroup = "admin"
|
||||
else
|
||||
defaultGroup = "user"
|
||||
@@ -63,12 +64,13 @@ AddEventHandler('playerConnecting', function(name, setCallback, deferrals)
|
||||
local playerId, identifier = source
|
||||
Citizen.Wait(100)
|
||||
|
||||
for k,v in ipairs(GetPlayerIdentifiers(playerId)) do
|
||||
if string.match(v, 'license:') then
|
||||
identifier = string.sub(v, 9)
|
||||
break
|
||||
for k,v in ipairs(GetPlayerIdentifiers(playerId)) do
|
||||
if string.match(v, 'license:') then
|
||||
identifier = string.sub(v, 9)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if identifier then
|
||||
if ESX.GetPlayerFromIdentifier(identifier) then
|
||||
@@ -81,7 +83,6 @@ AddEventHandler('playerConnecting', function(name, setCallback, deferrals)
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
function loadESXPlayer(identifier, playerId)
|
||||
local tasks = {}
|
||||
|
||||
@@ -122,7 +123,7 @@ function loadESXPlayer(identifier, playerId)
|
||||
if ESX.DoesJobExist(job, grade) then
|
||||
jobObject, gradeObject = ESX.Jobs[job], ESX.Jobs[job].grades[grade]
|
||||
else
|
||||
print(('[es_extended] [^3WARNING^7] Ignoring invalid job for %s [job: %s, grade: %s]'):format(identifier, job, grade))
|
||||
print(('[^5es_extended^0] [^3WARNING^7] Ignoring invalid job for %s [job: %s, grade: %s]'):format(identifier, job, grade))
|
||||
job, grade = 'unemployed', '0'
|
||||
jobObject, gradeObject = ESX.Jobs[job], ESX.Jobs[job].grades[grade]
|
||||
end
|
||||
@@ -152,7 +153,7 @@ function loadESXPlayer(identifier, playerId)
|
||||
if item then
|
||||
foundItems[name] = count
|
||||
else
|
||||
print(('[es_extended] [^3WARNING^7] Ignoring invalid item "%s" for "%s"'):format(name, identifier))
|
||||
print(('[^5es_extended^0] [^3WARNING^7] Ignoring invalid item "%s" for "%s"'):format(name, identifier))
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -178,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
|
||||
@@ -209,7 +214,7 @@ function loadESXPlayer(identifier, playerId)
|
||||
if result[1].position and result[1].position ~= '' then
|
||||
userData.coords = json.decode(result[1].position)
|
||||
else
|
||||
print('[es_extended] [^3WARNING^7] Column "position" in "users" table is missing required default value. Using backup coords, fix your database.')
|
||||
print('[^5es_extended^0] [^3WARNING^7] Column ^5"position"^0 in ^5"users"^0 table is missing required default value. Using backup coords, fix your database.')
|
||||
userData.coords = {x = -269.4, y = -955.3, z = 31.2, heading = 205.8}
|
||||
end
|
||||
|
||||
@@ -220,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(),
|
||||
@@ -235,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(('[^5es_extended^0] [^2INFO^0] Player ^5"%s" ^0has connected to the server. ID: ^5%s^7'):format(xPlayer.getName(), playerId))
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -509,5 +513,84 @@ ESX.RegisterServerCallback('esx:getPlayerNames', function(source, cb, players)
|
||||
cb(players)
|
||||
end)
|
||||
|
||||
AddEventHandler('txAdmin:events:scheduledRestart', function(eventData)
|
||||
if eventData.secondsRemaining == 60 then
|
||||
Citizen.CreateThread(function()
|
||||
Citizen.Wait(50000)
|
||||
ESX.SavePlayers()
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
||||
-- version check
|
||||
Citizen.CreateThread(
|
||||
function()
|
||||
local vRaw = LoadResourceFile(GetCurrentResourceName(), 'version.json')
|
||||
if vRaw then
|
||||
local v = json.decode(vRaw)
|
||||
PerformHttpRequest(
|
||||
'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.commit ~= v.commit then
|
||||
print(
|
||||
([[
|
||||
|
||||
^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
|
||||
)
|
||||
)
|
||||
else
|
||||
print(
|
||||
([[
|
||||
|
||||
^8-------------------------------------------------------
|
||||
^2Your Es-extended is the latest version!
|
||||
^5Version:^0 %s
|
||||
^5COMMIT:^0 %s
|
||||
^5CHANGELOG:^0 %s
|
||||
^8-------------------------------------------------------
|
||||
]]):format(
|
||||
rv.version,
|
||||
rv.commit,
|
||||
rv.changelog
|
||||
)
|
||||
)
|
||||
end
|
||||
else
|
||||
print(
|
||||
([[
|
||||
^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
|
||||
)
|
||||
)
|
||||
end
|
||||
else
|
||||
print('[^5es_extended^0] [^1ERROR^0] Es-Extended unable to check version!')
|
||||
end
|
||||
end,
|
||||
'GET'
|
||||
)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
|
||||
ESX.StartDBSync()
|
||||
ESX.StartPayCheck()
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"version": "legacy",
|
||||
"commit" : "1.1.7",
|
||||
"changelog": "Performance Improvements; Config Updates; Bug Fixes"
|
||||
}
|
||||
Reference in New Issue
Block a user