diff --git a/scripts/client/animation.js b/scripts/client/animation.js index 5e9c46c6..dff997d2 100644 --- a/scripts/client/animation.js +++ b/scripts/client/animation.js @@ -10,7 +10,7 @@ function makePedPlayAnimation(pedId, animGroup, animId, animType, animSpeed, loop, loopNoControl, freezeLastFrame, returnToOriginalPosition) { if(getGame() < VRR_GAME_GTA_IV) { if(animType == VRR_ANIMTYPE_ADD) { - if(getGame() == GAME_GTA_VC || getGame() == GAME_GTA_SA) { + if(getGame() == VRR_GAME_GTA_VC || getGame() == VRR_GAME_GTA_SA) { getElementFromId(pedId).clearAnimations(); } else { getElementFromId(pedId).clearObjective(); diff --git a/scripts/client/job.js b/scripts/client/job.js index ba1f5293..27b7a48a 100644 --- a/scripts/client/job.js +++ b/scripts/client/job.js @@ -38,14 +38,14 @@ function setLocalPlayerWorkingState(tempWorking) { function showJobRouteStop() { logToConsole(LOG_DEBUG, `[VRR.Job] Showing route stop`); if(getMultiplayerMod() == VRR_MPMOD_GTAC) { - if(gta.game == GAME_GTA_SA) { - jobRouteStopSphere = gta.createPickup(1318, position, 1); + if(game.game == VRR_GAME_GTA_SA) { + jobRouteStopSphere = game.createPickup(1318, position, 1); } else { - jobRouteStopSphere = gta.createSphere(position, 3); + jobRouteStopSphere = game.createSphere(position, 3); jobRouteStopSphere.colour = colour; } - jobRouteStopBlip = gta.createBlip(position, 0, 2, colour); + jobRouteStopBlip = game.createBlip(position, 0, 2, colour); } } @@ -54,14 +54,14 @@ function showJobRouteStop() { function showJobRouteStop(position, colour) { logToConsole(LOG_DEBUG, `[VRR.Job] Showing route stop`); if(getMultiplayerMod() == VRR_MPMOD_GTAC) { - if(gta.game == GAME_GTA_SA) { - jobRouteStopSphere = gta.createPickup(1318, position, 1); + if(game.game == VRR_GAME_GTA_SA) { + jobRouteStopSphere = game.createPickup(1318, position, 1); } else { - jobRouteStopSphere = gta.createSphere(position, 3); + jobRouteStopSphere = game.createSphere(position, 3); jobRouteStopSphere.colour = colour; } - jobRouteStopBlip = gta.createBlip(position, 0, 2, colour); + jobRouteStopBlip = game.createBlip(position, 0, 2, colour); } } diff --git a/scripts/client/mousecam.js b/scripts/client/mousecam.js index 4dde1961..cd4bfd7b 100644 --- a/scripts/client/mousecam.js +++ b/scripts/client/mousecam.js @@ -14,12 +14,16 @@ function SetStandardControlsEnabled(bEnabled) { - if (gta.standardControls === undefined) + if(typeof gta == "undefined") { + return false; + } + + if (game.standardControls === undefined) { - console.warn("gta.standardControls not implemented"); + console.warn("game.standardControls not implemented"); return; } - gta.standardControls = bEnabled; + game.standardControls = bEnabled; } function GetCurrentPlayerIndex() @@ -63,7 +67,7 @@ function GetEntityType(Entity) function GetPlaceableMatrix(pPlaceable) { if (pPlaceable == GetCamera()) - return gta.cameraMatrix; + return game.cameraMatrix; return pPlaceable.matrix; } @@ -81,18 +85,18 @@ function GetMouseSpeed() { if (gui.cursorEnabled) return [0,0]; - let MouseSpeed = gta.getMouseSpeed(); + let MouseSpeed = game.getMouseSpeed(); return [MouseSpeed.x,-MouseSpeed.y]; } function GetMouseSensitivity() { - if (gta.getMouseSensitivity === undefined) + if (game.getMouseSensitivity === undefined) { - //console.error("gta.getMouseSensitivity not implemented"); + //console.error("game.getMouseSensitivity not implemented"); return [0.0025,0.003]; } - let MouseSensitivity = gta.getMouseSensitivity(); + let MouseSensitivity = game.getMouseSensitivity(); return [MouseSensitivity.x,MouseSensitivity.y]; } @@ -118,12 +122,12 @@ function SetEntityCollisionsEnabled(pEntity, bCollisionsEnabled) function ProcessLineOfSight(vecStartX, vecStartY, vecStartZ, vecEndX, vecEndY, vecEndZ, bCheckBuildings, bCheckVehicles, bCheckPeds, bCheckObjects, bCheckDummies, bCheckSeeThroughStuff, bIgnoreSomeObjectsForCamera) { - if (gta.processLineOfSight === undefined) + if (game.processLineOfSight === undefined) { - console.warn("gta.processLineOfSight not implemented"); + console.warn("game.processLineOfSight not implemented"); return [null]; } - let Result = gta.processLineOfSight([vecStartX, vecStartY, vecStartZ], [vecEndX, vecEndY, vecEndZ], bCheckBuildings, bCheckVehicles, bCheckPeds, bCheckObjects, bCheckDummies, bCheckSeeThroughStuff, bIgnoreSomeObjectsForCamera); + let Result = game.processLineOfSight([vecStartX, vecStartY, vecStartZ], [vecEndX, vecEndY, vecEndZ], bCheckBuildings, bCheckVehicles, bCheckPeds, bCheckObjects, bCheckDummies, bCheckSeeThroughStuff, bIgnoreSomeObjectsForCamera); if (Result == null) return [null]; return [Result.position.x, Result.position.y ,Result.position.z, Result.normal.x, Result.normal.y ,Result.normal.z, Result.entity]; @@ -133,13 +137,13 @@ function SetPlaceableMatrix(pPlaceable, mat) { if (pPlaceable == GetCamera()) { - gta.setCameraMatrix(mat); + game.setCameraMatrix(mat); return; } pPlaceable.matrix = mat; } -const UpdateCamera = gta.updateCamera; +const UpdateCamera = game.updateCamera; let GetTickCount; { @@ -162,7 +166,7 @@ let GetTickCount; if (bFrames) return bGTA ? GTAFrameCount : FrameCount; else - return bGTA ? gta.tickCount : sdl.ticks; + return bGTA ? game.tickCount : sdl.ticks; } } @@ -466,7 +470,7 @@ function processReturnToRestRotation() let [TargetCameraRotZ2, TargetCameraRotY2] = getCameraRestRotation(Target); if (Speed < 0) TargetCameraRotZ2 += Math.PI; - let TimeStep = gta.timeStep/50*60; + let TimeStep = game.timeStep/50*60; cameraRotZ += getDifferenceBetweenAngles(cameraRotZ,TargetCameraRotZ2)*applyMultiplierTimeStep(1/20,TimeStep)*Multiplier; cameraRotY += getDifferenceBetweenAngles(cameraRotY,TargetCameraRotY2)*applyMultiplierTimeStep(1/20,TimeStep)*Multiplier; } diff --git a/scripts/client/nametag.js b/scripts/client/nametag.js index f37e0f49..15c212c6 100644 --- a/scripts/client/nametag.js +++ b/scripts/client/nametag.js @@ -48,7 +48,7 @@ function updatePlayerNameTag(clientName, characterName, colour, paused, ping) { playerPaused[clientName] = paused; playerPing[clientName] = ping; - if(gta.game == GAME_GTA_IV) { + if(game.game == VRR_GAME_GTA_IV) { let client = getPlayerFromParams(clientName); if(client != false) { if(client.player != null) { @@ -81,7 +81,7 @@ function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour, // Health Bar if(getMultiplayerMod() == VRR_MPMOD_GTAC) { - if(gta.game == GAME_GTA_III) { + if(game.game == VRR_GAME_GTA_III) { // Mickey Hamfists is ridiculously tall. Raise the nametag for him a bit if(skin == 109) { y -= 20; @@ -207,7 +207,7 @@ function getClientFromPlayer(player) { // =========================================================================== function processNameTagRendering(event) { - //if(gta.game >= GAME_GTA_IV) { + //if(game.game >= GAME_GTA_IV) { // return false; //} diff --git a/scripts/client/server.js b/scripts/client/server.js index d004ac7e..8a6148af 100644 --- a/scripts/client/server.js +++ b/scripts/client/server.js @@ -186,10 +186,10 @@ function setEnterPropertyKey(key) { function setGameScriptState(scriptName, state) { if(state == VRR_GAMESCRIPT_FORCE) { logToConsole(`[VRR.Server] Starting game script '${scriptName}'`); - gta.startNewScript(scriptName); + game.startNewScript(scriptName); } else if(state == VRR_GAMESCRIPT_DENY) { logToConsole(`[VRR.Server] Terminating game script '${scriptName}'`); - gta.terminateScript(scriptName); + game.terminateScript(scriptName); } } @@ -242,7 +242,7 @@ function makePedStopAnimation(pedId) { return false; } - if(getGame() == GAME_GTA_VC || getGame() == GAME_GTA_SA) { + if(getGame() == VRR_GAME_GTA_VC || getGame() == VRR_GAME_GTA_SA) { getElementFromId(pedId).clearAnimations(); } else { getElementFromId(pedId).clearObjective(); diff --git a/scripts/client/sync.js b/scripts/client/sync.js index 41683950..5ad59c92 100644 --- a/scripts/client/sync.js +++ b/scripts/client/sync.js @@ -9,12 +9,12 @@ function processSync(event, deltaTime) { if(localPlayer != null) { - if(!doesGameHaveServerElements()) { + if(!areServerElementsSupported()) { triggerNetworkEvent("vrr.player.position", localPlayer.position); triggerNetworkEvent("vrr.player.heading", localPlayer.heading); } - //if(gta.game == GAME_GTA_SA) { + //if(game.game == VRR_GAME_GTA_SA) { // let lookAtPos = getLocalPlayerLookAtPosition(); // triggerNetworkEvent("vrr.player.lookat", lookAtPos); // setEntityData(localPlayer, "vrr.headLook", lookAtPos); @@ -102,7 +102,7 @@ function syncVehicleProperties(vehicle) { // vehicle.setSuspensionHeight(suspensionHeight); //} - if(getGame() == GAME_GTA_SA) { + if(getGame() == VRR_GAME_GTA_SA) { if(doesEntityDataExist(vehicle, "vrr.upgrades")) { let upgrades = getEntityData(vehicle, "vrr.upgrades"); for(let i in upgrades) { @@ -113,12 +113,12 @@ function syncVehicleProperties(vehicle) { } } - if(getGame() == GAME_GTA_SA || getGame() == GAME_GTA_IV) { + if(getGame() == VRR_GAME_GTA_SA || getGame() == VRR_GAME_GTA_IV) { if(doesEntityDataExist(vehicle, "vrr.livery")) { let livery = getEntityData(vehicle, "vrr.livery"); - if(getGame() == GAME_GTA_SA) { + if(getGame() == VRR_GAME_GTA_SA) { vehicle.setPaintJob(livery); - } else if(getGame() == GAME_GTA_IV) { + } else if(getGame() == VRR_GAME_GTA_IV) { vehicle.livery = livery; } } @@ -128,7 +128,7 @@ function syncVehicleProperties(vehicle) { // =========================================================================== function syncCivilianProperties(civilian) { - if(getGame() == GAME_GTA_III) { + if(getGame() == VRR_GAME_GTA_III) { if(doesEntityDataExist(civilian, "vrr.scale")) { let scaleFactor = getEntityData(civilian, "vrr.scale"); let tempMatrix = civilian.matrix; @@ -140,21 +140,21 @@ function syncCivilianProperties(civilian) { } } - if(getGame() == GAME_GTA_SA) { + if(getGame() == VRR_GAME_GTA_SA) { if(doesEntityDataExist(civilian, "vrr.fightStyle")) { let fightStyle = getEntityData(civilian, "vrr.fightStyle"); civilian.setFightStyle(fightStyle[0], fightStyle[1]); } } - if(getGame() == GAME_GTA_III) { + if(getGame() == VRR_GAME_GTA_III) { if(doesEntityDataExist(civilian, "vrr.walkStyle")) { let walkStyle = getEntityData(civilian, "vrr.walkStyle"); civilian.walkStyle = walkStyle; } } - if(getGame() == GAME_GTA_IV) { + if(getGame() == VRR_GAME_GTA_IV) { if(doesEntityDataExist(civilian, "vrr.bodyPropHair")) { let bodyPropHair = getEntityData(civilian, "vrr.bodyPropHair"); civilian.changeBodyProp(0, bodyPropHair[0], bodyPropHair[1]); @@ -220,7 +220,7 @@ function syncCivilianProperties(civilian) { // =========================================================================== function syncPlayerProperties(player) { - if(getGame() == GAME_GTA_III) { + if(getGame() == VRR_GAME_GTA_III) { if(doesEntityDataExist(player, "vrr.scale")) { let scaleFactor = getEntityData(player, "vrr.scale"); let tempMatrix = player.matrix; @@ -232,21 +232,21 @@ function syncPlayerProperties(player) { } } - if(getGame() == GAME_GTA_SA) { + if(getGame() == VRR_GAME_GTA_SA) { if(doesEntityDataExist(player, "vrr.fightStyle")) { let fightStyle = getEntityData(player, "vrr.fightStyle"); player.setFightStyle(fightStyle[0], fightStyle[1]); } } - //if(getGame() == GAME_GTA_SA) { + //if(getGame() == VRR_GAME_GTA_SA) { // if(doesEntityDataExist(player, "vrr.walkStyle")) { // let walkStyle = getEntityData(player, "vrr.walkStyle"); // player.walkStyle = walkStyle; // } //} - if(getGame() == GAME_GTA_IV) { + if(getGame() == VRR_GAME_GTA_IV) { if(doesEntityDataExist(player, "vrr.bodyPartHair")) { let bodyPartHead = getEntityData(player, "vrr.bodyPartHair"); player.changeBodyPart(0, bodyPartHead[0], bodyPartHair[1]); @@ -268,7 +268,7 @@ function syncPlayerProperties(player) { } } - if(getGame() == GAME_GTA_IV) { + if(getGame() == VRR_GAME_GTA_IV) { if(doesEntityDataExist(player, "vrr.bodyPropHair")) { let bodyPropHair = getEntityData(player, "vrr.bodyPropHair"); player.changeBodyProp(0, bodyPropHair[0], bodyPropHair[1]); @@ -329,7 +329,7 @@ function syncPlayerProperties(player) { // =========================================================================== function syncObjectProperties(object) { - if(getGame() == GAME_GTA_III || getGame() == GAME_GTA_VC) { + if(getGame() == VRR_GAME_GTA_III || getGame() == VRR_GAME_GTA_VC) { if(doesEntityDataExist(object, "vrr.scale")) { let scaleFactor = getEntityData(object, "vrr.scale"); let tempMatrix = object.matrix; diff --git a/scripts/client/utilities.js b/scripts/client/utilities.js index e23aa93a..0dbbbfdf 100644 --- a/scripts/client/utilities.js +++ b/scripts/client/utilities.js @@ -117,22 +117,22 @@ let weaponSlots = [ ]; function openAllGarages() { - switch(gta.game) { - case GAME_GTA_III: + switch(game.game) { + case VRR_GAME_GTA_III: for(let i=0;i<=26;i++) { openGarage(i); - //gta.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i); + game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i); } break; - case GAME_GTA_VC: + case VRR_GAME_GTA_VC: for(let i=0;i<=32;i++) { openGarage(i); - //gta.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i); + game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i); } break; - case GAME_GTA_SA: + case VRR_GAME_GTA_SA: for(let i=0;i<=44;i++) { openGarage(i); } @@ -146,22 +146,22 @@ function openAllGarages() { // =========================================================================== function closeAllGarages() { - switch(gta.game) { - case GAME_GTA_III: + switch(game.game) { + case VRR_GAME_GTA_III: for(let i=0;i<=26;i++) { closeGarage(i); - //gta.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i); + game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i); } break; - case GAME_GTA_VC: + case VRR_GAME_GTA_VC: for(let i=0;i<=32;i++) { closeGarage(i); - //gta.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i); + game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i); } break; - case GAME_GTA_SA: + case VRR_GAME_GTA_SA: for(let i=0;i<=44;i++) { closeGarage(i); } @@ -185,7 +185,7 @@ function setLocalPlayerControlState(controlState, cursorState = false) { logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting control state to ${controlState} (Cursor: ${cursorState})`); controlsEnabled = controlState; //localPlayer.invincible = true; - //if(getGame() != GAME_GTA_IV) { + //if(getGame() != VRR_GAME_GTA_IV) { // localPlayer.collisionsEnabled = controlState; // localPlayer.invincible = false; //} @@ -198,7 +198,7 @@ function fadeLocalCamera(state, time) { logToConsole(LOG_DEBUG, `[VRR.Utilities] Fading camera ${(state)?"in":"out"} for ${time} seconds`); if(isFadeCameraSupported()) { - gta.fadeCamera(state, time); + game.fadeCamera(state, time); } } } @@ -214,7 +214,7 @@ function removeLocalPlayerFromVehicle() { function restoreLocalCamera() { logToConsole(LOG_DEBUG, `[VRR.Utilities] Camera restored`); if(isCustomCameraSupported()) { - gta.restoreCamera(true); + game.restoreCamera(true); } }; @@ -231,7 +231,7 @@ function clearLocalPlayerOwnedPeds() { 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}]`); if(isCustomCameraSupported()) { - gta.setCameraLookAt(cameraPosition, cameraLookAt, true); + game.setCameraLookAt(cameraPosition, cameraLookAt, true); } } @@ -242,9 +242,9 @@ function setCityAmbienceState(state, clearElements = false) { game.setTrafficEnabled(state); if(getMultiplayerMod() == VRR_MPMOD_GTAC) { - gta.setGenerateCarsAroundCamera(state); - if(gta.game != GAME_GTA_SA) { - gta.setCiviliansEnabled(state); + game.setGenerateCarsAroundCamera(state); + if(game.game != VRR_GAME_GTA_SA) { + game.setCiviliansEnabled(state); } if(clearElements) { @@ -336,7 +336,7 @@ function setLocalPlayerInterior(interior) { if(getMultiplayerMod() == VRR_MPMOD_GTAC) { if(!isGTAIV()) { localPlayer.interior = interior; - gta.cameraInterior = interior; + game.cameraInterior = interior; } } @@ -378,7 +378,7 @@ function isSnowEnabled() { function playPedSpeech(pedName, speechId) { logToConsole(LOG_DEBUG, `[VRR.Utilities] Making ${pedName}'s ped talk (${speechId})`); if(getMultiplayerMod() == VRR_MPMOD_GTAC) { - gta.SET_CHAR_SAY(int, int); + game.SET_CHAR_SAY(int, int); } } @@ -404,8 +404,8 @@ function setLocalPlayerDrunkEffect(amount, duration) { drunkEffectDurationTimer = setInterval(function() { drunkEffectAmount = drunkEffectAmount; if(drunkEffectAmount > 0) { - //gta.SET_MOTION_BLUR(drunkEffectAmount); - gta.SET_PLAYER_DRUNKENNESS(drunkEffectAmount, duration); + //game.SET_MOTION_BLUR(drunkEffectAmount); + game.SET_PLAYER_DRUNKENNESS(drunkEffectAmount, duration); } else { clearInterval(drunkEffectDurationTimer); drunkEffectDurationTimer = null; @@ -558,25 +558,27 @@ function processLocalPlayerVehicleControlState() { function processLocalPlayerSphereEntryExitHandling() { let position = getLocalPlayerPosition(); - getElementsByType(ELEMENT_MARKER).forEach(function(sphere) { - if(getDistance(position, sphere.position) <= sphere.radius) { - if(!inSphere) { - inSphere = sphere; - triggerEvent("OnLocalPlayerEnterSphere", null, sphere); + if(areMarkersSupported()) { + getElementsByType(ELEMENT_MARKER).forEach(function(sphere) { + if(getDistance(position, sphere.position) <= sphere.radius) { + if(!inSphere) { + inSphere = sphere; + triggerEvent("OnLocalPlayerEnterSphere", null, sphere); + } + } else { + if(inSphere) { + inSphere = false; + triggerEvent("OnLocalPlayerExitSphere", null, sphere); + } } - } else { - if(inSphere) { - inSphere = false; - triggerEvent("OnLocalPlayerExitSphere", null, sphere); - } - } - }); + }); + } } // =========================================================================== function processJobRouteSphere() { - if(gta.game == GAME_GTA_SA) { + if(game.game == VRR_GAME_GTA_SA) { let position = getLocalPlayerPosition(); if(jobRouteStopSphere != null) { if(getDistance(position, jobRouteStopSphere.position) <= 2.0) { @@ -643,32 +645,11 @@ function getVehicleForNetworkEvent(vehicleArg) { // =========================================================================== -function getPosInFrontOfPos(pos, angle, distance) { - let x = (pos.x+((Math.cos(angle+(Math.PI/2)))*distance)); - let y = (pos.y+((Math.sin(angle+(Math.PI/2)))*distance)); - let z = pos.z; - - return toVector3(x, y, z); -} - -// =========================================================================== - -function getAllowedSkinIndexBySkinId(skinId) { - for(let i in allowedSkins[getGame()]) { - if(skinId == allowedSkins[getGame()][i][0]) { - return i; - } - } - return -1; -} - -// =========================================================================== - function setMinuteDuration(minuteDuration) { logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting minute duration to ${minuteDuration}ms`); if(isTimeSupported()) { - gta.time.minuteDuration = minuteDuration; + game.time.minuteDuration = minuteDuration; } } @@ -734,4 +715,110 @@ function processNearbyPickups() { } } +// =========================================================================== + +function setUpInitialGame() { + if(getGame() == VRR_GAME_GTA_III) { + game.SET_PLAYER_NEVER_GETS_TIRED(game.GET_PLAYER_ID(), 0); + game.setGameStat(STAT_PROGRESSMADE, 9999); + game.setGameStat(STAT_TOTALPROGRESSINGAME, 9999); + game.onMission = true; + return true; + } + + if(getGame() == VRR_GAME_GTA_VC) { + game.SET_PLAYER_NEVER_GETS_TIRED(game.GET_PLAYER_ID(), 0); + game.setGameStat(STAT_PROGRESSMADE, 0); + game.setGameStat(STAT_TOTALPROGRESSINGAME, 0); + + game.REQUEST_ANIMATION("bikev"); + game.REQUEST_ANIMATION("bikeh"); + game.REQUEST_ANIMATION("biked"); + game.REQUEST_ANIMATION("knife"); + game.REQUEST_ANIMATION("python"); + game.REQUEST_ANIMATION("shotgun"); + game.REQUEST_ANIMATION("buddy"); + game.REQUEST_ANIMATION("tec"); + game.REQUEST_ANIMATION("uzi"); + game.REQUEST_ANIMATION("rifle"); + game.REQUEST_ANIMATION("m60"); + game.REQUEST_ANIMATION("sniper"); + game.REQUEST_ANIMATION("grenade"); + game.REQUEST_ANIMATION("flame"); + game.REQUEST_ANIMATION("medic"); + game.REQUEST_ANIMATION("sunbathe"); + //game.REQUEST_ANIMATION("playidles"); + game.REQUEST_ANIMATION("riot"); + game.REQUEST_ANIMATION("strip"); + game.REQUEST_ANIMATION("lance"); + game.REQUEST_ANIMATION("skate"); + + game.LOAD_ALL_MODELS_NOW(); + game.onMission = true; + return true; + } + + if(getGame() == VRR_GAME_GTA_SA) { + game.setGameStat(STAT_WEAPONTYPE_PISTOL_SKILL, 400); + game.setGameStat(STAT_WEAPONTYPE_PISTOL_SILENCED_SKILL, 400); + game.setGameStat(STAT_WEAPONTYPE_DESERT_EAGLE_SKILL, 400); + game.setGameStat(STAT_WEAPONTYPE_SHOTGUN_SKILL, 400); + game.setGameStat(STAT_WEAPONTYPE_SAWNOFF_SHOTGUN_SKILL, 1); + game.setGameStat(STAT_WEAPONTYPE_SPAS12_SHOTGUN_SKILL, 400); + game.setGameStat(STAT_WEAPONTYPE_MICRO_UZI_SKILL, 400); + game.setGameStat(STAT_WEAPONTYPE_MP5_SKILL, 400); + game.setGameStat(STAT_WEAPONTYPE_AK47_SKILL, 400); + game.setGameStat(STAT_WEAPONTYPE_M4_SKILL, 400); + game.setGameStat(STAT_DRIVING_SKILL, 9999); + game.setGameStat(STAT_FAT, 0); + game.setGameStat(STAT_ENERGY, 9999); + game.setGameStat(STAT_CYCLE_SKILL, 9999); + game.setGameStat(STAT_BIKE_SKILL, 9999); + game.setGameStat(STAT_GAMBLING, 9999); + game.setGameStat(STAT_PROGRESS_MADE, 9999); + game.setGameStat(STAT_RESPECT, 0); + game.setGameStat(STAT_RESPECT_TOTAL, 0); + game.setGameStat(STAT_SEX_APPEAL, 0); + game.setGameStat(STAT_STAMINA, 9999); + game.setGameStat(STAT_TOTAL_PROGRESS, 100); + game.setGameStat(STAT_UNDERWATER_STAMINA, 9999); + game.setGameStat(STAT_BODY_MUSCLE, 0); + + game.setDefaultInteriors(false); + game.onMission = true; + return true; + } + + if(getGame() == VRR_GAME_GTA_IV) { + natives.allowEmergencyServices(false); + natives.setCreateRandomCops(true); + natives.setMaxWantedLevel(0); + natives.setWantedMultiplier(0.0); + natives.allowPlayerToCarryNonMissionObjects(natives.getPlayerId(), true); + + natives.setPlayerTeam(natives.getPlayerId(), 0); + natives.usePlayerColourInsteadOfTeamColour(true); + natives.loadAllObjectsNow(); + + natives.requestAnims("DANCING"); + return true; + } + + if(getGame() == VRR_GAME_MAFIA_ONE) { + game.mapEnabled = false; + game.setTrafficEnabled(false); + return true; + } +} + +// =========================================================================== + +function processGameSpecifics() { + if(game.game != VRR_GAME_GTA_IV) { + game.clearMessages(); + } + + destroyAutoCreatedPickups(); +} + // =========================================================================== \ No newline at end of file diff --git a/scripts/server/job.js b/scripts/server/job.js index d025b32b..0f9626a2 100644 --- a/scripts/server/job.js +++ b/scripts/server/job.js @@ -203,7 +203,7 @@ function createAllJobBlips() { logToConsole(LOG_DEBUG, `[VRR.Job] Spawning all job location blips ...`); for(let i in getServerData().jobs) { for(let j in getServerData().jobs[i].locations) { - getServerData().jobs[i].locations[j].blip = gta.createBlip((getServerData().jobs[i].blipModel!=0) ? getServerData().jobs[i].blipModel : 0, getServerData().jobs[i].locations[j].position, 2, getColourByName("yellow")); + getServerData().jobs[i].locations[j].blip = game.createBlip((getServerData().jobs[i].blipModel!=0) ? getServerData().jobs[i].blipModel : 0, getServerData().jobs[i].locations[j].position, 2, getColourByName("yellow")); addToWorld(getServerData().jobs[i].locations[j].blip); logToConsole(LOG_DEBUG, `[VRR.Job] Job '${getServerData().jobs[i].name}' location blip ${j} spawned!`); } @@ -220,7 +220,7 @@ function createAllJobPickups() { if(getServerData().jobs[i].pickupModel != 0) { for(let j in getServerData().jobs[i].locations) { pickupCount++; - getServerData().jobs[i].locations[j].pickup = gta.createPickup(getServerData().jobs[i].pickupModel, getServerData().jobs[i].locations[j].position); + getServerData().jobs[i].locations[j].pickup = game.createPickup(getServerData().jobs[i].pickupModel, getServerData().jobs[i].locations[j].position); getServerData().jobs[i].locations[j].pickup.onAllDimensions = false; setEntityData(getServerData().jobs[i].locations[j].pickup, "vrr.owner.type", VRR_PICKUP_JOB, false); setEntityData(getServerData().jobs[i].locations[j].pickup, "vrr.owner.id", j, false); @@ -1619,7 +1619,7 @@ function createJobLocationBlip(jobId, locationId) { blipModelId = getJobData(jobId).blipModel; } - getJobData(jobId).locations[locationId].blip = gta.createBlip(getJobData(jobId).locations[locationId].position, blipModelId, getColourByType("job")); + getJobData(jobId).locations[locationId].blip = game.createBlip(getJobData(jobId).locations[locationId].position, blipModelId, getColourByType("job")); //getJobData(jobId).locations[locationId].blip.onAllDimensions = false; getJobData(jobId).locations[locationId].blip.dimension = getJobData(jobId).locations[locationId].dimension; addToWorld(getJobData(jobId).locations[locationId].blip); diff --git a/scripts/server/timers.js b/scripts/server/timers.js index 7aeb9bae..7c27130f 100644 --- a/scripts/server/timers.js +++ b/scripts/server/timers.js @@ -13,7 +13,7 @@ let serverTimers = {}; function updateTimeRule() { if(isTimeSupported()) { - server.setRule("Time", makeReadableTime(gta.time.hour, gta.time.minute)); + server.setRule("Time", makeReadableTime(game.time.hour, game.time.minute)); } } diff --git a/scripts/server/utilities.js b/scripts/server/utilities.js index 1bca3524..3748d331 100644 --- a/scripts/server/utilities.js +++ b/scripts/server/utilities.js @@ -448,10 +448,10 @@ function getSpeedFromVelocity(vel) { // =========================================================================== -function isValidSkin(skin, game = GAME_GTA_III) { - if(game == GAME_GTA_III) { +function isValidSkin(skin, game = VRR_GAME_GTA_III) { + if(game == VRR_GAME_GTA_III) { return true; - } else if(game == GAME_GTA_VC) { + } else if(game == VRR_GAME_GTA_VC) { switch(skin) { case 111: return false; @@ -715,6 +715,21 @@ function getAccentFromParams(params) { // =========================================================================== +function getLocaleNameFromParams(params) { + let locales = getLocales(); + if(isNaN(params)) { + for(let i in locales) { + if(toLowerCase(i).indexOf(toLowerCase(params)) != -1) { + return locales[i]; + } + } + } + + return false; +} + +// =========================================================================== + function getWeatherFromParams(params) { if(isNaN(params)) { for(let i in getGameData().weatherNames[getServerGame()]) { @@ -895,7 +910,7 @@ function getItemTypeFromParams(params) { // =========================================================================== function clearChatBox(client) { - //gta.messages.clear(); + //game.messages.clear(); for(let i = 0; i <= 20; i++) { messageClient(" ", client, COLOUR_WHITE); } @@ -903,58 +918,6 @@ function clearChatBox(client) { // =========================================================================== -function getSkinIdFromParams(params, gameId = getServerGame()) { - if(isNaN(params)) { - return getSkinIdFromName(params, gameId); - } else { - params = toInteger(params); - if(gameId == GAME_GTA_IV || gameId == GAME_GTA_IV_EFLC) { - return getGameData().gtaivSkinModels[params][1]; - } else { - return params; - } - } - - return false; -} - -// =========================================================================== - -function getSkinNameFromId(modelId, gameId = getServerGame()) { - if(gameId >= GAME_GTA_IV) { - for(let i in getGameData().gtaivSkinModels) { - if(getGameData().gtaivSkinModels[i][1] == modelId) { - return getGameData().gtaivSkinModels[i][0]; - } - } - } else { - let modelIndex = modelId; - return getGameData().skinNames[gameId][modelIndex]; - } -} - -// =========================================================================== - -function getSkinIdFromName(params, gameId = getServerGame()) { - if(gameId == GAME_GTA_IV || gameId == GAME_GTA_IV_EFLC) { - for(let i in gtaivSkinModels) { - if(toLowerCase(getGameData().gtaivSkinModels[i][0]).indexOf(toLowerCase(params)) != -1) { - return getGameData().gtaivSkinModels[i][1]; - } - } - } else { - for(let i in getGameData().skinNames[gameId]) { - if(toLowerCase(getGameData().skinNames[gameId][i]).indexOf(toLowerCase(params)) != -1) { - return i; - } - } - } - - return false; -} - -// =========================================================================== - function getClosestHospital(position) { let closest = 0; for(let i in getGameData().hospitals[getServerGame()]) { @@ -1320,72 +1283,6 @@ function getPlayerFromParams(params) { // =========================================================================== -function getPosToRightOfPos(pos, angle, distance) { - let x = (pos.x+((Math.cos((-angle+1.57)+(Math.PI/2)))*distance)); - let y = (pos.y+((Math.sin((-angle+1.57)+(Math.PI/2)))*distance)); - - let rightPos = toVector3(x, y, pos.z); - - return rightPos; -} - -// =========================================================================== - -function getPosToLeftOfPos(pos, angle, distance) { - let x = (pos.x+((Math.cos((angle+1.57)+(Math.PI/2)))*distance)); - let y = (pos.y+((Math.sin((angle+1.57)+(Math.PI/2)))*distance)); - - let leftPos = toVector3(x, y, pos.z); - - return leftPos; -} - -// =========================================================================== - -function getPosInFrontOfPos(pos, angle, distance) { - let x = (pos.x+((Math.cos(angle+(Math.PI/2)))*distance)); - let y = (pos.y+((Math.sin(angle+(Math.PI/2)))*distance)); - let z = pos.z; - - return toVector3(x, y, z); -} - -// =========================================================================== - -function getPosBehindPos(pos, angle, distance) { - let x = (pos.x+((Math.cos(angle-(Math.PI/2)))*distance)); - let y = (pos.y+((Math.sin(angle-(Math.PI/2)))*distance)); - let z = pos.z; - - return toVector3(x, y, z); -} - -// =========================================================================== - -function getPosAbovePos(pos, distance) { - return toVector3(pos.x, pos.y, pos.z+distance); -} - -// =========================================================================== - -function getPosBelowPos(pos, distance) { - return toVector3(pos.x, pos.y, pos.z-distance); -} - -// =========================================================================== - -function applyOffsetToPos(position, position2) { - return toVector3(position.x+position2.x, position.y+position2.y, position.z+position2.z); -} - -// =========================================================================== - -function getRandom(min, max) { - return Math.floor(Math.random() * (toInteger(max) - toInteger(min) + 1)) + toInteger(min) -} - -// =========================================================================== - function getArrayOfElementId(elements) { let tempArray = []; for(let i in elements) { @@ -1640,8 +1537,30 @@ async function triggerWebHook(webHookURL, payloadData) { // =========================================================================== -function getGameName(gameId = getGame()) { - return getGameData().gameNames[gameId]; +function clearTemporaryVehicles() { + let vehicles = getVehicles(); + for(let i in vehicles) { + if(vehicles[i].owner == -1) { + if(!getVehicleData(vehicles[i])) { + destroyElement(vehicles[i]); + } + } + } +} + +// =========================================================================== + +function clearTemporaryPeds() { + let peds = getPeds(); + for(let i in peds) { + if(peds[i].owner == -1) { + if(peds[i].isType != ELEMENT_PLAYER) { + if(!getNPCData(peds[i])) { + destroyElement(peds[i]); + } + } + } + } } // =========================================================================== \ No newline at end of file diff --git a/scripts/shared/const.js b/scripts/shared/const.js index 95679d2d..863397e1 100644 --- a/scripts/shared/const.js +++ b/scripts/shared/const.js @@ -35,10 +35,10 @@ const VRR_GAME_GTA_VC = 2; const VRR_GAME_GTA_SA = 3; const VRR_GAME_GTA_IV = 4; const VRR_GAME_GTA_V = 50; -const VRR_GAME_MAFIA_ONE = 100; -const VRR_GAME_MAFIA_TWO = 102; -const VRR_GAME_MAFIA_THREE = 102; -const VRR_GAME_MAFIA_ONE_DE = 103; +const VRR_GAME_MAFIA_ONE = 10; +const VRR_GAME_MAFIA_TWO = 11; +const VRR_GAME_MAFIA_THREE = 12; +const VRR_GAME_MAFIA_ONE_DE = 13; // Key States const VRR_KEYSTATE_NONE = 0; diff --git a/third-party/mexui/mexui.js b/third-party/mexui/mexui.js index c9017bf5..c102c836 100644 --- a/third-party/mexui/mexui.js +++ b/third-party/mexui/mexui.js @@ -287,13 +287,13 @@ mexui.isAnyWindowShown = function() mexui.setInput = function(showInput) { gui.showCursor(showInput, !showInput); - //if(gta.game != GAME_GTA_IV) { + //if(game.game != VRR_GAME_GTA_IV) { // if(localPlayer) // { // if(showInput) - // gta.setCameraLookAt(new Vec3(gta.cameraMatrix.m41, gta.cameraMatrix.m42, gta.cameraMatrix.m43), localPlayer.position, false); + // game.setCameraLookAt(new Vec3(game.cameraMatrix.m41, game.cameraMatrix.m42, game.cameraMatrix.m43), localPlayer.position, false); // else - // gta.restoreCamera(false); + // game.restoreCamera(false); // } //} };