Use player control func

This commit is contained in:
Vortrex
2022-09-04 15:49:41 -05:00
parent 1896dd956f
commit 5039f5a4f3

View File

@@ -18,9 +18,10 @@ function setLocalPlayerFrozenState(state) {
function setLocalPlayerControlState(controlState, cursorState = false) { function setLocalPlayerControlState(controlState, cursorState = false) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting control state to ${controlState} (Cursor: ${cursorState})`); logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting control state to ${controlState} (Cursor: ${cursorState})`);
controlsEnabled = controlState; controlsEnabled = controlState;
game.setPlayerControl(controlState);
if (getGame() == AGRP_GAME_GTA_III || getGame() == AGRP_GAME_GTA_VC) { if (getGame() == AGRP_GAME_GTA_III || getGame() == AGRP_GAME_GTA_VC) {
game.SET_PLAYER_CONTROL(game.GET_PLAYER_ID(), boolToInt(controlState)); game.SET_PLAYER_CONTROL(game.GET_PLAYER_ID(), boolToInt(controlState));
} else if (getGame() != AGRP_GAME_GTA_IV) { } else if (getGame() <= AGRP_GAME_GTA_IV) {
setElementCollisionsEnabled(localPlayer, controlState); setElementCollisionsEnabled(localPlayer, controlState);
setPedInvincible(localPlayer, true); setPedInvincible(localPlayer, true);
} }
@@ -55,14 +56,6 @@ function restoreLocalCamera() {
// =========================================================================== // ===========================================================================
function clearLocalPlayerOwnedPeds() {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Clearing all self-owned peds ...`);
clearSelfOwnedPeds();
logToConsole(LOG_DEBUG, `[VRR.Utilities] All self-owned peds cleared`);
};
// ===========================================================================
function setLocalCameraLookAt(cameraPosition, cameraLookAt) { function setLocalCameraLookAt(cameraPosition, cameraLookAt) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Set camera to look at [${cameraLookAt.x}, ${cameraLookAt.y}, ${cameraLookAt.z}] from [${cameraPosition.x}, ${cameraPosition.y}, ${cameraPosition.z}]`); logToConsole(LOG_DEBUG, `[VRR.Utilities] Set camera to look at [${cameraLookAt.x}, ${cameraLookAt.y}, ${cameraLookAt.z}] from [${cameraPosition.x}, ${cameraPosition.y}, ${cameraPosition.z}]`);
if (isCustomCameraSupported()) { if (isCustomCameraSupported()) {
@@ -72,6 +65,14 @@ function setLocalCameraLookAt(cameraPosition, cameraLookAt) {
// =========================================================================== // ===========================================================================
function clearLocalPlayerOwnedPeds() {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Clearing all self-owned peds ...`);
clearSelfOwnedPeds();
logToConsole(LOG_DEBUG, `[VRR.Utilities] All self-owned peds cleared`);
};
// ===========================================================================
function setCityAmbienceState(state, clearElements = false) { function setCityAmbienceState(state, clearElements = false) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Ambient civilians and traffic ${(state) ? "enabled" : "disabled"}`); logToConsole(LOG_DEBUG, `[VRR.Utilities] Ambient civilians and traffic ${(state) ? "enabled" : "disabled"}`);
game.setTrafficEnabled(state); game.setTrafficEnabled(state);