Files
GTA4RP/scripts/server/animation.js
Vortrex 80eeaa14c5 Lots of changes and fixes
* Add guiReady state
* Add mouseCameraEnabled state
* Make sure GUI is ready on some things
* Fix wrong veh prop funcs being used clientside
* Add local player ped parts/props util for IV
* Add vehicle.lightStatus sync
* Add element interior sync
* Dont use interior on IV
* Use new class structure
* Set default anim offset to 1
* Set biz data to save when changing biz properties
* Add mouse cam state util
* Prefix item type admin cmds with "itemtype"
* Fix server config saving
* Fix server time setting hour to minute arg
* Add player returnTo data types
* Make veh rent/buy price numbers readable
* Fix wrong house index being used to create blip/pickup on create
* Don't cache player hotbar items if working
* Fix cache player hotbar items util
* Add lots of anims to GTA SA
* Try/catch on all data saving to prevent one from blocking the rest
* Fix readable time from showing AM for 12 PM (noon)
* Set veh interior on create
* Dont set engine for spawnlocked vehicles
2021-09-18 06:48:13 -05:00

75 lines
3.0 KiB
JavaScript

// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: animation.js
// DESC: Provides animation functions and usage
// TYPE: Server (JavaScript)
// ===========================================================================
function initAnimationScript() {
logToConsole(LOG_DEBUG, "[VRR.Animation]: Initializing animation script ...");
logToConsole(LOG_DEBUG, "[VRR.Animation]: Animation script initialized!");
}
// ===========================================================================
function playPlayerAnimationCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
let splitParams = params.split(" ");
let animationSlot = getAnimationFromParams(splitParams[0]);
let animationPositionOffset = getAnimationFromParams(splitParams[1]) || 1;
if(!animationSlot) {
messagePlayerError(client, "That animation doesn't exist!");
messagePlayerInfo(client, "Use /animlist to see a list of valid animations");
return false;
}
if(toInteger(animationPositionOffset) < 0 || toInteger(animationPositionOffset) > 3) {
messagePlayerError(client, "The offset must be between 0 and 3!")
return false;
}
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, animationPositionOffset);
setPlayerMouseCameraState(client, true);
}
// ===========================================================================
function stopPlayerAnimationCommand(command, params, client) {
setPlayerPosition(client, getPlayerData(client).currentAnimationPositionReturnTo);
makePedStopAnimation(getPlayerData(client).ped);
setPlayerMouseCameraState(client, false);
}
// ===========================================================================
function showAnimationListCommand(command, params, client) {
let animList = getGameData().animations[getServerGame()].map(function(x) { return x[0]; });
let chunkedList = splitArrayIntoChunks(animList, 10);
messagePlayerInfo(client, `${getInlineChatColourByType("clanOrange")}== ${getInlineChatColourByType("jobYellow")}Animation List ${getInlineChatColourByType("clanOrange")}===========================`);
for(let i in chunkedList) {
messagePlayerInfo(client, chunkedList[i].join(", "));
}
}
// ===========================================================================
function getAnimationData(animationSlot, gameId = getServerGame()) {
return getGameData().animations[gameId][animationSlot];
}
// ===========================================================================