Backup current script state
This commit is contained in:
417
scripts/client/netevents.js
Normal file
417
scripts/client/netevents.js
Normal file
@@ -0,0 +1,417 @@
|
|||||||
|
// ===========================================================================
|
||||||
|
// Vortrex's Roleplay Resource
|
||||||
|
// https://github.com/VortrexFTW/gtac_roleplay
|
||||||
|
// ===========================================================================
|
||||||
|
// FILE: netevents.js
|
||||||
|
// DESC: Provides server communication and cross-endpoint network events
|
||||||
|
// TYPE: Client (JavaScript)
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function initServerScript() {
|
||||||
|
logToConsole(LOG_DEBUG, "[VRR.Server]: Initializing server script ...");
|
||||||
|
addAllNetworkHandlers();
|
||||||
|
logToConsole(LOG_DEBUG, "[VRR.Server]: Server script initialized!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function addAllNetworkHandlers() {
|
||||||
|
logToConsole(LOG_DEBUG, "[VRR.Server]: Adding network handlers ...");
|
||||||
|
|
||||||
|
// Chat history
|
||||||
|
addNetworkEventHandler("m", receiveChatBoxMessageFromServer); // Not prefixed with VRR to make it as small as possible
|
||||||
|
addNetworkEventHandler("vrr.chatScrollLines", setChatScrollLines);
|
||||||
|
addNetworkEventHandler("vrr.chatAutoHideDelay", setChatAutoHideDelay);
|
||||||
|
|
||||||
|
// Messaging (like textdraws and stuff)
|
||||||
|
addNetworkEventHandler("vrr.smallGameMessage", showSmallGameMessage);
|
||||||
|
|
||||||
|
// Job
|
||||||
|
addNetworkEventHandler("vrr.job", receiveJobFromServer);
|
||||||
|
addNetworkEventHandler("vrr.working", setLocalPlayerWorkingState);
|
||||||
|
addNetworkEventHandler("vrr.jobType", setLocalPlayerJobType);
|
||||||
|
addNetworkEventHandler("vrr.showJobRouteLocation", showJobRouteLocation);
|
||||||
|
addNetworkEventHandler("vrr.hideJobRouteLocation", hideJobRouteLocation);
|
||||||
|
|
||||||
|
// Local player states and values
|
||||||
|
addNetworkEventHandler("vrr.restoreCamera", restoreLocalCamera);
|
||||||
|
addNetworkEventHandler("vrr.cameraLookAt", setLocalCameraLookAt);
|
||||||
|
addNetworkEventHandler("vrr.freeze", setLocalPlayerFrozenState);
|
||||||
|
addNetworkEventHandler("vrr.control", setLocalPlayerControlState);
|
||||||
|
addNetworkEventHandler("vrr.fadeCamera", fadeLocalCamera);
|
||||||
|
addNetworkEventHandler("vrr.removeFromVehicle", removeLocalPlayerFromVehicle);
|
||||||
|
addNetworkEventHandler("vrr.clearWeapons", clearLocalPlayerWeapons);
|
||||||
|
addNetworkEventHandler("vrr.giveWeapon", giveLocalPlayerWeapon);
|
||||||
|
addNetworkEventHandler("vrr.position", setLocalPlayerPosition);
|
||||||
|
addNetworkEventHandler("vrr.heading", setLocalPlayerHeading);
|
||||||
|
addNetworkEventHandler("vrr.interior", setLocalPlayerInterior);
|
||||||
|
addNetworkEventHandler("vrr.spawned", onServerSpawnedLocalPlayer);
|
||||||
|
addNetworkEventHandler("vrr.money", setLocalPlayerCash);
|
||||||
|
addNetworkEventHandler("vrr.armour", setLocalPlayerArmour);
|
||||||
|
addNetworkEventHandler("vrr.localPlayerSkin", setLocalPlayerSkin);
|
||||||
|
addNetworkEventHandler("vrr.pedSpeak", makeLocalPlayerPedSpeak);
|
||||||
|
addNetworkEventHandler("vrr.infiniteRun", setLocalPlayerInfiniteRun);
|
||||||
|
addNetworkEventHandler("vrr.playerCop", setLocalPlayerAsCopState);
|
||||||
|
addNetworkEventHandler("vrr.health", setLocalPlayerHealth);
|
||||||
|
addNetworkEventHandler("vrr.wantedLevel", setLocalPlayerWantedLevel);
|
||||||
|
addNetworkEventHandler("vrr.playerPedId", sendLocalPlayerNetworkIdToServer);
|
||||||
|
addNetworkEventHandler("vrr.ped", setLocalPlayerPedPartsAndProps);
|
||||||
|
addNetworkEventHandler("vrr.spawn", serverRequestedLocalPlayerSpawn);
|
||||||
|
addNetworkEventHandler("vrr.clearPedState", clearLocalPedState);
|
||||||
|
addNetworkEventHandler("vrr.drunkEffect", setLocalPlayerDrunkEffect);
|
||||||
|
addNetworkEventHandler("vrr.deleteLocalPlayerPed", deleteLocalPlayerPed);
|
||||||
|
|
||||||
|
// Vehicle
|
||||||
|
addNetworkEventHandler("vrr.vehicle", receiveVehicleFromServer);
|
||||||
|
addNetworkEventHandler("vrr.veh.lights", setVehicleLights);
|
||||||
|
addNetworkEventHandler("vrr.veh.engine", setVehicleEngine);
|
||||||
|
addNetworkEventHandler("vrr.veh.repair", repairVehicle);
|
||||||
|
|
||||||
|
// Radio
|
||||||
|
addNetworkEventHandler("vrr.radioStream", playStreamingRadio);
|
||||||
|
addNetworkEventHandler("vrr.audioFileStream", playAudioFile);
|
||||||
|
addNetworkEventHandler("vrr.stopRadioStream", stopStreamingRadio);
|
||||||
|
addNetworkEventHandler("vrr.radioVolume", setStreamingRadioVolume);
|
||||||
|
|
||||||
|
// Key Bindings
|
||||||
|
addNetworkEventHandler("vrr.delKeyBind", unBindAccountKey);
|
||||||
|
addNetworkEventHandler("vrr.addKeyBind", bindAccountKey);
|
||||||
|
addNetworkEventHandler("vrr.clearKeyBinds", clearKeyBinds);
|
||||||
|
|
||||||
|
// Weapon Damage
|
||||||
|
addNetworkEventHandler("vrr.weaponDamageEnabled", setPlayerWeaponDamageEnabled);
|
||||||
|
addNetworkEventHandler("vrr.weaponDamageEvent", setPlayerWeaponDamageEvent);
|
||||||
|
|
||||||
|
// GUI
|
||||||
|
addNetworkEventHandler("vrr.showRegistration", showRegistrationGUI);
|
||||||
|
addNetworkEventHandler("vrr.showNewCharacter", showNewCharacterGUI);
|
||||||
|
addNetworkEventHandler("vrr.showLogin", showLoginGUI);
|
||||||
|
addNetworkEventHandler("vrr.2fa", showTwoFactorAuthGUI);
|
||||||
|
addNetworkEventHandler("vrr.showResetPasswordCodeInput", resetPasswordCodeInputGUI);
|
||||||
|
addNetworkEventHandler("vrr.showResetPasswordEmailInput", resetPasswordEmailInputGUI);
|
||||||
|
addNetworkEventHandler("vrr.showChangePassword", showChangePasswordGUI);
|
||||||
|
addNetworkEventHandler("vrr.showCharacterSelect", showCharacterSelectGUI);
|
||||||
|
addNetworkEventHandler("vrr.switchCharacterSelect", switchCharacterSelectGUI);
|
||||||
|
addNetworkEventHandler("vrr.showError", showErrorGUI);
|
||||||
|
addNetworkEventHandler("vrr.showInfo", showInfoGUI);
|
||||||
|
addNetworkEventHandler("vrr.showPrompt", showYesNoPromptGUI);
|
||||||
|
addNetworkEventHandler("vrr.loginSuccess", loginSuccess);
|
||||||
|
addNetworkEventHandler("vrr.characterSelectSuccess", characterSelectSuccess);
|
||||||
|
addNetworkEventHandler("vrr.loginFailed", loginFailed);
|
||||||
|
addNetworkEventHandler("vrr.registrationSuccess", registrationSuccess);
|
||||||
|
addNetworkEventHandler("vrr.registrationFailed", registrationFailed);
|
||||||
|
addNetworkEventHandler("vrr.newCharacterFailed", newCharacterFailed);
|
||||||
|
addNetworkEventHandler("vrr.changePassword", showChangePasswordGUI);
|
||||||
|
addNetworkEventHandler("vrr.showLocaleChooser", showLocaleChooserGUI);
|
||||||
|
addNetworkEventHandler("vrr.guiColour", setGUIColours);
|
||||||
|
|
||||||
|
// Business
|
||||||
|
addNetworkEventHandler("vrr.business", receiveBusinessFromServer);
|
||||||
|
|
||||||
|
// House
|
||||||
|
addNetworkEventHandler("vrr.house", receiveHouseFromServer);
|
||||||
|
|
||||||
|
// GPS
|
||||||
|
addNetworkEventHandler("vrr.showGPSBlip", showGPSLocation);
|
||||||
|
|
||||||
|
// Locale
|
||||||
|
addNetworkEventHandler("vrr.locale", setLocale);
|
||||||
|
addNetworkEventHandler("vrr.localeChooser", toggleLocaleChooserGUI);
|
||||||
|
|
||||||
|
// Misc
|
||||||
|
addNetworkEventHandler("vrr.mouseCursor", toggleMouseCursor);
|
||||||
|
addNetworkEventHandler("vrr.mouseCamera", toggleMouseCamera);
|
||||||
|
addNetworkEventHandler("vrr.clearPeds", clearLocalPlayerOwnedPeds);
|
||||||
|
addNetworkEventHandler("vrr.passenger", enterVehicleAsPassenger);
|
||||||
|
addNetworkEventHandler("vrr.logo", setServerLogoRenderState);
|
||||||
|
addNetworkEventHandler("vrr.ambience", setCityAmbienceState);
|
||||||
|
addNetworkEventHandler("vrr.runCode", runClientCode);
|
||||||
|
addNetworkEventHandler("vrr.minuteDuration", setMinuteDuration);
|
||||||
|
addNetworkEventHandler("vrr.snow", setSnowState);
|
||||||
|
addNetworkEventHandler("vrr.enterPropertyKey", setEnterPropertyKey);
|
||||||
|
addNetworkEventHandler("vrr.skinSelect", toggleSkinSelect);
|
||||||
|
addNetworkEventHandler("vrr.hotbar", updatePlayerHotBar);
|
||||||
|
addNetworkEventHandler("vrr.showItemActionDelay", showItemActionDelay);
|
||||||
|
addNetworkEventHandler("vrr.set2DRendering", set2DRendering);
|
||||||
|
addNetworkEventHandler("vrr.mouseCameraForce", setMouseCameraState);
|
||||||
|
addNetworkEventHandler("vrr.logLevel", setLogLevel);
|
||||||
|
addNetworkEventHandler("vrr.hideAllGUI", hideAllGUI);
|
||||||
|
addNetworkEventHandler("vrr.nametag", updatePlayerNameTag);
|
||||||
|
addNetworkEventHandler("vrr.nametagDistance", setNameTagDistance);
|
||||||
|
addNetworkEventHandler("vrr.ping", updatePlayerPing);
|
||||||
|
addNetworkEventHandler("vrr.anim", makePedPlayAnimation);
|
||||||
|
addNetworkEventHandler("vrr.stopAnim", makePedStopAnimation);
|
||||||
|
addNetworkEventHandler("vrr.forceAnim", forcePedAnimation);
|
||||||
|
addNetworkEventHandler("vrr.clientInfo", serverRequestedClientInfo);
|
||||||
|
addNetworkEventHandler("vrr.interiorLights", updateInteriorLightsState);
|
||||||
|
addNetworkEventHandler("vrr.cutsceneInterior", setCutsceneInterior);
|
||||||
|
addNetworkEventHandler("vrr.syncElement", forceSyncElementProperties);
|
||||||
|
addNetworkEventHandler("vrr.elementPosition", setElementPosition);
|
||||||
|
addNetworkEventHandler("vrr.elementCollisions", setElementCollisionsEnabled);
|
||||||
|
addNetworkEventHandler("vrr.vehBuyState", setVehiclePurchaseState);
|
||||||
|
addNetworkEventHandler("vrr.holdObject", makePedHoldObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function sendResourceReadySignalToServer() {
|
||||||
|
sendNetworkEventToServer("vrr.clientReady");
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function sendResourceStartedSignalToServer() {
|
||||||
|
sendNetworkEventToServer("vrr.clientStarted");
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function sendResourceStoppedSignalToServer() {
|
||||||
|
if (isConnected) {
|
||||||
|
sendNetworkEventToServer("vrr.clientStopped");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function set2DRendering(hudState, labelState, smallGameMessageState, scoreboardState, hotBarState, itemActionDelayState) {
|
||||||
|
logToConsole(LOG_DEBUG, `[VRR.Main] Updating render states (HUD: ${hudState}, Labels: ${labelState}, Bottom Text: ${smallGameMessageState}, Scoreboard: ${scoreboardState}, HotBar: ${hotBarState}, Item Action Delay: ${itemActionDelayState})`);
|
||||||
|
renderHUD = hudState;
|
||||||
|
|
||||||
|
if (getGame() == VRR_GAME_GTA_IV) {
|
||||||
|
natives.displayCash(hudState);
|
||||||
|
natives.displayAmmo(hudState);
|
||||||
|
natives.displayHud(hudState);
|
||||||
|
natives.displayRadar(hudState);
|
||||||
|
natives.displayAreaName(hudState);
|
||||||
|
} else {
|
||||||
|
if (typeof setHUDEnabled != "undefined") {
|
||||||
|
setHUDEnabled(hudState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
renderLabels = labelState;
|
||||||
|
renderSmallGameMessage = smallGameMessageState;
|
||||||
|
renderScoreBoard = scoreboardState;
|
||||||
|
renderHotBar = hotBarState;
|
||||||
|
renderItemActionDelay = itemActionDelayState;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function onServerSpawnedLocalPlayer(state) {
|
||||||
|
logToConsole(LOG_DEBUG, `[VRR.Main] Setting spawned state to ${state}`);
|
||||||
|
isSpawned = state;
|
||||||
|
setUpInitialGame();
|
||||||
|
if (state) {
|
||||||
|
setTimeout(function () {
|
||||||
|
calledDeathEvent = false;
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
getElementsByType(ELEMENT_PED).filter(ped => !ped.isType(ELEMENT_PLAYER)).forEach(ped => {
|
||||||
|
syncCivilianProperties(ped);
|
||||||
|
});
|
||||||
|
|
||||||
|
getElementsByType(ELEMENT_PLAYER).forEach(player => {
|
||||||
|
syncPlayerProperties(player);
|
||||||
|
});
|
||||||
|
|
||||||
|
getElementsByType(ELEMENT_VEHICLE).forEach(vehicle => {
|
||||||
|
syncVehicleProperties(vehicle);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function tellServerPlayerUsedKeyBind(key) {
|
||||||
|
sendNetworkEventToServer("vrr.useKeyBind", key);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function tellServerPlayerArrivedAtJobRouteLocation() {
|
||||||
|
sendNetworkEventToServer("vrr.arrivedAtJobRouteLocation");
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function tellServerItemActionDelayComplete() {
|
||||||
|
sendNetworkEventToServer("vrr.itemActionDelayComplete");
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function sendServerClientInfo() {
|
||||||
|
let clientVersion = "0.0.0.0";
|
||||||
|
if (typeof CLIENT_VERSION_MAJOR != "undefined") {
|
||||||
|
clientVersion = `${CLIENT_VERSION_MAJOR}.${CLIENT_VERSION_MINOR}.${CLIENT_VERSION_PATCH}.${CLIENT_VERSION_BUILD}`;
|
||||||
|
}
|
||||||
|
sendNetworkEventToServer("vrr.clientInfo", clientVersion, game.width, game.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function sendServerNewAFKStatus(state) {
|
||||||
|
sendNetworkEventToServer("vrr.afk", state);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function anchorBoat(vehicleId) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function setEnterPropertyKey(key) {
|
||||||
|
enterPropertyKey = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function serverRequestedClientInfo() {
|
||||||
|
sendServerClientInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function updateInteriorLightsState(state) {
|
||||||
|
interiorLightsEnabled = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function forceSyncElementProperties(elementId) {
|
||||||
|
if (getElementFromId(elementId) == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
syncElementProperties(getElementFromId(elementId));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function setElementCollisionsEnabled(elementId, state) {
|
||||||
|
if (getElementFromId(elementId) == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
getElementFromId(elementId).collisionsEnabled = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function setLocalPlayerArmour(armour) {
|
||||||
|
if (typeof localPlayer.armour != "undefined") {
|
||||||
|
localPlayer.armour = armour;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function setLocalPlayerWantedLevel(wantedLevel) {
|
||||||
|
forceWantedLevel = toInteger(wantedLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function setLogLevel(level) {
|
||||||
|
logLevel = level;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function setLocalPlayerInfiniteRun(state) {
|
||||||
|
if (localPlayer != null) {
|
||||||
|
if (getGame() == VRR_GAME_GTA_III || getGame() == VRR_GAME_GTA_VC) {
|
||||||
|
game.SET_PLAYER_NEVER_GETS_TIRED(game.GET_PLAYER_ID(), boolToInt(state));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function setLocalPlayerSkin(skinId) {
|
||||||
|
logToConsole(LOG_INFO, `[VRR.Server] Setting locale player skin to ${skinId}`);
|
||||||
|
if (getGame() == VRR_GAME_GTA_IV) {
|
||||||
|
natives.changePlayerModel(natives.getPlayerId(), skinId);
|
||||||
|
} else {
|
||||||
|
localPlayer.skin = skinId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function makePedHoldObject(pedId, modelIndex) {
|
||||||
|
if (getGame() == VRR_GAME_GTA_IV) {
|
||||||
|
natives.givePedAmbientObject(natives.getPedFromNetworkId(pedId), getGameConfig().objects[getGame()][modelIndex][1])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function sendLocalPlayerNetworkIdToServer() {
|
||||||
|
sendNetworkEventToServer("vrr.playerPedId", natives.getNetworkIdFromPed(localPlayer));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function setCutsceneInterior(cutsceneName) {
|
||||||
|
if (getGame() == VRR_GAME_GTA_IV) {
|
||||||
|
if (cutsceneName == "") {
|
||||||
|
natives.clearCutscene();
|
||||||
|
} else {
|
||||||
|
if (natives.isInteriorScene()) {
|
||||||
|
natives.clearCutscene();
|
||||||
|
}
|
||||||
|
natives.initCutscene(cutsceneName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function makeLocalPlayerPedSpeak(speechName) {
|
||||||
|
if (getGame() == VRR_GAME_GTA_IV) {
|
||||||
|
// if player is in vehicle, allow megaphone (if last arg is "1", it will cancel megaphone echo)
|
||||||
|
// Only speeches with _MEGAPHONE will have the bullhorn effect
|
||||||
|
// Afaik it only works on police voices anyway
|
||||||
|
if (localPlayer.vehicle != null) {
|
||||||
|
natives.sayAmbientSpeech(localPlayer, speechName, true, false, 0);
|
||||||
|
} else {
|
||||||
|
natives.sayAmbientSpeech(localPlayer, speechName, true, false, 1);
|
||||||
|
}
|
||||||
|
} else if (getGame() == VRR_GAME_GTA_III || getGame() == VRR_GAME_GTA_VC) {
|
||||||
|
// Don't have a way to get the ped ref ID and can't use ped in arg
|
||||||
|
//game.SET_CHAR_SAY(game.GET_PLAYER_ID(), int);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function setLocalPlayerAsCopState(state) {
|
||||||
|
if (getGame() == VRR_GAME_GTA_IV) {
|
||||||
|
natives.setPlayerAsCop(natives.getPlayerId(), state);
|
||||||
|
natives.setPoliceIgnorePlayer(natives.getPlayerId(), state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function serverRequestedLocalPlayerSpawn(skinId, position) {
|
||||||
|
if (getGame() == VRR_GAME_GTA_IV) {
|
||||||
|
natives.createPlayer(skinId, position);
|
||||||
|
//if(isCustomCameraSupported()) {
|
||||||
|
// game.restoreCamera(true);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function sendLocaleSelectToServer(localeId) {
|
||||||
|
sendNetworkEventToServer("vrr.localeSelect", localeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
22
scripts/server/crime.js
Normal file
22
scripts/server/crime.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
// ===========================================================================
|
||||||
|
// Vortrex's Roleplay Resource
|
||||||
|
// https://github.com/VortrexFTW/gtac_roleplay
|
||||||
|
// ===========================================================================
|
||||||
|
// FILE: crime.js
|
||||||
|
// DESC: Provides crime data structures, functions, and operations
|
||||||
|
// TYPE: Server (JavaScript)
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class Representing a crime's data. Loaded and saved in the database
|
||||||
|
*/
|
||||||
|
class CrimeData {
|
||||||
|
constructor(suspectId, crimeType, reporterId = 0) {
|
||||||
|
this.crimeType = crimeType;
|
||||||
|
this.suspectId = suspectId;
|
||||||
|
this.reporterId = reporterId;
|
||||||
|
this.whenCommitted = 0;
|
||||||
|
this.whenReported = 0;
|
||||||
|
this.databaseId = 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
20
scripts/server/forensics.js
Normal file
20
scripts/server/forensics.js
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
// ===========================================================================
|
||||||
|
// Vortrex's Roleplay Resource
|
||||||
|
// https://github.com/VortrexFTW/gtac_roleplay
|
||||||
|
// ===========================================================================
|
||||||
|
// FILE: forensics.js
|
||||||
|
// DESC: Provides forensics functions and commands (bullet casings, blood, etc)
|
||||||
|
// TYPE: Server (JavaScript)
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
// Forensic Types
|
||||||
|
const VRR_FORENSICS_NONE = 0;
|
||||||
|
const VRR_FORENSICS_BULLET = 1; // Bullet. The actual tip that hits a target. Has rifling and ballistics information of the weapon.
|
||||||
|
const VRR_FORENSICS_BLOOD = 2; // Blood. Automatically applied to ground and bullets that hit when somebody is shot
|
||||||
|
const VRR_FORENSICS_BODY = 3; // Body. A dead body lol
|
||||||
|
const VRR_FORENSICS_HAIR = 4; // Hair. Automatically applied to
|
||||||
|
const VRR_FORENSICS_SWEAT = 5; // Sweat. Automatically applied to clothing when worn
|
||||||
|
const VRR_FORENSICS_SALIVA = 6; // Saliva. Automatically applied to drinks when drank
|
||||||
|
const VRR_FORENSICS_BULLETCASINGS = 7; // Bullet casings. Automatically dropped when fired from a weapon except when used in a vehicle (driveby)
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
148
scripts/server/gps.js
Normal file
148
scripts/server/gps.js
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
// ===========================================================================
|
||||||
|
// Vortrex's Roleplay Resource
|
||||||
|
// https://github.com/VortrexFTW/gtac_roleplay
|
||||||
|
// ===========================================================================
|
||||||
|
// FILE: gps.js
|
||||||
|
// DESC: Provides GPS functions and commands
|
||||||
|
// TYPE: Server (JavaScript)
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
// GPS State Types
|
||||||
|
const VRR_GPS_TYPE_NONE = 0; // None (invalid)
|
||||||
|
const VRR_GPS_TYPE_BUSINESS = 1; // Business
|
||||||
|
const VRR_GPS_TYPE_POLICE = 2; // Police Station
|
||||||
|
const VRR_GPS_TYPE_HOSPITAL = 3; // Hospital
|
||||||
|
const VRR_GPS_TYPE_JOB = 4; // Job
|
||||||
|
const VRR_GPS_TYPE_GAMELOC = 5; // Game Location
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function gpsCommand(command, params, client) {
|
||||||
|
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBusinessList")));
|
||||||
|
|
||||||
|
let locationType = VRR_GPS_TYPE_NONE;
|
||||||
|
let useType = VRR_ITEM_USETYPE_NONE;
|
||||||
|
let blipColour = "white";
|
||||||
|
|
||||||
|
switch(toLowerCase(params)) {
|
||||||
|
case "police":
|
||||||
|
blipColour = "businessBlue"
|
||||||
|
locationType = VRR_GPS_TYPE_POLICE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "hospital":
|
||||||
|
blipColour = "businessBlue"
|
||||||
|
locationType = VRR_GPS_TYPE_HOSPITAL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "job":
|
||||||
|
blipColour = "businessBlue"
|
||||||
|
locationType = VRR_GPS_TYPE_JOB;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "skin":
|
||||||
|
case "skins":
|
||||||
|
case "clothes":
|
||||||
|
case "player":
|
||||||
|
blipColour = "businessBlue"
|
||||||
|
locationType = VRR_GPS_TYPE_BUSINESS;
|
||||||
|
useType = VRR_ITEM_USETYPE_SKIN;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "gun":
|
||||||
|
case "guns":
|
||||||
|
case "weapon":
|
||||||
|
case "weapons":
|
||||||
|
case "wep":
|
||||||
|
case "weps":
|
||||||
|
blipColour = "businessBlue"
|
||||||
|
locationType = VRR_GPS_TYPE_BUSINESS;
|
||||||
|
useType = VRR_ITEM_USETYPE_WEAPON;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "food":
|
||||||
|
case "eat":
|
||||||
|
blipColour = "businessBlue"
|
||||||
|
locationType = VRR_GPS_TYPE_BUSINESS;
|
||||||
|
useType = VRR_ITEM_USETYPE_FOOD;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "drink":
|
||||||
|
blipColour = "businessBlue"
|
||||||
|
locationType = VRR_GPS_TYPE_BUSINESS;
|
||||||
|
useType = VRR_ITEM_USETYPE_DRINK;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "alcohol":
|
||||||
|
case "booze":
|
||||||
|
case "bar":
|
||||||
|
blipColour = "businessBlue"
|
||||||
|
locationType = VRR_GPS_TYPE_BUSINESS;
|
||||||
|
useType = VRR_ITEM_USETYPE_ALCOHOL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "repair":
|
||||||
|
case "carrepair":
|
||||||
|
case "vehrepair":
|
||||||
|
case "spray":
|
||||||
|
case "fix":
|
||||||
|
blipColour = "businessBlue"
|
||||||
|
locationType = VRR_GPS_TYPE_BUSINESS;
|
||||||
|
useType = VRR_ITEM_USETYPE_VEHREPAIR;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "vehiclecolour":
|
||||||
|
case "vehcolour":
|
||||||
|
case "carcolour":
|
||||||
|
case "colour":
|
||||||
|
blipColour = "businessBlue"
|
||||||
|
locationType = VRR_GPS_TYPE_BUSINESS;
|
||||||
|
useType = VRR_ITEM_USETYPE_VEHCOLOUR;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: {
|
||||||
|
let itemTypeId = getItemTypeFromParams(params);
|
||||||
|
if(getItemTypeData(itemTypeId) != false) {
|
||||||
|
locationType = VRR_GPS_TYPE_BUSINESS;
|
||||||
|
blipColour = "businessBlue";
|
||||||
|
useType = getItemTypeData(itemTypeId).useType;
|
||||||
|
} else {
|
||||||
|
let gameLocationId = getGameLocationFromParams(params);
|
||||||
|
if(gameLocationId != false) {
|
||||||
|
position = getGameConfig().locations[getServerGame()][gameLocationId][1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(locationType == VRR_GPS_TYPE_NONE) {
|
||||||
|
messagePlayerError(client, getLocaleString(client, "InvalidGPSLocation"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(locationType == VRR_GPS_TYPE_BUSINESS) {
|
||||||
|
let businessId = getClosestBusinessWithBuyableItemOfUseType(useType);
|
||||||
|
if(!businessId) {
|
||||||
|
messagePlayerError(client, getLocaleString(client, "NoBusinessWithItemType"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!getBusinessData(businessId)) {
|
||||||
|
messagePlayerError(client, getLocaleString(client, "NoBusinessWithItemType"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
hideAllBlipsForPlayerGPS(client);
|
||||||
|
blinkGenericGPSBlipForPlayer(client, getBusinessData(businessId).entrancePosition, getBusinessData(businessId).entranceBlipModel, getColourByType(blipColour), 10);
|
||||||
|
messagePlayerSuccess(client, "Look for the blinking icon on your mini map");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(locationType == VRR_GPS_TYPE_GAMELOC) {
|
||||||
|
hideAllBlipsForPlayerGPS(client);
|
||||||
|
blinkGenericGPSBlipForPlayer(client, position, 0, getColourByType(blipColour), 10);
|
||||||
|
messagePlayerSuccess(client, "Look for the blinking icon on your mini map");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
40
scripts/server/insurance.js
Normal file
40
scripts/server/insurance.js
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
// ===========================================================================
|
||||||
|
// Vortrex's Roleplay Resource
|
||||||
|
// https://github.com/VortrexFTW/gtac_roleplay
|
||||||
|
// ===========================================================================
|
||||||
|
// FILE: insurance.js
|
||||||
|
// DESC: Provides insurance commands, functions, and usage
|
||||||
|
// TYPE: Server (JavaScript)
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
// Insurance Account Owner Types
|
||||||
|
const VRR_INS_ACCT_OWNER_NONE = 0; // None
|
||||||
|
const VRR_INS_ACCT_OWNER_PLAYER = 1; // Player owns insurance company
|
||||||
|
const VRR_INS_ACCT_OWNER_BIZ = 2; // Business owns insurance company
|
||||||
|
const VRR_INS_ACCT_OWNER_CLAN = 3; // Clan owns insurance company
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
// Insurance Account Entity Types
|
||||||
|
const VRR_INS_ACCT_ENTITY_NONE = 0; // None
|
||||||
|
const VRR_INS_ACCT_ENTITY_PLAYER_HEALTH = 1; // Health Insurance
|
||||||
|
const VRR_INS_ACCT_ENTITY_PLAYER_LIFE = 2; // Life Insurance
|
||||||
|
const VRR_INS_ACCT_ENTITY_VEH = 3; // Vehicle Insurance
|
||||||
|
const VRR_INS_ACCT_ENTITY_BIZ = 4; // Business Insurance
|
||||||
|
const VRR_INS_ACCT_ENTITY_HOUSE = 5; // House Insurance
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
// Insurance Account History Types
|
||||||
|
const VRR_INS_ACCT_HISTORY_NONE = 0; // None
|
||||||
|
const VRR_INS_ACCT_HISTORY_PLAYER_MEDICAL = 1; // Medical insurance was used (player disease/injury)
|
||||||
|
const VRR_INS_ACCT_HISTORY_PLAYER_DEATH = 2; // Life insurance was used (player death)
|
||||||
|
const VRR_INS_ACCT_HISTORY_VEH_DAMAGE = 3; // Vehicle was damaged, but not destroyed
|
||||||
|
const VRR_INS_ACCT_HISTORY_VEH_WRECKED = 4; // Vehicle was completely destroyed
|
||||||
|
const VRR_INS_ACCT_HISTORY_VEH_THEFT = 5; // Vehicle was stolen
|
||||||
|
const VRR_INS_ACCT_HISTORY_BIZ_DAMAGE = 6; // Business was damaged (broken items/window/door)
|
||||||
|
const VRR_INS_ACCT_HISTORY_BIZ_THEFT = 7; // Business was stolen from
|
||||||
|
const VRR_INS_ACCT_HISTORY_HOUSE_DAMAGE = 8; // House was damaged
|
||||||
|
const VRR_INS_ACCT_HISTORY_HOUSE_THEFT = 9; // House was stolen from
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
1235
scripts/server/netevents.js
Normal file
1235
scripts/server/netevents.js
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user