[RELEASE][ESX] KASHacters Multi Character

esx
characters

#309

i realized where the problem are. if i’m right the problem lies on es_extended side ( Saving cords problem ) im using now es_extended v1.0.14 and problem its gone


#310

if I choose to create a character, something like this pops up


#311

Have you been able to fix this yet?


#312

esx_ambulancejob combat logger issue after choosing the character wasn’t directly fixed by @officialRobins fix for some reason so i had to just remove one thing. Hope this helps someone!

@officialRobins original fix
RegisterNetEvent('esx_ambulancejob:multicharacter')
AddEventHandler('esx_ambulancejob:multicharacter', function()
	IsDead = 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.ShowNotification(_U('combatlog_message'))
				RemoveItemsAfterRPDeath()
			end
		end)
	end
end)

All I did was remove the check for FirstSpawn in the esx_ambulancejob:multicharacter

With esx_ambulancejob:multicharacter being called from esx_kashacters when choosing a char it shouldn’t matter if was FirstSpawn or not (would assume this fix would not work if using the switch characters)

Removed FirstSpawn Check
RegisterNetEvent('esx_ambulancejob:multicharacter')
AddEventHandler('esx_ambulancejob:multicharacter', function()
	IsDead = false
	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.ShowNotification(_U('combatlog_message'))
			RemoveItemsAfterRPDeath()
		end
	end)
end)

Loving this Script :heart_eyes::sunglasses:


#313

didn´t add what??


#315

All I did was replace this section of code in esx_ambulancejob client and in esx_kashacters client

stock esx_ambulancejob/client/main.lua lines 43 - 61
AddEventHandler('playerSpawned', function()
	IsDead = 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.ShowNotification(_U('combatlog_message'))
				RemoveItemsAfterRPDeath()
			end
		end)
	end
end)
Replacement lines 43 - 78 now
addEventHandler('playerSpawned', function()
	IsDead = 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.ShowNotification(_U('combatlog_message'))
				RemoveItemsAfterRPDeath()
			end
		end)
	end
end)
RegisterNetEvent('esx_ambulancejob:multicharacter')
AddEventHandler('esx_ambulancejob:multicharacter', function()
	IsDead = false
	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.ShowNotification(_U('combatlog_message'))
			RemoveItemsAfterRPDeath()
		end
	end)
end)

make sure you trigger esx_ambulancejob:multicharacter in esx_kashacters/client/main.lua

