mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 10:01:28 +00:00
5b591a94b5
Thanks You KASH (github.com/KASHZIN)Who The Original Develop This ESX_KASHACTERS RELEASE And To for the tutorial XxFri3ndlyxX (github.com/XxFri3ndlyxX)
this tutorial i made little bit use XxFri3ndlyxX tutorial
1.Step One [ essentialmode\client\main.lua ]
Delete Or Replace This !
--[[Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if NetworkIsSessionStarted() then
TriggerServerEvent('es:firstJoinProper')
TriggerEvent('es:allowedToSpawn')
return
end
end
end)]]--
2.Step Two [ es_extended [ LINE : 457 ] client/main.lua ]
This To Fix Cant Open Inventory When You Die And Get Revived
Change You Menu interactions to this !
``` ---Menu interactions
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if IsControlJustReleased(0, 289) and IsInputDisabled(0) and not ESX.UI.Menu.IsOpen('default', 'es_extended', 'inventory') then
ESX.ShowInventory()
end
end
end)```
3. Step Three
To Get Your esx_kashacters work you need do this on your database
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'owner'
And This
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'indentifier'
Credit @Xnubil
6. Step Six [Fix Datastore]
Duplicate Your esx_datastore or add This line on your esx_datastore server\main.lua
-- Fix was taken from this link --
-- https://forum.fivem.net/t/release-esx-kashacters-multi-character/251613/448?u=xxfri3ndlyxx --
AddEventHandler('esx:playerLoaded', function(source)
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
local result2 = MySQL.Sync.fetchAll('SELECT * FROM datastore_data WHERE name = @name', {
['@name'] = name
})
if shared == 0 then
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)
table.insert(DataStores[name], dataStore)
end
end
end
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
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'] = '{}'
})
dataStore = CreateDataStore(name, xPlayer.identifier, {})
table.insert(DataStores[name], dataStore)
end
table.insert(dataStores, dataStore)
end
xPlayer.set('dataStores', dataStores)
end)
Download Link : https://github.com/XxFri3ndlyxX/esx_datastore
Credits : https://github.com/XxFri3ndlyxX
5. Step Five [ Fix Ambulance ]
This To Fix Die Tele And When Your Get Revived You Cant Open any Menu only F2
Download My File the esx_ambulancejob (or download the lastest version esx_ambulancejob :v)
6. Step Six [ Fix your esx_kashacters identifier ]
Download My mysql-async And start on your server.cfg
7. Step Seven [ Fix Your Identifier And Spawn]
Download My esx_kashacters Modified And start on your server.cfg
Thats All Identifier [esx_kashacters\server\main.lua] maybe thats all
you need in Roleplay Server if you wan to change just change it
===--------------------------------------------------------------------===
Okey Thats All Make My esx_kashacters work properly if you wanna ask
My Discord : Blue.#5108
Thank you Again to KASH And XxFri3ndlyxX ! :)
ENJOY YOUR ESX_KASHACTERS
123 lines
5.1 KiB
Lua
123 lines
5.1 KiB
Lua
---------------------------------------------------------------------------------------
|
|
-- Edit this table to all the database tables and columns
|
|
-- where identifiers are used (such as users, owned_vehicles, owned_properties etc.)
|
|
---------------------------------------------------------------------------------------
|
|
local IdentifierTables = {
|
|
{table = "users", column = "identifier"},
|
|
{table = "user_accounts", column = "identifier"},
|
|
-- {table = "user_contacts", column = "identifier"},
|
|
{table = "user_inventory", column = "identifier"},
|
|
-- {table = "user_parkings", column = "identifier"},
|
|
{table = "society_moneywash", column = "identifier"},
|
|
{table = "phone_users_contacts", column = "identifier"},
|
|
--{table = "jail", column = "identifier"},
|
|
{table = "characters", column = "identifier"},
|
|
{table = "billing", column = "identifier"},
|
|
{table = "rented_vehicles", column = "owner"},
|
|
{table = "addon_account_data", column = "owner"},
|
|
{table = "addon_inventory_items", column = "owner"},
|
|
{table = "datastore_data", column = "owner"},
|
|
{table = "owned_vehicles", column = "owner"},
|
|
{table = "phone_calls", column = "owner"},
|
|
{table = "phone_messages", column = "owner"},
|
|
{table = "rented_vehicles", column = "owner"},
|
|
{table = "user_licenses", column = "owner"},
|
|
}
|
|
|
|
RegisterServerEvent("kashactersS:SetupCharacters")
|
|
AddEventHandler('kashactersS:SetupCharacters', function()
|
|
local src = source
|
|
local LastCharId = GetLastCharacter(src)
|
|
SetIdentifierToChar(GetPlayerIdentifiers(src)[1], LastCharId)
|
|
local Characters = GetPlayerCharacters(src)
|
|
TriggerClientEvent('kashactersC:SetupUI', src, Characters)
|
|
end)
|
|
|
|
RegisterServerEvent("kashactersS:CharacterChosen")
|
|
AddEventHandler('kashactersS:CharacterChosen', function(charid, ischar)
|
|
local src = source
|
|
local spawn = {}
|
|
SetLastCharacter(src, tonumber(charid))
|
|
SetCharToIdentifier(GetPlayerIdentifiers(src)[1], tonumber(charid))
|
|
if ischar == "true" then
|
|
spawn = GetSpawnPos(src)
|
|
else
|
|
TriggerClientEvent('skinchanger:loadDefaultModel', src, true, cb)
|
|
spawn = { x = 195.55, y = -933.36, z = 29.90 } -- DEFAULT SPAWN POSITION
|
|
end
|
|
TriggerClientEvent("kashactersC:SpawnCharacter", src, spawn)
|
|
end)
|
|
|
|
RegisterServerEvent("kashactersS:DeleteCharacter")
|
|
AddEventHandler('kashactersS:DeleteCharacter', function(charid)
|
|
local src = source
|
|
DeleteCharacter(GetPlayerIdentifiers(src)[1], charid)
|
|
TriggerClientEvent("kashactersC:ReloadCharacters", src)
|
|
end)
|
|
|
|
function GetPlayerCharacters(source)
|
|
local identifier = GetIdentifierWithoutSteam(GetPlayerIdentifiers(source)[1])
|
|
local Chars = MySQLAsyncExecute("SELECT * FROM `users` WHERE identifier LIKE '%"..identifier.."%'")
|
|
for i = 1, #Chars, 1 do
|
|
charJob = MySQLAsyncExecute("SELECT * FROM `jobs` WHERE `name` = '"..Chars[i].job.."'")
|
|
charJobgrade = MySQLAsyncExecute("SELECT * FROM `job_grades` WHERE `grade` = '"..Chars[i].job_grade.."'")
|
|
Chars[i].job = charJob[1].label
|
|
Chars[i].job_grade = charJobgrade[1].label
|
|
end
|
|
return Chars
|
|
end
|
|
|
|
function GetLastCharacter(source)
|
|
local LastChar = MySQLAsyncExecute("SELECT `charid` FROM `user_lastcharacter` WHERE `steamid` = '"..GetPlayerIdentifiers(source)[1].."'")
|
|
if LastChar[1] ~= nil and LastChar[1].charid ~= nil then
|
|
return tonumber(LastChar[1].charid)
|
|
else
|
|
MySQLAsyncExecute("INSERT INTO `user_lastcharacter` (`steamid`, `charid`) VALUES('"..GetPlayerIdentifiers(source)[1].."', 1)")
|
|
return 1
|
|
end
|
|
end
|
|
|
|
function SetLastCharacter(source, charid)
|
|
MySQLAsyncExecute("UPDATE `user_lastcharacter` SET `charid` = '"..charid.."' WHERE `steamid` = '"..GetPlayerIdentifiers(source)[1].."'")
|
|
end
|
|
|
|
function SetIdentifierToChar(identifier, charid)
|
|
for _, itable in pairs(IdentifierTables) do
|
|
MySQLAsyncExecute("UPDATE `"..itable.table.."` SET `"..itable.column.."` = 'Char"..charid..GetIdentifierWithoutSteam(identifier).."' WHERE `"..itable.column.."` = '"..identifier.."'")
|
|
end
|
|
end
|
|
|
|
function SetCharToIdentifier(identifier, charid)
|
|
for _, itable in pairs(IdentifierTables) do
|
|
MySQLAsyncExecute("UPDATE `"..itable.table.."` SET `"..itable.column.."` = '"..identifier.."' WHERE `"..itable.column.."` = 'Char"..charid..GetIdentifierWithoutSteam(identifier).."'")
|
|
end
|
|
end
|
|
|
|
function DeleteCharacter(identifier, charid)
|
|
for _, itable in pairs(IdentifierTables) do
|
|
MySQLAsyncExecute("DELETE FROM `"..itable.table.."` WHERE `"..itable.column.."` = 'Char"..charid..GetIdentifierWithoutSteam(identifier).."'")
|
|
end
|
|
end
|
|
|
|
function GetSpawnPos(source)
|
|
local SpawnPos = MySQLAsyncExecute("SELECT `position` FROM `users` WHERE `identifier` = '"..GetPlayerIdentifiers(source)[1].."'")
|
|
return json.decode(SpawnPos[1].position)
|
|
end
|
|
|
|
function GetIdentifierWithoutSteam(Identifier)
|
|
return string.gsub(Identifier, "steam", "")
|
|
end
|
|
|
|
function MySQLAsyncExecute(query)
|
|
local IsBusy = true
|
|
local result = nil
|
|
MySQL.Async.fetchAll(query, {}, function(data)
|
|
result = data
|
|
IsBusy = false
|
|
end)
|
|
while IsBusy do
|
|
Citizen.Wait(0)
|
|
end
|
|
return result
|
|
end
|