Advertisement
Guest User

Untitled

a guest
Jan 2nd, 2020
2,852
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.94 KB | None | 0 0
  1. # KASHacters - ESX Multi Characters
  2.  
  3. ## Installation
  4. **_How to install instruction._ Created By XxFri3ndlyxX**
  5. <br>
  6. - First you need a serrver that has at least the basic scripts and their requirements.
  7.  
  8.  
  9.  
  10. ```
  11. ### [ESSENTIALS] ###
  12. start mysql-async
  13. start essentialmode
  14. start esplugin_mysql
  15. start es_extended
  16. start async
  17. start es_ui
  18. start es_admin2
  19. start esx_kashacters
  20. start esx_identity
  21. start skinchanger
  22. start esx_skin
  23. start instance
  24. start esx_datastore
  25. start esx_addonaccount
  26. start esx_addoninventory
  27. start cron
  28. start esx_menu_default
  29. start esx_menu_list
  30. start esx_menu_dialog
  31. start esx_license
  32. start esx_billing
  33. start esx_society
  34. start esx_policejob
  35. start esx_ambulancejob
  36. start esx_vehicleshop
  37. ```
  38.  
  39. <br>
  40. Then
  41. <br>
  42. - Download the resource
  43. - Rename the resource to esx_kashacters
  44. - import the sql file in your database
  45. - Go to *essentialmode\client\main.lua* and edit/comment the code.
  46.  
  47.  
  48. ```
  49. --[[Citizen.CreateThread(function()
  50. while true do
  51. Citizen.Wait(0)
  52.  
  53. if NetworkIsSessionStarted() then
  54. TriggerServerEvent('es:firstJoinProper')
  55. TriggerEvent('es:allowedToSpawn')
  56. return
  57. end
  58. end
  59. end)]]--
  60. ```
  61. ## Inventory Quick Fix
  62. - To fix the inventory not showing after death.
  63. Quick fix you can do.
  64. In es_extended Look for
  65.  
  66. ```
  67. -- Menu interactions
  68. Citizen.CreateThread(function()
  69. while true do
  70.  
  71. Citizen.Wait(0)
  72.  
  73. if IsControlJustReleased(0, Keys['F2']) and IsInputDisabled(0) and not isDead and not ESX.UI.Menu.IsOpen('default', 'es_extended', 'inventory') then
  74. ESX.ShowInventory()
  75. end
  76.  
  77. end
  78. end)
  79. ```
  80. and change it to
  81. ```
  82. -- Menu interactions
  83. Citizen.CreateThread(function()
  84. while true do
  85.  
  86. Citizen.Wait(0)
  87.  
  88. if IsControlJustReleased(0, Keys['F2']) and IsInputDisabled(0) and not ESX.UI.Menu.IsOpen('default', 'es_extended', 'inventory') then
  89. ESX.ShowInventory()
  90. end
  91.  
  92. end
  93. end)
  94. ```
  95. -I know this is not the best solution. But i don't have time to fix this the proper way. Use this quick fix or fix it properly on your own. I's something to do with isdead not being trigged properly. Also you can do the same to other menu that don't work by removing the and not isDead
  96.  
  97. ## Tables (Owned & Identifier)
  98. - Now we edit the table and add all our identifier to make sure our character loads.
  99. - *Edit the code in esx_kashacters\server\main.lua*
  100.  
  101.  
  102. ```
  103. local IdentifierTables = {
  104. {table = "addon_account_data", column = "owner"},
  105. {table = "addon_inventory_items", column = "owner"},
  106. {table = "billing", column = "identifier"},
  107. {table = "characters", column = "identifier"},
  108. {table = "datastore_data", column = "owner"},
  109. {table = "owned_vehicles", column = "owner"},
  110. {table = "rented_vehicles", column = "owner"},
  111. {table = "society_moneywash", column = "identifier"},
  112. {table = "users", column = "identifier"},
  113. {table = "user_accounts", column = "identifier"},
  114. {table = "user_inventory", column = "identifier"},
  115. {table = "user_licenses", column = "owner"},
  116. }
  117. ```
  118.  
  119. To get your identifier.
  120. Do this query in your database
  121.  
  122. `SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'owner'`
  123.  
  124. and
  125.  
  126. `SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'indentifier'`
  127.  
  128.  
  129. Credit @Xnubil for this query line
  130.  
  131.  
  132. The table list provided is just an example. Yours may differ depending on what you install on your server.
  133.  
  134. Once You've done all that. add start esx_kashacters to your server.cfg
  135.  
  136.  
  137. ## Ambulance Fix
  138. The Fix for the ambulance on the kashacter script is already implemented.
  139.  
  140. Now all you have to do is go to your ambulance script that is up to date and
  141. comment or delete
  142.  
  143.  
  144.  
  145. ```
  146. --[[
  147. AddEventHandler('playerSpawned', function()
  148. IsDead = false
  149.  
  150. if FirstSpawn then
  151. exports.spawnmanager:setAutoSpawn(false) -- disable respawn
  152. FirstSpawn = false
  153.  
  154. ESX.TriggerServerCallback('esx_ambulancejob:getDeathStatus', function(isDead)
  155. if isDead and Config.AntiCombatLog then
  156. while not PlayerLoaded do
  157. Citizen.Wait(1000)
  158. end
  159.  
  160. ESX.ShowNotification(_U('combatlog_message'))
  161. RemoveItemsAfterRPDeath()
  162. end
  163. end)
  164. end
  165. end)
  166. ]]--
  167. ```
  168. <br>
  169. Then add this
  170. <br>
  171.  
  172. ```
  173. RegisterNetEvent('esx_ambulancejob:multicharacter')
  174. AddEventHandler('esx_ambulancejob:multicharacter', function()
  175. IsDead = false
  176.  
  177. ESX.TriggerServerCallback('esx_ambulancejob:getDeathStatus', function(isDead)
  178. if isDead and Config.AntiCombatLog then
  179. ESX.ShowNotification(_U('combatlog_message'))
  180. RemoveItemsAfterRPDeath()
  181. end
  182. end)
  183. end)
  184. ```
  185. Then change this
  186. ```
  187. function RespawnPed(ped, coords, heading)
  188. SetEntityCoordsNoOffset(ped, coords.x, coords.y, coords.z, false, false, false, true)
  189. NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z, heading, true, false)
  190. SetPlayerInvincible(ped, false)
  191. TriggerEvent('playerspawned', coords.x, coords.y, coords.z)
  192. ClearPedBloodDamage(ped)
  193.  
  194. ESX.UI.Menu.CloseAll()
  195. end
  196. ```
  197. to
  198. ```
  199. function RespawnPed(ped, coords, heading)
  200. SetEntityCoordsNoOffset(ped, coords.x, coords.y, coords.z, false, false, false, true)
  201. NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z, heading, true, false)
  202. SetPlayerInvincible(ped, false)
  203. TriggerEvent('esx_ambulancejob:multicharacter', coords.x, coords.y, coords.z)
  204. ClearPedBloodDamage(ped)
  205.  
  206. ESX.UI.Menu.CloseAll()
  207. end
  208. ```
  209. If you do not do this last part once you repawn after death you will be frozen into place.
  210.  
  211. ## Duplication Entry (Datastore)
  212. To fix The datastore duplicated entry download this https://github.com/XxFri3ndlyxX/esx_datastore
  213.  
  214. Or
  215.  
  216. Add this code to your server/main.lua
  217. ```-- Fix for kashacters duplication entry --
  218. -- Fix was taken from this link --
  219. -- https://forum.fivem.net/t/release-esx-kashacters-multi-character/251613/448?u=xxfri3ndlyxx --
  220. AddEventHandler('esx:playerLoaded', function(source)
  221.  
  222. local result = MySQL.Sync.fetchAll('SELECT * FROM datastore')
  223.  
  224. for i=1, #result, 1 do
  225. local name = result[i].name
  226. local label = result[i].label
  227. local shared = result[i].shared
  228.  
  229. local result2 = MySQL.Sync.fetchAll('SELECT * FROM datastore_data WHERE name = @name', {
  230. ['@name'] = name
  231. })
  232.  
  233. if shared == 0 then
  234.  
  235. table.insert(DataStoresIndex, name)
  236. DataStores[name] = {}
  237.  
  238. for j=1, #result2, 1 do
  239. local storeName = result2[j].name
  240. local storeOwner = result2[j].owner
  241. local storeData = (result2[j].data == nil and {} or json.decode(result2[j].data))
  242. local dataStore = CreateDataStore(storeName, storeOwner, storeData)
  243.  
  244. table.insert(DataStores[name], dataStore)
  245. end
  246. end
  247. end
  248.  
  249. local _source = source
  250. local xPlayer = ESX.GetPlayerFromId(_source)
  251. local dataStores = {}
  252.  
  253. for i=1, #DataStoresIndex, 1 do
  254. local name = DataStoresIndex[i]
  255. local dataStore = GetDataStore(name, xPlayer.identifier)
  256.  
  257. if dataStore == nil then
  258. MySQL.Async.execute('INSERT INTO datastore_data (name, owner, data) VALUES (@name, @owner, @data)',
  259. {
  260. ['@name'] = name,
  261. ['@owner'] = xPlayer.identifier,
  262. ['@data'] = '{}'
  263. })
  264.  
  265. dataStore = CreateDataStore(name, xPlayer.identifier, {})
  266. table.insert(DataStores[name], dataStore)
  267. end
  268.  
  269. table.insert(dataStores, dataStore)
  270. end
  271.  
  272. xPlayer.set('dataStores', dataStores)
  273. end)
  274. ```
  275.  
  276. > *Pay ATTENTION: You have to call the resource 'esx_kashacters' in order for the javascript to work!!!**
  277.  
  278. ## How it works
  279. > What this script does it manipulates ESX for loading characters
  280. So when you are choosing your character it changes your steam id which is normally steam: to Char: this prevents ESX from loading another character because it is looking for you exact steamid. So when you choose your character it will change it from Char: to your normal steam id (steam:). When creating a new character it will spawn you without an exact steamid which creates a new database entry for your steamid
  281.  
  282. ## Credits
  283.  
  284. > ESX Framework and **KASH** AND **Onno204** for creating the resource. You can do whatever the f with it what you want but it is nice to give the main man credits ;)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement