From baa1b6ed82111f25d4b0293b6f9b61feca0d9ee7 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Sun, 9 Jan 2022 05:23:49 -0600 Subject: [PATCH] Add clientside natives file for connected mods --- scripts/client/native/connected.js | 70 ++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/scripts/client/native/connected.js b/scripts/client/native/connected.js index e69de29b..dd77dec1 100644 --- a/scripts/client/native/connected.js +++ b/scripts/client/native/connected.js @@ -0,0 +1,70 @@ +// =========================================================================== +// Vortrex's Roleplay Resource +// https://github.com/VortrexFTW/gtac_roleplay +// =========================================================================== +// FILE: connected.js +// DESC: Provides wrapped natives for GTA Connected and Mafia Connected mods +// TYPE: Server (JavaScript) +// =========================================================================== + +function sendNetworkEventToPlayer(networkEvent, client, ...args) { + triggerNetworkEvent.apply(null, networkEvent, client, args); +} + +// =========================================================================== + +function getPlayerPosition() { + return localPlayer.position; +} + +// =========================================================================== + +function setPlayerPosition(position) { + localPlayer.position = position; +} + +// =========================================================================== + +function getElementPosition(element) { + return element.position; +} + +// =========================================================================== + +function setElementPosition(element, position) { + if(!element.isSyncer) { + return false; + } + + element.position = position; +} + +// =========================================================================== + +function deleteGameElement(element, position) { + if(!element.isOwner) { + return false; + } + + destroyGameElement(element); +} + +// =========================================================================== + +function createGameVehicle(modelIndex, position, heading) { + return game.createVehicle(getGameData().vehicles[getGame()][modelIndex][0], position, heading); +} + +// =========================================================================== + +function addNetworkEventHandler(eventName, ...args) { + addNetworkHandler.apply(null, eventName, args); +} + +// =========================================================================== + +function sendNetworkEventToServer(eventName, ...args) { + triggerNetworkEvent.apply(null, eventName, args); +} + +// =========================================================================== \ No newline at end of file