Hi, I’m new to C# coding and I’m wondering when I should use the natives of FiveM and when the references like Game.XY World.XY
Welcome!
The Game.XY
World.XY
references you mention are types and methods that are actually wrappers for the natives, if it suits your needs then use them, all up to you.
1 Like
Keep in mind that functions such as Game.PlayerPed.Position
is a wrapper and do not write such code:
SetEntityPosition(enityHandle,
Game.PlayerPed.Position.X,
Game.PlayerPed.Position.Y,
Game.PlayerPed.Position.Z
);
Every use of Game.PlayerPed.Position
will call native function, so use it right:
var localPosition = Game.PlayerPed.Position;
SetEntityPosition(entityHandle,
localPosition.X,
localPosition.Y,
localPosition.Z
);