Move get anim utils to shared
This commit is contained in:
@@ -15,7 +15,7 @@ function initAnimationScript() {
|
||||
// ===========================================================================
|
||||
|
||||
function playPlayerAnimationCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -23,22 +23,22 @@ function playPlayerAnimationCommand(command, params, client) {
|
||||
let animationSlot = getAnimationFromParams(getParam(params, " ", 1));
|
||||
let animationPositionOffset = 1;
|
||||
|
||||
if(!animationSlot) {
|
||||
if (!animationSlot) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidAnimation"));
|
||||
messagePlayerInfo(client, getLocaleString(client, "AnimationCommandTip", `{ALTCOLOUR}/animlist{MAINCOLOUR}`));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(toInteger(animationPositionOffset) < 0 || toInteger(animationPositionOffset) > 3) {
|
||||
if (toInteger(animationPositionOffset) < 0 || toInteger(animationPositionOffset) > 3) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidAnimationDistance"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(getAnimationData(animationSlot)[3] == VRR_ANIMTYPE_SURRENDER) {
|
||||
if (getAnimationData(animationSlot)[3] == VRR_ANIMTYPE_SURRENDER) {
|
||||
getPlayerData(client).pedState = VRR_PEDSTATE_HANDSUP;
|
||||
}
|
||||
|
||||
if(isPlayerHandCuffed(client) || isPlayerTazed(client) || isPlayerInForcedAnimation(client)) {
|
||||
if (isPlayerHandCuffed(client) || isPlayerTazed(client) || isPlayerInForcedAnimation(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "UnableToDoThat"));
|
||||
return false;
|
||||
}
|
||||
@@ -50,7 +50,7 @@ function playPlayerAnimationCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function stopPlayerAnimationCommand(command, params, client) {
|
||||
if(isPlayerHandCuffed(client) || isPlayerTazed(client) || isPlayerInForcedAnimation(client)) {
|
||||
if (isPlayerHandCuffed(client) || isPlayerTazed(client) || isPlayerInForcedAnimation(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "UnableToDoThat"));
|
||||
return false;
|
||||
}
|
||||
@@ -70,29 +70,19 @@ function stopPlayerAnimationCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function showAnimationListCommand(command, params, client) {
|
||||
let animList = getGameConfig().animations[getGame()].map(function(x) { return x.name; });
|
||||
let animList = getGameConfig().animations[getGame()].map(function (x) { return x.name; });
|
||||
|
||||
let chunkedList = splitArrayIntoChunks(animList, 10);
|
||||
|
||||
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderAnimationsList")));
|
||||
|
||||
for(let i in chunkedList) {
|
||||
for (let i in chunkedList) {
|
||||
messagePlayerNormal(client, chunkedList[i].join(", "));
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
/**
|
||||
* @param {number} animationSlot - The slot index of the animation
|
||||
* @return {Array} The animation's data (array)
|
||||
*/
|
||||
function getAnimationData(animationSlot, gameId = getGame()) {
|
||||
return getGameConfig().animations[gameId][animationSlot];
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function isPlayerInForcedAnimation(client) {
|
||||
return getPlayerData(client).animationForced;
|
||||
}
|
||||
@@ -125,7 +115,7 @@ function forcePlayerPlayAnimation(client, animationSlot, offsetPosition = 1) {
|
||||
getPlayerData(client).animationForced = true;
|
||||
|
||||
setPlayerControlState(client, false);
|
||||
forcePedAnimation(getPlayerPed(client), animationSlot, offsetPosition);
|
||||
forcePedAnimation(getPlayerPed(client), animationSlot, offsetPosition);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -141,23 +131,4 @@ function makePlayerStopAnimation(client) {
|
||||
getPlayerData(client).animationForced = false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getAnimationFromParams(params) {
|
||||
let animations = getGameConfig().animations[getGame()];
|
||||
if(isNaN(params)) {
|
||||
for(let i in animations) {
|
||||
if(toLowerCase(animations[i].name).indexOf(toLowerCase(params)) != -1) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(typeof getGameConfig().animations[getGame()][params] != "undefined") {
|
||||
return toInteger(params);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
Reference in New Issue
Block a user