Set Player Position (GTA IV, Native MP Mode
Jump to navigation
Jump to search
Description
This code sets the position for a player in GTA IV [[NativeMultiplayer|native MP mode}}. This is necessary because in native MP mode, the server is not aware of ANY game elements, including player peds. The server will need to tell a client to set it's own player ped's position.
Note: This is not necessary if you're not using native MP mode, or are running the server for another game.
Code
Server-Side (JavaScript):
triggerNetworkEvent("set-my-position", client, position);
Client-Side (JavaScript):
addNetworkHandler("set-my-position", function(position) {
localPlayer.position = position;
});