I recently started doing some work on RedM and I wanted to create a small function that spawns Peds. I used FiveM reference since I managed to achieve this there but on RedM I faced an issue. It seems that when you are spawning ped it is there but it is invisible even if you request model. Original code
RegisterCommand('zombie', function()
SpawnZombie()
end, false)
function SpawnZombie()
--local zombieModel = GetHashKey("A_M_O_WapTownfolk_01")
zombieModel = GetHashKey("A_C_Wolf")
-- Request Model To be Loaded (IT DOESNT LOAD FOR SOME REASON)
RequestModel(zombieModel)
while not HasModelLoaded(zombieModel) do
RequestModel(zombieModel)
Wait(1)
end
local x, y, z = table.unpack(GetEntityCoords(PlayerPedId(), false))
-- Spawn Zombie
local zombie = CreatePed(zombieModel, x, y, z+5, 45.0, false, false, 0)
end
I tried to research it, looked through everything on cfx forum but cant seem to figure it out. Is it possible that this RequestModel or CreatePed is broken or am I missing something. Thank you all for your help!
Just tried to include this into the code but it does not work, it throws an error - Attempt to call nil value (Global ‘SetRandomOutfitVariantion’).
This is what I have done:
local zombieModel = GetHashKey("A_M_O_WapTownfolk_01")
--zombieModel = GetHashKey("A_C_Wolf")
-- Request Model To be Loaded (IT DOESNT LOAD FOR SOME REASON)
RequestModel(zombieModel)
while not HasModelLoaded(zombieModel) do
RequestModel(zombieModel)
Wait(1)
end
local x, y, z = table.unpack(GetEntityCoords(PlayerPedId(), false))
-- Spawn Zombie
SetRandomOutfitVariation(zombieModel, true)
local zombie = CreatePed(zombieModel, x, y, z+5, 45.0, false, false, 0)
I tried to change boolean to false as well, same result.
The HASH key is already called by using GetHashKey(string), i tried to do it manually but still the result was the same. I believe that there might be an actual glitch when it comes to creating these peds since this works perfectly on FiveM.
I had this same issue, however I’m using JavaScript rather than Lua.
My solution was to invoke the native function as opposed to the global JavaScript function. That is, rather than calling SetRandomOutfitVariation I execute Citizen.invokeNative('0x283978A15512B2FE', horsePed, false) instead.
Great, it works !!!
By the way, I’m following your RDX frameworks redm_extended.
When you do other modules such as horse and stable management, then you need one for the shop.
Another very important module is that of user management with the first access and creation of the avatar.
Then to follow that of work and many other activities.
I wanted to install it but I’m waiting, assuming you don’t say that other mods of the RedM version also work: RP … but then how many mods should be installed to make everything work ???
I’m waiting for you to release the mods for Your Frameworks which I see that you have done a really good job.