mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 01:08:54 +00:00
Update readme.md
This commit is contained in:
@@ -3,23 +3,23 @@
|
||||
|
||||
Instrukcja w języku Polskim znajduje się [tutaj](https://github.com/fivem-ex/esx_kashacter/blob/master/readme-pl.md).
|
||||
|
||||
### Current design:
|
||||
## Current design:
|
||||

|
||||
|
||||
## Required changes:
|
||||
# Required changes:
|
||||
|
||||
* es_extended: (`es_extended/client/main.lua`)
|
||||
### Replace this code:
|
||||
```lua
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(0)
|
||||
while true do
|
||||
Citizen.Wait(0)
|
||||
|
||||
if NetworkIsPlayerActive(PlayerId()) then
|
||||
TriggerServerEvent('esx:onPlayerJoined')
|
||||
break
|
||||
end
|
||||
end
|
||||
if NetworkIsPlayerActive(PlayerId()) then
|
||||
TriggerServerEvent('esx:onPlayerJoined')
|
||||
break
|
||||
end
|
||||
end
|
||||
end)
|
||||
```
|
||||
|
||||
@@ -27,94 +27,95 @@ end)
|
||||
```lua
|
||||
RegisterNetEvent('esx:kashloaded')
|
||||
AddEventHandler('esx:kashloaded', function()
|
||||
TriggerServerEvent('esx:onPlayerJoined')
|
||||
TriggerServerEvent('esx:onPlayerJoined')
|
||||
end)
|
||||
```
|
||||
|
||||
* es_extended: (`es_extended/client/main.lua` at RegisterNetEvent('esx:playerLoaded'))
|
||||
### Comment out this code:
|
||||
```lua
|
||||
-- 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)
|
||||
-- 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)
|
||||
|
||||
while not HasModelLoaded(defaultModel) do
|
||||
Citizen.Wait(100)
|
||||
end
|
||||
while not HasModelLoaded(defaultModel) do
|
||||
Citizen.Wait(100)
|
||||
end
|
||||
|
||||
SetPlayerModel(PlayerId(), defaultModel)
|
||||
local playerPed = PlayerPedId()
|
||||
SetPlayerModel(PlayerId(), defaultModel)
|
||||
local playerPed = PlayerPedId()
|
||||
|
||||
SetPedDefaultComponentVariation(playerPed)
|
||||
SetPedRandomComponentVariation(playerPed, true)
|
||||
SetModelAsNoLongerNeeded(defaultModel)
|
||||
FreezeEntityPosition(playerPed, false)
|
||||
end
|
||||
SetPedDefaultComponentVariation(playerPed)
|
||||
SetPedRandomComponentVariation(playerPed, true)
|
||||
SetModelAsNoLongerNeeded(defaultModel)
|
||||
FreezeEntityPosition(playerPed, false)
|
||||
end
|
||||
```
|
||||
|
||||
### find:
|
||||
```lua
|
||||
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
|
||||
TriggerEvent('esx:restoreLoadout')
|
||||
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
|
||||
TriggerEvent('esx:restoreLoadout')
|
||||
|
||||
Citizen.Wait(3000)
|
||||
ShutdownLoadingScreen()
|
||||
FreezeEntityPosition(PlayerPedId(), false)
|
||||
DoScreenFadeIn(10000)
|
||||
StartServerSyncLoops()
|
||||
end)
|
||||
Citizen.Wait(3000)
|
||||
ShutdownLoadingScreen()
|
||||
FreezeEntityPosition(PlayerPedId(), false)
|
||||
DoScreenFadeIn(10000)
|
||||
StartServerSyncLoops()
|
||||
end)
|
||||
```
|
||||
|
||||
### replace with:
|
||||
```lua
|
||||
--[[
|
||||
ESX.Game.Teleport(PlayerPedId(), {
|
||||
x = playerData.coords.x,
|
||||
y = playerData.coords.y,
|
||||
z = playerData.coords.z + 0.25,
|
||||
heading = playerData.coords.heading
|
||||
}, function()
|
||||
end)
|
||||
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')
|
||||
TriggerServerEvent('esx:onPlayerSpawn')
|
||||
TriggerEvent('esx:onPlayerSpawn')
|
||||
TriggerEvent('playerSpawned') -- compatibility with old scripts, will be removed soon
|
||||
TriggerEvent('esx:restoreLoadout')
|
||||
|
||||
Citizen.Wait(3000)
|
||||
ShutdownLoadingScreen()
|
||||
FreezeEntityPosition(PlayerPedId(), false)
|
||||
DoScreenFadeIn(10000)
|
||||
StartServerSyncLoops()
|
||||
Citizen.Wait(0)
|
||||
ShutdownLoadingScreen()
|
||||
FreezeEntityPosition(PlayerPedId(), false)
|
||||
DoScreenFadeIn(0)
|
||||
StartServerSyncLoops()
|
||||
```
|
||||
|
||||
* es_extended: (`es_extended/server/main.lua`)
|
||||
|
||||
### Change this code in `onPlayerJoined(playerId)` function:
|
||||
```lua
|
||||
for k,v in ipairs(GetPlayerIdentifiers(playerId)) do
|
||||
if string.match(v, 'license:') then
|
||||
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
|
||||
```
|
||||
|
||||
### to:
|
||||
```lua
|
||||
for k,v in ipairs(GetPlayerIdentifiers(playerId)) do
|
||||
if string.match(v, 'license:') then
|
||||
identifier = v
|
||||
break
|
||||
end
|
||||
end
|
||||
for k,v in ipairs(GetPlayerIdentifiers(playerId)) do
|
||||
if string.match(v, 'license:') then
|
||||
identifier = v
|
||||
break
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
|
||||
@@ -122,7 +123,7 @@ end)
|
||||
## Tables (Owned & Identifier)
|
||||
- Now we edit the table and add all our identifier to make sure our character loads.
|
||||
- *Edit the code in esx_kashacters\server\main.lua*
|
||||
```
|
||||
```lua
|
||||
local IdentifierTables = {
|
||||
{table = "addon_account_data", column = "owner"},
|
||||
{table = "addon_inventory_items", column = "owner"},
|
||||
@@ -145,6 +146,7 @@ and
|
||||
|
||||
`SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'identifier'`
|
||||
|
||||
|
||||
## Duplication Entry (Datastore)
|
||||
To fix The datastore duplicated entry download this https://github.com/XxFri3ndlyxX/esx_datastore
|
||||
|
||||
@@ -154,155 +156,155 @@ Or
|
||||
### Comment out this code:
|
||||
```lua
|
||||
AddEventHandler('esx:playerLoaded', function(playerId, xPlayer)
|
||||
for i=1, #DataStoresIndex, 1 do
|
||||
local name = DataStoresIndex[i]
|
||||
local dataStore = GetDataStore(name, xPlayer.identifier)
|
||||
for i=1, #DataStoresIndex, 1 do
|
||||
local name = DataStoresIndex[i]
|
||||
local dataStore = GetDataStore(name, xPlayer.identifier)
|
||||
|
||||
if not dataStore then
|
||||
MySQL.Async.execute('INSERT INTO datastore_data (name, owner, data) VALUES (@name, @owner, @data)', {
|
||||
['@name'] = name,
|
||||
['@owner'] = xPlayer.identifier,
|
||||
['@data'] = '{}'
|
||||
})
|
||||
if not dataStore then
|
||||
MySQL.Async.execute('INSERT INTO datastore_data (name, owner, data) VALUES (@name, @owner, @data)', {
|
||||
['@name'] = name,
|
||||
['@owner'] = xPlayer.identifier,
|
||||
['@data'] = '{}'
|
||||
})
|
||||
|
||||
dataStore = CreateDataStore(name, xPlayer.identifier, {})
|
||||
table.insert(DataStores[name], dataStore)
|
||||
end
|
||||
end
|
||||
dataStore = CreateDataStore(name, xPlayer.identifier, {})
|
||||
table.insert(DataStores[name], dataStore)
|
||||
end
|
||||
end
|
||||
end)
|
||||
```
|
||||
|
||||
## Add this code
|
||||
### Add this code
|
||||
```lua
|
||||
-- Fix for kashacters duplication entry --
|
||||
-- Fix was taken from this link --
|
||||
-- https://forum.fivem.net/t/release-esx-kashacters-multi-character/251613/448?u=xxfri3ndlyxx --
|
||||
AddEventHandler('esx:playerLoaded', function(playerId, xPlayer)
|
||||
|
||||
local result = MySQL.Sync.fetchAll('SELECT * FROM datastore')
|
||||
local result = MySQL.Sync.fetchAll('SELECT * FROM datastore')
|
||||
|
||||
for i=1, #result, 1 do
|
||||
local name = result[i].name
|
||||
local label = result[i].label
|
||||
local shared = result[i].shared
|
||||
for i=1, #result, 1 do
|
||||
local name = result[i].name
|
||||
local label = result[i].label
|
||||
local shared = result[i].shared
|
||||
|
||||
local result2 = MySQL.Sync.fetchAll('SELECT * FROM datastore_data WHERE name = @name', {
|
||||
['@name'] = name
|
||||
})
|
||||
local result2 = MySQL.Sync.fetchAll('SELECT * FROM datastore_data WHERE name = @name', {
|
||||
['@name'] = name
|
||||
})
|
||||
|
||||
if shared == 0 then
|
||||
if shared == 0 then
|
||||
|
||||
table.insert(DataStoresIndex, name)
|
||||
DataStores[name] = {}
|
||||
table.insert(DataStoresIndex, name)
|
||||
DataStores[name] = {}
|
||||
|
||||
for j=1, #result2, 1 do
|
||||
local storeName = result2[j].name
|
||||
local storeOwner = result2[j].owner
|
||||
local storeData = (result2[j].data == nil and {} or json.decode(result2[j].data))
|
||||
local dataStore = CreateDataStore(storeName, storeOwner, storeData)
|
||||
for j=1, #result2, 1 do
|
||||
local storeName = result2[j].name
|
||||
local storeOwner = result2[j].owner
|
||||
local storeData = (result2[j].data == nil and {} or json.decode(result2[j].data))
|
||||
local dataStore = CreateDataStore(storeName, storeOwner, storeData)
|
||||
|
||||
table.insert(DataStores[name], dataStore)
|
||||
end
|
||||
end
|
||||
end
|
||||
table.insert(DataStores[name], dataStore)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local dataStores = {}
|
||||
for i=1, #DataStoresIndex, 1 do
|
||||
local name = DataStoresIndex[i]
|
||||
local dataStore = GetDataStore(name, xPlayer.identifier)
|
||||
local dataStores = {}
|
||||
for i=1, #DataStoresIndex, 1 do
|
||||
local name = DataStoresIndex[i]
|
||||
local dataStore = GetDataStore(name, xPlayer.identifier)
|
||||
|
||||
if dataStore == nil then
|
||||
MySQL.Async.execute('INSERT INTO datastore_data (name, owner, data) VALUES (@name, @owner, @data)',
|
||||
{
|
||||
['@name'] = name,
|
||||
['@owner'] = xPlayer.identifier,
|
||||
['@data'] = '{}'
|
||||
})
|
||||
if dataStore == nil then
|
||||
MySQL.Async.execute('INSERT INTO datastore_data (name, owner, data) VALUES (@name, @owner, @data)',
|
||||
{
|
||||
['@name'] = name,
|
||||
['@owner'] = xPlayer.identifier,
|
||||
['@data'] = '{}'
|
||||
})
|
||||
|
||||
dataStore = CreateDataStore(name, xPlayer.identifier, {})
|
||||
table.insert(DataStores[name], dataStore)
|
||||
end
|
||||
dataStore = CreateDataStore(name, xPlayer.identifier, {})
|
||||
table.insert(DataStores[name], dataStore)
|
||||
end
|
||||
|
||||
table.insert(dataStores, dataStore)
|
||||
end
|
||||
table.insert(dataStores, dataStore)
|
||||
end
|
||||
|
||||
xPlayer.set('dataStores', dataStores)
|
||||
xPlayer.set('dataStores', dataStores)
|
||||
end)
|
||||
```
|
||||
## Ambulance Fix
|
||||
|
||||
# Ambulance Fix
|
||||
The Fix for the ambulance on the kashacter script is already implemented.
|
||||
|
||||
Now all you have to do is go to your ambulance script that is up to date and
|
||||
comment or delete
|
||||
|
||||
|
||||
|
||||
```
|
||||
--[[
|
||||
* esx_ambulancejob: (`esx_ambulancejob/client/main.lua`)
|
||||
### find:
|
||||
```lua
|
||||
AddEventHandler('playerSpawned', function()
|
||||
IsDead = false
|
||||
IsDead = false
|
||||
|
||||
if FirstSpawn then
|
||||
exports.spawnmanager:setAutoSpawn(false) -- disable respawn
|
||||
FirstSpawn = false
|
||||
if FirstSpawn then
|
||||
exports.spawnmanager:setAutoSpawn(false) -- disable respawn
|
||||
FirstSpawn = false
|
||||
|
||||
ESX.TriggerServerCallback('esx_ambulancejob:getDeathStatus', function(isDead)
|
||||
if isDead and Config.AntiCombatLog then
|
||||
while not PlayerLoaded do
|
||||
Citizen.Wait(1000)
|
||||
end
|
||||
ESX.TriggerServerCallback('esx_ambulancejob:getDeathStatus', function(isDead)
|
||||
if isDead and Config.AntiCombatLog then
|
||||
while not PlayerLoaded do
|
||||
Citizen.Wait(1000)
|
||||
end
|
||||
|
||||
ESX.ShowNotification(_U('combatlog_message'))
|
||||
RemoveItemsAfterRPDeath()
|
||||
end
|
||||
end)
|
||||
end
|
||||
ESX.ShowNotification(_U('combatlog_message'))
|
||||
RemoveItemsAfterRPDeath()
|
||||
end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
]]--
|
||||
```
|
||||
|
||||
### Then add this
|
||||
|
||||
```
|
||||
### replace with:
|
||||
```lua
|
||||
RegisterNetEvent('esx_ambulancejob:multicharacter')
|
||||
AddEventHandler('esx_ambulancejob:multicharacter', function()
|
||||
IsDead = false
|
||||
if Config.AntiCombatLog then
|
||||
while not PlayerLoaded do
|
||||
Citizen.Wait(1000)
|
||||
end
|
||||
ESX.TriggerServerCallback('esx_ambulancejob:getDeathStatus', function(isDead)
|
||||
if isDead and Config.AntiCombatLog then
|
||||
ESX.ShowNotification(_U('combatlog_message'))
|
||||
RemoveItemsAfterRPDeath()
|
||||
end
|
||||
end)
|
||||
end
|
||||
IsDead = false
|
||||
if Config.AntiCombatLog then
|
||||
while not PlayerLoaded do
|
||||
Citizen.Wait(1000)
|
||||
end
|
||||
ESX.TriggerServerCallback('esx_ambulancejob:getDeathStatus', function(isDead)
|
||||
if isDead and Config.AntiCombatLog then
|
||||
ESX.ShowNotification(_U('combatlog_message'))
|
||||
RemoveItemsAfterRPDeath()
|
||||
end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
```
|
||||
### Then change this
|
||||
```
|
||||
function RespawnPed(ped, coords, heading)
|
||||
SetEntityCoordsNoOffset(ped, coords.x, coords.y, coords.z, false, false, false, true)
|
||||
NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z, heading, true, false)
|
||||
SetPlayerInvincible(ped, false)
|
||||
TriggerEvent('playerspawned', coords.x, coords.y, coords.z)
|
||||
ClearPedBloodDamage(ped)
|
||||
|
||||
ESX.UI.Menu.CloseAll()
|
||||
### find:
|
||||
```lua
|
||||
function RespawnPed(ped, coords, heading)
|
||||
SetEntityCoordsNoOffset(ped, coords.x, coords.y, coords.z, false, false, false, true)
|
||||
NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z, heading, true, false)
|
||||
SetPlayerInvincible(ped, false)
|
||||
TriggerEvent('playerspawned', coords.x, coords.y, coords.z)
|
||||
ClearPedBloodDamage(ped)
|
||||
|
||||
ESX.UI.Menu.CloseAll()
|
||||
end
|
||||
```
|
||||
### to
|
||||
```
|
||||
function RespawnPed(ped, coords, heading)
|
||||
SetEntityCoordsNoOffset(ped, coords.x, coords.y, coords.z, false, false, false, true)
|
||||
NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z, heading, true, false)
|
||||
SetPlayerInvincible(ped, false)
|
||||
TriggerEvent('esx_ambulancejob:multicharacter', coords.x, coords.y, coords.z)
|
||||
ClearPedBloodDamage(ped)
|
||||
|
||||
ESX.UI.Menu.CloseAll()
|
||||
end
|
||||
### repalce with:
|
||||
```lua
|
||||
function RespawnPed(ped, coords, heading)
|
||||
SetEntityCoordsNoOffset(ped, coords.x, coords.y, coords.z, false, false, false, true)
|
||||
NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z, heading, true, false)
|
||||
SetPlayerInvincible(ped, false)
|
||||
TriggerEvent('esx_ambulancejob:multicharacter', coords.x, coords.y, coords.z)
|
||||
ClearPedBloodDamage(ped)
|
||||
|
||||
ESX.UI.Menu.CloseAll()
|
||||
end
|
||||
```
|
||||
*If you do not do this last part once you repawn after death you will be frozen into place.*
|
||||
|
||||
|
||||
Reference in New Issue
Block a user