diff --git a/scripts/client/event.js b/scripts/client/event.js index a99a7eed..17ff4e58 100644 --- a/scripts/client/event.js +++ b/scripts/client/event.js @@ -99,6 +99,7 @@ function onProcess(event, deltaTime) { function onKeyUp(event, keyCode, scanCode, keyModifiers) { processSkinSelectKeyPress(keyCode); + //processKeyDuringAnimation(); } // =========================================================================== diff --git a/scripts/client/gui.js b/scripts/client/gui.js index 7279f16e..32012d77 100644 --- a/scripts/client/gui.js +++ b/scripts/client/gui.js @@ -1139,6 +1139,46 @@ let switchCharacterSelect = function(firstName, lastName, cash, clan, lastPlayed characterSelect.window.shown = true; } +let isAnyGUIActive = function() { + if(infoDialog.window.shown) { + return true; + } + + if(yesNoDialog.window.shown) { + return true; + } + + if(errorDialog.window.shown) { + return true; + } + + if(register.window.shown) { + return true; + } + + if(login.window.shown) { + return true; + } + + if(newCharacter.window.shown) { + return true; + } + + if(characterSelect.window.shown) { + return true; + } + + if(twoFactorAuth.window.shown) { + return true; + } + + if(listDialog.window.shown) { + return true; + } + + return false; +} + // =========================================================================== addNetworkHandler("vrr.showLogin", function() { diff --git a/scripts/client/main.js b/scripts/client/main.js index 42854e51..c21ce06a 100644 --- a/scripts/client/main.js +++ b/scripts/client/main.js @@ -47,6 +47,7 @@ let streamingRadioElement = false; let enterPropertyKey = null; +let inAnimation = false; let forcedAnimation = null; let calledDeathEvent = false; diff --git a/scripts/client/scoreboard.js b/scripts/client/scoreboard.js index c4f0b980..5007d78b 100644 --- a/scripts/client/scoreboard.js +++ b/scripts/client/scoreboard.js @@ -38,6 +38,10 @@ function initScoreBoardListFont() { // =========================================================================== function processScoreBoardRendering() { + if(isAnyGUIActive()) { + return false; + } + if(renderScoreBoard) { if(isKeyDown(SDLK_TAB)) { if(scoreBoardListFont != null && scoreBoardTitleFont != null) { diff --git a/scripts/client/server.js b/scripts/client/server.js index 963db41b..6d71d88f 100644 --- a/scripts/client/server.js +++ b/scripts/client/server.js @@ -79,12 +79,15 @@ function addAllNetworkHandlers() { addNetworkHandler("vrr.veh.repair", repairVehicle); addNetworkHandler("vrr.pedAnim", makePedPlayAnimation); + addNetworkHandler("vrr.pedStopAnim", makePedStopAnimation); addNetworkHandler("vrr.hideAllGUI", hideAllGUI); addNetworkHandler("vrr.gameScript", setGameScriptState); addNetworkHandler("vrr.clientInfo", serverRequestedClientInfo); addNetworkHandler("vrr.interiorLights", updateInteriorLightsState); addNetworkHandler("vrr.syncElement", forceSyncElementProperties); + addNetworkHandler("vrr.elementPosition", setElementPosition); + addNetworkHandler("vrr.elementCollisions", setElementCollisionsEnabled); } // =========================================================================== @@ -221,11 +224,24 @@ function setEnterPropertyKey(key) { function makePedPlayAnimation(pedId, animGroup, animId, animType, animSpeed, loop, loopNoControl, freezeLastFrame, returnToOriginalPosition) { if(getGame() < VRR_GAME_GTA_IV) { if(animType == VRR_ANIMTYPE_ADD) { - getElementFromId(pedId).position = getElementFromId(pedId).position; + if(getGame() == GAME_GTA_VC || getGame() == GAME_GTA_SA) { + getElementFromId(pedId).clearAnimations(); + } else { + getElementFromId(pedId).clearObjective(); + } getElementFromId(pedId).addAnimation(animGroup, animId); + + if(getElementFromId(pedId) == localPlayer) { + inAnimation = true; + setLocalPlayerControlState(false, false); + localPlayer.collisionsEnabled = false; + } } else if(animType == VRR_ANIMTYPE_BLEND) { getElementFromId(pedId).position = getElementFromId(pedId).position; getElementFromId(pedId).blendAnimation(animGroup, animId, animSpeed); + } else if(animType == VRR_ANIMTYPE_MOVEADD) { + getElementFromId(pedId).position = getElementFromId(pedId).position; + getElementFromId(pedId).blendAnimation(animGroup, animId, animSpeed); } } else { natives.requestAnims(animGroup); @@ -281,4 +297,31 @@ function forceSyncElementProperties(elementId) { syncElementProperties(getElementFromId(elementId)); } +// =========================================================================== + +function setElementPosition(elementId, position) { + getElementFromId(elementId).position = position; +} + +// =========================================================================== + +function setElementCollisionsEnabled(elementId, state) { + getElementFromId(elementId).collisionsEnabled = state; +} + +// =========================================================================== + +function makePedStopAnimation(pedId) { + if(getGame() == GAME_GTA_VC || getGame() == GAME_GTA_SA) { + getElementFromId(pedId).clearAnimations(); + } else { + getElementFromId(pedId).clearObjective(); + } + + if(getElementFromId(pedId) == localPlayer) { + localPlayer.collisionsEnabled = true; + setLocalPlayerControlState(true, false); + } +} + // =========================================================================== \ No newline at end of file diff --git a/scripts/server/animation.js b/scripts/server/animation.js index 449160cf..00d56ffc 100644 --- a/scripts/server/animation.js +++ b/scripts/server/animation.js @@ -20,7 +20,9 @@ function playPlayerAnimationCommand(command, params, client) { return false; } - let animationSlot = getAnimationFromParams(params); + let splitParams = params.split(" "); + let animationSlot = getAnimationFromParams(splitParams[0]); + let animationPositionOffset = getAnimationFromParams(splitParams[1]); if(!animationSlot) { messagePlayerError(client, "That animation doesn't exist!"); @@ -29,9 +31,18 @@ function playPlayerAnimationCommand(command, params, client) { } getPlayerData(client).currentAnimation = animationSlot; + getPlayerData(client).currentAnimationPositionOffset = animationSlot; + getPlayerData(client).currentAnimationPositionReturnTo = getPlayerPosition(client); getPlayerData(client).animationStart = getCurrentUnixTimestamp(); //setEntityData(getPlayerData(client).ped, "vrr.animation", animationSlot, true); - makePedPlayAnimation(getPlayerData(client).ped, animationSlot); + makePedPlayAnimation(getPlayerData(client).ped, animationSlot, animationPositionOffset); +} + +// =========================================================================== + +function stopPlayerAnimationCommand(command, params, client) { + setPlayerPosition(client, getPlayerData(client).currentAnimationPositionReturnTo); + makePedStopAnimation(getPlayerData(client).ped); } // =========================================================================== diff --git a/scripts/server/chat.js b/scripts/server/chat.js index 5b58c882..e31c3ea0 100644 --- a/scripts/server/chat.js +++ b/scripts/server/chat.js @@ -159,7 +159,7 @@ function phoneIncomingToNearbyPlayers(client, messageText) { function whisperToNearbyPlayers(client, messageText) { let clients = getClientsInRange(getPlayerPosition(client), getGlobalConfig().talkDistance); for(let i in clients) { - if(getPlayerInterior(client) == getPlayerInterior(clients[i] && getPlayerDimension(client) == getPlayerDimension(clients[i]))) { + if(getPlayerInterior(client) == getPlayerInterior(clients[i]) && getPlayerDimension(client) == getPlayerDimension(clients[i])) { messagePlayerWhisper(clients[i], client, messageText); } } @@ -170,7 +170,7 @@ function whisperToNearbyPlayers(client, messageText) { function shoutToNearbyPlayers(client, messageText) { let clients = getClientsInRange(getPlayerPosition(client), getGlobalConfig().shoutDistance); for(let i in clients) { - if(getPlayerInterior(client) == getPlayerInterior(clients[i] && getPlayerDimension(client) == getPlayerDimension(clients[i]))) { + if(getPlayerInterior(client) == getPlayerInterior(clients[i]) && getPlayerDimension(client) == getPlayerDimension(clients[i])) { messagePlayerShout(clients[i], client, messageText); } } @@ -181,7 +181,7 @@ function shoutToNearbyPlayers(client, messageText) { function doActionToNearbyPlayers(client, messageText) { let clients = getClientsInRange(getPlayerPosition(client), getGlobalConfig().doActionDistance); for(let i in clients) { - if(getPlayerInterior(client) == getPlayerInterior(clients[i] && getPlayerDimension(client) == getPlayerDimension(clients[i]))) { + if(getPlayerInterior(client) == getPlayerInterior(clients[i]) && getPlayerDimension(client) == getPlayerDimension(clients[i])) { messagePlayerDoAction(clients[i], client, messageText); } } @@ -192,7 +192,7 @@ function doActionToNearbyPlayers(client, messageText) { function meActionToNearbyPlayers(client, messageText) { let clients = getClientsInRange(getPlayerPosition(client), getGlobalConfig().meActionDistance); for(let i in clients) { - if(getPlayerInterior(client) == getPlayerInterior(clients[i] && getPlayerDimension(client) == getPlayerDimension(clients[i]))) { + if(getPlayerInterior(client) == getPlayerInterior(clients[i]) && getPlayerDimension(client) == getPlayerDimension(clients[i])) { messagePlayerMeAction(clients[i], client, messageText); } } diff --git a/scripts/server/client.js b/scripts/server/client.js index 336e7ea1..afc5d7d9 100644 --- a/scripts/server/client.js +++ b/scripts/server/client.js @@ -140,23 +140,23 @@ function showGameMessage(client, text, colour, duration) { // =========================================================================== function enableCityAmbienceForPlayer(client, clearElements = false) { - if(server.getCVar("civilians") == false) { - return false; - } + //if(server.getCVar("civilians") == false) { + // return false; + //} - logToConsole(LOG_DEBUG, `[VRR.Client] Setting ${getPlayerDisplayForConsole(client)}'s city ambience to ${toUpperCase(getOnOffFromBool(false))}`); - triggerNetworkEvent("vrr.ambience", client, true); + //logToConsole(LOG_DEBUG, `[VRR.Client] Setting ${getPlayerDisplayForConsole(client)}'s city ambience to ${toUpperCase(getOnOffFromBool(false))}`); + //triggerNetworkEvent("vrr.ambience", client, true); } // =========================================================================== function disableCityAmbienceForPlayer(client, clearElements = false) { - if(server.getCVar("civilians") == true) { - return false; - } + //if(server.getCVar("civilians") == true) { + // return false; + //} - logToConsole(LOG_DEBUG, `[VRR.Client] Setting ${getPlayerDisplayForConsole(client)}'s city ambience to ${toUpperCase(getOnOffFromBool(false))}`); - triggerNetworkEvent("vrr.ambience", client, false, clearElements); + //logToConsole(LOG_DEBUG, `[VRR.Client] Setting ${getPlayerDisplayForConsole(client)}'s city ambience to ${toUpperCase(getOnOffFromBool(false))}`); + //triggerNetworkEvent("vrr.ambience", client, false, clearElements); } // =========================================================================== @@ -928,10 +928,35 @@ function sendPlayerEnterPropertyKey(client, key) { // =========================================================================== -function makePedPlayAnimation(ped, animationSlot) { +function makePedPlayAnimation(ped, animationSlot, positionOffset) { let animationData = getAnimationData(animationSlot); + if(animationData[9] != VRR_ANIMMOVE_NONE) { + setElementCollisionsEnabled(ped, false); + switch(animationData[9]) { + case VRR_ANIMMOVE_FORWARD: + setElementPosition(ped, getPosInFrontOfPos(getElementPosition(ped), getElementHeading(ped), positionOffset)); + break; - triggerNetworkEvent("vrr.pedAnim", null, ped.id, animationData[1], animationData[2], animationData[3], animationData[4]); + case VRR_ANIMMOVE_BACK: + setElementPosition(ped, getPosBehindPos(getElementPosition(ped), getElementHeading(ped), positionOffset)); + break; + + case VRR_ANIMMOVE_LEFT: + setElementPosition(ped, getPosToLeftOfPos(getElementPosition(ped), getElementHeading(ped), positionOffset)); + break; + + case VRR_ANIMMOVE_RIGHT: + setElementPosition(ped, getPosToRightOfPos(getElementPosition(ped), getElementHeading(ped), positionOffset)); + break; + } + } + triggerNetworkEvent("vrr.pedAnim", null, ped.id, animationData[1], animationData[2], animationData[3], animationData[4], animationData[5], positionOffset); +} + +// =========================================================================== + +function makePedStopAnimation(ped) { + triggerNetworkEvent("vrr.pedStopAnim", null, ped.id); } // =========================================================================== diff --git a/scripts/server/command.js b/scripts/server/command.js index 2c9bae94..61cb4526 100644 --- a/scripts/server/command.js +++ b/scripts/server/command.js @@ -56,6 +56,7 @@ function loadCommands() { commandData("e", playPlayerAnimationCommand, "", getStaffFlagValue("none"), true, true, "Makes your player ped use an animation"), commandData("anims", showAnimationListCommand, "", getStaffFlagValue("none"), true, true, "Shows a list of animations"), commandData("animlist", showAnimationListCommand, "", getStaffFlagValue("none"), true, true, "Shows a list of animations"), + commandData("stopanim", stopPlayerAnimationCommand, "", getStaffFlagValue("none"), true, true, "Stops your current animation"), ], antiCheat: [ //commandData("addacscriptwl", addAntiCheatWhiteListedScriptCommand, "