Notice: Failed to invoke Pygments: [Called from MediaWiki\SyntaxHighlight\SyntaxHighlight::highlightInner in /home/pi/www/gtac/wiki/wiki/extensions/SyntaxHighlight_GeSHi/includes/SyntaxHighlight.php at line 334] in /home/pi/www/gtac/wiki/wiki/includes/debug/MWDebug.php on line 507

Notice: Failed to invoke Pygments: [Called from MediaWiki\SyntaxHighlight\SyntaxHighlight::highlightInner in /home/pi/www/gtac/wiki/wiki/extensions/SyntaxHighlight_GeSHi/includes/SyntaxHighlight.php at line 334] in /home/pi/www/gtac/wiki/wiki/includes/debug/MWDebug.php on line 507
Set Player Position (GTA IV, Native MP Mode - GTA Connected

Set Player Position (GTA IV, Native MP Mode

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;
});