Bunch of stuff

This commit is contained in:
Vortrex
2022-05-12 16:41:32 -05:00
parent 5e075e25f9
commit 0543a58597
16 changed files with 265 additions and 334 deletions

View File

@@ -0,0 +1,69 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: localechooser.js
// DESC: Provides locale chooser GUI
// TYPE: Client (JavaScript)
// ===========================================================================
let localeChooser = {
window: null,
flagImages: []
};
// ===========================================================================
function initLocaleChooserGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating locale chooser GUI ...`);
localeChooser.window = mexui.window(game.width/2-200, game.height/2-70, 400, 140, 'Choose a language', {
main: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
},
title: {
textSize: 11.0,
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], 255),
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha),
},
icon: {
textSize: 0.0,
textColour: toColour(0, 0, 0, 0),
backgroundColour: toColour(0, 0, 0, 0),
},
});
login.window.titleBarShown = false;
for(let i in localeOptions) {
let flagImage = localeChooser.window.image(25, 25, 100, 100, localeOptions[i].flagImage, {
focused: {
borderColour: toColour(0, 0, 0, 0),
},
});
flagImage.callback = function() {
localeChooserSetLocale(localeOptions[i].locale);
}
localeChooser.flagImages.push(flagImage);
}
logToConsole(LOG_DEBUG, `[VRR.GUI] Created locale chooser GUI`);
}
// ===========================================================================
function closeLocaleChooser() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Closing locale chooser window`);
localeChooser.window.shown = false;
mexui.setInput(false);
}
// ===========================================================================
function showLocaleChooser() {
closeAllWindows();
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing locale chooser window`);
mexui.setInput(true);
}
// ===========================================================================

View File

@@ -7,9 +7,6 @@
// TYPE: Client (JavaScript)
// ===========================================================================
let flagImagesPosition = toVector2(getScreenWidth()/2, login.window.position.y+100);
let flagImageSize = toVector2(50, 50);
function getLocaleString(stringName, ...args) {
if(typeof getServerData().localeStrings[stringName] == undefined) {
return "";
@@ -31,4 +28,13 @@ function receiveLocaleStringFromServer(stringName, stringValue) {
getServerData().localeStrings[stringName] = stringValue;
}
// ===========================================================================
function receiveLocaleStringsFromServer(strings) {
for(let i in strings) {
let stringName = strings[i][0];
getServerData().localeStrings[stringName] = strings[i][1];
}
}
// ===========================================================================

View File

@@ -579,4 +579,70 @@ function getScreenHeight() {
return game.height;
}
// ===========================================================================
// ===========================================================================
function openAllGarages() {
switch(getGame()) {
case VRR_GAME_GTA_III:
for(let i=0;i<=26;i++) {
openGarage(i);
game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i);
}
break;
case VRR_GAME_GTA_VC:
for(let i=0;i<=32;i++) {
openGarage(i);
game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i);
}
break;
case VRR_GAME_GTA_SA:
for(let i=0;i<=44;i++) {
openGarage(i);
}
break;
default:
break;
}
}
// ===========================================================================
function closeAllGarages() {
switch(getGame()) {
case VRR_GAME_GTA_III:
for(let i=0;i<=26;i++) {
closeGarage(i);
game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i);
}
break;
case VRR_GAME_GTA_VC:
for(let i=0;i<=32;i++) {
closeGarage(i);
game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i);
}
break;
case VRR_GAME_GTA_SA:
for(let i=0;i<=44;i++) {
closeGarage(i);
}
break;
default:
break;
}
}
// ===========================================================================
function setPedInvincible(ped, state) {
ped.invincible = state;
}
// ===========================================================================

View File

@@ -94,6 +94,7 @@ function addAllNetworkHandlers() {
// Locale
addNetworkEventHandler("vrr.localeString", receiveLocaleStringFromServer);
addNetworkEventHandler("vrr.localeStrings", receiveLocaleStringsFromServer);
// Misc
addNetworkEventHandler("vrr.mouseCursor", toggleMouseCursor);

View File

@@ -161,7 +161,7 @@ function setUpInitialGame() {
natives.requestAnims("DANCING");
// Some last steps
natives.loadAllObjectsNow();
//natives.loadAllObjectsNow();
break;
case VRR_GAME_MAFIA_ONE:

View File

@@ -7,173 +7,6 @@
// TYPE: Client (JavaScript)
// ===========================================================================
let weaponSlots = [
false,
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
],
[
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
3,
3,
4,
4,
4,
5,
5,
5,
5,
6,
6,
8,
8,
7,
7,
7,
7,
9,
-1,
9,
],
[
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
8,
8,
8,
-1,
-1,
-1,
2,
2,
2,
3,
3,
3,
4,
4,
5,
5,
4,
6,
6,
7,
7,
7,
7,
8,
12,
9,
9,
9,
9,
9,
11,
9,
9,
9,
],
];
function openAllGarages() {
switch(getGame()) {
case VRR_GAME_GTA_III:
for(let i=0;i<=26;i++) {
openGarage(i);
game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i);
}
break;
case VRR_GAME_GTA_VC:
for(let i=0;i<=32;i++) {
openGarage(i);
game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i);
}
break;
case VRR_GAME_GTA_SA:
for(let i=0;i<=44;i++) {
openGarage(i);
}
break;
default:
break;
}
}
// ===========================================================================
function closeAllGarages() {
switch(getGame()) {
case VRR_GAME_GTA_III:
for(let i=0;i<=26;i++) {
closeGarage(i);
game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i);
}
break;
case VRR_GAME_GTA_VC:
for(let i=0;i<=32;i++) {
closeGarage(i);
game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i);
}
break;
case VRR_GAME_GTA_SA:
for(let i=0;i<=44;i++) {
closeGarage(i);
}
break;
default:
break;
}
}
// ===========================================================================
function setLocalPlayerFrozenState(state) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting frozen state to ${state}`);
gui.showCursor(state, !state);
@@ -186,11 +19,9 @@ function setLocalPlayerControlState(controlState, cursorState = false) {
controlsEnabled = controlState;
if(getGame() == VRR_GAME_GTA_III || getGame() == VRR_GAME_GTA_VC) {
game.SET_PLAYER_CONTROL(game.GET_PLAYER_ID(), boolToInt(controlState));
}
if(getGame() != VRR_GAME_GTA_IV) {
localPlayer.collisionsEnabled = controlState;
localPlayer.invincible = true;
} else if(getGame() != VRR_GAME_GTA_IV) {
setElementCollisionsEnabled(localPlayer, controlState);
setPedInvincible(localPlayer, true);
}
}
@@ -371,12 +202,12 @@ function setLocalPlayerInterior(interior) {
//}
}
//let vehicles = getElementsByType(ELEMENT_VEHICLE);
//for(let i in vehicles) {
// if(getEntityData(vehicles[i], "vrr.interior")) {
// vehicles[i].interior = getEntityData(vehicles[i], "vrr.interior");
// }
//}
let vehicles = getElementsByType(ELEMENT_VEHICLE);
for(let i in vehicles) {
if(getEntityData(vehicles[i], "vrr.interior")) {
vehicles[i].interior = getEntityData(vehicles[i], "vrr.interior");
}
}
}
// ===========================================================================
@@ -398,12 +229,6 @@ function setLocalPlayerHealth(health) {
// ===========================================================================
function isSnowEnabled() {
return (typeof snowing != "undefined");
}
// ===========================================================================
function playPedSpeech(pedName, speechId) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Making ${pedName}'s ped talk (${speechId})`);
if(getMultiplayerMod() == VRR_MPMOD_GTAC) {
@@ -421,18 +246,14 @@ function clearLocalPedState() {
// ===========================================================================
function getWeaponSlot(weaponId) {
if(getGame() == VRR_GAME_GTA_IV) {
return false;
}
return weaponSlots[getGame()][weaponId];
return getGameConfig().weaponSlots[getGame()][weaponId];
}
// ===========================================================================
function setLocalPlayerDrunkEffect(amount, duration) {
if(getMultiplayerMod() == VRR_MPMOD_GTAC) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Drunk effect set to ${amount} for ${duration}ms`);
logToConsole(LOG_DEBUG, `[VRR.Utilities] Drunk effect set to ${amount} for ${duration} ms`);
drunkEffectAmount = 0;
drunkEffectDurationTimer = setInterval(function() {
drunkEffectAmount = drunkEffectAmount;
@@ -599,28 +420,6 @@ function processLocalPlayerVehicleControlState() {
// ===========================================================================
function processLocalPlayerSphereEntryExitHandling() {
let position = getLocalPlayerPosition();
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);
}
}
});
}
}
// ===========================================================================
function processJobRouteSphere() {
if(getGame() == VRR_GAME_GTA_SA) {
let position = getLocalPlayerPosition();
@@ -670,29 +469,11 @@ function getLocalPlayerPosition() {
// ===========================================================================
function processLocalPlayerVehicleEntryExitHandling() {
if(localPlayer.vehicle) {
if(!inVehicle) {
inVehicle = localPlayer.vehicle;
inVehicleSeat = getLocalPlayerVehicleSeat();
triggerEvent("OnLocalPlayerEnteredVehicle", inVehicle, inVehicleSeat);
}
} else {
if(inVehicle) {
triggerEvent("OnLocalPlayerExitedVehicle", inVehicle, inVehicleSeat);
inVehicle = false;
inVehicleSeat = false;
}
}
}
// ===========================================================================
function getVehicleForNetworkEvent(vehicle) {
if(getGame() == VRR_GAME_GTA_IV) {
return natives.getNetworkIdFromVehicle(vehicle);
}
return vehicle;
return vehicle.id;
}
// ===========================================================================
@@ -781,59 +562,6 @@ function processGameSpecifics() {
// ===========================================================================
function processVehiclePurchasing() {
if(vehiclePurchaseState == VRR_VEHBUYSTATE_TESTDRIVE) {
if(inVehicle == false) {
vehiclePurchaseState = VRR_VEHBUYSTATE_EXITVEH;
sendNetworkEventToServer("vrr.vehBuyState", VRR_VEHBUYSTATE_EXITVEH);
return false;
} else {
if(vehiclePurchasing == inVehicle) {
if(getDistance(inVehicle.position, vehiclePurchasePosition) >= 25) {
vehiclePurchaseState = VRR_VEHBUYSTATE_FARENOUGH;
sendNetworkEventToServer("vrr.vehBuyState", VRR_VEHBUYSTATE_FARENOUGH);
}
} else {
vehiclePurchaseState = VRR_VEHBUYSTATE_WRONGVEH;
sendNetworkEventToServer("vrr.vehBuyState", VRR_VEHBUYSTATE_WRONGVEH);
}
}
}
}
// ===========================================================================
function setVehiclePurchaseState(state, vehicleId, position) {
vehiclePurchaseState = state;
if(vehicleId != null) {
vehiclePurchasing = getElementFromId(vehicleId);
} else {
vehiclePurchasing = null;
}
vehiclePurchasePosition = position;
}
// ===========================================================================
function processVehicleFires() {
/*
let vehicles = getElementsByType(ELEMENT_VEHICLE);
for(let i in vehicles) {
if(vehicles[i].isSyncer) {
if(!doesEntityDataExist(vehicles[i], "vrr.fire")) {
triggerNetworkEvent("vrr.vehFire", vehicles[i].id);
} else {
vehicles[i].health = 249;
}
}
}
*/
}
// ===========================================================================
function getServerData() {
return serverData;
}

View File

@@ -15,4 +15,48 @@ function receiveVehicleFromServer(vehicleId, position, model, colour1, colour2,
}
}
// ===========================================================================
function processVehiclePurchasing() {
if(vehiclePurchaseState == VRR_VEHBUYSTATE_TESTDRIVE) {
if(getLocalPlayerVehicle() == false) {
vehiclePurchaseState = VRR_VEHBUYSTATE_EXITVEH;
sendNetworkEventToServer("vrr.vehBuyState", VRR_VEHBUYSTATE_EXITVEH);
return false;
} else {
if(vehiclePurchasing == getLocalPlayerVehicle()) {
if(getDistance(getLocalPlayerVehicle().position, vehiclePurchasePosition) >= 25) {
vehiclePurchaseState = VRR_VEHBUYSTATE_FARENOUGH;
sendNetworkEventToServer("vrr.vehBuyState", VRR_VEHBUYSTATE_FARENOUGH);
}
} else {
vehiclePurchaseState = VRR_VEHBUYSTATE_WRONGVEH;
sendNetworkEventToServer("vrr.vehBuyState", VRR_VEHBUYSTATE_WRONGVEH);
}
}
}
}
// ===========================================================================
function processVehicleBurning() {
getElementsByType(ELEMENT_VEHICLE).filter(vehicle => vehicle.isSyncer && vehicle.health < 250).forEach((vehicle) => {
vehicle.health = 250;
});
}
// ===========================================================================
function setVehiclePurchaseState(state, vehicleId, position) {
vehiclePurchaseState = state;
if(vehicleId != null) {
vehiclePurchasing = getElementFromId(vehicleId);
} else {
vehiclePurchasing = null;
}
vehiclePurchasePosition = position;
}
// ===========================================================================