Ped Spawning & Actions

It’s more of a ‘can I do this’ than an issue I am having.

I would like to do some GTA Editor scenes for a few videos I have in mind. I have the Ped Spawner by JediJosh and it allows me to spawn peds, but they just walk away.

Is there a script or a means to spawn a ped and have them perform a certain emote/action? Or even just a way of telling a ped ‘walk from here to here’? For example, to have a ped that walks around with a gun as if they were a guard.

Secondly, I have been using the lambda menu to check on emotes/actions etc. I found lots I like but some of them, ones that say ‘loop’ only do the action once before snapping back to my guy standing up. Is there a means to loop it truly? So that it plays until I stop it?

Are these just limitations that there are no ‘fixes’ or means to get around? Any help is welcome, I’ll try to give any other info you need.

Is something like this what you’re looking for? (Don’t mind the commands, as it’s just testing, just a demo of the functionality)

ps, moved this to #development:scripts.

1 Like

Yes, like that. If that can program for having a particular action, i.e. a maid cleaning and so on, then that would be perfect.

As for myself, is there a means to add actions like sit, lean, smoke and so forth? I’ve seen them on a FiveM server I play on but can’t find the actual commands anywhere.

1 Like

You mean, smoke a cig ingame yourself? well there are plenty of emote resources out there, or you can use a client trainer like lambda or trainerv, or server side menus like vMenu and others.

I’ll see if I can make this a bit easier to use and will release it as a dev release so anyone can use and improve it.

Don’t have time to create an api for it, but these are the commands used in the example: (note that model loading was already done by another resource, you will need to add that to this one for it to work.)

local x1, y1, z1 = 0.0
local x2, y2, z2 = 0.0
local ped = PlayerPedId()
local nped = 0

RegisterCommand("ped", function()
     nped = CreatePed(4, "csb_mweather", x1, y1, z1, 0.0, true, true)
end, false)

RegisterCommand("1", function()
    ped = PlayerPedId()
    x1, y1, z1 = table.unpack(GetEntityCoords(ped, true))
end, false)


RegisterCommand("2", function()
    ped = PlayerPedId()
    x2, y2, z2 = table.unpack(GetEntityCoords(ped, true))
end, false)

RegisterCommand("go", function()
    --TaskGoStraightToCoord(nped, x2, y2, z2, 1.0, 100000, 0.0, 2.0)
    if (nped == 0) then
        nped = CreatePed(4, "csb_mweather", x1, y1, z1, 0.0, true, true)
    end
    GiveWeaponToPed(nped, "WEAPON_COMBATPISTOL", 1, false, true)
    TaskGoToCoordAnyMeans(nped, x2, y2, z2, 1.0, 0, 0, 786603, 1.0)
    while true do
        Citizen.Wait(100)
        local coords = GetEntityCoords(nped, true)
        local dist = Vdist2(coords.x, coords.y, coords.z, x2, y2, z2)
        print(dist)
        if (dist < 2.0) then
            ClearPedTasks(nped)
            TaskStartScenarioInPlace(nped, "WORLD_HUMAN_PUSH_UPS", 0, true)
            print("done with task")
            break
        end
    end
end, false)

RegisterCommand("reset", function()
    SetEntityAsMissionEntity(nped, true, true)
    DeleteEntity(nped)
    nped = 0
end, false)

4 Likes

hi I know this is a old thread but im kinda looking for this kind of script i want to learn how to spawn certain peds and make them behave a simple action like be aggressive to player near him shoot him something like that

but anway how this code work i want to learn from it the one you posted might learn something from it?where do i paste it? how to run it on the game?

edit: sorry i just watch the video and i thought its spawning the peds

Kinda late but I came across this today and I believe this might be what you are looking for

1 Like

Good looks friend! :grin:

1 Like

I personally haven’t gotten to really mess around with it yet beyond just using the default ones, but it looks pretty darn solid, so might as well share good resources when you find em :smiley:

Is there a way in fivem to spawn as a ped in game, I’m in a server where I do /uniform and it changes my whole character does anyone know this

Are you wanting only clothing to change? A ped would be the whole character, and if you’re changing the ped, then your actual character will change.