[HELP] Esx_Shop replace marker by a ped

Hello guys , i need help with something, i want to replace esx_shop marker by a Ped :

SO basically what i’m trying to is to replace the Drawmarker fuction with a CreatePed function.
I already isolate the function to do so:

-- Display markers
Citizen.CreateThread(function()
	while true do
		Citizen.Wait(10)
		local coords = GetEntityCoords(GetPlayerPed(-1))

		for k,v in pairs(Config.Zones) do
			for i = 1, #v.Pos, 1 do
				if(Config.Type ~= -1 and GetDistanceBetweenCoords(coords, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, true) < Config.DrawDistance) then
					DrawMarker(Config.Type, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.Size.x, Config.Size.y, Config.Size.z, Config.Color.r, Config.Color.g, Config.Color.b, 100, false, true, 2, false, false, false, false)
				end
			end
		end
	end
end)

And I tried to Create a Ped instead by writing this :

-- Display markers
Citizen.CreateThread(function()
	while true do
		Citizen.Wait(10)
		local coords = GetEntityCoords(GetPlayerPed(-1))

		for k,v in pairs(Config.Zones) do
			for i = 1, #v.Pos, 1 do
				if(Config.Type ~= -1 and GetDistanceBetweenCoords(coords, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, true) < Config.DrawDistance) then
                        CreatePed( PED_TYPE_NETWORK_PLAYER , mp_m_freemode_01, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z,0.0, false, true )
				end
			end
		end
	end
end)

But the ped doesn’t seems to appear. Even so the shop system is still here like his bilp.

If you guys know what I’ve done wrong please tell me! :smile:
Thanks for taking the time to read me and my shitty english :sunny:

1 Like

Your ped type needs to be an integer, so a number, and the model has to be a string so “model_name”

1 Like

Thanks for your answer!

Looks like it worked a little bit too good :joy:

Is there an error from me?

CreatePed( 1, "mp_m_freemode_01", v.Pos[i].x, v.Pos[i].y, v.Pos[i].z,0.0, false, true )

Or if it’s not do you have any clues?

Yikes, that would be because it is running in a while loop that is never broken lol.

I would just change the while loop to ensure that peds are actually created

Citizen.CreateThread(function()
    pedCreated = false
	while not pedCreated do
		Citizen.Wait(10)
		local coords = GetEntityCoords(GetPlayerPed(-1))

		for k,v in pairs(Config.Zones) do
			for i = 1, #v.Pos, 1 do
                if(Config.Type ~= -1 and GetDistanceBetweenCoords(coords, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, true) < Config.DrawDistance) then
                    if not pedCreated then
                        CreatePed( 1, "mp_m_freemode_01", v.Pos[i].x, v.Pos[i].y, v.Pos[i].z,0.0, false, true )
                        pedCreated = true
                    end
				end
			end
		end
	end
end)
1 Like

Oh yeah :joy:

mmmh looks like the peds in the several areas don’t spawn at all with that loop

That was entirely my fault, brain isn’t working right cause of my pain meds for my broken ankle :rofl:

Forgot to remove the distance checks

Citizen.CreateThread(function()
    pedCreated = false
	while not pedCreated do
		Citizen.Wait(10)
		local coords = GetEntityCoords(GetPlayerPed(-1))

		for k,v in pairs(Config.Zones) do
			for i = 1, #v.Pos, 1 do
                if (Config.Type ~= -1 and not pedCreated) then
                    CreatePed( 1, "mp_m_freemode_01", v.Pos[i].x, v.Pos[i].y, v.Pos[i].z,0.0, false, true )
                    pedCreated = true
				end
			end
		end
	end
end)

Ho sorry for your ankle dude!
Thanks a lot for helping me out, I reallys appreciate it!:smile:

But looks like it stills doesn’t work:joy: Maybe due to the fact that i have multiples shops coords? What do you think?

Really shouldn’t be an issue, are you getting errors in your F8 console? Are they spawning but only a few?

You can try removing the loop all together with a print, then you can at least see how many is being created because it should execute the CreatePed() and the print for each shop in the config.

Citizen.CreateThread(function()
	local coords = GetEntityCoords(GetPlayerPed(-1))

	for k,v in pairs(Config.Zones) do
		for i = 1, #v.Pos, 1 do
            if (Config.Type ~= -1) then
				CreatePed( 1, "mp_m_freemode_01", v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, 0.0, false, true)
				print('DEBUG: ped created')
			end
		end
	end
end)

So no error with the F8 console.

And with the new code, the console show me the print for each coords but when I go to a coord I don’t see the ped

I didn’t notice that you changed the ped type, change the 1 back to a 2, and the false to true

So I have tried it, but the peds still didn’t appear, even if the print says that they do. Think this is the fact to close the loop because when the loop is open it works but there is no stop, and when there is a stop, the peds don’t appears

If it’s doing the print for each of the shops, then it will also spawn the ped, maybe it’s an invalid hash or something of that sort, there’s no F8 console errors? When im back at my PC I can test it further on my end

Yeah was thinking that also, but if the hash corrupted why would it be working when we don’t close the loop? that’s what is strange. And no i don’t see errors in the console. Okay man would be appreciated for you testing it :yum:

Hey there, have you find a way to figure it out ?

Hi you can try this more easy to do, just disable the marker:

local Npc = {
{x= -512.31, y= -1738.59, z= 18.3, h=324.46},
}

Citizen.CreateThread(function()
for k in pairs(Npc) do
RequestModel(GetHashKey(“s_m_m_dockwork_01”))
while not HasModelLoaded(GetHashKey(“s_m_m_dockwork_01”)) do
Citizen.Wait(1)
end
local ped = CreatePed(4, GetHashKey(“s_m_m_dockwork_01”), Npc[k].x, Npc[k].y, Npc[k].z, Npc[k].h, false, true)
FreezeEntityPosition(ped, true)
SetEntityHeading(ped, Npc[k].h, true)
SetEntityInvincible(ped, true)
SetBlockingOfNonTemporaryEvents(ped, true)
end
end)

just change the coords or add as u wish, hope i got u right

Pretty sure you need to add break; after the print to break the loop