What is the function to get the coordinates of the player character in moonloader sa-mp…
- User
What is the function to get the coordinates of the player character in moonloader sa-mp luajit
- Assistant
In MoonLoader for SA-MP with LuaJIT, you can get the player character's coordinates using the function
getCharCoordinates. The player's character handle is available asPLAYER_PED. Here's how you can use it:local x, y, z = getCharCoordinates(PLAYER_PED)This function retrieves the X, Y, and Z coordinates of the player character and stores them in the variables
x,y, andzrespectively.Explanation:
getCharCoordinates(ped)is a function that returns the coordinates of the specified character (pedestrian).PLAYER_PEDis a global variable in MoonLoader that represents the player's character handle.
Example Usage:
-- Sample script to get and print player coordinates local x, y, z = getCharCoordinates(PLAYER_PED) print(string.format("Player coordinates: X=%.2f, Y=%.2f, Z=%.2f", x, y, z))