Global Functions / Problem with GetClosestPed

Hello, i discover today all global functions (example Global.CreateObject , etc).
If i well understood it allow to store data clientside in a global array.

My goal is to use Global.GetClosestPed but i think a have to register all peds (get all data) to the table in the client before. And i don’t know how…

Thanks for help

Check export (for client only)

Why do i have to use export here but not for non-Global functions?

For example :
GetDistanceBetweenCoords works very well

Theses functions are linked, just like in C with #include <mycomponent.h>

1 Like

But the files are already included, aren’t they? Because it work with the other native functions

“Theses functions” == “natives functions” >> TRUE

Ok, so these are already linked, i know, but i don’t manage to use them…


local coords = GetEntityCoords(PlayerPedId())
local ped = GetClosestPed(coords, 20.0, 1, 0, 0, 0, -1)

What do you mean by that?! The _G table is already global, the natives.lua file being prefixed with Global. is just internal detail.

When i use this code :

		local pos = GetEntityCoords(GetPlayerPed(-1))
		local ped = GetClosestPed(pos.x,pos.y,pos.z, 20.0, 1, 0, 0, 0, -1)	
		local pedPos = GetEntityCoords(ped)
		TriggerEvent("chatMessage", "debug", {255, 0, 0}, "px:"..pedPos.x)

Debug tell me : ‘px : 0.0’ wherever i go, even if i am in front of a ped.

you fixed it?

1 Like