SetEntityCoords not working

help

#1

I am a little confused on why this is not working.
Here’s what I put into my client.lua file:

SetEntityCoords(PlayerPedId(), 110.647, -1301.97, 29.7186, 205.968)

but it’s not doing anything.
Is there something I’m missing?

Any help is greatly appreciated :wink:


#2

What does the full script look like? It’s possible that you’re setting the coords before the player’s ped is loaded.


#3

Alright, here’s my project I’ve been working on

-- client.lua
local looped = 8
local looped2 = 16
local PlayingAnim = IsPedActiveInScenario(GetPlayerPed(-1)) -- Registering whether or not the player is in an active scenario
local danceStart = false

function cancelAnim() -- Cancels the emote slowly
    ClearPedTasks(GetPlayerPed(-1))
    PlayingAnim = false
end

function CreateNPC(type,model,anim,dict,pos,help,key,range,start,finish)
  Citizen.CreateThread(function()
    -- Define variables
    local hash = GetHashKey(model)
    local talking = false

    -- Loads model
    RequestModel(hash)
    while not HasModelLoaded(hash) do
      Wait(1)
    end

    -- Loads animation
    RequestAnimDict(anim)
    while not HasAnimDictLoaded(anim) do
      Wait(1)
    end

    -- Creates ped when everything is loaded
    local ped = CreatePed(type, hash, pos.x, pos.y, pos.z, pos.h, false, true)
    SetEntityHeading(ped, pos.h)
    FreezeEntityPosition(ped, false)
    SetEntityInvincible(ped, false)
    SetBlockingOfNonTemporaryEvents(ped, true)
    TaskPlayAnim(ped,anim,dict, 8.0, 0.0, -1, 1, 0, 0, 0, 0)
    
    -- Process NPC interaction
    while true do
      Citizen.Wait(0)
	  local your = GetEntityCoords(GetPlayerPed(-1), false)
      if(Vdist(pos.x, pos.y, pos.z, your.x, your.y, your.z) < range)then
	    danceStart = true
        SetTextComponentFormat("STRING")
        AddTextComponentString(help)
        DisplayHelpTextFromStringLabel(0, 0, 1, -1)
        if(IsControlJustReleased(key[1], key[2]))then
          if not talking then
            talking = true
            start()
          else
            talking = false
            finish()
          end
        end
      end
	  if(Vdist(pos.x, pos.y, pos.z, your.x, your.y, your.z) > range)then
	    danceStart = false
	  end
    end
  end)
end

-- Ped Types: Player = 1 Male = 4  Female = 5  Cop = 6 Taxi Driver = 25 (sfink) Human = 26 SWAT = 27  Animal = 28 Army = 29
-- Ped Models: https://wiki.■■■■■■■/index.php?title=Peds
-- Animations: https://docs.ragepluginhook.net/html/62951c37-a440-478c-b389-c471230ddfc5.htm (takes awhile to load)
-- Dict: Usually the last @
-- Pos: H is for Heading (the direction he is looking), and you can guess what XYZ are.
-- Help: help text
-- Key: https://docs.fivem.net/game-references/controls/
-- Range: distance it can be interacted from
-- Start: function to start interaction
-- Finish: function to stop

-- Example:
CreateNPC(5,"s_f_y_bartender_01","mini@strip_club@drink@idle_a","idle_a",{x = 128.748, y = -1282.8, z = 28.2724, h = 100.0},"Press ~INPUT_CONTEXT~ to order a drink",{1,38},2.5,
  function()
    Citizen.Wait(500)
	OpenMenu()
  end,
  function()
    CloseMenu() -- A function to close some menu, could be TriggerEvent or TriggerServerEvent
  end
)

CreateNPC(5,"csb_stripper_02","mini@strip_club@lap_dance@ld_girl_a_song_a_p3","ld_girl_a_song_a_p3_f",{x = 111.287, y = -1304.19, z = 28.0195, h = 300.0},"Press ~INPUT_CONTEXT~ to watch",{1,38},2.5,
	function()
		Citizen.CreateThread(function()
			while true do
				Citizen.Wait(0)
				local playerCoords = GetEntityCoords(PlayerPedId(), true)
				local ped = PlayerPedId()
				if not IsPedActiveInScenario(ped) and PlayingAnim then
					PlayingAnim = false
				end
				if (IsControlPressed(0, 51)) and danceStart == true then
					SetEntityCoords(PlayerPedId(), 110.647, -1301.97, 29.7186, 205.968)
					PlayingAnim = true
					TaskStartScenarioInPlace(ped, "PROP_HUMAN_SEAT_ARMCHAIR", 0, false)
				end
				if (IsControlPressed(0, 32) or IsControlPressed(0, 33) or IsControlPressed(0, 34) or IsControlPressed(0, 35)) and PlayingAnim == true then
					cancelAnim()
					danceStart = false
					SetEntityCoords(PlayerPedId(), 114.973, -1302.09, 29.0192, 300.0)
				end
			end
		end)
	end
)

This is where I got the base script from:


#4

Nevermind I figured it out. It was my bad in the script.