TriggerEvent('esx_ambulancejob:multicharacter')
Stock esx_kashacters/client/main.lua lines 53 - 81
RegisterNetEvent('kashactersC:SpawnCharacter')
AddEventHandler('kashactersC:SpawnCharacter', function(spawn)
    TriggerServerEvent('es:firstJoinProper')
    TriggerEvent('es:allowedToSpawn')
    SetTimecycleModifier('default')
    local pos = spawn
    SetEntityCoords(GetPlayerPed(-1), pos.x, pos.y, pos.z)
    DoScreenFadeIn(500)
    Citizen.Wait(500)
    cam2 = CreateCamWithParams("DEFAULT_SCRIPTED_CAMERA", -1355.93,-1487.78,520.75, 300.00,0.00,0.00, 100.00, false, 0)
    PointCamAtCoord(cam2, pos.x,pos.y,pos.z+200)
    SetCamActiveWithInterp(cam2, cam, 900, true, true)
    Citizen.Wait(900)

    cam = CreateCamWithParams("DEFAULT_SCRIPTED_CAMERA", pos.x,pos.y,pos.z+200, 300.00,0.00,0.00, 100.00, false, 0)
    PointCamAtCoord(cam, pos.x,pos.y,pos.z+2)
    SetCamActiveWithInterp(cam, cam2, 3700, true, true)
    Citizen.Wait(3700)
    PlaySoundFrontend(-1, "Zoom_Out", "DLC_HEIST_PLANNING_BOARD_SOUNDS", 1)
    RenderScriptCams(false, true, 500, true, true)
    PlaySoundFrontend(-1, "CAR_BIKE_WHOOSH", "MP_LOBBY_SOUNDS", 1)
    FreezeEntityPosition(GetPlayerPed(-1), false)
    Citizen.Wait(500)
    SetCamActive(cam, false)
    DestroyCam(cam, true)
    IsChoosing = false
    DisplayHud(true)
    DisplayRadar(true)
end)
Replacement lines 53 - 87 now
RegisterNetEvent('kashactersC:SpawnCharacter')
AddEventHandler('kashactersC:SpawnCharacter', function(spawn, isnew)
    TriggerServerEvent('es:firstJoinProper')
    TriggerEvent('es:allowedToSpawn')
    TriggerEvent('esx_ambulancejob:multicharacter')

    SetTimecycleModifier('default')
    local pos = spawn
    SetEntityCoords(GetPlayerPed(-1), pos.x, pos.y, pos.z)
    DoScreenFadeIn(500)
    Citizen.Wait(500)
    cam2 = CreateCamWithParams("DEFAULT_SCRIPTED_CAMERA", -1355.93,-1487.78,520.75, 300.00,0.00,0.00, 100.00, false, 0)
    PointCamAtCoord(cam2, pos.x,pos.y,pos.z+200)
    SetCamActiveWithInterp(cam2, cam, 900, true, true)
    Citizen.Wait(900)
	
 if isnew then
	TriggerEvent('esx_identity:showRegisterIdentity')
 end

    cam = CreateCamWithParams("DEFAULT_SCRIPTED_CAMERA", pos.x,pos.y,pos.z+200, 300.00,0.00,0.00, 100.00, false, 0)
    PointCamAtCoord(cam, pos.x,pos.y,pos.z+2)
    SetCamActiveWithInterp(cam, cam2, 3700, true, true)
    Citizen.Wait(3700)
    PlaySoundFrontend(-1, "Zoom_Out", "DLC_HEIST_PLANNING_BOARD_SOUNDS", 1)
    RenderScriptCams(false, true, 500, true, true)
    PlaySoundFrontend(-1, "CAR_BIKE_WHOOSH", "MP_LOBBY_SOUNDS", 1)
    FreezeEntityPosition(GetPlayerPed(-1), false)
    Citizen.Wait(500)
    SetCamActive(cam, false)
    DestroyCam(cam, true)
    IsChoosing = false
    DisplayHud(true)
    DisplayRadar(true)
end)

#316

:warning: RESOURCE WARNING :warning:

This resource seems to make use of flawed logic to initialize itself. We’ve had multiple users come on the FiveM Discord today blaming ‘game updates’ for ‘breaking everything’, and it seems the issue is down to this kashacters resource.

In particular, it seems to expect that NETWORK_IS_SESSION_STARTED will return true within 7 milliseconds from the game initially loading.

This is not always the case, and is dependent on how much native code is executed by the game. I’m not sure where the number 7 came from, but for it to be relevant the user would need to be running at 142.8 FPS, which I doubt anyone is at all.

Correct code for this segment is as follows:

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)
        if NetworkIsSessionStarted() then
            Citizen.Wait(100)
            TriggerServerEvent("kashactersS:SetupCharacters")
            TriggerEvent("kashactersC:SetupCharacters")
            return -- break the loop
        end
    end
end)

#318

trying now, will report back


#319

Ok so confirmed it works! but now it loads in a default fivem character then it comes up with the character selection, can we increase the (0) to something so players dont see this?


#320

Try before you die.


#321

Working great now thank you for this.


#324

hey, were you ever able to fix the /switch issue?


#325

Not yet unfortunately.


#327

The way esx works I dont think the /switch command is gonna be possible. It will allow you to change the character but with esx_skin the way it loads your character upon loading into the server it will not change your physical players skin.


#328

No errors. Works fine for me but when other people join spawning as random character and no create character menu. wth


#329

Same for me. Dont know what happend. Came from nowhere


#330

With the last fivem update read above to see the fix for the players spawning in as default characters.


#331

Thanks. I’m not sure that’s gonna fix the issue where when a player logs out my car disappears and brings up the old money hud. Tempted to just uninstall this script. Caused more issues than its worth.


#332

ive been running kashacters since it was released and no issues at all…amazing resource…


#333

I’ve found as long as you have all the tables in correctly it works amazing!