From ab0819998cee174644190a8bd4f24717be5fbcfd Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Sun, 7 Mar 2021 14:11:10 -0600 Subject: [PATCH] Start working on skin selector for clothes item --- scripts/client/main.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/scripts/client/main.js b/scripts/client/main.js index 6257eb2c..0c20d9ed 100644 --- a/scripts/client/main.js +++ b/scripts/client/main.js @@ -68,6 +68,8 @@ let drunkEffectDurationTimer = null; let controlsEnabled = false; +let usingSkinSelector = false; + // --------------------------------------------------------------------------- addEvent("OnLocalPlayerEnterSphere", 1); @@ -121,6 +123,27 @@ bindEventHandler("onResourceStop", thisResource, function(event, resource) { // --------------------------------------------------------------------------- +addEventHandler("onKeyUp", function(event, virtualKey, physicalKey, keyModifiers) { + if(usingSkinSelector) { + if(physicalKey == SDLK_d) { + if(getGameData(gta.game).allowedSkins.length-1 == skinSelectorIndex) { + skinSelectorIndex = 0; + } + localPlayer.skin = getGameData(gta.game).allowedSkins[skinSelectorIndex]; + } else if(physicalKey == SDLK_a) { + if(getGameData(gta.game).allowedSkins.length-1 == 0) { + skinSelectorIndex = getGameData(gta.game).allowedSkins.length-1; + } + localPlayer.skin = getGameData(gta.game).allowedSkins[skinSelectorIndex]; + } else if(physicalKey == SDLK_RETURN) { + triggerNetworkEvent("ag.skinSelected", getGameData(gta.game).allowedSkins[skinSelectorIndex]); + usingSkinSelector = false; + } + } +}); + +// --------------------------------------------------------------------------- + addNetworkHandler("ag.cameraLookAt", function(cameraPosition, cameraLookat) { logToConsole(LOG_DEBUG, `[Asshat.Main] Set camera to look at ${cameraPosition.x}, ${cameraPosition.y}, ${cameraPosition.z}`); gta.setCameraLookAt(cameraPosition, cameraLookat, true); @@ -460,6 +483,10 @@ addEventHandler("OnDrawnHUD", function (event) { } } } + + if(usingSkinSelector) { + + } }); // --------------------------------------------------------------------------- @@ -859,4 +886,16 @@ function getPedFromNetworkEvent(ped) { return getElementFromId(ped); } +// --------------------------------------------------------------------------- + +addNetworkHandler("ag.skinSelect", function() { + usingSkinSelector = true; + let frontCameraPosition = getPosInFrontOfPos(localPlayer.position, localPlayer.heading, 5); + setCameraLookAt(frontCamPos, localPlayer.position); + gui.toggleCursor(true, false); + localPlayer.invincible = true; + localPlayer.setProofs(true, true, true, true, true); + localPlayer.collisionsEnabled = false; +}); + // --------------------------------------------------------------------------- \ No newline at end of file