Merge branch 'nightly' into ragemp

This commit is contained in:
Vortrex
2022-04-16 22:39:48 -05:00
172 changed files with 25499 additions and 10148 deletions

View File

@@ -7,6 +7,7 @@
// TYPE: Client (JavaScript)
// ===========================================================================
// Init AFK script
function initAFKScript() {
logToConsole(LOG_DEBUG, "[VRR.AFK]: Initializing AFK script ...");
logToConsole(LOG_DEBUG, "[VRR.AFK]: AFK script initialized!");
@@ -14,14 +15,16 @@ function initAFKScript() {
// ===========================================================================
// Process stuff when game loses focus
function processLostFocusAFK(event) {
sendServerNewAFKStatus(true);
}
// ===========================================================================
// Process stuff when game gains focus
function processFocusAFK(event) {
sendServerNewAFKStatus(false);
sendServerNewAFKStatus(false);
}
// ===========================================================================

View File

@@ -7,69 +7,115 @@
// TYPE: Client (JavaScript)
// ===========================================================================
function makePedPlayAnimation(pedId, animGroup, animId, animType, animSpeed, loop, loopNoControl, freezeLastFrame, returnToOriginalPosition, freezePlayer) {
logToConsole(LOG_DEBUG, `[VRR.Animation] Playing animation ${animGroup}/${animId} for ped ${pedId}`);
if(getGame() < VRR_GAME_GTA_IV) {
if(animType == VRR_ANIMTYPE_NORMAL || animType == VRR_ANIMTYPE_SURRENDER) {
if(getGame() == VRR_GAME_GTA_VC || getGame() == VRR_GAME_GTA_SA) {
getElementFromId(pedId).clearAnimations();
} else {
getElementFromId(pedId).clearObjective();
}
getElementFromId(pedId).addAnimation(animGroup, animId);
function makePedPlayAnimation(pedId, animationSlot, positionOffset) {
let animationData = getAnimationData(animationSlot);
logToConsole(LOG_DEBUG, `[VRR.Animation] Playing animation ${animationData[0]} for ped ${pedId}`);
if(getElementFromId(pedId) == localPlayer && freezePlayer == true) {
inAnimation = true;
setLocalPlayerControlState(false, false);
localPlayer.collisionsEnabled = false;
}
} else if(animType == VRR_ANIMTYPE_BLEND) {
getElementFromId(pedId).position = getElementFromId(pedId).position;
getElementFromId(pedId).blendAnimation(animGroup, animId, animSpeed);
}
} else {
natives.requestAnims(animGroup);
natives.taskPlayAnimNonInterruptable(getElementFromId(pedId), animId, animGroup, animSpeed, loop, loopNoControl, freezeLastFrame, returnToOriginalPosition, -1);
}
let freezePlayer = false;
switch(animationData.moveType) {
case VRR_ANIMMOVE_FORWARD:
setElementCollisionsEnabled(ped, false);
setElementPosition(ped, getPosInFrontOfPos(getElementPosition(ped), fixAngle(getElementHeading(ped)), positionOffset));
freezePlayer = true;
break;
case VRR_ANIMMOVE_BACK:
setElementCollisionsEnabled(ped, false);
setElementPosition(ped, getPosBehindPos(getElementPosition(ped), fixAngle(getElementHeading(ped)), positionOffset));
freezePlayer = true;
break;
case VRR_ANIMMOVE_LEFT:
setElementCollisionsEnabled(ped, false);
setElementPosition(ped, getPosToLeftOfPos(getElementPosition(ped), fixAngle(getElementHeading(ped)), positionOffset));
freezePlayer = true;
break;
case VRR_ANIMMOVE_RIGHT:
setElementCollisionsEnabled(ped, false);
setElementPosition(ped, getPosToRightOfPos(getElementPosition(ped), fixAngle(getElementHeading(ped)), positionOffset));
freezePlayer = true;
break;
default:
break;
}
if(getGame() < VRR_GAME_GTA_IV) {
if(animationData.animType == VRR_ANIMTYPE_NORMAL || animationData.animType == VRR_ANIMTYPE_SURRENDER) {
if(getGame() == VRR_GAME_GTA_VC || getGame() == VRR_GAME_GTA_SA) {
getElementFromId(pedId).clearAnimations();
} else {
getElementFromId(pedId).clearObjective();
}
getElementFromId(pedId).addAnimation(animationData.groupId, animationData.animId);
if(getElementFromId(pedId) == localPlayer && freezePlayer == true) {
inAnimation = true;
setLocalPlayerControlState(false, false);
localPlayer.collisionsEnabled = false;
}
} else if(animationData.animType == VRR_ANIMTYPE_BLEND) {
getElementFromId(pedId).position = getElementFromId(pedId).position;
getElementFromId(pedId).blendAnimation(animationData.groupId, animationData.animId, animationData.animSpeed);
}
} else {
natives.requestAnims(animationData.groupId);
natives.taskPlayAnimNonInterruptable(getElementFromId(pedId), animationData.groupId, animationData.animId, animationData.animSpeed, boolToInt(animationData.infiniteLoop), boolToInt(animationData.infiniteLoopNoMovement), boolToInt(animationData.dontReturnToStartCoords), boolToInt(animationData.freezeLastFrame), -1);
}
}
// ===========================================================================
function forcePedAnimation(pedId, animGroup, animId, animType, animSpeed, loop, loopNoControl, freezeLastFrame, returnToOriginalPosition) {
if(getGame() < VRR_GAME_GTA_IV) {
forcedAnimation = [animGroup, animId];
getElementFromId(pedId).position = getElementFromId(pedId).position;
getElementFromId(pedId).addAnimation(animGroup, animId);
function forcePedAnimation(pedId, animSlot) {
let animationData = getAnimationData(animSlot);
if(getElementFromId(pedId) == localPlayer) {
inAnimation = true;
setLocalPlayerControlState(false, false);
localPlayer.collisionsEnabled = false;
}
}
if(getGame() < VRR_GAME_GTA_IV) {
getElementFromId(pedId).position = getElementFromId(pedId).position;
getElementFromId(pedId).addAnimation(animationData.groupId, animationData.animId);
if(getElementFromId(pedId) == localPlayer) {
inAnimation = true;
setLocalPlayerControlState(false, false);
localPlayer.collisionsEnabled = false;
}
} else {
natives.requestAnims(animationData.groupId);
natives.taskPlayAnimNonInterruptable(getElementFromId(pedId), animationData.groupId, animationData.animId, animationData.animSpeed, boolToInt(animationData.infiniteLoop), boolToInt(animationData.infiniteLoopNoMovement), boolToInt(animationData.dontReturnToStartCoords), boolToInt(animationData.freezeLastFrame), -1);
}
}
// ===========================================================================
function makePedStopAnimation(pedId) {
if(getElementFromId(pedId) == null) {
return false;
}
if(getElementFromId(pedId) == null) {
return false;
}
if(getGame() != VRR_GAME_GTA_IV) {
if(getGame() == VRR_GAME_GTA_VC || getGame() == VRR_GAME_GTA_SA) {
getElementFromId(pedId).clearAnimations();
} else {
getElementFromId(pedId).clearObjective();
}
}
if(getGame() != VRR_GAME_GTA_IV) {
if(getGame() == VRR_GAME_GTA_VC || getGame() == VRR_GAME_GTA_SA) {
getElementFromId(pedId).clearAnimations();
} else {
getElementFromId(pedId).clearObjective();
}
}
if(getElementFromId(pedId) == localPlayer) {
if(getGame() != VRR_GAME_GTA_IV) {
localPlayer.collisionsEnabled = true;
}
setLocalPlayerControlState(true, false);
}
if(getElementFromId(pedId) == localPlayer) {
if(getGame() != VRR_GAME_GTA_IV) {
localPlayer.collisionsEnabled = true;
}
setLocalPlayerControlState(true, false);
}
}
// ===========================================================================
/**
* @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];
}
// ===========================================================================

View File

@@ -8,85 +8,84 @@
// ===========================================================================
class BusinessData {
constructor(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems) {
this.index = -1;
this.businessId = businessId;
this.name = name;
this.entrancePosition = entrancePosition;
this.blipModel = blipModel;
this.pickupModel = pickupModel;
this.hasInterior = hasInterior;
this.hasItems = hasItems;
this.blipId = -1;
}
constructor(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems) {
this.index = -1;
this.businessId = businessId;
this.name = name;
this.entrancePosition = entrancePosition;
this.blipModel = blipModel;
this.pickupModel = pickupModel;
this.hasInterior = hasInterior;
this.hasItems = hasItems;
this.blipId = -1;
this.labelInfoType = 0;
}
}
// ===========================================================================
function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems) {
logToConsole(LOG_DEBUG, `[VRR.Business] Received business ${businessId} (${name}) from server`);
if(getGame() == VRR_GAME_GTA_IV) {
if(getBusinessData(businessId) != false) {
let businessData = getBusinessData(businessId);
businessData.name = name;
businessData.entrancePosition = entrancePosition;
businessData.blipModel = blipModel;
businessData.pickupModel = pickupModel;
businessData.hasInterior = hasInterior;
businessData.hasItems = hasItems;
logToConsole(LOG_DEBUG, `[VRR.Business] Received business ${businessId} (${name}) from server`);
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId} already exists. Checking blip ...`);
if(blipModel == -1) {
if(businessData.blipId != -1) {
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been removed by the server`);
natives.removeBlipAndClearIndex(getBusinessData(businessId).blipId);
businessData.blipId = -1;
//businesses.splice(businessData.index, 1);
//setAllBusinessDataIndexes();
} else {
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip is unchanged`);
}
} else {
if(businessData.blipId != -1) {
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been changed by the server`);
natives.setBlipCoordinates(businessData.blipId, businessData.entrancePosition);
natives.changeBlipSprite(businessData.blipId, businessData.blipModel);
natives.setBlipMarkerLongDistance(businessData.blipId, false);
natives.setBlipAsShortRange(tempBusinessData.blipId, true);
natives.changeBlipNameFromAscii(businessData.blipId, `${businessData.name.substr(0, 24)}${(businessData.name.length > 24) ? " ...": ""}`);
} else {
let blipId = natives.addBlipForCoord(entrancePosition);
if(blipId) {
businessData.blipId = blipId;
natives.changeBlipSprite(businessData.blipId, businessData.blipModel);
natives.setBlipMarkerLongDistance(businessData.blipId, false);
natives.setBlipAsShortRange(tempBusinessData.blipId, true);
natives.changeBlipNameFromAscii(businessData.blipId, `${businessData.name.substr(0, 24)}${(businessData.name.length > 24) ? " ...": ""}`);
}
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
}
}
} else {
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId} doesn't exist. Adding ...`);
let tempBusinessData = new BusinessData(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems);
if(blipModel != -1) {
let blipId = natives.addBlipForCoord(entrancePosition);
if(blipId) {
tempBusinessData.blipId = blipId;
natives.changeBlipSprite(tempBusinessData.blipId, blipModel);
natives.setBlipMarkerLongDistance(tempBusinessData.blipId, false);
natives.setBlipAsShortRange(tempBusinessData.blipId, true);
natives.changeBlipNameFromAscii(tempBusinessData.blipId, `${name.substr(0, 24)}${(name.length > 24) ? " ...": ""}`);
}
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
} else {
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId} has no blip.`);
}
businesses.push(tempBusinessData);
setAllBusinessDataIndexes();
}
}
if(getGame() == VRR_GAME_GTA_IV) {
if(getBusinessData(businessId) != false) {
let businessData = getBusinessData(businessId);
businessData.name = name;
businessData.entrancePosition = entrancePosition;
businessData.blipModel = blipModel;
businessData.pickupModel = pickupModel;
businessData.hasInterior = hasInterior;
businessData.hasItems = hasItems;
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId} already exists. Checking blip ...`);
if(blipModel == -1) {
if(businessData.blipId != -1) {
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been removed by the server`);
if(getGame() == VRR_GAME_GTA_IV) {
natives.removeBlipAndClearIndex(getBusinessData(businessId).blipId);
} else {
destroyElement(getElementFromId(blipId));
}
businessData.blipId = -1;
//businesses.splice(businessData.index, 1);
//setAllBusinessDataIndexes();
} else {
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip is unchanged`);
}
} else {
if(businessData.blipId != -1) {
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been changed by the server`);
if(getGame() == VRR_GAME_GTA_IV) {
natives.setBlipCoordinates(businessData.blipId, businessData.entrancePosition);
natives.changeBlipSprite(businessData.blipId, businessData.blipModel);
natives.setBlipMarkerLongDistance(businessData.blipId, false);
natives.setBlipAsShortRange(tempBusinessData.blipId, true);
natives.changeBlipNameFromAscii(businessData.blipId, `${businessData.name.substr(0, 24)}${(businessData.name.length > 24) ? " ...": ""}`);
}
} else {
let blipId = createGameBlip(tempBusinessData.blipModel, tempBusinessData.entrancePosition, tempBusinessData.name);
if(blipId != -1) {
tempBusinessData.blipId = blipId;
}
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
}
}
} else {
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId} doesn't exist. Adding ...`);
let tempBusinessData = new BusinessData(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems);
if(blipModel != -1) {
let blipId = createGameBlip(tempBusinessData.blipModel, tempBusinessData.entrancePosition, tempBusinessData.name);
if(blipId != -1) {
tempBusinessData.blipId = blipId;
}
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
} else {
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId} has no blip.`);
}
getServerData().businesses.push(tempBusinessData);
setAllBusinessDataIndexes();
}
}
}
// ===========================================================================
@@ -96,23 +95,26 @@ function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel
* @return {BusinessData} The business's data (class instance)
*/
function getBusinessData(businessId) {
//let tempBusinessData = businesses.find((b) => b.businessId == businessId);
//return (typeof tempBusinessData != "undefined") ? tempBusinessData[0] : false;
for(let i in businesses) {
if(businesses[i].businessId == businessId) {
return businesses[i];
}
}
//let tempBusinessData = businesses.find((b) => b.businessId == businessId);
//return (typeof tempBusinessData != "undefined") ? tempBusinessData[0] : false;
return false;
let businesses = getServerData().businesses;
for(let i in businesses) {
if(businesses[i].businessId == businessId) {
return businesses[i];
}
}
return false;
}
// ===========================================================================
function setAllBusinessDataIndexes() {
for(let i in businesses) {
businesses[i].index = i;
}
for(let i in getServerData().businesses) {
getServerData().businesses[i].index = i;
}
}
// ===========================================================================

View File

@@ -16,95 +16,156 @@ let maxChatBoxHistory = 500;
let scrollAmount = 1;
let maxChatBoxLines = 6;
let chatAutoHideDelay = 0;
let chatLastUse = 0;
let scrollUpKey = false;
let scrollDownKey = false;
// ===========================================================================
function initChatBoxScript() {
logToConsole(LOG_DEBUG, "[VRR.ChatBox]: Initializing chatbox script ...");
scrollUpKey = getKeyIdFromParams("pageup");
scrollDownKey = getKeyIdFromParams("pagedown");
bindChatBoxKeys();
logToConsole(LOG_DEBUG, "[VRR.ChatBox]: Chatbox script initialized!");
logToConsole(LOG_DEBUG, "[VRR.ChatBox]: Initializing chatbox script ...");
scrollUpKey = getKeyIdFromParams("pageup");
scrollDownKey = getKeyIdFromParams("pagedown");
bindChatBoxKeys();
logToConsole(LOG_DEBUG, "[VRR.ChatBox]: Chatbox script initialized!");
}
// ===========================================================================
function bindChatBoxKeys() {
bindKey(toInteger(scrollUpKey), KEYSTATE_DOWN, chatBoxScrollUp);
bindKey(toInteger(scrollDownKey), KEYSTATE_DOWN, chatBoxScrollDown);
bindKey(toInteger(scrollUpKey), KEYSTATE_DOWN, chatBoxScrollUp);
bindKey(toInteger(scrollDownKey), KEYSTATE_DOWN, chatBoxScrollDown);
}
// ===========================================================================
function unBindChatBoxKeys() {
unbindKey(toInteger(scrollUpKey));
unbindKey(toInteger(scrollDownKey));
unbindKey(toInteger(scrollUpKey));
unbindKey(toInteger(scrollDownKey));
}
// ===========================================================================
function receiveChatBoxMessageFromServer(messageString, colour) {
logToConsole(LOG_DEBUG, `[VRR.ChatBox]: Received chatbox message from server: ${messageString}`);
let colouredString = replaceColoursInMessage(messageString);
logToConsole(LOG_DEBUG, `[VRR.ChatBox]: Received chatbox message from server: ${messageString}`);
if(bottomMessageIndex >= chatBoxHistory.length-1) {
message(colouredString, colour);
bottomMessageIndex = chatBoxHistory.length-1;
}
addToChatBoxHistory(colouredString, colour);
// Just in case it's hidden by auto hide
//setChatWindowEnabled(true);
let colouredString = replaceColoursInMessage(messageString);
logToConsole(LOG_DEBUG, `[VRR.ChatBox]: Changed colours in string: ${colouredString}`);
addToChatBoxHistory(colouredString, colour);
//if(bottomMessageIndex >= chatBoxHistory.length-1) {
message(colouredString, colour);
bottomMessageIndex = chatBoxHistory.length-1;
//}
chatLastUse = getCurrentUnixTimestamp();
}
// ===========================================================================
function setChatScrollLines(amount) {
scrollAmount = amount;
scrollAmount = amount;
}
// ===========================================================================
function setChatAutoHideDelay(delay) {
chatAutoHideDelay = delay*1000;
}
// ===========================================================================
function addToChatBoxHistory(messageString, colour) {
chatBoxHistory.push([messageString, colour]);
chatBoxHistory.push([messageString, colour]);
}
// ===========================================================================
function chatBoxScrollUp() {
if(bottomMessageIndex > maxChatBoxLines) {
bottomMessageIndex = bottomMessageIndex-scrollAmount;
updateChatBox();
}
if(bottomMessageIndex > maxChatBoxLines) {
bottomMessageIndex = bottomMessageIndex-scrollAmount;
updateChatBox();
}
}
// ===========================================================================
function chatBoxScrollDown() {
if(bottomMessageIndex < chatBoxHistory.length-1) {
bottomMessageIndex = bottomMessageIndex+scrollAmount;
updateChatBox();
}
if(bottomMessageIndex < chatBoxHistory.length-1) {
bottomMessageIndex = bottomMessageIndex+scrollAmount;
updateChatBox();
}
}
// ===========================================================================
function clearChatBox() {
for(let i = 0 ; i <= maxChatBoxLines ; i++) {
message("", COLOUR_WHITE);
}
for(let i = 0 ; i <= maxChatBoxLines ; i++) {
message("", COLOUR_WHITE);
}
}
// ===========================================================================
function updateChatBox() {
clearChatBox();
for(let i = bottomMessageIndex-maxChatBoxLines ; i <= bottomMessageIndex ; i++) {
if(typeof chatBoxHistory[i] != "undefined") {
message(chatBoxHistory[i][0], chatBoxHistory[i][1]);
} else {
message("", COLOUR_WHITE);
}
}
clearChatBox();
for(let i = bottomMessageIndex-maxChatBoxLines ; i <= bottomMessageIndex ; i++) {
if(typeof chatBoxHistory[i] != "undefined") {
message(chatBoxHistory[i][0], chatBoxHistory[i][1]);
} else {
message("", COLOUR_WHITE);
}
}
chatLastUse = getCurrentUnixTimestamp();
}
// ===========================================================================
function processMouseWheelForChatBox(mouseId, deltaCoordinates, flipped) {
// There isn't a way to detect whether chat input is active, but mouse cursor is forced shown when typing so ¯\_(ツ)_/¯
if(!gui.cursorEnabled) {
return false;
}
if(!flipped) {
if(deltaCoordinates.y > 0) {
chatBoxScrollUp();
} else {
chatBoxScrollDown();
}
} else {
if(deltaCoordinates.y > 0) {
chatBoxScrollDown();
} else {
chatBoxScrollUp();
}
}
}
// ===========================================================================
function checkChatAutoHide() {
return false;
// Make sure chat input isn't active
if(gui.cursorEnabled) {
return false;
}
// Don't process auto-hide if it's disabled
if(chatAutoHideDelay == 0) {
return false;
}
if(getCurrentUnixTimestamp()-chatLastUse >= chatAutoHideDelay) {
setChatWindowEnabled(false);
}
}
// ===========================================================================

View File

@@ -8,58 +8,58 @@
// ===========================================================================
function getCustomImage(imageName) {
let contentResource = findResourceByName(getGameConfig().extraContentResource[getGame()]);
if(contentResource != null) {
if(contentResource.isStarted) {
let image = contentResource.exports.getCustomImage(imageName);
if(image != null) {
return image;
}
}
}
return false;
let contentResource = findResourceByName(getGameConfig().extraContentResource[getGame()]);
if(contentResource != null) {
if(contentResource.isStarted) {
let image = contentResource.exports.getCustomImage(imageName);
if(image != null) {
return image;
}
}
}
return false;
}
// ===========================================================================
function getCustomFont(fontName) {
let contentResource = findResourceByName(getGameConfig().extraContentResource[getGame()]);
if(contentResource != null) {
if(contentResource.isStarted) {
let font = contentResource.exports.getCustomFont(fontName);
if(font != null) {
return font;
}
}
}
return false;
let contentResource = findResourceByName(getGameConfig().extraContentResource[getGame()]);
if(contentResource != null) {
if(contentResource.isStarted) {
let font = contentResource.exports.getCustomFont(fontName);
if(font != null) {
return font;
}
}
}
return false;
}
// ===========================================================================
function getCustomAudio(audioName) {
let contentResource = findResourceByName(getGameConfig().extraContentResource[getGame()]);
if(contentResource != null) {
if(contentResource.isStarted) {
let audioFile = contentResource.exports.getCustomAudio(audioName);
if(audioFile != null) {
return audioFile;
}
}
}
return false;
let contentResource = findResourceByName(getGameConfig().extraContentResource[getGame()]);
if(contentResource != null) {
if(contentResource.isStarted) {
let audioFile = contentResource.exports.getCustomAudio(audioName);
if(audioFile != null) {
return audioFile;
}
}
}
return false;
}
// ===========================================================================
function playCustomAudio(audioName, volume = 0.5, loop = false) {
let contentResource = findResourceByName(getGameConfig().extraContentResource[getGame()]);
if(contentResource != null) {
if(contentResource.isStarted) {
contentResource.exports.playCustomAudio(audioName, volume, loop);
}
}
return false;
let contentResource = findResourceByName(getGameConfig().extraContentResource[getGame()]);
if(contentResource != null) {
if(contentResource.isStarted) {
contentResource.exports.playCustomAudio(audioName, volume, loop);
}
}
return false;
}
// ===========================================================================

View File

@@ -8,227 +8,231 @@
// ===========================================================================
function initEventScript() {
logToConsole(LOG_DEBUG, "[VRR.Event]: Initializing event script ...");
addCustomEvents();
addAllEventHandlers();
logToConsole(LOG_DEBUG, "[VRR.Event]: Event script initialized!");
logToConsole(LOG_DEBUG, "[VRR.Event]: Initializing event script ...");
addCustomEvents();
addAllEventHandlers();
logToConsole(LOG_DEBUG, "[VRR.Event]: Event script initialized!");
}
// ===========================================================================
function addCustomEvents() {
addEvent("OnLocalPlayerEnterSphere", 1);
addEvent("OnLocalPlayerExitSphere", 1);
addEvent("OnLocalPlayerEnteredVehicle", 1);
addEvent("OnLocalPlayerExitedVehicle", 1);
addEvent("OnLocalPlayerSwitchWeapon", 2);
addEvent("OnLocalPlayerEnterSphere", 1);
addEvent("OnLocalPlayerExitSphere", 1);
addEvent("OnLocalPlayerEnteredVehicle", 1);
addEvent("OnLocalPlayerExitedVehicle", 1);
addEvent("OnLocalPlayerSwitchWeapon", 2);
}
// ===========================================================================
function addAllEventHandlers() {
bindEventHandler("OnResourceStart", thisResource, onResourceStart);
bindEventHandler("OnResourceReady", thisResource, onResourceReady);
bindEventHandler("OnResourceStop", thisResource, onResourceStop);
bindEventHandler("OnResourceStart", thisResource, onResourceStart);
bindEventHandler("OnResourceReady", thisResource, onResourceReady);
bindEventHandler("OnResourceStop", thisResource, onResourceStop);
addEventHandler("OnProcess", onProcess);
addEventHandler("OnKeyUp", onKeyUp);
addEventHandler("OnDrawnHUD", onDrawnHUD);
addEventHandler("OnProcess", onProcess);
addEventHandler("OnKeyUp", onKeyUp);
addEventHandler("OnDrawnHUD", onDrawnHUD);
addEventHandler("OnPedWasted", onPedWasted);
addEventHandler("OnPedWasted", onPedWasted);
addEventHandler("OnElementStreamIn", onElementStreamIn);
addEventHandler("OnElementStreamIn", onElementStreamIn);
addEventHandler("OnLocalPlayerEnteredVehicle", onLocalPlayerEnteredVehicle);
addEventHandler("OnLocalPlayerExitedVehicle", onLocalPlayerExitedVehicle);
addEventHandler("OnLocalPlayerEnterSphere", onLocalPlayerEnterSphere);
addEventHandler("OnLocalPlayerExitSphere", onLocalPlayerExitSphere);
addEventHandler("OnLocalPlayerSwitchWeapon", onLocalPlayerSwitchWeapon);
addEventHandler("OnLocalPlayerEnteredVehicle", onLocalPlayerEnteredVehicle);
addEventHandler("OnLocalPlayerExitedVehicle", onLocalPlayerExitedVehicle);
addEventHandler("OnLocalPlayerEnterSphere", onLocalPlayerEnterSphere);
addEventHandler("OnLocalPlayerExitSphere", onLocalPlayerExitSphere);
addEventHandler("OnLocalPlayerSwitchWeapon", onLocalPlayerSwitchWeapon);
addEventHandler("OnPedInflictDamage", onPedInflictDamage);
addEventHandler("OnPedInflictDamage", onPedInflictDamage);
addEventHandler("OnLostFocus", onLostFocus);
addEventHandler("OnFocus", onFocus);
addEventHandler("OnLostFocus", onLostFocus);
addEventHandler("OnFocus", onFocus);
addEventHandler("OnCameraProcess", onCameraProcess);
addEventHandler("OnCameraProcess", onCameraProcess);
addEventHandler("OnMouseWheel", onMouseWheel);
}
// ===========================================================================
function onResourceStart(event, resource) {
sendResourceStartedSignalToServer();
setUpInitialGame();
garbageCollectorInterval = setInterval(collectAllGarbage, 1000*60);
sendResourceStartedSignalToServer();
setUpInitialGame();
garbageCollectorInterval = setInterval(collectAllGarbage, 1000*60);
}
// ===========================================================================
function onResourceStop(event, resource) {
sendResourceStoppedSignalToServer();
sendResourceStoppedSignalToServer();
}
// ===========================================================================
function onResourceReady(event, resource) {
sendResourceReadySignalToServer();
sendResourceReadySignalToServer();
}
// ===========================================================================
function onProcess(event, deltaTime) {
if(localPlayer == null) {
return false;
}
if(localPlayer == null) {
return false;
}
if(!isSpawned) {
return false;
}
if(!isSpawned) {
return false;
}
processSync();
processLocalPlayerControlState();
processLocalPlayerVehicleControlState();
processLocalPlayerSphereEntryExitHandling();
processLocalPlayerVehicleEntryExitHandling();
processJobRouteSphere();
forceLocalPlayerEquippedWeaponItem();
processWantedLevelReset();
processGameSpecifics();
processNearbyPickups();
processVehiclePurchasing();
//processVehicleFires();
processSync();
processLocalPlayerControlState();
processLocalPlayerVehicleControlState();
processLocalPlayerSphereEntryExitHandling();
processLocalPlayerVehicleEntryExitHandling();
processJobRouteSphere();
forceLocalPlayerEquippedWeaponItem();
processWantedLevelReset();
processGameSpecifics();
processNearbyPickups();
processVehiclePurchasing();
//checkChatBoxAutoHide(); // Will be uncommented on 1.4.0 GTAC update
//processVehicleFires();
}
// ===========================================================================
function onKeyUp(event, keyCode, scanCode, keyModifiers) {
processSkinSelectKeyPress(keyCode);
//processKeyDuringAnimation();
processGUIKeyPress(keyCode);
processToggleGUIKeyPress(keyCode);
processSkinSelectKeyPress(keyCode);
//processKeyDuringAnimation();
processGUIKeyPress(keyCode);
processToggleGUIKeyPress(keyCode);
}
// ===========================================================================
function onDrawnHUD(event) {
if(!renderHUD) {
return false;
}
if(!renderHUD) {
return false;
}
if(localPlayer == null) {
return false;
}
if(localPlayer == null) {
return false;
}
processSmallGameMessageRendering();
processScoreBoardRendering();
processLabelRendering();
processLogoRendering();
processItemActionRendering();
processSkinSelectRendering();
processNameTagRendering();
processInteriorLightsRendering();
processSmallGameMessageRendering();
processScoreBoardRendering();
processLabelRendering();
processLogoRendering();
processItemActionRendering();
processSkinSelectRendering();
processNameTagRendering();
processInteriorLightsRendering();
}
// ===========================================================================
function onPedWasted(event, wastedPed, killerPed, weapon, pedPiece) {
logToConsole(LOG_DEBUG, `[VRR.Event] Ped ${wastedPed.name} died`);
wastedPed.clearWeapons();
logToConsole(LOG_DEBUG, `[VRR.Event] Ped ${wastedPed.name} died`);
wastedPed.clearWeapons();
}
// ===========================================================================
function onElementStreamIn(event, element) {
syncElementProperties(element);
syncElementProperties(element);
}
// ===========================================================================
function onLocalPlayerExitedVehicle(event, vehicle, seat) {
logToConsole(LOG_DEBUG, `[VRR.Event] Local player exited vehicle`);
sendNetworkEventToServer("vrr.onPlayerExitVehicle", getVehicleForNetworkEvent(vehicle), seat);
logToConsole(LOG_DEBUG, `[VRR.Event] Local player exited vehicle`);
sendNetworkEventToServer("vrr.onPlayerExitVehicle", getVehicleForNetworkEvent(vehicle), seat);
if(inVehicleSeat) {
parkedVehiclePosition = false;
parkedVehicleHeading = false;
}
if(inVehicleSeat) {
parkedVehiclePosition = false;
parkedVehicleHeading = false;
}
}
// ===========================================================================
function onLocalPlayerEnteredVehicle(event, vehicle, seat) {
logToConsole(LOG_DEBUG, `[VRR.Event] Local player entered vehicle`);
logToConsole(LOG_DEBUG, `[VRR.Event] Local player entered vehicle`);
sendNetworkEventToServer("vrr.onPlayerEnterVehicle", getVehicleForNetworkEvent(vehicle), seat);
sendNetworkEventToServer("vrr.onPlayerEnterVehicle", getVehicleForNetworkEvent(vehicle), seat);
if(inVehicleSeat == 0) {
inVehicle.engine = false;
if(!inVehicle.engine) {
parkedVehiclePosition = inVehicle.position;
parkedVehicleHeading = inVehicle.heading;
}
}
if(inVehicleSeat == 0) {
inVehicle.engine = false;
if(!inVehicle.engine) {
parkedVehiclePosition = inVehicle.position;
parkedVehicleHeading = inVehicle.heading;
}
}
}
// ===========================================================================
function onPedInflictDamage(event, damagedEntity, damagerEntity, weaponId, healthLoss, pedPiece) {
//let damagerEntityString = (!isNull(damagedEntity)) ? `${damagerEntity.name} (${damagerEntity.name}, ${damagerEntity.type} - ${typeof damagerEntity})` : `Unknown ped`;
//let damagedEntityString = (!isNull(damagedEntity)) ? `${damagedEntity.name} (${damagedEntity.name}, ${damagedEntity.type} - ${typeof damagedEntity})` : `Unknown ped`;
//logToConsole(LOG_DEBUG, `[VRR.Event] ${damagerEntityString} damaged ${damagedEntityString}'s '${pedPiece} with weapon ${weaponId}`);
if(!isNull(damagedEntity) && !isNull(damagerEntity)) {
if(damagedEntity.isType(ELEMENT_PLAYER)) {
if(damagedEntity == localPlayer) {
//if(!weaponDamageEnabled[damagerEntity.name]) {
event.preventDefault();
sendNetworkEventToServer("vrr.weaponDamage", damagerEntity.name, weaponId, pedPiece, healthLoss);
//}
}
}
}
//let damagerEntityString = (!isNull(damagedEntity)) ? `${damagerEntity.name} (${damagerEntity.name}, ${damagerEntity.type} - ${typeof damagerEntity})` : `Unknown ped`;
//let damagedEntityString = (!isNull(damagedEntity)) ? `${damagedEntity.name} (${damagedEntity.name}, ${damagedEntity.type} - ${typeof damagedEntity})` : `Unknown ped`;
//logToConsole(LOG_DEBUG, `[VRR.Event] ${damagerEntityString} damaged ${damagedEntityString}'s '${pedPiece} with weapon ${weaponId}`);
if(!isNull(damagedEntity) && !isNull(damagerEntity)) {
if(damagedEntity.isType(ELEMENT_PLAYER)) {
if(damagedEntity == localPlayer) {
//if(!weaponDamageEnabled[damagerEntity.name]) {
event.preventDefault();
sendNetworkEventToServer("vrr.weaponDamage", damagerEntity.name, weaponId, pedPiece, healthLoss);
//}
}
}
}
}
// ===========================================================================
function onLocalPlayerEnterSphere(event, sphere) {
logToConsole(LOG_DEBUG, `[VRR.Event] Local player entered sphere`);
if(sphere == jobRouteLocationSphere) {
enteredJobRouteSphere();
}
logToConsole(LOG_DEBUG, `[VRR.Event] Local player entered sphere`);
if(sphere == jobRouteLocationSphere) {
enteredJobRouteSphere();
}
}
// ===========================================================================
function onLocalPlayerExitSphere(event, sphere) {
logToConsole(LOG_DEBUG, `[VRR.Event] Local player exited sphere`);
logToConsole(LOG_DEBUG, `[VRR.Event] Local player exited sphere`);
}
// ===========================================================================
function onLostFocus(event) {
processLostFocusAFK();
processLostFocusAFK();
}
// ===========================================================================
function onFocus(event) {
processFocusAFK();
processFocusAFK();
}
// ===========================================================================
function onLocalPlayerSwitchWeapon(oldWeapon, newWeapon) {
}
// ===========================================================================
function onCameraProcess(event) {
}
// ===========================================================================
function onChatOutput(event, messageText, colour) {
//event.preventDefault();
//receiveChatBoxMessageFromServer(messageText, colour);
function onMouseWheel(event, mouseId, deltaCoordinates, flipped) {
processMouseWheelForChatBox(mouseId, deltaCoordinates, flipped);
}
// ===========================================================================

View File

@@ -29,27 +29,6 @@ let textInputAlpha = 180;
let guiReady = false;
let guiSubmitKey = false;
let guiLeftKey = false;
let guiRightKey = false;
let guiUpKey = false;
let guiDownKey = false;
// ===========================================================================
let placesOfOrigin = [
"Liberty City",
"Vice City",
"Los Santos",
"San Fierro",
"Las Venturas",
"San Andreas",
"Blaine County",
"Red County",
"Bone County",
"Other",
];
// ===========================================================================
let characterData = [];
@@ -104,7 +83,7 @@ function closeAllWindows() {
listDialog.window.shown = false;
resetPassword.window.shown = false;
passwordChange.window.shown = false;
mexui.setInput(false);
mexui.focusedControl = false;
@@ -185,23 +164,23 @@ addNetworkEventHandler("vrr.switchCharacterSelect", function(firstName, lastName
// ===========================================================================
addNetworkEventHandler("vrr.showError", function(errorMessage, errorTitle) {
addNetworkEventHandler("vrr.showError", function(errorMessage, errorTitle, buttonText) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Received request from server to show error window`);
showError(errorMessage, errorTitle);
showError(errorMessage, errorTitle, buttonText);
});
// ===========================================================================
addNetworkEventHandler("vrr.showPrompt", function(promptMessage, promptTitle) {
addNetworkEventHandler("vrr.showPrompt", function(promptMessage, promptTitle, yesButtonText, noButtonText) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Received request from server to show prompt window`);
showYesNoPromptGUI(promptMessage, promptTitle);
showYesNoPromptGUI(promptMessage, promptTitle, yesButtonText, noButtonText);
});
// ===========================================================================
addNetworkEventHandler("vrr.showInfo", function(infoMessage) {
addNetworkEventHandler("vrr.showInfo", function(infoMessage, buttonText) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Received request from server to show info dialog`);
showInfo(infoMessage);
showInfo(infoMessage, buttonText);
});
// ===========================================================================
@@ -284,37 +263,50 @@ addNetworkEventHandler("vrr.guiInit", function() {
// ===========================================================================
function hideAllGUI() {
closeAllWindows();
setChatWindowEnabled(true);
closeAllWindows();
setChatWindowEnabled(true);
guiSubmitKey = false;
}
// ===========================================================================
function processGUIKeyPress(keyCode) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Processing key press: ${keyCode}`);
if(!isAnyGUIActive()) {
logToConsole(LOG_DEBUG, `[VRR.GUI] GUI is not active. Cancelling keypress processing.`);
return false;
}
if(keyCode == SDLK_RETURN || keyCode == SDLK_RETURN2) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Key press is submit (${guiSubmitKey})`);
if(guiSubmitKey != false) {
guiSubmitKey();
logToConsole(LOG_DEBUG, `[VRR.GUI] Calling submit key function`);
guiSubmitKey.call();
}
} else if(keyCode == getKeyIdFromParams("left") || keyCode == getKeyIdFromParams("a")) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Key press is left (${guiLeftKey})`);
if(guiLeftKey != false) {
guiLeftKey();
logToConsole(LOG_DEBUG, `[VRR.GUI] Calling left key function`);
guiLeftKey.call();
}
} else if(keyCode == getKeyIdFromParams("right") || keyCode == getKeyIdFromParams("d")) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Key press is right (${guiRightKey})`);
if(guiRightKey != false) {
guiRightKey();
logToConsole(LOG_DEBUG, `[VRR.GUI] Calling right key function`);
guiRightKey.call();
}
} else if(keyCode == getKeyIdFromParams("down") || keyCode == getKeyIdFromParams("s")) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Key press is down (${guiDownKey})`);
if(guiDownKey != false) {
guiDownKey();
logToConsole(LOG_DEBUG, `[VRR.GUI] Calling down key function`);
guiDownKey.call();
}
} else if(keyCode == getKeyIdFromParams("up") || keyCode == getKeyIdFromParams("w")) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Key press is up (${guiUpKey})`);
if(guiUpKey != false) {
guiUpKey();
logToConsole(LOG_DEBUG, `[VRR.GUI] Calling up key function`);
guiUpKey.call();
}
}
}

View File

@@ -163,6 +163,10 @@ function showCharacterSelectGUI(firstName, lastName, cash, clan, lastPlayed, ski
characterSelect.lastPlayedText.text = `Last Played: ${lastPlayed}`;
characterSelect.skinImage = characterSelect.window.image(310, 32, 100, 90, "files/images/skins/none.png");
characterSelect.window.shown = true;
guiSubmitKey = selectThisCharacter;
guiLeftKey = selectPreviousCharacter;
guiRightKey = selectNextCharacter;
}
// ===========================================================================
@@ -211,6 +215,7 @@ function switchCharacterSelectGUI(firstName, lastName, cash, clan, lastPlayed, s
characterSelect.skinImage = (getGame() == VRR_GAME_GTA_III) ? characterSelect.window.image(310, 32, 100, 90, `files/images/skins/gta3/${getSkinImage(skinId)}.png`) : characterSelect.window.image(310, 32, 100, 90, "files/images/skins/none.png");
characterSelect.window.shown = true;
guiSubmitKey = selectThisCharacter;
guiLeftKey = selectPreviousCharacter;
guiRightKey = selectNextCharacter;

View File

@@ -63,12 +63,14 @@ function initErrorDialogGUI() {
// ===========================================================================
function showErrorGUI(errorMessage, errorTitle) {
function showErrorGUI(errorMessage, errorTitle, buttonText) {
closeAllWindows();
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing error window. Error: ${errorTitle} - ${errorMessage}`);
setChatWindowEnabled(false);
mexui.setInput(true);
errorDialog.messageLabel.text = errorMessage;
errorDialog.okayButton.text = buttonText;
errprDialog.window.title = errorTitle;
errorDialog.window.shown = true;
}

View File

@@ -70,11 +70,13 @@ function closeInfoDialog() {
// ===========================================================================
function showInfo(infoMessage, infoTitle) {
function showInfo(infoMessage, infoTitle, buttonText) {
closeAllWindows();
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing info dialog window. Info: ${infoTitle} - ${infoMessage}`);
mexui.setInput(true);
infoDialog.messageLabel.text = infoMessage;
infoDialog.okayButton.text = buttonText;
infoDialog.window.title = infoTitle;
infoDialog.window.shown = true;
}

View File

@@ -20,6 +20,28 @@ let login = {
// ===========================================================================
let loginHTML =
`<html>
<head>
<title>Connected RP: Login</title>
<style type="text/css" rel="stylesheet">
.input-box
{
font-family: "Roboto";
font-size: 14px;
border-style: solid;
border-colour: #0066AA;
border-radius: 2px;
color: #0066AA;
};
</style>
</head>
<body>
</body>
</html>`;
// ===========================================================================
function initLoginGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating login GUI ...`);
login.window = mexui.window(game.width/2-150, game.height/2-135, 300, 275, 'LOGIN', {
@@ -164,9 +186,10 @@ function loginSuccess() {
// ===========================================================================
function switchToPasswordResetGUI() {
closeAllWindows();
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing password reset dialog window`);
showResetPasswordGUI();
//closeAllWindows();
//logToConsole(LOG_DEBUG, `[VRR.GUI] Showing password reset dialog window`);
//showResetPasswordGUI();
sendNetworkEventToServer("vrr.checkResetPassword", "");
return false;
}

View File

@@ -40,7 +40,7 @@ function initRegisterGUI() {
register.window.titleBarIconSize = toVector2(0,0);
register.window.titleBarHeight = 0;
register.window.image(5, 20, 290, 80, mainLogoPath, {
register.window.image(5, 20, 290, 100, mainLogoPath, {
focused: {
borderColour: toColour(0, 0, 0, 0),
},

View File

@@ -48,7 +48,7 @@ function initYesNoDialogGUI() {
},
});
yesNoDialog.yesButton = yesNoDialog.window.button(5, 100, 197, 25, 'YES', {
yesNoDialog.yesButton = yesNoDialog.window.button(5, 105, 193, 30, 'YES', {
main: {
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], 255),
@@ -61,7 +61,7 @@ function initYesNoDialogGUI() {
},
}, yesNoDialogAnswerYes);
yesNoDialog.noButton = yesNoDialog.window.button(202, 105, 197, 25, 'NO', {
yesNoDialog.noButton = yesNoDialog.window.button(203, 105, 192, 30, 'NO', {
main: {
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], 255),
@@ -78,11 +78,14 @@ function initYesNoDialogGUI() {
// ===========================================================================
function showYesNoPromptGUI(promptMessage, promptTitle) {
function showYesNoPromptGUI(promptMessage, promptTitle, yesButtonText, noButtonText) {
closeAllWindows();
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing prompt window. Prompt: ${promptTitle} - ${promptMessage}`);
mexui.setInput(true);
yesNoDialog.messageLabel.text = promptMessage;
yesNoDialog.yesButton.text = yesButtonText;
yesNoDialog.noButton.text = noButtonText;
yesNoDialog.window.title = promptTitle;
yesNoDialog.window.shown = true;
}

View File

@@ -8,56 +8,77 @@
// ===========================================================================
class HouseData {
constructor(houseId, entrancePosition, blipModel, pickupModel, hasInterior) {
this.index = -1;
this.houseId = houseId;
this.entrancePosition = entrancePosition;
this.blipModel = blipModel;
this.pickupModel = pickupModel;
this.hasInterior = hasInterior;
this.blipId = -1;
}
constructor(houseId, entrancePosition, blipModel, pickupModel, hasInterior) {
this.index = -1;
this.houseId = houseId;
this.entrancePosition = entrancePosition;
this.blipModel = blipModel;
this.pickupModel = pickupModel;
this.hasInterior = hasInterior;
this.blipId = -1;
}
}
// ===========================================================================
function receiveHouseFromServer(houseId, entrancePosition, blipModel, pickupModel, hasInterior) {
if(getGame() == VRR_GAME_GTA_IV) {
if(getHouseData(houseId) != false) {
if(blipModel == -1) {
natives.removeBlipAndClearIndex(getHouseData(houseId).blipId);
getHouseData(houseId).blipId = -1;
//houses.splice(getHouseData(houseId).index, 1);
//setAllHouseDataIndexes();
} else {
if(getHouseData(houseId).blipId != -1) {
natives.setBlipCoordinates(getHouseData(houseId).blipId, getHouseData(houseId).entrancePosition);
natives.changeBlipSprite(getHouseData(houseId).blipId, getHouseData(houseId).blipModel);
//natives.changeBlipNameFromAscii(getHouseData(houseId).blipId, `${name.substr(0, 24)}${(name.length > 24) ? " ...": ""}`);
} else {
let blipId = natives.addBlipForCoord(entrancePosition);
if(blipId) {
getHouseData(houseId).blipId = blipId;
natives.changeBlipSprite(blipId, blipModel);
natives.setBlipMarkerLongDistance(blipId, false);
}
}
}
} else {
let tempHouseData = new HouseData(houseId, entrancePosition, blipModel, pickupModel, hasInterior, hasItems);
if(blipModel != -1) {
let blipId = natives.addBlipForCoord(entrancePosition);
if(blipId) {
tempHouseData.blipId = blipId;
natives.changeBlipSprite(blipId, blipModel);
natives.setBlipMarkerLongDistance(blipId, false);
//natives.changeBlipNameFromAscii(blipId, `${name.substr(0, 24)}${(name.length > 24) ? " ...": ""}`);
}
}
houses.push(tempHouseData);
setAllHouseDataIndexes();
}
}
logToConsole(LOG_DEBUG, `[VRR.House] Received house ${houseId} (${name}) from server`);
if(getGame() == VRR_GAME_GTA_IV) {
if(getHouseData(houseId) != false) {
let houseData = getHouseData(houseId);
houseData.entrancePosition = entrancePosition;
houseData.blipModel = blipModel;
houseData.pickupModel = pickupModel;
houseData.hasInterior = hasInterior;
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId} already exists. Checking blip ...`);
if(blipModel == -1) {
if(houseData.blipId != -1) {
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip has been removed by the server`);
if(getGame() == VRR_GAME_GTA_IV) {
natives.removeBlipAndClearIndex(getHouseData(houseId).blipId);
} else {
destroyElement(getElementFromId(blipId));
}
houseData.blipId = -1;
} else {
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip is unchanged`);
}
} else {
if(houseData.blipId != -1) {
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip has been changed by the server`);
if(getGame() == VRR_GAME_GTA_IV) {
natives.setBlipCoordinates(houseData.blipId, houseData.entrancePosition);
natives.changeBlipSprite(houseData.blipId, houseData.blipModel);
natives.setBlipMarkerLongDistance(houseData.blipId, false);
natives.setBlipAsShortRange(houseData.blipId, true);
natives.changeBlipNameFromAscii(houseData.blipId, `${houseData.name.substr(0, 24)}${(houseData.name.length > 24) ? " ...": ""}`);
}
} else {
let blipId = createGameBlip(houseData.blipModel, houseData.entrancePosition, houseData.name);
if(blipId != -1) {
houseData.blipId = blipId;
}
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
}
}
} else {
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId} doesn't exist. Adding ...`);
let tempHouseData = new HouseData(houseId, entrancePosition, blipModel, pickupModel, hasInterior);
if(blipModel != -1) {
let blipId = createGameBlip(tempHouseData.blipModel, tempHouseData.entrancePosition, "House");
if(blipId != -1) {
tempHouseData.blipId = blipId;
}
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
} else {
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId} has no blip.`);
}
getServerData().houses.push(tempHouseData);
setAllHouseDataIndexes();
}
}
}
// ===========================================================================
@@ -66,17 +87,23 @@ function receiveHouseFromServer(houseId, entrancePosition, blipModel, pickupMode
* @param {number} houseId - The ID of the house (initially provided by server)
* @return {HouseData} The house's data (class instance)
*/
function getHouseData(houseId) {
let tempHouseData = houses.find((h) => h.houseId == houseId);
return (typeof tempHouseData != "undefined") ? tempHouseData : false;
function getHouseData(houseId) {
let houses = getServerData().houses;
for(let i in houses) {
if(houses[i].houseId == houseId) {
return houses[i];
}
}
return false;
}
// ===========================================================================
function setAllHouseDataIndexes() {
for(let i in houses) {
houses[i].index = i;
}
for(let i in getServerData().houses) {
getServerData().houses[i].index = i;
}
}
// ===========================================================================

View File

@@ -23,40 +23,40 @@ function initItemScript() {
// ===========================================================================
function processItemActionRendering() {
if(renderItemActionDelay) {
if(itemActionDelayEnabled) {
let finishTime = itemActionDelayStart+itemActionDelayDuration;
if(sdl.ticks >= finishTime) {
itemActionDelayEnabled = false;
itemActionDelayDuration = 0;
itemActionDelayStart = 0;
tellServerItemActionDelayComplete();
} else {
let currentTick = sdl.ticks-itemActionDelayStart;
let progressPercent = Math.ceil(currentTick*100/itemActionDelayDuration);
let width = Math.ceil(getPercentage(itemActionDelaySize.x, progressPercent));
if(renderItemActionDelay) {
if(itemActionDelayEnabled) {
let finishTime = itemActionDelayStart+itemActionDelayDuration;
if(sdl.ticks >= finishTime) {
itemActionDelayEnabled = false;
itemActionDelayDuration = 0;
itemActionDelayStart = 0;
tellServerItemActionDelayComplete();
} else {
let currentTick = sdl.ticks-itemActionDelayStart;
let progressPercent = Math.ceil(currentTick*100/itemActionDelayDuration);
let width = Math.ceil(getPercentage(itemActionDelaySize.x, progressPercent));
let backgroundColour = toColour(0, 0, 0, 255);
graphics.drawRectangle(null, [itemActionDelayPosition.x-(itemActionDelaySize.x/2)-1, itemActionDelayPosition.y-(itemActionDelaySize.y/2)-1], [itemActionDelaySize.x+2, itemActionDelaySize.y+2], backgroundColour, backgroundColour, backgroundColour, backgroundColour);
graphics.drawRectangle(null, [itemActionDelayPosition.x-(itemActionDelaySize.x/2), itemActionDelayPosition.y-(itemActionDelaySize.y/2)-2], [width, itemActionDelaySize.y], COLOUR_LIME, COLOUR_LIME, COLOUR_LIME, COLOUR_LIME);
}
}
}
let backgroundColour = toColour(0, 0, 0, 255);
graphics.drawRectangle(null, [itemActionDelayPosition.x-(itemActionDelaySize.x/2)-1, itemActionDelayPosition.y-(itemActionDelaySize.y/2)-1], [itemActionDelaySize.x+2, itemActionDelaySize.y+2], backgroundColour, backgroundColour, backgroundColour, backgroundColour);
graphics.drawRectangle(null, [itemActionDelayPosition.x-(itemActionDelaySize.x/2), itemActionDelayPosition.y-(itemActionDelaySize.y/2)-2], [width, itemActionDelaySize.y], COLOUR_LIME, COLOUR_LIME, COLOUR_LIME, COLOUR_LIME);
}
}
}
}
// ===========================================================================
function updatePlayerHotBar(activeSlot, itemsArray) {
logToConsole(LOG_DEBUG, `[VRR.Main] Updating hotbar`);
logToConsole(LOG_DEBUG, `[VRR.Main] Updating hotbar`);
}
// ===========================================================================
function showItemActionDelay(duration) {
itemActionDelayDuration = duration;
itemActionDelayStart = sdl.ticks;
itemActionDelayEnabled = true;
logToConsole(LOG_DEBUG, `Item action delay started. Duration: ${itemActionDelayDuration}, Start: ${itemActionDelayStart}, Rendering Enabled: ${renderItemActionDelay}`);
itemActionDelayDuration = duration;
itemActionDelayStart = sdl.ticks;
itemActionDelayEnabled = true;
logToConsole(LOG_DEBUG, `Item action delay started. Duration: ${itemActionDelayDuration}, Start: ${itemActionDelayStart}, Rendering Enabled: ${renderItemActionDelay}`);
}
// ===========================================================================

View File

@@ -14,6 +14,20 @@ let jobRouteLocationSphere = null;
// ===========================================================================
class JobData {
constructor(jobId, name, position, blipModel, pickupModel) {
this.index = -1;
this.jobId = jobId;
this.name = name;
this.position = position;
this.blipModel = blipModel;
this.pickupModel = pickupModel;
this.blipId = -1;
}
}
// ===========================================================================
function initJobScript() {
logToConsole(LOG_DEBUG, "[VRR.Job]: Initializing job script ...");
logToConsole(LOG_DEBUG, "[VRR.Job]: Job script initialized!");
@@ -22,74 +36,161 @@ function initJobScript() {
// ===========================================================================
function setLocalPlayerJobType(tempJobType) {
logToConsole(LOG_DEBUG, `[VRR.Main] Set local player job type to ${tempJobType}`);
localPlayerJobType = tempJobType;
logToConsole(LOG_DEBUG, `[VRR.Job] Set local player job type to ${tempJobType}`);
localPlayerJobType = tempJobType;
}
// ===========================================================================
function setLocalPlayerWorkingState(tempWorking) {
logToConsole(LOG_DEBUG, `[VRR.Main] Setting working state to ${tempWorking}`);
localPlayerWorking = tempWorking;
logToConsole(LOG_DEBUG, `[VRR.Job] Setting working state to ${tempWorking}`);
localPlayerWorking = tempWorking;
}
// ===========================================================================
function showJobRouteLocation(position, colour) {
logToConsole(LOG_DEBUG, `[VRR.Job] Showing job route location`);
if(getMultiplayerMod() == VRR_MPMOD_GTAC) {
if(game.game == VRR_GAME_GTA_SA) {
jobRouteLocationSphere = game.createPickup(1318, position, 1);
} else {
jobRouteLocationSphere = game.createSphere(position, 3);
jobRouteLocationSphere.colour = colour;
}
logToConsole(LOG_DEBUG, `[VRR.Job] Showing job route location`);
if(getMultiplayerMod() == VRR_MPMOD_GTAC) {
if(game.game == VRR_GAME_GTA_SA) {
// Server-side spheres don't show in GTA SA for some reason.
jobRouteLocationSphere = game.createPickup(1318, position, 1);
} else {
jobRouteLocationSphere = game.createSphere(position, 3);
jobRouteLocationSphere.colour = colour;
}
if(jobRouteLocationBlip != null) {
destroyElement(jobRouteLocationBlip);
}
if(jobRouteLocationBlip != null) {
destroyElement(jobRouteLocationBlip);
}
blinkJobRouteLocationBlip(10, position, colour);
}
blinkJobRouteLocationBlip(10, position, colour);
}
}
// ===========================================================================
function enteredJobRouteSphere() {
logToConsole(LOG_DEBUG, `[VRR.Job] Entered job route sphere`);
tellServerPlayerArrivedAtJobRouteLocation();
destroyElement(jobRouteLocationSphere);
destroyElement(jobRouteLocationBlip);
jobRouteLocationSphere = null;
jobRouteLocationBlip = null;
logToConsole(LOG_DEBUG, `[VRR.Job] Entered job route sphere`);
tellServerPlayerArrivedAtJobRouteLocation();
destroyElement(jobRouteLocationSphere);
destroyElement(jobRouteLocationBlip);
jobRouteLocationSphere = null;
jobRouteLocationBlip = null;
}
// ===========================================================================
function blinkJobRouteLocationBlip(times, position, colour) {
for(let i = 1 ; i <= times ; i++) {
setTimeout(function() {
if(jobRouteLocationBlip != null) {
destroyElement(jobRouteLocationBlip);
jobRouteLocationBlip = null;
} else {
jobRouteLocationBlip = game.createBlip(position, 0, 2, colour);
}
}, 500*i);
}
for(let i = 1 ; i <= times ; i++) {
setTimeout(function() {
if(jobRouteLocationBlip != null) {
destroyElement(jobRouteLocationBlip);
jobRouteLocationBlip = null;
} else {
jobRouteLocationBlip = game.createBlip(position, 0, 2, colour);
}
}, 500*i);
}
setTimeout(function() {
jobRouteLocationBlip = game.createBlip(position, 0, 2, colour);
}, 500*times+1);
setTimeout(function() {
jobRouteLocationBlip = game.createBlip(position, 0, 2, colour);
}, 500*times+1);
}
// ===========================================================================
function hideJobRouteLocation() {
destroyElement(jobRouteLocationSphere);
destroyElement(jobRouteLocationBlip);
jobRouteLocationSphere = null;
jobRouteLocationBlip = null;
destroyElement(jobRouteLocationSphere);
destroyElement(jobRouteLocationBlip);
jobRouteLocationSphere = null;
jobRouteLocationBlip = null;
}
// ===========================================================================
function receiveJobFromServer(jobId, name, position, blipModel, pickupModel) {
logToConsole(LOG_DEBUG, `[VRR.Job] Received job ${jobId} (${name}) from server`);
if(getGame() == VRR_GAME_GTA_IV) {
if(getJobData(jobId) != false) {
let jobData = getJobData(jobId);
jobData.name = name;
jobData.position = position;
jobData.blipModel = blipModel;
jobData.pickupModel = pickupModel;
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId} already exists. Checking blip ...`);
if(blipModel == -1) {
if(jobData.blipId != -1) {
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId}'s blip has been removed by the server`);
if(getGame() == VRR_GAME_GTA_IV) {
natives.removeBlipAndClearIndex(getJobData(jobId).blipId);
} else {
destroyElement(getElementFromId(blipId));
}
jobData.blipId = -1;
} else {
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId}'s blip is unchanged`);
}
} else {
if(jobData.blipId != -1) {
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId}'s blip has been changed by the server`);
if(getGame() == VRR_GAME_GTA_IV) {
natives.setBlipCoordinates(jobData.blipId, jobData.position);
natives.changeBlipSprite(jobData.blipId, jobData.blipModel);
natives.setBlipMarkerLongDistance(jobData.blipId, false);
natives.setBlipAsShortRange(jobData.blipId, true);
natives.changeBlipNameFromAscii(jobData.blipId, `${jobData.name.substr(0, 24)}${(jobData.name.length > 24) ? " ...": ""}`);
}
} else {
let blipId = createGameBlip(jobData.blipModel, jobData.position, jobData.name);
if(blipId != -1) {
jobData.blipId = blipId;
}
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
}
}
} else {
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId} doesn't exist. Adding ...`);
let tempJobData = new JobData(jobId, name, position, blipModel, pickupModel);
if(blipModel != -1) {
let blipId = createGameBlip(tempJobData.blipModel, tempJobData.position, tempJobData.name);
if(blipId != -1) {
tempJobData.blipId = blipId;
}
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
} else {
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId} has no blip.`);
}
jobs.push(tempJobData);
setAllJobDataIndexes();
}
}
}
// ===========================================================================
/**
* @param {number} job - The ID of the job (initially provided by server)
* @return {JobData} The job's data (class instance)
*/
function getJobData(jobId) {
for(let i in jobs) {
if(jobs[i].jobId == jobId) {
return jobs[i];
}
}
return false;
}
// ===========================================================================
function setAllJobDataIndexes() {
for(let i in jobs) {
jobs[i].index = i;
}
}
// ===========================================================================

View File

@@ -1,14 +1,14 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"moduleResolution": "classic"
"module": "commonjs",
"target": "es6",
"moduleResolution": "classic"
},
"include": [
"*.js",
"gui/*.js",
"native/*.js",
"../shared/*.js",
"../third-party/mexui/*"
"*.js",
"gui/*.js",
"native/*.js",
"../shared/*.js",
"../third-party/mexui/*"
]
}

View File

@@ -23,71 +23,71 @@ function initKeyBindScript() {
// ===========================================================================
function bindAccountKey(key, keyState) {
logToConsole(LOG_DEBUG, `[VRR.KeyBind]: Binded key ${toUpperCase(getKeyNameFromId(key))} (${key})`);
keyBinds.push(toInteger(key));
bindKey(toInteger(key), keyState, function(event) {
if(isAnyGUIActive()) {
return false;
}
logToConsole(LOG_DEBUG, `[VRR.KeyBind]: Binded key ${toUpperCase(getKeyNameFromId(key))} (${key})`);
keyBinds.push(toInteger(key));
bindKey(toInteger(key), keyState, function(event) {
if(isAnyGUIActive()) {
return false;
}
if(hasKeyBindDelayElapsed()) {
if(canLocalPlayerUseKeyBinds()) {
logToConsole(LOG_DEBUG, `[VRR.KeyBind]: Using keybind for key ${toUpperCase(getKeyNameFromId(key))} (${key})`);
lastKeyBindUse = sdl.ticks;
tellServerPlayerUsedKeyBind(key);
} else {
logToConsole(LOG_DEBUG, `[VRR.KeyBind]: Failed to use keybind for key ${toUpperCase(getKeyNameFromId(key))} (${key}) - Not allowed to use keybinds!`);
}
} else {
logToConsole(LOG_DEBUG, `[VRR.KeyBind]: Failed to use keybind for key ${toUpperCase(getKeyNameFromId(key))} (${key}) - Not enough time has passed since last keybind use!`);
}
});
if(hasKeyBindDelayElapsed()) {
if(canLocalPlayerUseKeyBinds()) {
logToConsole(LOG_DEBUG, `[VRR.KeyBind]: Using keybind for key ${toUpperCase(getKeyNameFromId(key))} (${key})`);
lastKeyBindUse = sdl.ticks;
tellServerPlayerUsedKeyBind(key);
} else {
logToConsole(LOG_DEBUG, `[VRR.KeyBind]: Failed to use keybind for key ${toUpperCase(getKeyNameFromId(key))} (${key}) - Not allowed to use keybinds!`);
}
} else {
logToConsole(LOG_DEBUG, `[VRR.KeyBind]: Failed to use keybind for key ${toUpperCase(getKeyNameFromId(key))} (${key}) - Not enough time has passed since last keybind use!`);
}
});
}
// ===========================================================================
function unBindAccountKey(key) {
logToConsole(LOG_DEBUG, `[VRR.KeyBind]: Unbinded key ${toUpperCase(getKeyNameFromId(key))} (${key})`);
unbindKey(key);
keyBinds.splice(keyBinds.indexOf(key), 1);
return true;
logToConsole(LOG_DEBUG, `[VRR.KeyBind]: Unbinded key ${toUpperCase(getKeyNameFromId(key))} (${key})`);
unbindKey(key);
keyBinds.splice(keyBinds.indexOf(key), 1);
return true;
}
// ===========================================================================
function hasKeyBindDelayElapsed() {
if(sdl.ticks-lastKeyBindUse >= keyBindDelayTime) {
return true;
}
if(sdl.ticks-lastKeyBindUse >= keyBindDelayTime) {
return true;
}
return false;
return false;
}
// ===========================================================================
function canLocalPlayerUseKeyBinds() {
if(isAnyGUIActive()) {
return false;
}
if(isAnyGUIActive()) {
return false;
}
if(!isSpawned) {
return false;
}
if(!isSpawned) {
return false;
}
if(itemActionDelayEnabled) {
return false;
}
if(itemActionDelayEnabled) {
return false;
}
return true;
return true;
}
// ===========================================================================
function clearKeyBinds() {
for(let i in keyBinds) {
unbindKey(keyBinds[i]);
}
keyBinds = [];
for(let i in keyBinds) {
unbindKey(keyBinds[i]);
}
keyBinds = [];
}
// ===========================================================================

View File

@@ -42,268 +42,334 @@ function initLabelScript() {
// ===========================================================================
function initLabelPropertyNameFont() {
return lucasFont.createDefaultFont(16.0, "Roboto", "Regular");
return lucasFont.createDefaultFont(16.0, "Roboto", "Regular");
}
// ===========================================================================
function initLabelPropertyLockedFont() {
return lucasFont.createDefaultFont(12.0, "Roboto", "Light");
return lucasFont.createDefaultFont(12.0, "Roboto", "Light");
}
// ===========================================================================
function initLabelJobNameFont() {
return lucasFont.createDefaultFont(16.0, "Roboto", "Regular");
return lucasFont.createDefaultFont(16.0, "Roboto", "Regular");
}
// ===========================================================================
function initLabelJobHelpFont() {
return lucasFont.createDefaultFont(10.0, "Roboto", "Light");
return lucasFont.createDefaultFont(10.0, "Roboto", "Light");
}
// ===========================================================================
function renderPropertyEntranceLabel(name, position, locked, isBusiness, price, rentPrice, labelInfoType) {
if(localPlayer == null) {
return false;
}
if(localPlayer == null) {
return false;
}
if(propertyLabelNameFont == null) {
return false;
}
}
if(propertyLabelLockedFont == null) {
return false;
}
}
let tempPosition = position;
tempPosition.z = tempPosition.z + propertyLabelHeight;
let screenPosition = getScreenFromWorldPosition(tempPosition);
if(getGame() == VRR_GAME_GTA_IV) {
if(!natives.doesViewportExist(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport does not exist!");
return false;
}
if(screenPosition.x < 0 || screenPosition.x > game.width) {
return false;
}
if(!natives.isViewportActive(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport is not active!");
return false;
}
}
let text = "";
if(price > "0") {
text = `For sale: $${price}`;
let size = propertyLabelLockedFont.measure(text, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true);
propertyLabelLockedFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(200, 200, 200, 255), false, true, false, true);
let tempPosition = position;
tempPosition.z = tempPosition.z + propertyLabelHeight;
let screenPosition = new Vec3(0.0, 0.0, 0.0);
if(getGame() == VRR_GAME_GTA_IV) {
screenPosition = natives.getViewportPositionOfCoord(tempPosition, natives.getGameViewportId());
} else {
screenPosition = getScreenFromWorldPosition(tempPosition);
}
screenPosition.y -= propertyLabelPriceOffset;
}
if(screenPosition.x < 0 || screenPosition.x > game.width) {
return false;
}
text = "";
if(rentPrice != "0") {
text = `For rent: $${rentPrice} every payday`;
let size = propertyLabelLockedFont.measure(text, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true);
propertyLabelLockedFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(200, 200, 200, 255), false, true, false, true);
let text = "";
if(price > "0") {
text = getLocaleString("PropertyForSaleLabel", price);
let size = propertyLabelLockedFont.measure(text, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true);
propertyLabelLockedFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(200, 200, 200, 255), false, true, false, true);
screenPosition.y -= propertyLabelPriceOffset;
}
screenPosition.y -= propertyLabelPriceOffset;
}
text = "";
if(rentPrice != "0") {
text = getLocaleString("PropertyForRentLabel", rentPrice);
let size = propertyLabelLockedFont.measure(text, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true);
propertyLabelLockedFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(200, 200, 200, 255), false, true, false, true);
screenPosition.y -= propertyLabelPriceOffset;
}
if(isBusiness) {
text = (locked) ? "CLOSED" : "OPEN";
} else {
text = (locked) ? "LOCKED" : "UNLOCKED";
}
if(isBusiness) {
text = (locked) ? toUpperCase(getLocaleString("Closed")) : toUpperCase(getLocaleString("Open"));
} else {
text = (locked) ? toUpperCase(getLocaleString("Locked")) : toUpperCase(getLocaleString("Unlocked"));
}
if(!locked && labelInfoType != VRR_PROPLABEL_INFO_NONE) {
let infoText = "";
switch(labelInfoType) {
case VRR_PROPLABEL_INFO_ENTER:
if(enterPropertyKey) {
infoText = `Press ${toUpperCase(getKeyNameFromId(enterPropertyKey))} to enter`;
} else {
infoText = `Use /enter to enter`;
}
break;
if(!locked && labelInfoType != VRR_PROPLABEL_INFO_NONE) {
let infoText = "";
switch(labelInfoType) {
case VRR_PROPLABEL_INFO_ENTER:
if(enterPropertyKey) {
infoText = getLocaleString("PropertyEnterCommandLabel", "/enter");
} else {
infoText = getLocaleString("PropertyEnterKeyPressLabel", getKeyNameFromId(enterPropertyKey));
}
break;
case VRR_PROPLABEL_INFO_BUY:
infoText = `Use /buy to purchase items`;
break;
case VRR_PROPLABEL_INFO_BUY:
infoText = getLocaleString("BusinessBuyItemsLabel", "/buy");
break;
case VRR_PROPLABEL_INFO_BUYBIZ:
infoText = `Use /buy to purchase items`;
break;
case VRR_PROPLABEL_INFO_BUYBIZ:
infoText = getLocaleString("PropertyForSaleLabel", price);
break;
//case VRR_PROPLABEL_INFO_RENTBIZ:
// infoText = `Use /bizrent to buy this business`;
// break;
//case VRR_PROPLABEL_INFO_RENTBIZ:
// infoText = `Use /bizrent to buy this business`;
// break;
case VRR_PROPLABEL_INFO_BUYHOUSE:
infoText = `Use /housebuy to buy this house`;
break;
case VRR_PROPLABEL_INFO_BUYHOUSE:
infoText = getLocaleString("PropertyForSaleLabel", price);
break;
case VRR_PROPLABEL_INFO_RENTHOUSE:
infoText = `Use /houserent to rent this house`;
break;
case VRR_PROPLABEL_INFO_RENTHOUSE:
infoText = getLocaleString("PropertyForRentLabel", rentPrice);
break;
case VRR_PROPLABEL_INFO_ENTERVEH:
infoText = "Enter a vehicle in the parking lot to buy it";
break;
case VRR_PROPLABEL_INFO_ENTERVEH:
infoText = getLocaleString("VehicleDealershipLabel");
break;
case VRR_PROPLABEL_INFO_NONE:
default:
infoText = "";
break;
}
if(getDistance(localPlayer.position, position) <= renderLabelDistance-2) {
let size = propertyLabelLockedFont.measure(infoText, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true);
propertyLabelLockedFont.render(infoText, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(234, 198, 126, 255), false, true, false, true);
screenPosition.y -= propertyLabelLockedOffset;
}
}
case VRR_PROPLABEL_INFO_NONE:
default:
infoText = "";
break;
}
if(getDistance(localPlayer.position, position) <= renderLabelDistance-2) {
let size = propertyLabelLockedFont.measure(infoText, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true);
propertyLabelLockedFont.render(infoText, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(234, 198, 126, 255), false, true, false, true);
screenPosition.y -= propertyLabelLockedOffset;
}
}
let size = propertyLabelLockedFont.measure(text, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true);
propertyLabelLockedFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, (locked) ? lockedColour : unlockedColour, false, true, false, true);
let size = propertyLabelLockedFont.measure(text, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true);
propertyLabelLockedFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, (locked) ? lockedColour : unlockedColour, false, true, false, true);
screenPosition.y -= propertyLabelNameOffset;
screenPosition.y -= propertyLabelNameOffset;
text = name || " ";
size = propertyLabelNameFont.measure(text, game.width, 0.0, 0.0, propertyLabelNameFont.size, true, true);
propertyLabelNameFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelNameFont.size, (isBusiness) ? toColour(0, 153, 255, 255) : toColour(17, 204, 17, 255), false, true, false, true);
text = name || " ";
size = propertyLabelNameFont.measure(text, game.width, 0.0, 0.0, propertyLabelNameFont.size, true, true);
propertyLabelNameFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelNameFont.size, (isBusiness) ? toColour(0, 153, 255, 255) : toColour(17, 204, 17, 255), false, true, false, true);
}
// -------------------------------------------------------------------------
function renderPropertyExitLabel(position) {
if(localPlayer == null) {
return false;
}
if(localPlayer == null) {
return false;
}
if(propertyLabelNameFont == null) {
return false;
}
}
if(propertyLabelLockedFont == null) {
return false;
}
let tempPosition = position;
tempPosition.z = tempPosition.z + propertyLabelHeight;
let screenPosition = getScreenFromWorldPosition(tempPosition);
if(getGame() == VRR_GAME_GTA_IV) {
if(!natives.doesViewportExist(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport does not exist!");
return false;
}
if(screenPosition.x < 0 || screenPosition.x > game.width) {
return false;
}
if(!natives.isViewportActive(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport is not active!");
return false;
}
}
let text = "EXIT";
let size = propertyLabelNameFont.measure(text, game.width, 0.0, 0.0, propertyLabelNameFont.size, true, true);
propertyLabelNameFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelNameFont.size, COLOUR_WHITE, false, true, false, true);
let tempPosition = position;
tempPosition.z = tempPosition.z + propertyLabelHeight;
let screenPosition = new Vec3(0.0, 0.0, 0.0);
if(getGame() == VRR_GAME_GTA_IV) {
screenPosition = natives.getViewportPositionOfCoord(tempPosition, natives.getGameViewportId());
} else {
screenPosition = getScreenFromWorldPosition(tempPosition);
}
if(screenPosition.x < 0 || screenPosition.x > game.width) {
return false;
}
let text = "EXIT";
let size = propertyLabelNameFont.measure(text, game.width, 0.0, 0.0, propertyLabelNameFont.size, true, true);
propertyLabelNameFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelNameFont.size, COLOUR_WHITE, false, true, false, true);
}
// -------------------------------------------------------------------------
function renderJobLabel(name, position, jobType) {
if(localPlayer == null) {
return false;
}
if(localPlayer == null) {
return false;
}
if(jobNameLabelFont == null) {
return false;
}
}
if(jobHelpLabelFont == null) {
return false;
}
let tempPosition = position;
tempPosition.z = tempPosition.z + propertyLabelHeight;
let screenPosition = getScreenFromWorldPosition(tempPosition);
if(getGame() == VRR_GAME_GTA_IV) {
if(!natives.doesViewportExist(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport does not exist!");
return false;
}
if(screenPosition.x < 0 || screenPosition.x > game.width) {
return false;
}
if(!natives.isViewportActive(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport is not active!");
return false;
}
}
let text = "";
if(jobType == localPlayerJobType) {
if(localPlayerWorking) {
text = "Use /uniform and /equip for job stuff, or /stopwork to go off duty";
} else {
text = "Use /startwork to go on duty";
}
} else {
if(localPlayerJobType == 0) {
text = "Use /takejob to work here";
} else {
text = "You already have a job. Use /quitjob if you want this one";
}
}
let tempPosition = position;
tempPosition.z = tempPosition.z + propertyLabelHeight;
let screenPosition = new Vec3(0.0, 0.0, 0.0);
if(getGame() == VRR_GAME_GTA_IV) {
screenPosition = natives.getViewportPositionOfCoord(tempPosition, natives.getGameViewportId());
} else {
screenPosition = getScreenFromWorldPosition(tempPosition);
}
let size = jobHelpLabelFont.measure(text, game.width, 0.0, 0.0, jobHelpLabelFont.size, true, true);
jobHelpLabelFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, jobHelpLabelFont.size, COLOUR_YELLOW, false, true, false, true);
if(screenPosition.x < 0 || screenPosition.x > game.width) {
return false;
}
screenPosition.y -= 18;
let text = "";
if(jobType == localPlayerJobType) {
if(localPlayerWorking) {
text = getLocaleString("JobEquipAndUniformLabel", "/equip", "/uniform", "/stopwork");
} else {
text = getLocaleString("StartWorkLabel", "/startwork");
}
} else {
if(localPlayerJobType == 0) {
text = getLocaleString("TakeJobLabel", "/takejob");
} else {
text = getLocaleString("NotYourJobLabel", "/quitjob");
}
}
text = name + " Job";
size = jobNameLabelFont.measure(text, game.width, 0.0, 0.0, jobNameLabelFont.size, true, true);
jobNameLabelFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, jobNameLabelFont.size, COLOUR_WHITE, false, true, false, true);
let size = jobHelpLabelFont.measure(text, game.width, 0.0, 0.0, jobHelpLabelFont.size, true, true);
jobHelpLabelFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, jobHelpLabelFont.size, COLOUR_YELLOW, false, true, false, true);
screenPosition.y -= 18;
text = getLocaleString("JobLabel", name);
size = jobNameLabelFont.measure(text, game.width, 0.0, 0.0, jobNameLabelFont.size, true, true);
jobNameLabelFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, jobNameLabelFont.size, COLOUR_WHITE, false, true, false, true);
}
// -------------------------------------------------------------------------
function processLabelRendering() {
if(renderLabels) {
if(!areServerElementsSupported()) {
if(localPlayer != null) {
for(let i in businesses) {
if(getDistance(localPlayer.position, businesses[i].entrancePosition) <= 75.0) {
natives.drawColouredCylinder(getPosBelowPos(businesses[i].entrancePosition, 1.0), 0.0, 0.0, 0, 153, 255, 255);
}
}
}
}
if(areWorldLabelsSupported()) {
if(localPlayer != null) {
let pickups = getElementsByType(ELEMENT_PICKUP);
for(let i in pickups) {
if(pickups[i].getData("vrr.label.type") != null) {
if(getDistance(localPlayer.position, pickups[i].position) <= renderLabelDistance) {
if(!pickups[i].isOnScreen) {
let price = "0";
let rentPrice = "0";
let labelInfoType = VRR_PROPLABEL_INFO_NONE;
if(pickups[i].getData("vrr.label.price") != null) {
price = makeLargeNumberReadable(pickups[i].getData("vrr.label.price"));
}
if(pickups[i].getData("vrr.label.rentprice") != null) {
rentPrice = makeLargeNumberReadable(pickups[i].getData("vrr.label.rentprice"));
}
if(pickups[i].getData("vrr.label.help") != null) {
labelInfoType = pickups[i].getData("vrr.label.help");
}
switch(pickups[i].getData("vrr.label.type")) {
case VRR_LABEL_BUSINESS:
renderPropertyEntranceLabel(pickups[i].getData("vrr.label.name"), pickups[i].position, pickups[i].getData("vrr.label.locked"), true, price, rentPrice, labelInfoType);
break;
case VRR_LABEL_HOUSE:
renderPropertyEntranceLabel("House", pickups[i].position, pickups[i].getData("vrr.label.locked"), false, price, rentPrice, labelInfoType);
break;
case VRR_LABEL_JOB:
renderJobLabel(pickups[i].getData("vrr.label.name"), pickups[i].position, pickups[i].getData("vrr.label.jobType"));
break;
case VRR_LABEL_EXIT:
renderPropertyExitLabel(pickups[i].position);
break;
}
}
}
}
}
}
}
}
if(renderLabels) {
if(!areServerElementsSupported()) {
if(localPlayer != null) {
getServerData().businesses.forEach((business) => {
if(getDistance(localPlayer.position, business.entrancePosition) <= 75.0) {
natives.drawColouredCylinder(getPosBelowPos(business.entrancePosition, 1.0), 0.0, 0.0, 0, 153, 255, 255);
//renderPropertyEntranceLabel(business.name, business.entrancePosition, business.locked, true, makeLargeNumberReadable(business.price), makeLargeNumberReadable(business.rentPrice), business.labelInfoType);
}
});
getServerData().houses.forEach((house) => {
if(getDistance(localPlayer.position, house.entrancePosition) <= 75.0) {
natives.drawColouredCylinder(getPosBelowPos(house.entrancePosition, 1.0), 0.0, 0.0, 0, 200, 0, 255);
//renderPropertyEntranceLabel("House", house.entrancePosition, house.locked, true, makeLargeNumberReadable(house.price), makeLargeNumberReadable(house.rentPrice), 0);
}
});
getServerData().jobs.forEach((job) => {
if(getDistance(localPlayer.position, job.position) <= 75.0) {
natives.drawColouredCylinder(getPosBelowPos(job.position, 1.0), 0.0, 0.0, 255, 255, 0, 255);
//renderJobLabel(job.name, job.position, job.jobType);
}
});
}
}
if(areWorldLabelsSupported()) {
if(localPlayer != null) {
let pickups = getElementsByType(ELEMENT_PICKUP);
for(let i in pickups) {
if(pickups[i].getData("vrr.label.type") != null) {
if(getDistance(localPlayer.position, pickups[i].position) <= renderLabelDistance) {
if(!pickups[i].isOnScreen) {
let price = "0";
let rentPrice = "0";
let labelInfoType = VRR_PROPLABEL_INFO_NONE;
if(pickups[i].getData("vrr.label.price") != null) {
price = makeLargeNumberReadable(pickups[i].getData("vrr.label.price"));
}
if(pickups[i].getData("vrr.label.rentprice") != null) {
rentPrice = makeLargeNumberReadable(pickups[i].getData("vrr.label.rentprice"));
}
if(pickups[i].getData("vrr.label.help") != null) {
labelInfoType = pickups[i].getData("vrr.label.help");
}
switch(pickups[i].getData("vrr.label.type")) {
case VRR_LABEL_BUSINESS:
renderPropertyEntranceLabel(pickups[i].getData("vrr.label.name"), pickups[i].position, pickups[i].getData("vrr.label.locked"), true, price, rentPrice, labelInfoType);
break;
case VRR_LABEL_HOUSE:
renderPropertyEntranceLabel("House", pickups[i].position, pickups[i].getData("vrr.label.locked"), false, price, rentPrice, labelInfoType);
break;
case VRR_LABEL_JOB:
renderJobLabel(pickups[i].getData("vrr.label.name"), pickups[i].position, pickups[i].getData("vrr.label.jobType"));
break;
case VRR_LABEL_EXIT:
renderPropertyExitLabel(pickups[i].position);
break;
}
}
}
}
}
}
}
}
}
// -------------------------------------------------------------------------

31
scripts/client/locale.js Normal file
View File

@@ -0,0 +1,31 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: locale.js
// DESC: Provides locale functions and usage
// TYPE: Client (JavaScript)
// ===========================================================================
function getLocaleString(stringName, ...args) {
if(typeof getServerData().localeStrings[stringName] == undefined) {
return "";
}
let tempString = getServerData().localeStrings[stringName];
for(let i = 1; i <= args.length; i++) {
tempString = tempString.replace(`{${i}}`, args[i-1]);
}
return tempString;
}
// ===========================================================================
function receiveLocaleStringFromServer(stringName, stringValue) {
logToConsole(LOG_INFO, `[VRR.Locale]: Received locale string "${stringName}" from server (${stringValue})`);
getServerData().localeStrings[stringName] = stringValue;
}
// ===========================================================================

View File

@@ -15,38 +15,38 @@ let logoSize = toVector2(128, 128);
function initLogoScript() {
logToConsole(LOG_DEBUG, "[VRR.Logo]: Initializing logo script ...");
//logoImage = loadLogoImage();
//logoImage = loadLogoImage();
logToConsole(LOG_DEBUG, "[VRR.Logo]: Logo script initialized!");
}
// ===========================================================================
function loadLogoImage() {
let logoStream = openFile(mainLogoPath);
let tempLogoImage = null;
if(logoStream != null) {
tempLogoImage = graphics.loadPNG(logoStream);
logoStream.close();
}
let logoStream = openFile(mainLogoPath);
let tempLogoImage = null;
if(logoStream != null) {
tempLogoImage = graphics.loadPNG(logoStream);
logoStream.close();
}
return tempLogoImage;
return tempLogoImage;
}
// ===========================================================================
function processLogoRendering() {
if(renderLogo) {
if(logoImage != null) {
graphics.drawRectangle(logoImage, logoPos, logoSize);
}
}
if(renderLogo) {
if(logoImage != null) {
graphics.drawRectangle(logoImage, logoPos, logoSize);
}
}
}
// ===========================================================================
function setServerLogoRenderState(state) {
logToConsole(LOG_DEBUG, `[VRR.Main] Server logo ${(state) ? "enabled" : "disabled"}`);
renderLogo = state;
logToConsole(LOG_DEBUG, `[VRR.Main] Server logo ${(state) ? "enabled" : "disabled"}`);
renderLogo = state;
}
// ===========================================================================

View File

@@ -27,7 +27,7 @@ let renderHotBar = true;
let renderItemActionDelay = true;
let renderInteriorLights = true;
let logLevel = LOG_ERROR|LOG_WARN|LOG_INFO;
let logLevel = LOG_INFO|LOG_DEBUG|LOG_VERBOSE|LOG_WARN|LOG_ERROR;
let weaponDamageEnabled = {};
let weaponDamageEvent = {};
@@ -66,12 +66,21 @@ let vehiclePurchasePosition = null;
let forceWantedLevel = 0;
let guiSubmitKey = false;
let guiLeftKey = false;
let guiRightKey = false;
let guiUpKey = false;
let guiDownKey = false;
// Pre-cache all allowed skins
let allowedSkins = getAllowedSkins(getGame());
let businesses = [];
let houses = [];
let jobs = [];
let vehicles = [];
let serverData = {
houses: [],
businesses: [],
localeStrings: [],
vehicles: [],
jobs: [],
};
// ===========================================================================
// ===========================================================================

View File

@@ -7,7 +7,14 @@
// TYPE: Client (JavaScript)
// ===========================================================================
let smallGameMessageFont = null;
let bigGameMessageFonts = {};
let bigGameMessageFontName = "";
let bigGameMessageText = "";
let bigGameMessageColour = COLOUR_WHITE;
let bigGameMessageTimer = null;
let smallGameMessageFonts = {};
let smallGameMessageFontName = "";
let smallGameMessageText = "";
let smallGameMessageColour = COLOUR_WHITE;
let smallGameMessageTimer = null;
@@ -16,64 +23,73 @@ let smallGameMessageTimer = null;
function initMessagingScript() {
logToConsole(LOG_DEBUG, "[VRR.Messaging]: Initializing messaging script ...");
smallGameMessageFont = loadSmallGameMessageFont();
smallGameMessageFonts = loadSmallGameMessageFonts();
bigGameMessageFonts = loadSmallGameMessageFonts();
logToConsole(LOG_DEBUG, "[VRR.Messaging]: Messaging script initialized!");
}
// ===========================================================================
function loadSmallGameMessageFont() {
let tempSmallGameMessageFont = null;
let fontStream = openFile("files/fonts/pricedown.ttf");
if(fontStream != null) {
tempSmallGameMessageFont = lucasFont.createFont(fontStream, 20.0);
fontStream.close();
}
function loadSmallGameMessageFonts() {
let tempSmallGameMessageFonts = {};
let fontStream = openFile("files/fonts/pricedown.ttf");
if(fontStream != null) {
tempSmallGameMessageFonts["Pricedown"] = lucasFont.createFont(fontStream, 20.0);
fontStream.close();
}
return tempSmallGameMessageFont;
tempSmallGameMessageFonts["Roboto"] = lucasFont.createDefaultFont(20.0, "Roboto");
tempSmallGameMessageFonts["RobotoLight"] = lucasFont.createDefaultFont(20.0, "Roboto", "Light");
return tempSmallGameMessageFonts;
}
// ===========================================================================
function loadBigGameMessageFont() {
let tempBigGameMessageFont = null;
let fontStream = openFile("files/fonts/pricedown.ttf");
if(fontStream != null) {
tempBigGameMessageFont = lucasFont.createFont(fontStream, 28.0);
fontStream.close();
}
let tempBigGameMessageFonts = {};
let fontStream = openFile("files/fonts/pricedown.ttf");
if(fontStream != null) {
tempBigGameMessageFonts["Pricedown"] = lucasFont.createFont(fontStream, 28.0);
fontStream.close();
}
return tempBigGameMessageFont;
tempBigGameMessageFonts["Roboto"] = lucasFont.createDefaultFont(28.0, "Roboto");
tempBigGameMessageFonts["RobotoLight"] = lucasFont.createDefaultFont(28.0, "Roboto", "Light");
return tempBigGameMessageFonts;
}
// ===========================================================================
function processSmallGameMessageRendering() {
if(renderSmallGameMessage) {
if(smallGameMessageFont != null) {
if(smallGameMessageFont != "") {
smallGameMessageFont.render(smallGameMessageText, [0, game.height-90], game.width, 0.5, 0.0, smallGameMessageFont.size, smallGameMessageColour, true, true, false, true);
}
}
}
if(renderSmallGameMessage) {
if(smallGameMessageText != "") {
if(smallGameMessageFonts[smallGameMessageFontName] != null) {
smallGameMessageFonts[smallGameMessageFontName].render(smallGameMessageText, [0, game.height-90], game.width, 0.5, 0.0, smallGameMessageFonts[smallGameMessageFontName].size, smallGameMessageColour, true, true, false, true);
}
}
}
}
// ===========================================================================
function showSmallGameMessage(text, colour, duration) {
logToConsole(LOG_DEBUG, `[VRR.Messaging] Showing small game message '${text}' for ${duration}ms`);
if(smallGameMessageText != "") {
clearTimeout(smallGameMessageTimer);
}
function showSmallGameMessage(text, colour, duration, fontName) {
logToConsole(LOG_DEBUG, `[VRR.Messaging] Showing small game message '${text}' using font ${fontName} for ${duration}ms`);
if(smallGameMessageText != "") {
clearTimeout(smallGameMessageTimer);
}
smallGameMessageColour = colour;
smallGameMessageText = text;
smallGameMessageFontName = fontName;
smallGameMessageColour = colour;
smallGameMessageText = text;
smallGameMessageTimer = setTimeout(function() {
smallGameMessageText = "";
smallGameMessageColour = COLOUR_WHITE;
smallGameMessageTimer = null;
}, duration);
smallGameMessageTimer = setTimeout(function() {
smallGameMessageText = "";
smallGameMessageColour = COLOUR_WHITE;
smallGameMessageTimer = null;
smallGameMessageFontName = "";
}, duration);
}
// ===========================================================================

View File

@@ -632,10 +632,10 @@ function update()
addEventHandler("OnCameraProcess", (event) =>
{
if(mouseCameraEnabled) {
update();
event.preventDefault();
}
if(mouseCameraEnabled) {
update();
event.preventDefault();
}
});
function toggleMouseCamera() {

View File

@@ -51,8 +51,8 @@ function updatePlayerNameTag(clientName, characterName, colour, paused, ping) {
if(game.game == VRR_GAME_GTA_IV) {
let client = getPlayerFromParams(clientName);
if(client != false) {
if(client.player != null) {
client.player.setNametag(characterName, colour);
if(getPlayerPed(client) != null) {
getPlayerPed(client).setNametag(characterName, colour);
}
}
}
@@ -74,11 +74,11 @@ function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour,
alpha *= 0.75;
let width = nametagWidth;
health = Math.max(0.0, Math.min(1.0, health));
armour = Math.max(0.0, Math.min(1.0, armour));
armour = Math.max(0.0, Math.min(1.0, armour));
// Starts at bottom and works it's way up
// -------------------------------------------
// Health Bar
// Starts at bottom and works it's way up
// -------------------------------------------
// Health Bar
if(getMultiplayerMod() == VRR_MPMOD_GTAC) {
if(game.game == VRR_GAME_GTA_III) {
@@ -104,7 +104,7 @@ function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour,
graphics.drawRectangle(null, [hx+2, hy+2], [(width-4)*health, 10-6], colour, colour, colour, colour);
}
// Armour Bar
// Armour Bar
if (armour > 0.0)
{
// Go up 10 pixels to draw the next part
@@ -119,16 +119,16 @@ function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour,
y -= 20;
// Nametag
// Nametag
if(nametagFont != null) {
let size = nametagFont.measure(text, game.width, 0.0, 0.0, nametagFont.size, false, false);
nametagFont.render(text, [x-size[0]/2, y-size[1]/2], game.width, 0.0, 0.0, nametagFont.size, colour, false, false, false, true);
}
// Go up another 10 pixels for the next part
y -= 20;
// Go up another 10 pixels for the next part
y -= 20;
// AFK Status
// AFK Status
if(afkStatusFont != null) {
if(afk) {
let size = afkStatusFont.measure("PAUSED", game.width, 0.0, 0.0, afkStatusFont.size, false, false);
@@ -147,7 +147,7 @@ function updateNametags(element) {
if(localPlayer != null) {
let playerPos = localPlayer.position;
let elementPos = element.position;
let client = getClientFromPlayerElement(element);
let client = getClientFromPlayerElement(element);
elementPos[2] += 0.9;
@@ -173,26 +173,26 @@ function updateNametags(element) {
}
if(element.type == ELEMENT_PLAYER) {
let name = element.name;
let colour = COLOUR_WHITE;
let name = element.name;
let colour = COLOUR_WHITE;
let paused = false;
let ping = -1;
if(typeof playerNames[element.name] != "undefined") {
name = playerNames[element.name];
}
if(typeof playerPaused[element.name] != "undefined") {
paused = playerPaused[element.name];
}
if(typeof playerColours[element.name] != "undefined") {
colour = playerColours[element.name];
if(typeof playerNames[element.name] != "undefined") {
name = playerNames[element.name];
}
if(typeof playerPing[element.name] != "undefined") {
ping = playerPing[element.name];
}
if(typeof playerPaused[element.name] != "undefined") {
paused = playerPaused[element.name];
}
if(typeof playerColours[element.name] != "undefined") {
colour = playerColours[element.name];
}
if(typeof playerPing[element.name] != "undefined") {
ping = playerPing[element.name];
}
drawNametag(screenPos[0], screenPos[1], health, armour, name, ping, 1.0-distance/nametagDistance, distance, colour, paused, element.skin);
}
@@ -205,7 +205,7 @@ function updateNametags(element) {
function getClientFromPlayer(player) {
getClients().forEach(function(client) {
if(client.player == player) {
if(getPlayerPed(client) == player) {
return client;
}
});

View File

@@ -8,57 +8,61 @@
// ===========================================================================
function sendNetworkEventToPlayer(networkEvent, client, ...args) {
triggerNetworkEvent.apply(null, networkEvent, client, args);
triggerNetworkEvent.apply(null, networkEvent, client, args);
}
// ===========================================================================
function getPlayerPosition() {
return localPlayer.position;
return localPlayer.position;
}
// ===========================================================================
function setPlayerPosition(position) {
localPlayer.position = position;
if(getGame() == VRR_GAME_GTA_IV) {
natives.setCharCoordinates(localPlayer, position);
} else {
localPlayer.position = position;
}
}
// ===========================================================================
function getElementPosition(element) {
return element.position;
return element.position;
}
// ===========================================================================
function setElementPosition(element, position) {
if(!element.isSyncer) {
return false;
}
if(!element.isSyncer) {
return false;
}
element.position = position;
element.position = position;
}
// ===========================================================================
function deleteGameElement(element, position) {
if(!element.isOwner) {
return false;
}
if(!element.isOwner) {
return false;
}
destroyGameElement(element);
destroyGameElement(element);
}
// ===========================================================================
function createGameVehicle(modelIndex, position, heading) {
return game.createVehicle(getGameConfig().vehicles[getGame()][modelIndex][0], position, heading);
return game.createVehicle(getGameConfig().vehicles[getGame()][modelIndex][0], position, heading);
}
// ===========================================================================
function addNetworkEventHandler(eventName, handlerFunction) {
addNetworkHandler(eventName, handlerFunction);
addNetworkHandler(eventName, handlerFunction);
}
// ===========================================================================
@@ -141,4 +145,47 @@ function getVehiclesInRange(position, range) {
return inRangeVehicles;
}
// ===========================================================================
function createGameBlip(blipModel, position, name = "") {
if(getGame() == VRR_GAME_GTA_IV) {
let blipId = natives.addBlipForCoord(position);
if(blipId) {
natives.changeBlipSprite(blipId, blipModel);
natives.setBlipMarkerLongDistance(blipId, false);
natives.setBlipAsShortRange(blipId, true);
natives.changeBlipNameFromAscii(blipId, `${name.substr(0, 24)}${(name.length > 24) ? " ...": ""}`);
return blipId;
}
}
return -1;
}
// ===========================================================================
function setEntityData(entity, dataName, dataValue, syncToClients = true) {
if(entity != null) {
return entity.setData(dataName, dataValue);
}
}
// ===========================================================================
function removeEntityData(entity, dataName) {
if(entity != null) {
return entity.removeData(dataName);
}
return null;
}
// ===========================================================================
function doesEntityDataExist(entity, dataName) {
if(entity != null) {
return (entity.getData(dataName) != null);
}
return null;
}
// ===========================================================================

View File

@@ -8,39 +8,39 @@
// ===========================================================================
function playStreamingRadio(url, loop, volume, element = false) {
if(streamingRadio != null) {
streamingRadio.stop();
}
if(streamingRadio != null) {
streamingRadio.stop();
}
streamingRadioVolume = volume;
streamingRadioVolume = volume;
streamingRadio = audio.createSoundFromURL(url, loop);
streamingRadio.volume = volume/100;
streamingRadio.play();
streamingRadio = audio.createSoundFromURL(url, loop);
streamingRadio.volume = volume/100;
streamingRadio.play();
}
// ===========================================================================
function stopStreamingRadio() {
if(streamingRadio != null) {
streamingRadio.stop();
}
streamingRadio = null;
if(streamingRadio != null) {
streamingRadio.stop();
}
streamingRadio = null;
}
// ===========================================================================
function setStreamingRadioVolume(volume) {
if(streamingRadio != null) {
streamingRadioVolume = volume;
streamingRadio.volume = volume/100;
}
if(streamingRadio != null) {
streamingRadioVolume = volume;
streamingRadio.volume = volume/100;
}
}
// ===========================================================================
function playAudioFile(audioName, loop, volume) {
playCustomAudio(audioName, volume/100, loop);
findResourceByName("connectedrp-extra").exports.playCustomAudio(audioName, volume/100, loop);
}
// ===========================================================================

View File

@@ -43,7 +43,7 @@ function processScoreBoardRendering() {
}
if(renderScoreBoard) {
if(isKeyDown(SDLK_TAB)) {
if(isKeyDown(SDLK_TAB)) {
if(scoreBoardListFont != null && scoreBoardTitleFont != null) {
let scoreboardStart = (game.height/2)-(Math.floor(getClients().length/2)*20);
let titleSize = scoreBoardTitleFont.measure("PLAYERS", game.width, 0.0, 1.0, 10, false, false);

View File

@@ -8,197 +8,216 @@
// ===========================================================================
function initServerScript() {
logToConsole(LOG_DEBUG, "[VRR.Server]: Initializing server script ...");
addAllNetworkHandlers();
logToConsole(LOG_DEBUG, "[VRR.Server]: Server script initialized!");
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 ...");
logToConsole(LOG_DEBUG, "[VRR.Server]: Adding network handlers ...");
addNetworkEventHandler("vrr.smallGameMessage", showSmallGameMessage);
addNetworkEventHandler("vrr.working", setLocalPlayerWorkingState);
addNetworkEventHandler("vrr.jobType", setLocalPlayerJobType);
addNetworkEventHandler("vrr.passenger", enterVehicleAsPassenger);
// Chat history
addNetworkEventHandler("m", receiveChatBoxMessageFromServer); // Not prefixed with VRR to make it as small as possible
addNetworkEventHandler("vrr.chatScrollLines", setChatScrollLines);
addNetworkEventHandler("vrr.chatAutoHideDelay", setChatAutoHideDelay);
addNetworkEventHandler("vrr.freeze", setLocalPlayerFrozenState);
addNetworkEventHandler("vrr.control", setLocalPlayerControlState);
addNetworkEventHandler("vrr.fadeCamera", fadeLocalCamera);
addNetworkEventHandler("vrr.removeFromVehicle", removeLocalPlayerFromVehicle);
addNetworkEventHandler("vrr.clearPeds", clearLocalPlayerOwnedPeds);
addNetworkEventHandler("vrr.restoreCamera", restoreLocalCamera);
addNetworkEventHandler("vrr.cameraLookAt", setLocalCameraLookAt);
addNetworkEventHandler("vrr.logo", setServerLogoRenderState);
addNetworkEventHandler("vrr.ambience", setCityAmbienceState);
addNetworkEventHandler("vrr.runCode", runClientCode);
addNetworkEventHandler("vrr.clearWeapons", clearLocalPlayerWeapons);
addNetworkEventHandler("vrr.giveWeapon", giveLocalPlayerWeapon);
addNetworkEventHandler("vrr.position", setLocalPlayerPosition);
addNetworkEventHandler("vrr.heading", setLocalPlayerHeading);
addNetworkEventHandler("vrr.interior", setLocalPlayerInterior);
addNetworkEventHandler("vrr.minuteDuration", setMinuteDuration);
addNetworkEventHandler("vrr.showJobRouteLocation", showJobRouteLocation);
addNetworkEventHandler("vrr.hideJobRouteLocation", hideJobRouteLocation);
addNetworkEventHandler("vrr.snow", setSnowState);
addNetworkEventHandler("vrr.health", setLocalPlayerHealth);
addNetworkEventHandler("vrr.enterPropertyKey", setEnterPropertyKey);
addNetworkEventHandler("vrr.skinSelect", toggleSkinSelect);
addNetworkEventHandler("vrr.hotbar", updatePlayerHotBar);
addNetworkEventHandler("vrr.pedSpeech", playPedSpeech);
addNetworkEventHandler("vrr.clearPedState", clearLocalPedState);
addNetworkEventHandler("vrr.drunkEffect", setLocalPlayerDrunkEffect);
addNetworkEventHandler("vrr.showItemActionDelay", showItemActionDelay);
addNetworkEventHandler("vrr.set2DRendering", setPlayer2DRendering);
addNetworkEventHandler("vrr.mouseCursor", toggleMouseCursor);
addNetworkEventHandler("vrr.mouseCamera", toggleMouseCamera);
addNetworkEventHandler("vrr.mouseCameraForce", setMouseCameraState);
addNetworkEventHandler("vrr.weaponDamageEnabled", setPlayerWeaponDamageEnabled);
addNetworkEventHandler("vrr.weaponDamageEvent", setPlayerWeaponDamageEvent);
addNetworkEventHandler("vrr.spawned", onServerSpawnedPlayer);
addNetworkEventHandler("vrr.money", setLocalPlayerCash);
addNetworkEventHandler("vrr.armour", setLocalPlayerArmour);
addNetworkEventHandler("vrr.wantedLevel", forceLocalPlayerWantedLevel);
// Messaging (like textdraws and stuff)
addNetworkEventHandler("vrr.smallGameMessage", showSmallGameMessage);
addNetworkEventHandler("vrr.delKeyBind", unBindAccountKey);
addNetworkEventHandler("vrr.addKeyBind", bindAccountKey);
addNetworkEventHandler("vrr.clearKeyBinds", clearKeyBinds);
// Job
addNetworkEventHandler("vrr.job", receiveJobFromServer);
addNetworkEventHandler("vrr.working", setLocalPlayerWorkingState);
addNetworkEventHandler("vrr.jobType", setLocalPlayerJobType);
addNetworkEventHandler("vrr.showJobRouteLocation", showJobRouteLocation);
addNetworkEventHandler("vrr.hideJobRouteLocation", hideJobRouteLocation);
addNetworkEventHandler("vrr.nametag", updatePlayerNameTag);
addNetworkEventHandler("vrr.ping", updatePlayerPing);
// 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.m", receiveChatBoxMessageFromServer);
addNetworkEventHandler("vrr.chatScrollLines", setChatScrollLines);
// Vehicle
addNetworkEventHandler("vrr.vehicle", receiveVehicleFromServer);
addNetworkEventHandler("vrr.veh.lights", setVehicleLights);
addNetworkEventHandler("vrr.veh.engine", setVehicleEngine);
addNetworkEventHandler("vrr.veh.repair", repairVehicle);
addNetworkEventHandler("vrr.radioStream", playStreamingRadio);
addNetworkEventHandler("vrr.audioFileStream", playAudioFile);
addNetworkEventHandler("vrr.stopRadioStream", stopStreamingRadio);
addNetworkEventHandler("vrr.radioVolume", setStreamingRadioVolume);
// Radio
addNetworkEventHandler("vrr.radioStream", playStreamingRadio);
addNetworkEventHandler("vrr.audioFileStream", playAudioFile);
addNetworkEventHandler("vrr.stopRadioStream", stopStreamingRadio);
addNetworkEventHandler("vrr.radioVolume", setStreamingRadioVolume);
addNetworkEventHandler("vrr.veh.lights", setVehicleLights);
addNetworkEventHandler("vrr.veh.engine", setVehicleEngine);
addNetworkEventHandler("vrr.veh.repair", repairVehicle);
// Key Bindings
addNetworkEventHandler("vrr.delKeyBind", unBindAccountKey);
addNetworkEventHandler("vrr.addKeyBind", bindAccountKey);
addNetworkEventHandler("vrr.clearKeyBinds", clearKeyBinds);
addNetworkEventHandler("vrr.pedAnim", makePedPlayAnimation);
addNetworkEventHandler("vrr.pedStopAnim", makePedStopAnimation);
addNetworkEventHandler("vrr.localPlayerSkin", setLocalPlayerSkin);
addNetworkEventHandler("vrr.forcePedAnim", forcePedAnimation);
addNetworkEventHandler("vrr.hideAllGUI", hideAllGUI);
addNetworkEventHandler("vrr.clientInfo", serverRequestedClientInfo);
addNetworkEventHandler("vrr.interiorLights", updateInteriorLightsState);
// Weapon Damage
addNetworkEventHandler("vrr.weaponDamageEnabled", setPlayerWeaponDamageEnabled);
addNetworkEventHandler("vrr.weaponDamageEvent", setPlayerWeaponDamageEvent);
addNetworkEventHandler("vrr.syncElement", forceSyncElementProperties);
addNetworkEventHandler("vrr.elementPosition", setElementPosition);
addNetworkEventHandler("vrr.elementCollisions", setElementCollisionsEnabled);
// GUI
addNetworkEventHandler("vrr.showRegistration", showRegistrationGUI);
addNetworkEventHandler("vrr.showNewCharacter", showNewCharacterGUI);
addNetworkEventHandler("vrr.showLogin", showLoginGUI);
addNetworkEventHandler("vrr.vehBuyState", setVehiclePurchaseState);
// Business
addNetworkEventHandler("vrr.business", receiveBusinessFromServer);
addNetworkEventHandler("vrr.showRegistration", showRegistrationGUI);
addNetworkEventHandler("vrr.showNewCharacter", showNewCharacterGUI);
addNetworkEventHandler("vrr.showLogin", showLoginGUI);
// House
addNetworkEventHandler("vrr.house", receiveHouseFromServer);
addNetworkEventHandler("vrr.logLevel", setLogLevel);
addNetworkEventHandler("vrr.infiniteRun", setLocalPlayerInfiniteRun);
// Locale
addNetworkEventHandler("vrr.localeString", receiveLocaleStringFromServer);
addNetworkEventHandler("vrr.business", receiveBusinessFromServer);
addNetworkEventHandler("vrr.house", receiveHouseFromServer);
addNetworkEventHandler("vrr.holdObject", makePedHoldObject);
addNetworkEventHandler("vrr.playerPedId", sendLocalPlayerNetworkIdToServer);
addNetworkEventHandler("vrr.ped", setLocalPlayerPedPartsAndProps);
// 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.ping", updatePlayerPing);
addNetworkEventHandler("vrr.pedAnim", makePedPlayAnimation);
addNetworkEventHandler("vrr.pedStopAnim", makePedStopAnimation);
addNetworkEventHandler("vrr.forcePedAnim", 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");
sendNetworkEventToServer("vrr.clientReady");
}
// ===========================================================================
function sendResourceStartedSignalToServer() {
sendNetworkEventToServer("vrr.clientStarted");
sendNetworkEventToServer("vrr.clientStarted");
}
// ===========================================================================
function sendResourceStoppedSignalToServer() {
if(isConnected) {
sendNetworkEventToServer("vrr.clientStopped");
}
if(isConnected) {
sendNetworkEventToServer("vrr.clientStopped");
}
}
// ===========================================================================
function setPlayer2DRendering(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;
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);
}
}
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;
renderLabels = labelState;
renderSmallGameMessage = smallGameMessageState;
renderScoreBoard = scoreboardState;
renderHotBar = hotBarState;
renderItemActionDelay = itemActionDelayState;
}
// ===========================================================================
function onServerSpawnedPlayer(state) {
logToConsole(LOG_DEBUG, `[VRR.Main] Setting spawned state to ${state}`);
isSpawned = state;
if(state) {
setUpInitialGame();
calledDeathEvent = false;
}
function onServerSpawnedLocalPlayer(state) {
logToConsole(LOG_DEBUG, `[VRR.Main] Setting spawned state to ${state}`);
isSpawned = state;
if(state) {
setUpInitialGame();
setTimeout(function() {
calledDeathEvent = false;
}, 1000);
}
}
// ===========================================================================
function tellServerPlayerUsedKeyBind(key) {
sendNetworkEventToServer("vrr.useKeyBind", key);
sendNetworkEventToServer("vrr.useKeyBind", key);
}
// ===========================================================================
function tellServerPlayerArrivedAtJobRouteLocation() {
sendNetworkEventToServer("vrr.arrivedAtJobRouteLocation");
sendNetworkEventToServer("vrr.arrivedAtJobRouteLocation");
}
// ===========================================================================
function tellServerItemActionDelayComplete() {
sendNetworkEventToServer("vrr.itemActionDelayComplete");
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);
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);
sendNetworkEventToServer("vrr.afk", state);
}
// ===========================================================================
@@ -210,109 +229,167 @@ function anchorBoat(vehicleId) {
// ===========================================================================
function setEnterPropertyKey(key) {
enterPropertyKey = key;
enterPropertyKey = key;
}
// ===========================================================================
function serverRequestedClientInfo() {
sendServerClientInfo();
sendServerClientInfo();
}
// ===========================================================================
function updateInteriorLightsState(state) {
interiorLightsEnabled = state;
interiorLightsEnabled = state;
}
// ===========================================================================
function forceSyncElementProperties(elementId) {
if(getElementFromId(elementId) == null) {
return false;
}
if(getElementFromId(elementId) == null) {
return false;
}
syncElementProperties(getElementFromId(elementId));
syncElementProperties(getElementFromId(elementId));
}
// ===========================================================================
function setElementPosition(elementId, position) {
if(getElementFromId(elementId) == null) {
return false;
}
if(getElementFromId(elementId) == null) {
return false;
}
if(!getElementFromId(elementId).isSyncer) {
return false;
}
if(!getElementFromId(elementId).isSyncer) {
return false;
}
getElementFromId(elementId).position = position;
getElementFromId(elementId).position = position;
}
// ===========================================================================
function setElementCollisionsEnabled(elementId, state) {
if(getElementFromId(elementId) == null) {
return false;
}
if(getElementFromId(elementId) == null) {
return false;
}
getElementFromId(elementId).collisionsEnabled = state;
getElementFromId(elementId).collisionsEnabled = state;
}
// ===========================================================================
function setLocalPlayerArmour(armour) {
if(typeof localPlayer.armour != "undefined") {
localPlayer.armour = armour;
}
if(typeof localPlayer.armour != "undefined") {
localPlayer.armour = armour;
}
}
// ===========================================================================
function forceLocalPlayerWantedLevel(wantedLevel) {
forceWantedLevel = toInteger(wantedLevel);
function setLocalPlayerWantedLevel(wantedLevel) {
forceWantedLevel = toInteger(wantedLevel);
}
// ===========================================================================
function setLogLevel(level) {
logLevel = 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));
}
}
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) {
if(getGame() == VRR_GAME_GTA_IV) {
natives.changePlayerModel(natives.getPlayerId(), skinId);
//localPlayer.skin = allowedSkins[skinSelectorIndex][0];
//localPlayer.modelIndex = allowedSkins[skinSelectorIndex][0];
} else {
localPlayer.skin = skinId;
}
logToConsole(LOG_INFO, skinId);
if(getGame() == VRR_GAME_GTA_IV) {
if(natives.isModelInCdimage(skinId)) {
natives.requestModel(skinId);
natives.loadAllObjectsNow();
if(natives.hasModelLoaded(skinId)) {
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])
}
if(getGame() == VRR_GAME_GTA_IV) {
natives.givePedAmbientObject(natives.getPedFromNetworkId(pedId), getGameConfig().objects[getGame()][modelIndex][1])
}
}
// ===========================================================================
function sendLocalPlayerNetworkIdToServer() {
sendNetworkEventToServer("vrr.playerPedId", natives.getNetworkIdFromPed(localPlayer));
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);
//}
}
}
// ===========================================================================

View File

@@ -45,95 +45,111 @@ function loadSkinSelectMessageFontBottom() {
function processSkinSelectKeyPress(keyCode) {
if(usingSkinSelector) {
if(keyCode == SDLK_PAGEUP) {
if(skinSelectorIndex >= allowedSkins.length-1) {
skinSelectorIndex = 1;
} else {
skinSelectorIndex = skinSelectorIndex + 1;
}
logToConsole(LOG_DEBUG, `Switching to skin ${allowedSkins[skinSelectorIndex][1]} (Index: ${skinSelectorIndex}, Skin: ${allowedSkins[skinSelectorIndex][0]})`);
skinSelectMessageTextTop = allowedSkins[skinSelectorIndex][1];
if(getGame() == VRR_GAME_GTA_IV) {
//natives.changePlayerModel(natives.getPlayerId(), allowedSkins[skinSelectorIndex][0]);
//localPlayer.skin = allowedSkins[skinSelectorIndex][0];
//localPlayer.modelIndex = allowedSkins[skinSelectorIndex][0];
} else {
localPlayer.skin = allowedSkins[skinSelectorIndex][0];
}
} else if(keyCode == SDLK_PAGEDOWN) {
if(skinSelectorIndex <= 0) {
skinSelectorIndex = allowedSkins.length-1;
} else {
skinSelectorIndex = skinSelectorIndex - 1;
}
logToConsole(LOG_DEBUG, `Switching to skin ${allowedSkins[skinSelectorIndex][1]} (Index: ${skinSelectorIndex}, Skin: ${allowedSkins[skinSelectorIndex][0]})`);
skinSelectMessageTextTop = allowedSkins[skinSelectorIndex][1];
if(getGame() == VRR_GAME_GTA_IV) {
//natives.changePlayerModel(natives.getPlayerId(), allowedSkins[skinSelectorIndex][0]);
//localPlayer.skin = allowedSkins[skinSelectorIndex][0];
//localPlayer.modelIndex = allowedSkins[skinSelectorIndex][0];
} else {
localPlayer.skin = allowedSkins[skinSelectorIndex][0];
}
} else if(keyCode == SDLK_RETURN) {
sendNetworkEventToServer("vrr.skinSelected", skinSelectorIndex);
toggleSkinSelect(false);
return true;
} else if(keyCode == SDLK_BACKSPACE) {
sendNetworkEventToServer("vrr.skinSelected", -1);
toggleSkinSelect(false);
return true;
}
localPlayer.heading = skinSelectHeading;
}
if(keyCode == SDLK_PAGEUP) {
if(skinSelectorIndex >= allowedSkins.length-1) {
skinSelectorIndex = 1;
} else {
skinSelectorIndex = skinSelectorIndex + 1;
}
logToConsole(LOG_DEBUG, `Switching to skin ${allowedSkins[skinSelectorIndex][1]} (Index: ${skinSelectorIndex}, Skin: ${allowedSkins[skinSelectorIndex][0]})`);
skinSelectMessageTextTop = allowedSkins[skinSelectorIndex][1];
if(getGame() == VRR_GAME_GTA_IV) {
let skinId = allowedSkins[skinSelectorIndex][0];
if(natives.isModelInCdimage(skinId)) {
natives.requestModel(skinId);
natives.loadAllObjectsNow();
if(natives.hasModelLoaded(skinId)) {
natives.changePlayerModel(natives.getPlayerId(), skinId);
}
}
} else {
localPlayer.skin = allowedSkins[skinSelectorIndex][0];
}
} else if(keyCode == SDLK_PAGEDOWN) {
if(skinSelectorIndex <= 0) {
skinSelectorIndex = allowedSkins.length-1;
} else {
skinSelectorIndex = skinSelectorIndex - 1;
}
logToConsole(LOG_DEBUG, `Switching to skin ${allowedSkins[skinSelectorIndex][1]} (Index: ${skinSelectorIndex}, Skin: ${allowedSkins[skinSelectorIndex][0]})`);
skinSelectMessageTextTop = allowedSkins[skinSelectorIndex][1];
if(getGame() == VRR_GAME_GTA_IV) {
let skinId = allowedSkins[skinSelectorIndex][0];
if(natives.isModelInCdimage(skinId)) {
natives.requestModel(skinId);
natives.loadAllObjectsNow();
if(natives.hasModelLoaded(skinId)) {
natives.changePlayerModel(natives.getPlayerId(), skinId);
}
}
} else {
localPlayer.skin = allowedSkins[skinSelectorIndex][0];
}
} else if(keyCode == SDLK_RETURN) {
sendNetworkEventToServer("vrr.skinSelected", skinSelectorIndex);
toggleSkinSelect(false);
return true;
} else if(keyCode == SDLK_BACKSPACE) {
sendNetworkEventToServer("vrr.skinSelected", -1);
toggleSkinSelect(false);
return true;
}
localPlayer.heading = skinSelectHeading;
}
}
// ===========================================================================
function processSkinSelectRendering() {
if(usingSkinSelector) {
if(skinSelectMessageFontTop != null && skinSelectMessageFontBottom != null) {
if(skinSelectMessageTextTop != "" && skinSelectMessageTextBottom != "") {
skinSelectMessageFontTop.render(skinSelectMessageTextTop, [0, game.height-100], game.width, 0.5, 0.0, skinSelectMessageFontTop.size, skinSelectMessageColourTop, true, true, false, true);
skinSelectMessageFontBottom.render(skinSelectMessageTextBottom, [0, game.height-65], game.width, 0.5, 0.0, skinSelectMessageFontBottom.size, skinSelectMessageColourBottom, true, true, false, true);
}
}
}
if(skinSelectMessageFontTop != null && skinSelectMessageFontBottom != null) {
if(skinSelectMessageTextTop != "" && skinSelectMessageTextBottom != "") {
skinSelectMessageFontTop.render(skinSelectMessageTextTop, [0, game.height-100], game.width, 0.5, 0.0, skinSelectMessageFontTop.size, skinSelectMessageColourTop, true, true, false, true);
skinSelectMessageFontBottom.render(skinSelectMessageTextBottom, [0, game.height-65], game.width, 0.5, 0.0, skinSelectMessageFontBottom.size, skinSelectMessageColourBottom, true, true, false, true);
}
}
}
}
// ===========================================================================
function toggleSkinSelect(state) {
if(state) {
skinSelectorIndex = getAllowedSkinIndexFromSkin(localPlayer.skin);
if(!skinSelectorIndex) {
skinSelectorIndex = 0;
}
if(state) {
skinSelectorIndex = getAllowedSkinIndexFromSkin(localPlayer.skin);
if(!skinSelectorIndex) {
skinSelectorIndex = 0;
}
usingSkinSelector = true;
skinSelectPosition = localPlayer.position;
skinSelectHeading = localPlayer.heading;
usingSkinSelector = true;
skinSelectPosition = localPlayer.position;
skinSelectHeading = localPlayer.heading;
if(isCustomCameraSupported()) {
let tempPosition = localPlayer.position;
tempPosition.z += 0.5;
let frontCameraPosition = getPosInFrontOfPos(tempPosition, localPlayer.heading, 3);
game.setCameraLookAt(frontCameraPosition, localPlayer.position, true);
}
if(isCustomCameraSupported()) {
let tempPosition = localPlayer.position;
tempPosition.z += 0.5;
let frontCameraPosition = getPosInFrontOfPos(tempPosition, localPlayer.heading, 3);
game.setCameraLookAt(frontCameraPosition, localPlayer.position, true);
}
if(getGame() == VRR_GAME_GTA_IV) {
//natives.changePlayerModel(natives.getPlayerId(), allowedSkins[skinSelectorIndex][0]);
localPlayer.skin = allowedSkins[skinSelectorIndex][0];
} else {
localPlayer.skin = allowedSkins[skinSelectorIndex][0];
}
skinSelectMessageTextTop = allowedSkins[skinSelectorIndex][1];
setLocalPlayerControlState(false, false);
} else {
usingSkinSelector = false;
setLocalPlayerControlState(false, false);
}
if(getGame() == VRR_GAME_GTA_IV) {
let skinId = allowedSkins[skinSelectorIndex][0];
if(natives.isModelInCdimage(skinId)) {
natives.requestModel(skinId);
natives.loadAllObjectsNow();
if(natives.hasModelLoaded(skinId)) {
natives.changePlayerModel(natives.getPlayerId(), skinId);
}
}
} else {
localPlayer.skin = allowedSkins[skinSelectorIndex][0];
}
skinSelectMessageTextTop = allowedSkins[skinSelectorIndex][1];
setLocalPlayerControlState(false, false);
} else {
usingSkinSelector = false;
setLocalPlayerControlState(false, false);
}
}
// ===========================================================================

View File

@@ -8,158 +8,167 @@
// ===========================================================================
function initClientScripts() {
initGUIScript();
initNameTagScript();
initScoreBoardScript();
initMessagingScript();
initServerScript();
initLogoScript();
initLabelScript();
initChatBoxScript();
initAFKScript();
initKeyBindScript();
initEventScript();
initSkinSelectScript();
initGUIScript();
initNameTagScript();
initScoreBoardScript();
initMessagingScript();
initServerScript();
initLogoScript();
initLabelScript();
initChatBoxScript();
initAFKScript();
initKeyBindScript();
initEventScript();
initSkinSelectScript();
}
// ===========================================================================
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.SET_CAR_DENSITY_MULTIPLIER(3.0);
game.SET_PED_DENSITY_MULTIPLIER(3.0);
game.onMission = true;
SetStandardControlsEnabled(true);
return true;
}
switch(getGame()) {
case 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.SET_CAR_DENSITY_MULTIPLIER(3.0); // No visual effect. Needs tweaking and testing.
//game.SET_PED_DENSITY_MULTIPLIER(3.0); // No visual effect. Needs tweaking and testing.
game.onMission = true; // Disables taxi/vigilante/etc and other start mission triggers
SetStandardControlsEnabled(true); // Provided by mouse camera script (mousecam.js)
break;
if(getGame() == VRR_GAME_GTA_VC) {
game.SET_PLAYER_NEVER_GETS_TIRED(game.GET_PLAYER_ID(), 0);
game.setGameStat(STAT_PROGRESSMADE, 9999);
game.setGameStat(STAT_TOTALPROGRESSINGAME, 9999);
game.SET_CAR_DENSITY_MULTIPLIER(3.0);
game.SET_PED_DENSITY_MULTIPLIER(3.0);
case VRR_GAME_GTA_VC:
game.SET_PLAYER_NEVER_GETS_TIRED(game.GET_PLAYER_ID(), 0);
game.setGameStat(STAT_PROGRESSMADE, 9999);
game.setGameStat(STAT_TOTALPROGRESSINGAME, 9999);
//game.SET_CAR_DENSITY_MULTIPLIER(3.0); // No visual effect. Needs tweaking and testing.
//game.SET_PED_DENSITY_MULTIPLIER(3.0); // No visual effect. Needs tweaking and testing.
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.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;
SetStandardControlsEnabled(true);
return true;
}
game.LOAD_ALL_MODELS_NOW();
game.onMission = true; // Disables taxi/vigilante/etc and other start mission triggers
SetStandardControlsEnabled(true); // Provided by mouse camera script (mousecam.js)
break;
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, 400);
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, 9999);
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, 9999);
game.setGameStat(STAT_UNDERWATER_STAMINA, 9999);
game.setGameStat(STAT_BODY_MUSCLE, 9999);
case 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, 400);
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, 9999);
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, 9999);
game.setGameStat(STAT_UNDERWATER_STAMINA, 9999);
game.setGameStat(STAT_BODY_MUSCLE, 9999);
game.setDefaultInteriors(false);
game.onMission = true;
return true;
}
game.setDefaultInteriors(false); // Disables default yellow cone at doors for entering places in singleplayer
game.onMission = true; // Disables taxi/vigilante/etc and other start mission triggers
break;
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.loadAllObjectsNow();
natives.setCellphoneRanked(false);
natives.setOverrideNoSprintingOnPhoneInMultiplayer(false);
natives.setSyncWeatherAndGameTime(false);
natives.usePlayerColourInsteadOfTeamColour(true);
natives.disablePauseMenu(true);
natives.allowReactionAnims(localPlayer, true);
natives.allowGameToPauseForStreaming(false);
natives.allowStuntJumpsToTrigger(false);
natives.setPickupsFixCars(false);
case 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.loadAllObjectsNow();
natives.setCellphoneRanked(false);
natives.setOverrideNoSprintingOnPhoneInMultiplayer(false);
natives.setSyncWeatherAndGameTime(false);
natives.usePlayerColourInsteadOfTeamColour(true);
natives.disablePauseMenu(true);
//natives.allowReactionAnims(localPlayer, false);
natives.allowGameToPauseForStreaming(false);
natives.allowStuntJumpsToTrigger(false);
natives.setPickupsFixCars(false);
natives.forceFullVoice(localPlayer);
// HUD and Display
//natives.displayCash(false);
//natives.displayAmmo(false);
//natives.displayHud(false);
//natives.displayRadar(false);
//natives.displayAreaName(false);
//natives.displayPlayerNames(false);
natives.setPoliceRadarBlips(false);
natives.removeTemporaryRadarBlipsForPickups();
natives.displayNonMinigameHelpMessages(false);
natives.setDisplayPlayerNameAndIcon(natives.getPlayerId(), false);
// HUD and Display
//natives.displayCash(false);
//natives.displayAmmo(false);
//natives.displayHud(false);
//natives.displayRadar(false);
//natives.displayAreaName(false);
natives.displayPlayerNames(true);
natives.setPoliceRadarBlips(false);
natives.removeTemporaryRadarBlipsForPickups();
natives.displayNonMinigameHelpMessages(false);
natives.setDisplayPlayerNameAndIcon(natives.getPlayerId(), true);
// Item/Money Dropping
natives.setMoneyCarriedByAllNewPeds(0);
natives.setDeadPedsDropWeapons(false);
natives.setPlayersDropMoneyInNetworkGame(false);
// Item/Money Dropping
natives.setMoneyCarriedByAllNewPeds(0);
natives.setDeadPedsDropWeapons(false);
natives.setPlayersDropMoneyInNetworkGame(false);
// Population
//natives.dontSuppressAnyCarModels(5.0);
//natives.dontSuppressAnyPedModels(5.0);
//natives.forceGenerateParkedCarsTooCloseToOthers(true);
//natives.setParkedCarDensityMultiplier(5.0);
//natives.setRandomCarDensityMultiplier(5.0);
//natives.setPedDensityMultiplier(5.0);
//natives.setCarDensityMultiplier(5.0);
//natives.setScenarioPedDensityMultiplier(5.0, 5.0);
natives.switchRandomTrains(true);
natives.switchRandomBoats(true);
natives.switchAmbientPlanes(true);
natives.switchMadDrivers(false);
// Population
//natives.dontSuppressAnyCarModels(5.0);
//natives.dontSuppressAnyPedModels(5.0);
//natives.forceGenerateParkedCarsTooCloseToOthers(true);
//natives.setParkedCarDensityMultiplier(5.0);
//natives.setRandomCarDensityMultiplier(5.0);
//natives.setPedDensityMultiplier(5.0);
//natives.setCarDensityMultiplier(5.0);
//natives.setScenarioPedDensityMultiplier(5.0, 5.0);
natives.switchRandomTrains(true);
natives.switchRandomBoats(true);
natives.switchAmbientPlanes(true);
natives.switchMadDrivers(false);
natives.requestAnims("DANCING");
return true;
}
// Singleplayer Cellphone
natives.requestScript("spcellphone");
natives.startNewScript("spcellphone", 0);
// Script "v-blockedscripts" blocks the mpcellphone scripts
natives.setMessagesWaiting(false); // Seems to have no effect
natives.setMobilePhoneRadioState(false);
if(getGame() == VRR_GAME_MAFIA_ONE) {
game.mapEnabled = false;
game.setTrafficEnabled(false);
return true;
}
// Animation libraries
natives.requestAnims("DANCING");
// Some last steps
natives.loadAllObjectsNow();
break;
case VRR_GAME_MAFIA_ONE:
game.mapEnabled = false;
game.setTrafficEnabled(false);
break;
}
}
// ===========================================================================

View File

@@ -8,37 +8,37 @@
// ===========================================================================
function processSync(event, deltaTime) {
if(localPlayer != null) {
if(!areServerElementsSupported()) {
sendNetworkEventToServer("vrr.plr.pos", localPlayer.position);
sendNetworkEventToServer("vrr.plr.rot", localPlayer.heading);
if(localPlayer != null) {
if(!areServerElementsSupported()) {
sendNetworkEventToServer("vrr.plr.pos", (localPlayer.vehicle != null) ? localPlayer.vehicle.position : localPlayer.position);
sendNetworkEventToServer("vrr.plr.rot", (localPlayer.vehicle != null) ? localPlayer.vehicle.heading : localPlayer.heading);
//if(localPlayer.vehicle != null) {
// sendNetworkEventToServer("vrr.veh.pos", getVehicleForNetworkEvent(localPlayer.vehicle), localPlayer.vehicle.position);
// sendNetworkEventToServer("vrr.veh.rot", getVehicleForNetworkEvent(localPlayer.vehicle), localPlayer.vehicle.heading);
//}
}
//if(localPlayer.vehicle != null) {
// sendNetworkEventToServer("vrr.veh.pos", getVehicleForNetworkEvent(localPlayer.vehicle), localPlayer.vehicle.position);
// sendNetworkEventToServer("vrr.veh.rot", getVehicleForNetworkEvent(localPlayer.vehicle), localPlayer.vehicle.heading);
//}
}
if(localPlayer.health <= 0) {
if(!calledDeathEvent) {
logToConsole(LOG_DEBUG, `Local player died`);
localPlayer.clearWeapons();
calledDeathEvent = true;
sendNetworkEventToServer("vrr.playerDeath");
}
}
if(localPlayer.health <= 0) {
if(!calledDeathEvent) {
logToConsole(LOG_DEBUG, `Local player died`);
localPlayer.clearWeapons();
calledDeathEvent = true;
sendNetworkEventToServer("vrr.playerDeath");
}
}
if(streamingRadioElement) {
streamingRadio.position = getElementPosition(streamingRadioElement);
//streamingRadio.volume = getStreamingRadioVolumeForPosition(streamingRadio.position);
}
}
if(streamingRadioElement) {
streamingRadio.position = getElementPosition(streamingRadioElement);
//streamingRadio.volume = getStreamingRadioVolumeForPosition(streamingRadio.position);
}
}
}
// ===========================================================================
function setVehicleEngine(vehicleId, state) {
getElementFromId(vehicleId).engine = state;
getElementFromId(vehicleId).engine = state;
}
// ===========================================================================
@@ -46,370 +46,390 @@ function setVehicleEngine(vehicleId, state) {
function setVehicleLights(vehicleId, state) {
if(getGame() != VRR_GAME_MAFIA_ONE) {
if(!state) {
getElementFromId(vehicleId).lightStatus = 2;
} else {
getElementFromId(vehicleId).lightStatus = 1;
}
} else if(getGame() == VRR_GAME_GTA_IV) {
if(!state) {
natives.forceCarLights(natives.getVehicleFromNetworkId(vehicleId, 0));
} else {
natives.forceCarLights(natives.getVehicleFromNetworkId(vehicleId, 1));
}
} else {
if(!state) {
getElementFromId(vehicleId).lights = false;
} else {
getElementFromId(vehicleId).lights = true;
}
}
if(getGame() != VRR_GAME_MAFIA_ONE) {
if(!state) {
getElementFromId(vehicleId).lightStatus = 2;
} else {
getElementFromId(vehicleId).lightStatus = 1;
}
} else if(getGame() == VRR_GAME_GTA_IV) {
if(!state) {
natives.forceCarLights(natives.getVehicleFromNetworkId(vehicleId, 0));
} else {
natives.forceCarLights(natives.getVehicleFromNetworkId(vehicleId, 1));
}
} else {
if(!state) {
getElementFromId(vehicleId).lights = false;
} else {
getElementFromId(vehicleId).lights = true;
}
}
}
// ===========================================================================
function repairVehicle(syncId) {
getVehicleFromSyncId(syncId).fix();
getVehicleFromSyncId(syncId).fix();
}
// ===========================================================================
function syncVehicleProperties(vehicle) {
if(!areServerElementsSupported()) {
return false;
}
if(!areServerElementsSupported()) {
return false;
}
if(doesEntityDataExist(vehicle, "vrr.lights")) {
let lightStatus = getEntityData(vehicle, "vrr.lights");
if(!lightStatus) {
vehicle.lightStatus = 2;
} else {
vehicle.lightStatus = 1;
}
}
if(doesEntityDataExist(vehicle, "vrr.lights")) {
let lightStatus = getEntityData(vehicle, "vrr.lights");
if(!lightStatus) {
vehicle.lightStatus = 2;
} else {
vehicle.lightStatus = 1;
}
}
if(doesEntityDataExist(vehicle, "vrr.invincible")) {
let invincible = getEntityData(vehicle, "vrr.invincible");
element.setProofs(invincible, invincible, invincible, invincible, invincible);
}
if(doesEntityDataExist(vehicle, "vrr.invincible")) {
let invincible = getEntityData(vehicle, "vrr.invincible");
element.setProofs(invincible, invincible, invincible, invincible, invincible);
}
if(doesEntityDataExist(vehicle, "vrr.panelStatus")) {
let panelsStatus = getEntityData(vehicle, "vrr.panelStatus");
for(let i in panelsStatus) {
vehicle.setPanelStatus(i, panelsStatus[i]);
}
}
if(doesEntityDataExist(vehicle, "vrr.panelStatus")) {
let panelsStatus = getEntityData(vehicle, "vrr.panelStatus");
for(let i in panelsStatus) {
vehicle.setPanelStatus(i, panelsStatus[i]);
}
}
if(doesEntityDataExist(vehicle, "vrr.wheelStatus")) {
let wheelsStatus = getEntityData(vehicle, "vrr.wheelStatus");
for(let i in wheelsStatus) {
vehicle.setWheelStatus(i, wheelsStatus[i]);
}
}
if(doesEntityDataExist(vehicle, "vrr.wheelStatus")) {
let wheelsStatus = getEntityData(vehicle, "vrr.wheelStatus");
for(let i in wheelsStatus) {
vehicle.setWheelStatus(i, wheelsStatus[i]);
}
}
if(doesEntityDataExist(vehicle, "vrr.lightStatus")) {
let lightStatus = getEntityData(vehicle, "vrr.lightStatus");
for(let i in lightStatus) {
vehicle.setLightStatus(i, lightStatus[i]);
}
}
if(doesEntityDataExist(vehicle, "vrr.lightStatus")) {
let lightStatus = getEntityData(vehicle, "vrr.lightStatus");
for(let i in lightStatus) {
vehicle.setLightStatus(i, lightStatus[i]);
}
}
if(doesEntityDataExist(vehicle, "vrr.suspensionHeight")) {
let suspensionHeight = getEntityData(vehicle, "vrr.suspensionHeight");
vehicle.setSuspensionHeight(suspensionHeight);
}
if(doesEntityDataExist(vehicle, "vrr.suspensionHeight")) {
let suspensionHeight = getEntityData(vehicle, "vrr.suspensionHeight");
vehicle.setSuspensionHeight(suspensionHeight);
}
if(getGame() == VRR_GAME_GTA_SA) {
let allUpgrades = getGameConfig().vehicleUpgrades[getGame()];
for(let i in allUpgrades) {
vehicle.removeUpgrade(i);
}
if(getGame() == VRR_GAME_GTA_SA) {
let allUpgrades = getGameConfig().vehicleUpgrades[getGame()];
for(let i in allUpgrades) {
vehicle.removeUpgrade(i);
}
if(doesEntityDataExist(vehicle, "vrr.upgrades")) {
let upgrades = getEntityData(vehicle, "vrr.upgrades");
for(let i in upgrades) {
if(upgrades[i] != 0) {
vehicle.addUpgrade(upgrades[i]);
}
}
}
}
if(doesEntityDataExist(vehicle, "vrr.upgrades")) {
let upgrades = getEntityData(vehicle, "vrr.upgrades");
for(let i in upgrades) {
if(upgrades[i] != 0) {
vehicle.addUpgrade(upgrades[i]);
}
}
}
}
if(getGame() == VRR_GAME_GTA_SA || getGame() == VRR_GAME_GTA_IV) {
if(doesEntityDataExist(vehicle, "vrr.livery")) {
let livery = getEntityData(vehicle, "vrr.livery");
if(getGame() == VRR_GAME_GTA_SA) {
vehicle.setPaintJob(livery);
} else if(getGame() == VRR_GAME_GTA_IV) {
vehicle.livery = livery;
}
}
}
if(getGame() == VRR_GAME_GTA_SA || getGame() == VRR_GAME_GTA_IV) {
if(doesEntityDataExist(vehicle, "vrr.livery")) {
let livery = getEntityData(vehicle, "vrr.livery");
if(getGame() == VRR_GAME_GTA_SA) {
vehicle.setPaintJob(livery);
} else if(getGame() == VRR_GAME_GTA_IV) {
vehicle.livery = livery;
}
}
}
}
// ===========================================================================
function syncCivilianProperties(civilian) {
if(!areServerElementsSupported()) {
return false;
}
if(!areServerElementsSupported()) {
return false;
}
if(getGame() == VRR_GAME_GTA_III) {
if(doesEntityDataExist(civilian, "vrr.scale")) {
let scaleFactor = getEntityData(civilian, "vrr.scale");
let tempMatrix = civilian.matrix;
tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z));
let tempPosition = civilian.position;
civilian.matrix = tempMatrix;
tempPosition.z += scaleFactor.z;
civilian.position = tempPosition;
}
}
if(getGame() == VRR_GAME_GTA_III) {
if(doesEntityDataExist(civilian, "vrr.scale")) {
let scaleFactor = getEntityData(civilian, "vrr.scale");
let tempMatrix = civilian.matrix;
tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z));
let tempPosition = civilian.position;
civilian.matrix = tempMatrix;
tempPosition.z += scaleFactor.z;
civilian.position = tempPosition;
}
}
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() == VRR_GAME_GTA_SA) {
if(doesEntityDataExist(civilian, "vrr.fightStyle")) {
let fightStyle = getEntityData(civilian, "vrr.fightStyle");
civilian.setFightStyle(fightStyle[0], fightStyle[1]);
}
}
if(getGame() == VRR_GAME_GTA_III) {
if(doesEntityDataExist(civilian, "vrr.walkStyle")) {
let walkStyle = getEntityData(civilian, "vrr.walkStyle");
civilian.walkStyle = walkStyle;
}
}
if(getGame() == VRR_GAME_GTA_III) {
if(doesEntityDataExist(civilian, "vrr.walkStyle")) {
let walkStyle = getEntityData(civilian, "vrr.walkStyle");
civilian.walkStyle = walkStyle;
}
}
if(getGame() == VRR_GAME_GTA_IV) {
if(doesEntityDataExist(civilian, "vrr.bodyPropHair")) {
let bodyPropHair = getEntityData(civilian, "vrr.bodyPropHair");
civilian.changeBodyProp(0, bodyPropHair[0], bodyPropHair[1]);
}
if(getGame() == VRR_GAME_GTA_IV) {
if(doesEntityDataExist(civilian, "vrr.bodyPropHair")) {
let bodyPropHair = getEntityData(civilian, "vrr.bodyPropHair");
civilian.changeBodyProp(0, bodyPropHair[0], bodyPropHair[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropHead")) {
let bodyPropHead = getEntityData(civilian, "vrr.bodyPropHead");
civilian.changeBodyProp(1, bodyPropHead[0], bodyPropHead[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropHead")) {
let bodyPropHead = getEntityData(civilian, "vrr.bodyPropHead");
civilian.changeBodyProp(1, bodyPropHead[0], bodyPropHead[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropEyes")) {
let bodyPropEyes = getEntityData(civilian, "vrr.bodyPropEyes");
civilian.changeBodyProp(1, bodyPropEyes[0], bodyPropEyes[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropEyes")) {
let bodyPropEyes = getEntityData(civilian, "vrr.bodyPropEyes");
civilian.changeBodyProp(1, bodyPropEyes[0], bodyPropEyes[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropLeftHand")) {
let bodyPropLeftHand = getEntityData(civilian, "vrr.bodyPropLeftHand");
civilian.changeBodyProp(1, bodyPropLeftHand[0], bodyPropLeftHand[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropLeftHand")) {
let bodyPropLeftHand = getEntityData(civilian, "vrr.bodyPropLeftHand");
civilian.changeBodyProp(1, bodyPropLeftHand[0], bodyPropLeftHand[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropRightHand")) {
let bodyPropRightHand = getEntityData(civilian, "vrr.bodyPropRightHand");
civilian.changeBodyProp(1, bodyPropRightHand[0], bodyPropRightHand[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropRightHand")) {
let bodyPropRightHand = getEntityData(civilian, "vrr.bodyPropRightHand");
civilian.changeBodyProp(1, bodyPropRightHand[0], bodyPropRightHand[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropLeftWrist")) {
let bodyPropLeftWrist = getEntityData(civilian, "vrr.bodyPropLeftWrist");
civilian.changeBodyProp(1, bodyPropLeftWrist[0], bodyPropLeftWrist[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropLeftWrist")) {
let bodyPropLeftWrist = getEntityData(civilian, "vrr.bodyPropLeftWrist");
civilian.changeBodyProp(1, bodyPropLeftWrist[0], bodyPropLeftWrist[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(civilian, "vrr.bodyPropRightWrist");
civilian.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(civilian, "vrr.bodyPropRightWrist");
civilian.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(civilian, "vrr.bodyPropRightWrist");
civilian.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(civilian, "vrr.bodyPropRightWrist");
civilian.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropHip")) {
let bodyPropHip = getEntityData(civilian, "vrr.bodyPropHip");
civilian.changeBodyProp(1, bodyPropHip[0], bodyPropHip[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropHip")) {
let bodyPropHip = getEntityData(civilian, "vrr.bodyPropHip");
civilian.changeBodyProp(1, bodyPropHip[0], bodyPropHip[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropLeftFoot")) {
let bodyPropLeftFoot = getEntityData(civilian, "vrr.bodyPropLeftFoot");
civilian.changeBodyProp(1, bodyPropLeftFoot[0], bodyPropLeftFoot[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropLeftFoot")) {
let bodyPropLeftFoot = getEntityData(civilian, "vrr.bodyPropLeftFoot");
civilian.changeBodyProp(1, bodyPropLeftFoot[0], bodyPropLeftFoot[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropRightFoot")) {
let bodyPropRightFoot = getEntityData(civilian, "vrr.bodyPropRightFoot");
civilian.changeBodyProp(1, bodyPropRightFoot[0], bodyPropRightFoot[1]);
}
}
if(doesEntityDataExist(civilian, "vrr.bodyPropRightFoot")) {
let bodyPropRightFoot = getEntityData(civilian, "vrr.bodyPropRightFoot");
civilian.changeBodyProp(1, bodyPropRightFoot[0], bodyPropRightFoot[1]);
}
}
if(doesEntityDataExist(civilian, "vrr.anim")) {
let animData = getEntityData(vehicle, "vrr.anim");
civilian.addAnimation(animData[0], animData[1]);
}
if(doesEntityDataExist(civilian, "vrr.anim")) {
let animData = getEntityData(civilian, "vrr.anim");
civilian.addAnimation(animData[0], animData[1]);
}
}
// ===========================================================================
function syncPlayerProperties(player) {
if(!areServerElementsSupported()) {
return false;
}
if(!areServerElementsSupported()) {
return false;
}
if(getGame() == VRR_GAME_GTA_III) {
if(doesEntityDataExist(player, "vrr.scale")) {
let scaleFactor = getEntityData(player, "vrr.scale");
let tempMatrix = player.matrix;
tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z));
let tempPosition = player.position;
player.matrix = tempMatrix;
tempPosition.z += scaleFactor.z;
player.position = tempPosition;
}
}
if(getGame() == VRR_GAME_GTA_III) {
if(doesEntityDataExist(player, "vrr.scale")) {
let scaleFactor = getEntityData(player, "vrr.scale");
let tempMatrix = player.matrix;
tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z));
let tempPosition = player.position;
player.matrix = tempMatrix;
tempPosition.z += scaleFactor.z;
player.position = tempPosition;
}
}
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() == VRR_GAME_GTA_SA) {
if(doesEntityDataExist(player, "vrr.fightStyle")) {
let fightStyle = getEntityData(player, "vrr.fightStyle");
player.setFightStyle(fightStyle[0], fightStyle[1]);
}
}
//if(getGame() == VRR_GAME_GTA_SA) {
// if(doesEntityDataExist(player, "vrr.walkStyle")) {
// let walkStyle = getEntityData(player, "vrr.walkStyle");
// player.walkStyle = walkStyle;
// }
//}
//if(getGame() == VRR_GAME_GTA_SA) {
// if(doesEntityDataExist(player, "vrr.walkStyle")) {
// let walkStyle = getEntityData(player, "vrr.walkStyle");
// player.walkStyle = walkStyle;
// }
//}
if(getGame() == VRR_GAME_GTA_IV) {
if(doesEntityDataExist(player, "vrr.bodyPartHair")) {
let bodyPartHead = getEntityData(player, "vrr.bodyPartHair");
player.changeBodyPart(0, bodyPartHead[0], bodyPartHair[1]);
}
if(getGame() == VRR_GAME_GTA_IV) {
if(doesEntityDataExist(player, "vrr.bodyPartHair")) {
let bodyPartHead = getEntityData(player, "vrr.bodyPartHair");
player.changeBodyPart(0, bodyPartHead[0], bodyPartHair[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPartHead")) {
let bodyPartHead = getEntityData(player, "vrr.bodyPartHead");
player.changeBodyPart(1, bodyPartHead[0], bodyPartHead[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPartHead")) {
let bodyPartHead = getEntityData(player, "vrr.bodyPartHead");
player.changeBodyPart(1, bodyPartHead[0], bodyPartHead[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPartUpper")) {
let bodyPartUpper = getEntityData(player, "vrr.bodyPartUpper");
player.changeBodyPart(1, bodyPartUpper[0], bodyPartUpper[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPartUpper")) {
let bodyPartUpper = getEntityData(player, "vrr.bodyPartUpper");
player.changeBodyPart(1, bodyPartUpper[0], bodyPartUpper[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPartLower")) {
let bodyPartLower = getEntityData(player, "vrr.bodyPartLower");
player.changeBodyPart(1, bodyPartLower[0], bodyPartLower[1]);
}
}
if(doesEntityDataExist(player, "vrr.bodyPartLower")) {
let bodyPartLower = getEntityData(player, "vrr.bodyPartLower");
player.changeBodyPart(1, bodyPartLower[0], bodyPartLower[1]);
}
}
if(getGame() == VRR_GAME_GTA_IV) {
if(doesEntityDataExist(player, "vrr.bodyPropHair")) {
let bodyPropHair = getEntityData(player, "vrr.bodyPropHair");
player.changeBodyProp(0, bodyPropHair[0], bodyPropHair[1]);
}
if(getGame() == VRR_GAME_GTA_IV) {
if(doesEntityDataExist(player, "vrr.bodyPropHair")) {
let bodyPropHair = getEntityData(player, "vrr.bodyPropHair");
player.changeBodyProp(0, bodyPropHair[0], bodyPropHair[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropHead")) {
let bodyPropHead = getEntityData(player, "vrr.bodyPropHead");
player.changeBodyProp(1, bodyPropHead[0], bodyPropHead[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropHead")) {
let bodyPropHead = getEntityData(player, "vrr.bodyPropHead");
player.changeBodyProp(1, bodyPropHead[0], bodyPropHead[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropEyes")) {
let bodyPropEyes = getEntityData(player, "vrr.bodyPropEyes");
player.changeBodyProp(1, bodyPropEyes[0], bodyPropEyes[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropEyes")) {
let bodyPropEyes = getEntityData(player, "vrr.bodyPropEyes");
player.changeBodyProp(1, bodyPropEyes[0], bodyPropEyes[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropLeftHand")) {
let bodyPropLeftHand = getEntityData(player, "vrr.bodyPropLeftHand");
player.changeBodyProp(1, bodyPropLeftHand[0], bodyPropLeftHand[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropLeftHand")) {
let bodyPropLeftHand = getEntityData(player, "vrr.bodyPropLeftHand");
player.changeBodyProp(1, bodyPropLeftHand[0], bodyPropLeftHand[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropRightHand")) {
let bodyPropRightHand = getEntityData(player, "vrr.bodyPropRightHand");
player.changeBodyProp(1, bodyPropRightHand[0], bodyPropRightHand[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropRightHand")) {
let bodyPropRightHand = getEntityData(player, "vrr.bodyPropRightHand");
player.changeBodyProp(1, bodyPropRightHand[0], bodyPropRightHand[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropLeftWrist")) {
let bodyPropLeftWrist = getEntityData(player, "vrr.bodyPropLeftWrist");
player.changeBodyProp(1, bodyPropLeftWrist[0], bodyPropLeftWrist[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropLeftWrist")) {
let bodyPropLeftWrist = getEntityData(player, "vrr.bodyPropLeftWrist");
player.changeBodyProp(1, bodyPropLeftWrist[0], bodyPropLeftWrist[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(player, "vrr.bodyPropRightWrist");
player.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(player, "vrr.bodyPropRightWrist");
player.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(player, "vrr.bodyPropRightWrist");
player.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(player, "vrr.bodyPropRightWrist");
player.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropHip")) {
let bodyPropHip = getEntityData(player, "vrr.bodyPropHip");
player.changeBodyProp(1, bodyPropHip[0], bodyPropHip[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropHip")) {
let bodyPropHip = getEntityData(player, "vrr.bodyPropHip");
player.changeBodyProp(1, bodyPropHip[0], bodyPropHip[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropLeftFoot")) {
let bodyPropLeftFoot = getEntityData(player, "vrr.bodyPropLeftFoot");
player.changeBodyProp(1, bodyPropLeftFoot[0], bodyPropLeftFoot[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropLeftFoot")) {
let bodyPropLeftFoot = getEntityData(player, "vrr.bodyPropLeftFoot");
player.changeBodyProp(1, bodyPropLeftFoot[0], bodyPropLeftFoot[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropRightFoot")) {
let bodyPropRightFoot = getEntityData(player, "vrr.bodyPropRightFoot");
player.changeBodyProp(1, bodyPropRightFoot[0], bodyPropRightFoot[1]);
}
}
if(doesEntityDataExist(player, "vrr.bodyPropRightFoot")) {
let bodyPropRightFoot = getEntityData(player, "vrr.bodyPropRightFoot");
player.changeBodyProp(1, bodyPropRightFoot[0], bodyPropRightFoot[1]);
}
}
}
// ===========================================================================
function syncObjectProperties(object) {
if(!areServerElementsSupported()) {
return false;
}
if(!areServerElementsSupported()) {
return false;
}
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;
tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z));
let tempPosition = object.position;
object.matrix = tempMatrix;
tempPosition.z += scaleFactor.z;
object.position = tempPosition;
}
}
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;
tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z));
let tempPosition = object.position;
object.matrix = tempMatrix;
tempPosition.z += scaleFactor.z;
object.position = tempPosition;
}
}
}
// ===========================================================================
function syncElementProperties(element) {
if(!areServerElementsSupported()) {
return false;
}
if(!areServerElementsSupported()) {
return false;
}
if(doesEntityDataExist(element, "vrr.interior")) {
if(typeof element.interior != "undefined") {
element.interior = getEntityData(element, "vrr.interior");
}
}
if(doesEntityDataExist(element, "vrr.interior")) {
if(typeof element.interior != "undefined") {
element.interior = getEntityData(element, "vrr.interior");
}
}
switch(element.type) {
case ELEMENT_VEHICLE:
syncVehicleProperties(element);
break;
if(getGame() == VRR_GAME_MAFIA_ONE) {
switch(element.type) {
case ELEMENT_VEHICLE:
syncVehicleProperties(element);
break;
case ELEMENT_PED:
syncCivilianProperties(element);
break;
case ELEMENT_PED:
syncCivilianProperties(element);
break;
case ELEMENT_PLAYER:
syncPlayerProperties(element);
break;
case ELEMENT_PLAYER:
syncPlayerProperties(element);
break;
case ELEMENT_OBJECT:
syncObjectProperties(element);
break;
default:
break;
}
} else {
switch(element.type) {
case ELEMENT_VEHICLE:
syncVehicleProperties(element);
break;
case ELEMENT_PED:
syncCivilianProperties(element);
break;
case ELEMENT_PLAYER:
syncPlayerProperties(element);
break;
case ELEMENT_OBJECT:
syncObjectProperties(element);
break;
default:
break;
}
}
default:
break;
}
}
@@ -417,21 +437,21 @@ function syncElementProperties(element) {
// ===========================================================================
function receiveHouseFromServer(houseId, entrancePosition, blipModel, pickupModel, hasInterior) {
if(getGame() == VRR_GAME_GTA_IV) {
}
if(getGame() == VRR_GAME_GTA_IV) {
}
}
// ===========================================================================
function setLocalPlayerPedPartsAndProps(parts, props) {
for(let i in parts) {
localPlayer.changeBodyPart(parts[i][0], parts[i][1], parts[i][2]);
}
for(let i in parts) {
localPlayer.changeBodyPart(parts[i][0], parts[i][1], parts[i][2]);
}
for(let j in props) {
localPlayer.changeBodyProp(props[j][0], props[j][1]);
}
for(let j in props) {
localPlayer.changeBodyProp(props[j][0], props[j][1]);
}
}
// ===========================================================================

File diff suppressed because it is too large Load Diff

18
scripts/client/vehicle.js Normal file
View File

@@ -0,0 +1,18 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: vehicle.js
// DESC: Provides vehicle functions and arrays with data
// TYPE: Client (JavaScript)
// ===========================================================================
function receiveVehicleFromServer(vehicleId, position, model, colour1, colour2, colour3 = 0, colour4 = 0) {
logToConsole(LOG_DEBUG, `[VRR.Job] Received vehicle ${vehicleId} (${getVehicleNameFromModel(model, getGame())}) from server`);
if(getGame() == VRR_GAME_GTA_IV) {
}
}
// ===========================================================================

View File

@@ -8,30 +8,30 @@
// ===========================================================================
function getPlayerAccentText(client) {
return getPlayerCurrentSubAccount(client).accent;
return getPlayerCurrentSubAccount(client).accent;
}
// ===========================================================================
function setPlayerAccentText(client, text) {
getPlayerCurrentSubAccount(client).accent = text;
getPlayerCurrentSubAccount(client).accent = text;
}
// ===========================================================================
function doesPlayerHaveAccent(client) {
return (getPlayerCurrentSubAccount(client).accent != "");
return (getPlayerCurrentSubAccount(client).accent != "");
}
// ===========================================================================
function getPlayerAccentInlineOutput(client) {
let outputText = "";
if(doesPlayerHaveAccent(client)) {
outputText = `[${getPlayerAccentText(client)}] `;
}
let outputText = "";
if(doesPlayerHaveAccent(client)) {
outputText = `[${getPlayerAccentText(client)}] `;
}
return outputText;
return outputText;
}
// ===========================================================================

View File

@@ -94,13 +94,13 @@ function toggleAutoSelectLastCharacterCommand(command, params, client) {
function toggleAccountGUICommand(command, params, client) {
let flagValue = getAccountSettingsFlagValue("NoGUI");
if(!doesPlayerHaveGUIEnabled(client)) {
if(doesPlayerHaveGUIEnabled(client)) {
getPlayerData(client).accountData.settings = removeBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerNormal(client, getLocaleString(client, "GUIAccountSettingToggle", `{softRed}${toUpperCase(getLocaleString(client, "Off"))}`));
messagePlayerNormal(client, getLocaleString(client, "GUIAccountSettingToggle", `{softRed}${toUpperCase(getLocaleString(client, "Off"))}{MAINCOLOUR}`));
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has toggled GUI for their account ON.`);
} else {
getPlayerData(client).accountData.settings = addBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerNormal(client, getLocaleString(client, "GUIAccountSettingToggle", `{softGreen}${toUpperCase(getLocaleString(client, "On"))}`));
messagePlayerNormal(client, getLocaleString(client, "GUIAccountSettingToggle", `{softGreen}${toUpperCase(getLocaleString(client, "On"))}{MAINCOLOUR}`));
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has toggled GUI for their account ON.`);
}
@@ -271,6 +271,26 @@ function setAccountChatScrollLinesCommand(command, params, client) {
// ===========================================================================
function setAccountChatAutoHideDelayCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
if(isNaN(params)) {
messagePlayerError(client, `The delay time must be a number!`);
return false;
}
let delay = Math.ceil(toInteger(params));
getPlayerData(client).accountData.chatAutoHideDelay = delay;
sendPlayerChatAutoHideDelay(client, delay);
messagePlayerSuccess(client, `Your chatbox will now automatically hide after ${toInteger(delay)} seconds!`);
}
// ===========================================================================
function setAccountEmailCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -569,6 +589,7 @@ function loginSuccess(client) {
if(doesServerHaveTesterOnlyEnabled()) {
if(!hasBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("IsTester"))) {
setTimeout(function() {
getPlayerData(client).customDisconnectReason = "Kicked - Not a tester";
client.disconnect();
}, 3500);
@@ -580,13 +601,13 @@ function loginSuccess(client) {
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the "not a tester" error message (GUI disabled).`);
messagePlayerError(client, getLocaleString(client, "NotATester"));
return false;
}
}
}
}
if(getPlayerData(client).subAccounts.length == 0) {
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
showPlayerPromptGUI(client, getLocaleString(client, "NoCharactersGUIMessage"), getLocaleString(client, "NoCharactersGUIWindowTitle"));
showPlayerPromptGUI(client, getLocaleString(client, "NoCharactersGUIMessage"), getLocaleString(client, "NoCharactersGUIWindowTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
getPlayerData(client).promptType = VRR_PROMPT_CREATEFIRSTCHAR;
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the no characters prompt GUI`);
} else {
@@ -600,8 +621,8 @@ function loginSuccess(client) {
getPlayerData(client).accountData.ipAddress = client.ip;
sendPlayerChatScrollLines(client, getPlayerData(client).accountData.chatScrollLines);
messagePlayerNormal(null, `👋 ${getPlayerName(client)} has joined the server`, getColourByName("softYellow"));
messageDiscordChatChannel(`👋 ${getPlayerName(client)} has joined the server`);
}
// ===========================================================================
@@ -636,6 +657,7 @@ function saveAccountToDatabase(accountData) {
["acct_svr_staff_flags", accountData.flags.admin],
["acct_svr_mod_flags", accountData.flags.moderation],
["acct_svr_chat_scroll_lines", accountData.chatScrollLines],
["acct_svr_chat_auto_hide_delay", accountData.chatAutoHideDelay],
];
let queryString1 = createDatabaseUpdateQuery("acct_main", data, `acct_id=${accountData.databaseId}`);
@@ -915,13 +937,13 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
} else {
messagePlayerError(client, "Password doesn't meet requirements!");
}
return false
return false;
}
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
if(!isValidEmailAddress(emailAddress)) {
showPlayerRegistrationFailedGUI(client, getLocaleString(client, "RegistrationFailedInvalidEmail"));
return false
return false;
}
}
@@ -947,7 +969,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
setAccountEmailVerificationCode(getPlayerData(client).accountData, emailVerificationCode);
sendEmailVerificationEmail(client, emailVerificationCode);
logToConsole(LOG_WARN, `${getPlayerDisplayForConsole(client)} was sent a registration email verification code`);
}
}
if(doesServerHaveTesterOnlyEnabled() && !isPlayerATester(client)) {
setTimeout(function() {
@@ -962,7 +984,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the "not a tester" error message (GUI disabled).`);
messagePlayerError(client, getLocaleString(client, "NotATester"));
return false;
}
}
} else {
messagePlayerAlert(client, getLocaleString(client, "RegistrationCreateCharReminder"));
@@ -979,6 +1001,10 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
// ===========================================================================
function checkAccountResetPasswordRequest(client, inputText) {
if(!checkForSMTPModule() || !getEmailConfig().enabled) {
return false;
}
if(getPlayerData(client).passwordResetState == VRR_RESETPASS_STATE_NONE) {
if(toLowerCase(getPlayerData(client).accountData.emailAddress) != toLowerCase(inputText)) {
logToConsole(LOG_DEBUG|LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to reset their password (email not correct)`);
@@ -1063,7 +1089,7 @@ function isValidEmailAddress(emailAddress) {
// ===========================================================================
function saveAllClientsToDatabase() {
function savePlayersToDatabase() {
logToConsole(LOG_DEBUG, "[VRR.Account]: Saving all clients to database ...");
getClients().forEach(function(client) {
savePlayerToDatabase(client);
@@ -1078,7 +1104,7 @@ function savePlayerToDatabase(client) {
return false;
}
if(!getPlayerData(client).loggedIn) {
if(!isPlayerLoggedIn(client)) {
return false;
}
@@ -1088,7 +1114,7 @@ function savePlayerToDatabase(client) {
if(getPlayerData(client).currentSubAccount != -1) {
//let subAccountData = getPlayerCurrentSubAccount(client);
if(client.player != null) {
if(getPlayerPed(client) != null) {
if(getPlayerData(client).returnToPosition != null) {
getPlayerCurrentSubAccount(client).spawnPosition = getPlayerData(client).returnToPosition;
getPlayerCurrentSubAccount(client).spawnHeading = getPlayerData(client).returnToHeading.z;
@@ -1146,6 +1172,7 @@ function initClient(client) {
if(isAccountAutoIPLoginEnabled(tempAccountData) && getPlayerData(client).accountData.ipAddress == client.ip) {
messagePlayerAlert(client, getLocaleString(client, "AutoLoggedInIP"));
loginSuccess(client);
playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client));
} else {
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI.`);
@@ -1153,6 +1180,12 @@ function initClient(client) {
} else {
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled).`);
messagePlayerNormal(client, getLocaleString(client, "WelcomeBack", getServerName(), getPlayerName(client), "/login"),getColourByName("softGreen"));
//if(checkForGeoIPModule()) {
// let iso = module.geoip.getCountryISO(client.ip);
// let localeId = getLocaleFromCountryISO(iso);
//}
//showGameMessage(client, getLocaleString(client, "LocaleOffer", `/lang ${getLocaleData(localeId)[2]}`), getColourByName("white"), 10000, "Roboto");
}
playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client));
}

View File

@@ -20,17 +20,17 @@ function playPlayerAnimationCommand(command, params, client) {
return false;
}
let animationSlot = getAnimationFromParams(getParam(params, " ", 1));
let animationPositionOffset = 1;
let animationSlot = getAnimationFromParams(getParam(params, " ", 1));
let animationPositionOffset = 1;
if(!animationSlot) {
messagePlayerError(client, getLocaleString(client, "AnimationNotFound"));
messagePlayerError(client, getLocaleString(client, "InvalidAnimation"));
messagePlayerInfo(client, getLocaleString(client, "AnimationHelpTip"), `{ALTCOLOUR}/animlist{MAINCOLOUR}`);
return false;
}
if(toInteger(animationPositionOffset) < 0 || toInteger(animationPositionOffset) > 3) {
messagePlayerError(client, getLocaleString(client, "AnimationInvalidDistance"));
messagePlayerError(client, getLocaleString(client, "InvalidAnimationDistance"));
return false;
}
@@ -39,7 +39,7 @@ let animationSlot = getAnimationFromParams(getParam(params, " ", 1));
}
if(isPlayerHandCuffed(client) || isPlayerTazed(client) || isPlayerInForcedAnimation(client)) {
messagePlayerError(client, `You aren't able to do that`);
messagePlayerError(client, getLocaleString(client, "UnableToDoThat"));
return false;
}
@@ -51,17 +51,17 @@ let animationSlot = getAnimationFromParams(getParam(params, " ", 1));
function stopPlayerAnimationCommand(command, params, client) {
if(isPlayerHandCuffed(client) || isPlayerTazed(client) || isPlayerInForcedAnimation(client)) {
messagePlayerError(client, `You aren't able to do that`);
messagePlayerError(client, getLocaleString(client, "UnableToDoThat"));
return false;
}
setPlayerPosition(client, getPlayerData(client).currentAnimationPositionReturnTo);
makePedStopAnimation(getPlayerData(client).ped);
makePedStopAnimation(getPlayerPed(client));
getPlayerData(client).currentAnimation = -1;
getPlayerData(client).currentAnimationPositionOffset = false;
getPlayerData(client).currentAnimationPositionReturnTo = false;
getPlayerData(client).animationStart = 0;
getPlayerData(client).animationStart = 0;
getPlayerData(client).animationForced = false;
setPlayerMouseCameraState(client, false);
@@ -70,7 +70,7 @@ function stopPlayerAnimationCommand(command, params, client) {
// ===========================================================================
function showAnimationListCommand(command, params, client) {
let animList = getGameConfig().animations[getServerGame()].map(function(x) { return x[0]; });
let animList = getGameConfig().animations[getServerGame()].map(function(x) { return x.name; });
let chunkedList = splitArrayIntoChunks(animList, 10);
@@ -88,7 +88,7 @@ function showAnimationListCommand(command, params, client) {
* @return {Array} The animation's data (array)
*/
function getAnimationData(animationSlot, gameId = getServerGame()) {
return getGameConfig().animations[gameId][animationSlot];
return getGameConfig().animations[gameId][animationSlot];
}
// ===========================================================================
@@ -100,14 +100,14 @@ function isPlayerInForcedAnimation(client) {
// ===========================================================================
function makePlayerPlayAnimation(client, animationSlot, offsetPosition = 1) {
getPlayerData(client).currentAnimation = animationSlot;
getPlayerData(client).currentAnimation = animationSlot;
getPlayerData(client).currentAnimationPositionOffset = offsetPosition;
getPlayerData(client).currentAnimationPositionReturnTo = getPlayerPosition(client);
getPlayerData(client).animationStart = getCurrentUnixTimestamp();
getPlayerData(client).animationStart = getCurrentUnixTimestamp();
getPlayerData(client).animationForced = false;
makePedPlayAnimation(getPlayerData(client).ped, animationSlot, offsetPosition);
makePedPlayAnimation(getPlayerPed(client), animationSlot, offsetPosition);
setEntityData(getPlayerPed(client), "vrr.anim", animationSlot, true);
//if(getAnimationData(animationSlot)[9] != VRR_ANIMMOVE_NONE) {
// if(getGame() < VRR_GAME_GTA_SA) {
// setPlayerMouseCameraState(client, true);
@@ -118,35 +118,36 @@ function makePlayerPlayAnimation(client, animationSlot, offsetPosition = 1) {
// ===========================================================================
function forcePlayerPlayAnimation(client, animationSlot, offsetPosition = 1) {
getPlayerData(client).currentAnimation = animationSlot;
getPlayerData(client).currentAnimation = animationSlot;
getPlayerData(client).currentAnimationPositionOffset = offsetPosition;
getPlayerData(client).currentAnimationPositionReturnTo = getPlayerPosition(client);
getPlayerData(client).animationStart = getCurrentUnixTimestamp();
getPlayerData(client).animationStart = getCurrentUnixTimestamp();
getPlayerData(client).animationForced = true;
setPlayerControlState(client, false);
forcePedAnimation(getPlayerData(client).ped, animationSlot, offsetPosition);
forcePedAnimation(getPlayerPed(client), animationSlot, offsetPosition);
}
// ===========================================================================
function makePlayerStopAnimation(client) {
//setPlayerPosition(client, getPlayerData(client).currentAnimationPositionReturnTo);
makePedStopAnimation(getPlayerData(client).ped);
makePedStopAnimation(getPlayerPed(client));
getPlayerData(client).currentAnimation = -1;
getPlayerData(client).currentAnimationPositionOffset = false;
getPlayerData(client).currentAnimationPositionReturnTo = false;
getPlayerData(client).animationStart = 0;
getPlayerData(client).animationStart = 0;
getPlayerData(client).animationForced = false;
}
// ===========================================================================
function getAnimationFromParams(params) {
let animations = getGameConfig().animations[getServerGame()];
if(isNaN(params)) {
for(let i in getGameConfig().animations[getServerGame()]) {
if(toLowerCase(getGameConfig().animations[getServerGame()][i][0]).indexOf(toLowerCase(params)) != -1) {
for(let i in animations) {
if(toLowerCase(animations[i].name).indexOf(toLowerCase(params)) != -1) {
return i;
}
}

View File

@@ -8,14 +8,14 @@
// ===========================================================================
function initAntiCheatScript() {
logToConsole(LOG_DEBUG, "[VRR.AntiCheat]: Initializing anticheat script ...");
logToConsole(LOG_DEBUG, "[VRR.AntiCheat]: Initializing anticheat script ...");
logToConsole(LOG_DEBUG, "[VRR.AntiCheat]: Anticheat script initialized!");
}
// ===========================================================================
function clearPlayerStateToEnterExitProperty(client) {
if(getPlayerData(client).pedState != VRR_PEDSTATE_READY) {
if(getPlayerData(client).pedState != VRR_PEDSTATE_READY) {
if(getPlayerData(client).pedState == VRR_PEDSTATE_ENTERINGVEHICLE) {
sendPlayerClearPedState(client);
getPlayerData(client).pedState = VRR_PEDSTATE_READY;

View File

@@ -10,8 +10,8 @@
// ===========================================================================
function initBanScript() {
logToConsole(LOG_INFO, "[VRR.Ban]: Initializing ban script ...");
logToConsole(LOG_INFO, "[VRR.Ban]: Ban script initialized!");
logToConsole(LOG_INFO, "[VRR.Ban]: Initializing ban script ...");
logToConsole(LOG_INFO, "[VRR.Ban]: Ban script initialized!");
}
// ===========================================================================
@@ -22,24 +22,24 @@ function accountBanCommand(command, params, client) {
return false;
}
let splitParams = params.split(" ");
let targetClient = getPlayerFromParams(getParam(params, " ", 1));
let reason = splitParams.slice(1).join(" ");
let splitParams = params.split(" ");
let targetClient = getPlayerFromParams(getParam(params, " ", 1));
let reason = splitParams.slice(1).join(" ");
if(!targetClient) {
messagePlayerError(client, "That player is not connected!")
return false;
}
// Prevent banning admins with really high permissions
if(doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) {
messagePlayerError(client, getLocaleString(client, "CantBanPlayer"));
return false;
if(!targetClient) {
messagePlayerError(client, "That player is not connected!")
return false;
}
logToConsole(LOG_WARN, `[VRR.Ban]: ${getPlayerDisplayForConsole(targetClient)} (${getPlayerData(targetClient).accountData.name}) account was banned by ${getPlayerDisplayForConsole(client)}. Reason: ${reason}`);
// Prevent banning admins with really high permissions
if(doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) {
messagePlayerError(client, getLocaleString(client, "CantBanPlayer"));
return false;
}
messageAdminAction(`{ALTCOLOUR}${getPlayerData(targetClient).currentSubAccountData.name} {MAINCOLOUR}has been account banned.`);
logToConsole(LOG_WARN, `[VRR.Ban]: ${getPlayerDisplayForConsole(targetClient)} (${getPlayerData(targetClient).accountData.name}) account was banned by ${getPlayerDisplayForConsole(client)}. Reason: ${reason}`);
announceAdminAction(`PlayerAccountBanned`, `{ALTCOLOUR}${targetClient.name}{MAINCOLOUR}`);
banAccount(getPlayerData(targetClient).accountData.databaseId, getPlayerData(client).accountData.databaseId, reason);
disconnectPlayer(client);
}
@@ -52,27 +52,27 @@ function subAccountBanCommand(command, params, client, fromDiscord) {
return false;
}
let splitParams = params.split(" ");
let targetClient = getPlayerFromParams(getParam(params, " ", 1));
let reason = splitParams.slice(1).join(" ");
let splitParams = params.split(" ");
let targetClient = getPlayerFromParams(getParam(params, " ", 1));
let reason = splitParams.slice(1).join(" ");
if(!targetClient) {
messagePlayerError(client, "That player is not connected!")
return false;
}
if(!targetClient) {
messagePlayerError(client, "That player is not connected!")
return false;
}
// Prevent banning admins with really high permissions
if(doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) {
messagePlayerError(client, getLocaleString(client, "CantBanPlayer"));
return false;
}
}
logToConsole(LOG_WARN, `[VRR.Ban]: ${getPlayerDisplayForConsole(targetClient)} (${getPlayerData(targetClient).accountData.name})'s subaccount was banned by ${getPlayerDisplayForConsole(client)}. Reason: ${reason}`);
logToConsole(LOG_WARN, `[VRR.Ban]: ${getPlayerDisplayForConsole(targetClient)} (${getPlayerData(targetClient).accountData.name})'s subaccount was banned by ${getPlayerDisplayForConsole(client)}. Reason: ${reason}`);
messageAdminAction(`{ALTCOLOUR}${getPlayerData(targetClient).currentSubAccountData.name} {MAINCOLOUR}has been character banned.`);
banSubAccount(getPlayerData(targetClient).currentSubAccountData.databaseId, getPlayerData(client).accountData.databaseId, reason);
announceAdminAction(`PlayerCharacterBanned`, `{ALTCOLOUR}${targetClient.name}{MAINCOLOUR}`);
banSubAccount(getPlayerData(targetClient).currentSubAccountData.databaseId, getPlayerData(client).accountData.databaseId, reason);
disconnectPlayer(client);
disconnectPlayer(client);
}
// ===========================================================================
@@ -81,28 +81,28 @@ function ipBanCommand(command, params, client, fromDiscord) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
}
let splitParams = params.split(" ");
let targetClient = getPlayerFromParams(getParam(params, " ", 1));
let reason = splitParams.slice(1).join(" ");
let splitParams = params.split(" ");
let targetClient = getPlayerFromParams(getParam(params, " ", 1));
let reason = splitParams.slice(1).join(" ");
if(!targetClient) {
messagePlayerError(client, "That player is not connected!")
return false;
}
if(!targetClient) {
messagePlayerError(client, "That player is not connected!")
return false;
}
// Prevent banning admins with really high permissions
if(doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) {
messagePlayerError(client, getLocaleString(client, "CantBanPlayer"));
return false;
}
}
messageAdminAction(`{ALTCOLOUR}${getPlayerData(targetClient).currentSubAccountData.name} {MAINCOLOUR}has been IP banned.`);
banIPAddress(targetClient.ip, getPlayerData(client).accountData.databaseId, reason);
announceAdminAction(`PlayerIPBanned`, `{ALTCOLOUR}${targetClient.name}{MAINCOLOUR}`);
banIPAddress(targetClient.ip, getPlayerData(client).accountData.databaseId, reason);
server.banIP(targetClient.ip);
targetClient.disconnect();
server.banIP(targetClient.ip);
targetClient.disconnect();
}
// ===========================================================================
@@ -111,190 +111,189 @@ function subNetBanCommand(command, params, client, fromDiscord) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
}
let splitParams = params.split(" ");
let targetClient = getPlayerFromParams(getParam(params, " ", 1));
let octetAmount = Number(getParam(params, " ", 2));
let reason = splitParams.slice(2).join(" ");
let splitParams = params.split(" ");
let targetClient = getPlayerFromParams(getParam(params, " ", 1));
let octetAmount = Number(getParam(params, " ", 2));
let reason = splitParams.slice(2).join(" ");
if(!targetClient) {
messagePlayerError(client, "That player is not connected!")
return false;
}
if(!targetClient) {
messagePlayerError(client, "That player is not connected!")
return false;
}
// Prevent banning admins with really high permissions
if(doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) {
messagePlayerError(client, getLocaleString(client, "CantBanPlayer"));
return false;
}
}
messageAdminAction(`{ALTCOLOUR}${getPlayerData(targetClient).currentSubAccountData.name} {MAINCOLOUR}has been subnet banned`);
announceAdminAction(`PlayerSubNetBanned`, `{ALTCOLOUR}${targetClient.name}{MAINCOLOUR}`);
banSubNet(targetClient.ip, getSubNet(targetClient.ip, octetAmount), getPlayerData(client).accountData.databaseId, reason);
server.banIP(targetClient.ip);
server.banIP(targetClient.ip);
}
// ===========================================================================
function banAccount(accountId, adminAccountId, reason) {
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeReason = dbConnection.escapetoString(reason);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${VRR_BANTYPE_ACCOUNT}, ${accountId}, ${adminAccountId}, '${safeReason}');`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeReason = dbConnection.escapetoString(reason);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${VRR_BANTYPE_ACCOUNT}, ${accountId}, ${adminAccountId}, '${safeReason}');`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
return false;
return false;
}
// ===========================================================================
function banSubAccount(subAccountId, adminAccountId, reason) {
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeReason = dbConnection.escapetoString(reason);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${VRR_BANTYPE_SUBACCOUNT}, ${subAccountId}, ${adminAccountId}, '${safeReason}');`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeReason = dbConnection.escapetoString(reason);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${VRR_BANTYPE_SUBACCOUNT}, ${subAccountId}, ${adminAccountId}, '${safeReason}');`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
return false;
return false;
}
// ===========================================================================
function banIPAddress(ipAddress, adminAccountId, reason) {
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeReason = dbConnection.escapetoString(reason);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${VRR_BANTYPE_IPADDRESS}, INET_ATON(${ipAddress}), ${adminAccountId}, '${safeReason}');`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeReason = dbConnection.escapetoString(reason);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${VRR_BANTYPE_IPADDRESS}, INET_ATON(${ipAddress}), ${adminAccountId}, '${safeReason}');`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
return false;
return false;
}
// ===========================================================================
function banSubNet(ipAddressStart, ipAddressEnd, adminAccountId, reason) {
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeReason = dbConnection.escapetoString(reason);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_ip_start, ban_ip_end, ban_who_banned, ban_reason) VALUES (${VRR_BANTYPE_SUBNET}, INET_ATON(${ipAddressStart}), INET_ATON(${ipAddressEnd}), ${adminAccountId}, '${safeReason}');`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeReason = dbConnection.escapetoString(reason);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_ip_start, ban_ip_end, ban_who_banned, ban_reason) VALUES (${VRR_BANTYPE_SUBNET}, INET_ATON(${ipAddressStart}), INET_ATON(${ipAddressEnd}), ${adminAccountId}, '${safeReason}');`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
return false;
return false;
}
// ===========================================================================
function unbanAccount(accountId, adminAccountId) {
let dbConnection = connectToDatabase();
if(dbConnection) {
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${VRR_BANTYPE_ACCOUNT} AND ban_detail=${accountId}`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
let dbConnection = connectToDatabase();
if(dbConnection) {
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${VRR_BANTYPE_ACCOUNT} AND ban_detail=${accountId}`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
return false;
return false;
}
// ===========================================================================
function unbanSubAccount(subAccountId, adminAccountId) {
let dbConnection = connectToDatabase();
if(dbConnection) {
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${VRR_BANTYPE_SUBACCOUNT} AND ban_detail=${subAccountId}`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
let dbConnection = connectToDatabase();
if(dbConnection) {
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${VRR_BANTYPE_SUBACCOUNT} AND ban_detail=${subAccountId}`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
return false;
return false;
}
// ===========================================================================
function unbanIPAddress(ipAddress, adminAccountId) {
let dbConnection = connectToDatabase();
if(dbConnection) {
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${VRR_BANTYPE_IPADDRESS} AND ban_detail=INET_ATON(${ipAddress})`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
let dbConnection = connectToDatabase();
if(dbConnection) {
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${VRR_BANTYPE_IPADDRESS} AND ban_detail=INET_ATON(${ipAddress})`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
return false;
return false;
}
// ===========================================================================
function unbanSubNet(ipAddressStart, ipAddressEnd, adminAccountId) {
let dbConnection = connectToDatabase();
if(dbConnection) {
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${VRR_BANTYPE_SUBNET} AND ban_ip_start=INET_ATON(${ipAddressStart}) AND ban_ip_end=INET_ATON(${ipAddressEnd})`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
let dbConnection = connectToDatabase();
if(dbConnection) {
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${VRR_BANTYPE_SUBNET} AND ban_ip_start=INET_ATON(${ipAddressStart}) AND ban_ip_end=INET_ATON(${ipAddressEnd})`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
return false;
return false;
}
// ===========================================================================
function isAccountBanned(accountId) {
let bans = getServerData().bans;
for(let i in bans) {
if(bans[i].type == VRR_BANTYPE_ACCOUNT) {
if(bans[i].detail == accountId) {
return true;
}
}
}
let bans = getServerData().bans;
for(let i in bans) {
if(bans[i].type == VRR_BANTYPE_ACCOUNT) {
if(bans[i].detail == accountId) {
return true;
}
}
}
return false;
return false;
}
// ===========================================================================
function isSubAccountBanned(subAccountId) {
let bans = getServerData().bans;
for(let i in bans) {
if(bans[i].type == VRR_BANTYPE_SUBACCOUNT) {
if(bans[i].detail == subAccountId) {
return true;
}
}
}
let bans = getServerData().bans;
for(let i in bans) {
if(bans[i].type == VRR_BANTYPE_SUBACCOUNT) {
if(bans[i].detail == subAccountId) {
return true;
}
}
}
return false;
return false;
}
// ===========================================================================
function isIpAddressBanned(ipAddress) {
let bans = getServerData().bans;
for(let i in bans) {
if(bans[i].type == VRR_BANTYPE_IPADDRESS) {
if(bans[i].detail == ipAddress) {
return true;
}
}
}
let bans = getServerData().bans;
for(let i in bans) {
if(bans[i].type == VRR_BANTYPE_IPADDRESS) {
if(bans[i].detail == ipAddress) {
return true;
}
}
}
return false;
return false;
}
// ===========================================================================

View File

@@ -21,7 +21,6 @@ let serverBitFlags = {
npcTriggerTypeFlags: {},
npcTriggerConditionTypesFlags: {},
npcTriggerResponseTypeFlags: {},
serverSettings: {}
};
// ===========================================================================
@@ -41,6 +40,8 @@ let serverBitFlagKeys = {
"ManageWorld",
"ManageAntiCheat",
"Developer",
"ManageNPCs",
"ManageRaces",
],
moderationFlagKeys: [
"None",
@@ -119,6 +120,8 @@ let serverBitFlagKeys = {
"NoRandomTips",
"NoActionTips",
],
// Not going to be used. Use trigger, condition, and response stuff in trigger.js
npcTriggerTypeKeys: [
"None",
"FarProximity", // Comes within a far distance of NPC
@@ -219,26 +222,6 @@ let serverBitFlagKeys = {
"ShowItemsAfterPurchase",
"BuyCommandAfterEnterBusiness",
],
serverSettingsKeys: [
"None",
"GUI",
"ServerLogo",
"FallingSnow",
"GroundSnow",
"Anticheat",
"CheckGameScripts",
"GameScriptBlackList",
"GameScriptWhiteList",
"JobBlips",
"JobPickups",
"BusinessBlips",
"BusinessPickups",
"HouseBlips",
"HousePickups",
"DiscordBot",
"RealTime",
"Testing",
],
};
// ===========================================================================
@@ -255,7 +238,6 @@ function initBitFlagScript() {
serverBitFlags.npcTriggerTypes = createBitFlagTable(serverBitFlagKeys.npcTriggerTypeKeys);
serverBitFlags.npcTriggerConditionTypes = createBitFlagTable(serverBitFlagKeys.npcTriggerConditionTypeKeys);
serverBitFlags.npcTriggerResponseTypes = createBitFlagTable(serverBitFlagKeys.npcTriggerResponseTypeKeys);
serverBitFlags.serverSettings = createBitFlagTable(serverBitFlagKeys.serverSettingsKeys);
logToConsole(LOG_INFO, "[VRR.BitFlag]: Bit flag script initialized successfully!");
return true;
}
@@ -311,15 +293,15 @@ function doesPlayerHaveStaffPermission(client, requiredFlags) {
}
// -1 is automatic override (having -1 for staff flags is basically god mode admin level)
if(staffFlags == getStaffFlagValue("All")) {
return true;
}
if(staffFlags == getStaffFlagValue("All")) {
return true;
}
if(hasBitFlag(staffFlags, requiredFlags)) {
return true;
}
if(hasBitFlag(staffFlags, requiredFlags)) {
return true;
}
return false;
return false;
}
// ===========================================================================
@@ -341,22 +323,22 @@ function doesPlayerHaveClanPermission(client, requiredFlags) {
clanFlags = getPlayerCurrentSubAccount(client).clanFlags | getClanRankFlags(getPlayerCurrentSubAccount(client).clanRank);
// -1 is automatic override (having -1 for staff flags is basically god mode admin level)
if(clanFlags == getClanFlagValue("All")) {
return true;
}
if(clanFlags == getClanFlagValue("All")) {
return true;
}
if(hasBitFlag(clanFlags, requiredFlags)) {
return true;
}
if(hasBitFlag(clanFlags, requiredFlags)) {
return true;
}
return false;
return false;
}
// ===========================================================================
function getStaffFlagValue(flagName) {
if(flagName == "All") {
return -1;
if(flagName == "All") {
return -1;
}
if(typeof serverBitFlags.staffFlags[flagName] == "undefined") {
@@ -369,8 +351,8 @@ function getStaffFlagValue(flagName) {
// ===========================================================================
function getClanFlagValue(flagName) {
if(flagName == "All") {
return -1;
if(flagName == "All") {
return -1;
}
if(typeof getServerBitFlags().clanFlags[flagName] == "undefined") {
@@ -383,8 +365,8 @@ function getClanFlagValue(flagName) {
// ===========================================================================
function getAccountSettingsFlagValue(flagName) {
if(flagName == "All") {
return -1;
if(flagName == "All") {
return -1;
}
if(typeof serverBitFlags.accountSettingsFlags[flagName] == "undefined") {
@@ -397,8 +379,8 @@ function getAccountSettingsFlagValue(flagName) {
// ===========================================================================
function getModerationFlagValue(flagName) {
if(flagName == "All") {
return -1;
if(flagName == "All") {
return -1;
}
if(typeof serverBitFlags.moderationFlags[flagName] == "undefined") {
@@ -410,20 +392,6 @@ function getModerationFlagValue(flagName) {
// ===========================================================================
function getServerSettingsFlagValue(flagName) {
if(flagName == "All") {
return -1;
}
if(typeof serverBitFlags.serverSettings[flagName] == "undefined") {
return false;
}
return serverBitFlags.serverSettings[flagName];
}
// ===========================================================================
function givePlayerStaffFlag(client, flagName) {
if(!getStaffFlagValue(flagName)) {
return false;

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +0,0 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: bakery.js
// DESC: Provides bakery business functions and usage
// TYPE: Business (JavaScript)
// ===========================================================================

View File

@@ -1,8 +0,0 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: bar.js
// DESC: Provides bar/pub business functions and usage
// TYPE: Business (JavaScript)
// ===========================================================================

View File

@@ -1,8 +0,0 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: burger.js
// DESC: Provides burger joint (McDonalds?) business functions and usage
// TYPE: Business (JavaScript)
// ===========================================================================

View File

@@ -1,67 +0,0 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: casino.js
// DESC: Provides casino business functions and usage
// TYPE: Business (JavaScript)
// ===========================================================================
let deckCards = [
DeckCardData("deckCardSpadeAce", VRR_DECKCARD_SUIT_SPADE, 1),
DeckCardData("deckCardSpade2", VRR_DECKCARD_SUIT_SPADE, 2),
DeckCardData("deckCardSpade3", VRR_DECKCARD_SUIT_SPADE, 3),
DeckCardData("deckCardSpade4", VRR_DECKCARD_SUIT_SPADE, 4),
DeckCardData("deckCardSpade5", VRR_DECKCARD_SUIT_SPADE, 5),
DeckCardData("deckCardSpade6", VRR_DECKCARD_SUIT_SPADE, 6),
DeckCardData("deckCardSpade7", VRR_DECKCARD_SUIT_SPADE, 7),
DeckCardData("deckCardSpade8", VRR_DECKCARD_SUIT_SPADE, 8),
DeckCardData("deckCardSpade9", VRR_DECKCARD_SUIT_SPADE, 9),
DeckCardData("deckCardSpade10", VRR_DECKCARD_SUIT_SPADE, 10),
DeckCardData("deckCardSpadeJack", VRR_DECKCARD_SUIT_SPADE, 11),
DeckCardData("deckCardSpadeQueen", VRR_DECKCARD_SUIT_SPADE, 12),
DeckCardData("deckCardSpadeKing", VRR_DECKCARD_SUIT_SPADE, 13),
DeckCardData("deckCardClubAce", VRR_DECKCARD_SUIT_CLUB, 1),
DeckCardData("deckCardClub2", VRR_DECKCARD_SUIT_CLUB, 2),
DeckCardData("deckCardClub3", VRR_DECKCARD_SUIT_CLUB, 3),
DeckCardData("deckCardClub4", VRR_DECKCARD_SUIT_CLUB, 4),
DeckCardData("deckCardClub5", VRR_DECKCARD_SUIT_CLUB, 5),
DeckCardData("deckCardClub6", VRR_DECKCARD_SUIT_CLUB, 6),
DeckCardData("deckCardClub7", VRR_DECKCARD_SUIT_CLUB, 7),
DeckCardData("deckCardClub8", VRR_DECKCARD_SUIT_CLUB, 8),
DeckCardData("deckCardClub9", VRR_DECKCARD_SUIT_CLUB, 9),
DeckCardData("deckCardClub10", VRR_DECKCARD_SUIT_CLUB, 10),
DeckCardData("deckCardClubJack", VRR_DECKCARD_SUIT_CLUB, 11),
DeckCardData("deckCardClubQueen", VRR_DECKCARD_SUIT_CLUB, 12),
DeckCardData("deckCardClubKing", VRR_DECKCARD_SUIT_CLUB, 13),
DeckCardData("deckCardHeartAce", VRR_DECKCARD_SUIT_HEART, 1),
DeckCardData("deckCardHeart2", VRR_DECKCARD_SUIT_HEART, 2),
DeckCardData("deckCardHeart3", VRR_DECKCARD_SUIT_HEART, 3),
DeckCardData("deckCardHeart4", VRR_DECKCARD_SUIT_HEART, 4),
DeckCardData("deckCardHeart5", VRR_DECKCARD_SUIT_HEART, 5),
DeckCardData("deckCardHeart6", VRR_DECKCARD_SUIT_HEART, 6),
DeckCardData("deckCardHeart7", VRR_DECKCARD_SUIT_HEART, 7),
DeckCardData("deckCardHeart8", VRR_DECKCARD_SUIT_HEART, 8),
DeckCardData("deckCardHeart9", VRR_DECKCARD_SUIT_HEART, 9),
DeckCardData("deckCardHeart10", VRR_DECKCARD_SUIT_HEART, 10),
DeckCardData("deckCardHeartJack", VRR_DECKCARD_SUIT_HEART, 11),
DeckCardData("deckCardHeartQueen", VRR_DECKCARD_SUIT_HEART, 12),
DeckCardData("deckCardHeartKing", VRR_DECKCARD_SUIT_HEART, 13),
DeckCardData("deckCardDiamondAce", VRR_DECKCARD_SUIT_DIAMOND, 1),
DeckCardData("deckCardDiamond2", VRR_DECKCARD_SUIT_DIAMOND, 2),
DeckCardData("deckCardDiamond3", VRR_DECKCARD_SUIT_DIAMOND, 3),
DeckCardData("deckCardDiamond4", VRR_DECKCARD_SUIT_DIAMOND, 4),
DeckCardData("deckCardDiamond5", VRR_DECKCARD_SUIT_DIAMOND, 5),
DeckCardData("deckCardDiamond6", VRR_DECKCARD_SUIT_DIAMOND, 6),
DeckCardData("deckCardDiamond7", VRR_DECKCARD_SUIT_DIAMOND, 7),
DeckCardData("deckCardDiamond8", VRR_DECKCARD_SUIT_DIAMOND, 8),
DeckCardData("deckCardDiamond9", VRR_DECKCARD_SUIT_DIAMOND, 9),
DeckCardData( "deckCardDiamond10", VRR_DECKCARD_SUIT_DIAMOND, 10),
DeckCardData("deckCardDiamondJack", VRR_DECKCARD_SUIT_DIAMOND, 11),
DeckCardData("deckCardDiamondQueen", VRR_DECKCARD_SUIT_DIAMOND, 12),
DeckCardData("deckCardDiamondKing", VRR_DECKCARD_SUIT_DIAMOND, 13),
];
let deckCardBacks = [
]

View File

@@ -1,8 +0,0 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: clothing.js
// DESC: Provides clothing (skin) business functions and usage
// TYPE: Business (JavaScript)
// ===========================================================================

View File

@@ -1,8 +0,0 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: club.js
// DESC: Provides club/nightclub business functions and usage
// TYPE: Business (JavaScript)
// ===========================================================================

View File

@@ -1,8 +0,0 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: fuel.js
// DESC: Provides fuel/petrol business functions and usage
// TYPE: Business (JavaScript)
// ===========================================================================

View File

@@ -1,8 +0,0 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: mechanic.js
// DESC: Provides mechanic/vehicle repair business functions and usage
// TYPE: Business (JavaScript)
// ===========================================================================

View File

@@ -1,8 +0,0 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: pizza.js
// DESC: Provides pizza restaurant business functions and usage
// TYPE: Business (JavaScript)
// ===========================================================================

View File

@@ -1,8 +0,0 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: restaurant.js
// DESC: Provides generic restaurant business functions and usage
// TYPE: Business (JavaScript)
// ===========================================================================

View File

@@ -1,8 +0,0 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: vehicle.js
// DESC: Provides vehicle dealership business functions and usage
// TYPE: Business (JavaScript)
// ===========================================================================

View File

@@ -1,9 +0,0 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: weapon.js
// DESC: Provides weapon (ammunations & illegal gunshops) business usage
// TYPE: Business (JavaScript)
// ===========================================================================

View File

@@ -39,12 +39,13 @@ function processPlayerChat(client, messageText) {
messageText = messageText.substring(0, 128);
messagePlayerNormal(null, `💬 ${getCharacterFullName(client)}: ${messageText}`);
messageDiscordChatChannel(`💬 ${getCharacterFullName(client)}: ${messageText}`);
} else {
messagePlayerNormal(null, `🛡️ (ADMIN) - ${messageText}`);
}
/*
let clients = getClients();
/*
let clients = getClients();
for(let i in clients) {
let translatedText;
translatedText = await translateMessage(messageText, getPlayerData(client).locale, getPlayerData(clients[i]).locale);
@@ -52,9 +53,9 @@ function processPlayerChat(client, messageText) {
let original = (getPlayerData(client).locale == getPlayerData(clients[i]).locale) ? `` : ` {ALTCOLOUR}(${messageText})`;
messagePlayerNormal(clients[i], `💬 ${getCharacterFullName(client)}: [#FFFFFF]${translatedText}${original}`, clients[i], getColourByName("mediumGrey"));
}
*/
//messageDiscordChatChannel(`💬 ${getCharacterFullName(client)}: ${messageText}`);
*/
//messageDiscordChatChannel(`💬 ${getCharacterFullName(client)}: ${messageText}`);
}
// ===========================================================================

View File

@@ -9,7 +9,10 @@
function initClanScript() {
logToConsole(LOG_INFO, "[VRR.Clan]: Initializing clans script ...");
getServerData().clans = loadClansFromDatabase();
if(!getServerConfig().devServer) {
getServerData().clans = loadClansFromDatabase();
}
setAllClanDataIndexes();
logToConsole(LOG_INFO, "[VRR.Clan]: Clan script initialized successfully!");
return true;
@@ -114,7 +117,7 @@ function createClanRank(clanId, rankId, rankName) {
let rankIndex = getClanData(clanId).ranks.push(tempClanRankData);
setAllClanDataIndexes();
saveAllClanRanksToDatabase(clanId);
saveClanRanksToDatabase(clanId);
return rankIndex;
}
@@ -927,12 +930,20 @@ function doesClanIdExist(clanId) {
// ===========================================================================
function reloadAllClans() {
if(getServerConfig().devServer) {
return false;
}
getServerData().clans = loadClansFromDatabase();
}
// ===========================================================================
function saveAllClanRanksToDatabase(clanId) {
function saveClanRanksToDatabase(clanId) {
if(getServerConfig().devServer) {
return false;
}
let ranks = getServerData().clans[clanId].ranks;
for(let i in ranks) {
saveClanRankToDatabase(clanId, i);
@@ -948,9 +959,13 @@ function saveClanToDatabase(clanId) {
return false;
}
if(!tempClanData.needsSaved) {
return false;
}
if(tempClanData.databaseId == -1) {
return false;
}
if(!tempClanData.needsSaved) {
return false;
}
let dbConnection = connectToDatabase();
if(dbConnection) {
@@ -982,7 +997,7 @@ function saveClanToDatabase(clanId) {
disconnectFromDatabase(dbConnection);
}
saveAllClanRanksToDatabase(clanId);
saveClanRanksToDatabase(clanId);
return true;
}
@@ -994,41 +1009,41 @@ function saveClanToDatabase(clanId) {
function saveClanRankToDatabase(clanId, rankId) {
let tempClanRankData = getClanRankData(clanId, rankId);
if(!tempClanRankData.needsSaved) {
return false;
}
if(!tempClanRankData.needsSaved) {
return false;
}
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeName = escapeDatabaseString(dbConnection, tempClanRankData.name);
let safeTag = escapeDatabaseString(dbConnection, tempClanRankData.customTag);
//let safeTitle = escapeDatabaseString(dbConnection, tempClanRankData.name);
let safeName = escapeDatabaseString(dbConnection, tempClanRankData.name);
let safeTag = escapeDatabaseString(dbConnection, tempClanRankData.customTag);
//let safeTitle = escapeDatabaseString(dbConnection, tempClanRankData.name);
let data = [
["clan_rank_name", safeName],
["clan_rank_clan", tempClanRankData.clan],
["clan_rank_custom_tag", safeTag],
//["clan_rank_title", safeTitle],
["clan_rank_flags", tempClanRankData.flags],
["clan_rank_level", tempClanRankData.level],
["clan_rank_enabled", boolToInt(tempClanRankData.enabled)],
];
let data = [
["clan_rank_name", safeName],
["clan_rank_clan", tempClanRankData.clan],
["clan_rank_custom_tag", safeTag],
//["clan_rank_title", safeTitle],
["clan_rank_flags", tempClanRankData.flags],
["clan_rank_level", tempClanRankData.level],
["clan_rank_enabled", boolToInt(tempClanRankData.enabled)],
];
let dbQuery = null;
if(tempClanRankData.databaseId == 0) {
let queryString = createDatabaseInsertQuery("clan_rank", data);
dbQuery = queryDatabase(dbConnection, queryString);
getClanRankData(clanId, rankId).databaseId = getDatabaseInsertId(dbConnection);
getClanRankData(clanId, rankId).needsSaved = false;
} else {
let queryString = createDatabaseUpdateQuery("clan_rank", data, `clan_rank_id=${tempClanRankData.databaseId} LIMIT 1`);
dbQuery = queryDatabase(dbConnection, queryString);
getClanRankData(clanId, rankId).needsSaved = false;
}
let dbQuery = null;
if(tempClanRankData.databaseId == 0) {
let queryString = createDatabaseInsertQuery("clan_rank", data);
dbQuery = queryDatabase(dbConnection, queryString);
getClanRankData(clanId, rankId).databaseId = getDatabaseInsertId(dbConnection);
getClanRankData(clanId, rankId).needsSaved = false;
} else {
let queryString = createDatabaseUpdateQuery("clan_rank", data, `clan_rank_id=${tempClanRankData.databaseId} LIMIT 1`);
dbQuery = queryDatabase(dbConnection, queryString);
getClanRankData(clanId, rankId).needsSaved = false;
}
freeDatabaseQuery(dbQuery);
disconnectFromDatabase(dbConnection);
return true;
freeDatabaseQuery(dbQuery);
disconnectFromDatabase(dbConnection);
return true;
}
return false;
@@ -1071,7 +1086,11 @@ function setClanRankTitle(clanId, rankId, title) {
// ===========================================================================
function saveAllClansToDatabase() {
function saveClansToDatabase() {
if(getServerConfig().devServer) {
return false;
}
for(let i in getServerData().clans) {
saveClanToDatabase(i);
}
@@ -1134,6 +1153,11 @@ function getClanRankIdFromDatabaseId(clanId, databaseId) {
// ===========================================================================
/**
* @param {number} clanId - The data index of the clan
* @param {number} clanRankId - The data index of the clan rank
* @return {ClanRankData} The clan rank's data (class instance)
*/
function getClanRankData(clanId, rankId) {
return getServerData().clans[clanId].ranks[rankId];
}
@@ -1213,6 +1237,10 @@ let rankId = getClanRankFromParams(clanId, getParam(params, " ", 1));
}
*/
/**
* @param {String} params - The params to search for
* @return {Number} The data index of a matching clan
*/
function getClanFromParams(params) {
if(isNaN(params)) {
for(let i in getServerData().clans) {
@@ -1231,6 +1259,11 @@ function getClanFromParams(params) {
// ===========================================================================
/**
* @param {Number} clanId - The clan ID to search ranks for
* @param {String} params - The params to search for
* @return {Number} The data index of a matching clan
*/
function getClanRankFromParams(clanId, params) {
if(isNaN(params)) {
for(let i in getClanData(clanId).ranks) {

View File

@@ -19,7 +19,7 @@ function initClassScript() {
/**
* @class Representing data for server configuration
*/
class ServerData {
class ServerConfigData {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.needsSaved = false;
@@ -58,7 +58,7 @@ class ServerData {
this.showLogo = true;
this.inflationMultiplier = 1;
this.testerOnly = false;
this.settings = 0;
this.devServer = false;
this.antiCheat = {
enabled: false,
@@ -87,9 +87,6 @@ class ServerData {
this.realTimeZone = 0;
this.discordConfig = {
eventChannelWebHookURL: "",
chatChannelWebHookURL: "",
adminChannelWebHookURL: "",
sendEvents: true,
sendChat: true,
sendAdminEvents: true,
@@ -104,7 +101,6 @@ class ServerData {
bank: dbAssoc["svr_newchar_bank"],
skin: dbAssoc["svr_newchar_skin"],
},
this.settings = toInteger(dbAssoc["svr_settings"]);
this.connectCameraPosition = toVector3(dbAssoc["svr_connectcam_pos_x"], dbAssoc["svr_connectcam_pos_y"], dbAssoc["svr_connectcam_pos_z"]);
this.connectCameraLookAt = toVector3(dbAssoc["svr_connectcam_lookat_x"], dbAssoc["svr_connectcam_lookat_y"], dbAssoc["svr_connectcam_lookat_z"]);
@@ -113,6 +109,21 @@ class ServerData {
this.minute = toInteger(dbAssoc["svr_start_time_min"]);
this.minuteDuration = toInteger(dbAssoc["svr_time_min_duration"]);
this.weather = toInteger(dbAssoc["svr_start_weather"]);
//this.fallingSnow = intToBool(toInteger(dbAssoc["svr_start_snow_falling"]));
//this.groundSnow = intToBool(toInteger(dbAssoc["svr_start_snow_ground"]));
//this.useGUI = intToBool(toInteger(dbAssoc["svr_gui_enabled"]));
//this.showLogo = intToBool(toInteger(dbAssoc["svr_logo_enabled"]));
//this.testerOnly = intToBool(toInteger(dbAssoc["svr_tester_only"]));
/*
this.createJobPickups = intToBool(toInteger(dbAssoc["svr_job_pickups_enabled"]));
this.createBusinessPickups = intToBool(toInteger(dbAssoc["svr_biz_pickups_enabled"]));
this.createHousePickups = intToBool(toInteger(dbAssoc["svr_house_pickups_enabled"]));
this.createJobBlips = intToBool(toInteger(dbAssoc["svr_job_blips_enabled"]));
this.createBusinessBlips = intToBool(toInteger(dbAssoc["svr_biz_blips_enabled"]));
this.createHouseBlips = intToBool(toInteger(dbAssoc["svr_house_blips_enabled"]));
*/
this.guiColourPrimary = [toInteger(dbAssoc["svr_gui_col1_r"]), toInteger(dbAssoc["svr_gui_col1_g"]), toInteger(dbAssoc["svr_gui_col1_b"])];
this.guiColourSecondary = [toInteger(dbAssoc["svr_gui_col2_r"]), toInteger(dbAssoc["svr_gui_col2_g"]), toInteger(dbAssoc["svr_gui_col2_b"])];
this.guiTextColourPrimary = [toInteger(dbAssoc["svr_gui_textcol1_r"]), toInteger(dbAssoc["svr_gui_textcol1_g"]), toInteger(dbAssoc["svr_gui_textcol1_b"])];
@@ -121,15 +132,14 @@ class ServerData {
this.discordBotToken = intToBool(dbAssoc["svr_discord_bot_token"]);
this.introMusicURL = dbAssoc["svr_intro_music"];
this.realTimeZone = dbAssoc["svr_time_realtime_timezone"];
this.discordConfig = {
eventChannelWebHookURL: dbAssoc["svr_discord_event_webhook"],
chatChannelWebHookURL: dbAssoc["svr_discord_chat_webhook"],
adminChannelWebHookURL: dbAssoc["svr_discord_admin_webhook"],
//this.useRealTime = intToBool(toInteger(dbAssoc["svr_real_time_enabled"]));
//this.realTimeZone = dbAssoc["svr_real_time_timezone"];
this.discord = {
sendEvents: true,
sendChat: true,
sendAdminEvents: true,
sendAdmin: true,
};
}
}
@@ -239,6 +249,10 @@ class ClientData {
this.locale = 0;
this.enteringVehicle = null;
this.customDisconnectReason = "";
this.interiorCutscene = "";
}
};
@@ -271,6 +285,7 @@ class AccountData {
this.twoFactorAuthVerificationCode = "";
this.chatScrollLines = 1;
this.chatAutoHideDelay = 0;
this.streamingRadioVolume = 20;
this.locale = 0;
@@ -300,6 +315,7 @@ class AccountData {
this.emailVerificationCode = dbAssoc["acct_code_verifyemail"];
this.twoFactorAuthVerificationCode = dbAssoc["acct_code_2fa"];
this.chatScrollLines = toInteger(dbAssoc["acct_svr_chat_scroll_lines"]);
this.chatAutoHideDelay = toInteger(dbAssoc["acct_svr_chat_auto_hide_delay"]);
this.streamingRadioVolume = toInteger(dbAssoc["acct_streaming_radio_volume"]);
this.locale = toInteger(dbAssoc["acct_locale"]);
}
@@ -524,6 +540,7 @@ class BusinessData {
this.entranceBlipModel = -1;
this.entrancePickup = null;
this.entranceBlip = null;
this.entranceCutscene = "";
this.exitPosition = false;
this.exitRotation = 0.0;
@@ -533,6 +550,7 @@ class BusinessData {
this.exitBlipModel = -1;
this.exitPickup = null;
this.exitBlip = null;
this.exitCutscene = "";
this.entranceFee = 0;
this.till = 0;
@@ -541,6 +559,8 @@ class BusinessData {
this.labelHelpType = VRR_PROPLABEL_INFO_NONE;
this.triggers = [];
if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["biz_id"]);
this.name = toString(dbAssoc["biz_name"]);
@@ -557,6 +577,7 @@ class BusinessData {
this.entranceDimension = toInteger(dbAssoc["biz_entrance_vw"]);
this.entrancePickupModel = toInteger(dbAssoc["biz_entrance_pickup"]);
this.entranceBlipModel = toInteger(dbAssoc["biz_entrance_blip"]);
this.entranceCutscene = toString(dbAssoc["biz_entrance_cutscene"]);
this.exitPosition = toVector3(dbAssoc["biz_exit_pos_x"], dbAssoc["biz_exit_pos_y"], dbAssoc["biz_exit_pos_z"]);
this.exitRotation = toInteger(dbAssoc["biz_exit_rot_z"]);
@@ -564,12 +585,14 @@ class BusinessData {
this.exitDimension = toInteger(dbAssoc["biz_exit_vw"]);
this.exitPickupModel = toInteger(dbAssoc["biz_exit_pickup"]);
this.exitBlipModel = toInteger(dbAssoc["biz_exit_blip"]);
this.exitCutscene = toString(dbAssoc["biz_exit_cutscene"]);
this.entranceFee = toInteger(dbAssoc["biz_entrance_fee"]);
this.till = toInteger(dbAssoc["biz_till"]);
this.labelHelpType = toInteger(dbAssoc["biz_label_help_type"]);
this.streamingRadioStation = toInteger(dbAssoc["biz_radiostation"]);
}
};
};
@@ -658,6 +681,7 @@ class HouseData {
this.entranceBlipModel = -1;
this.entrancePickup = null;
this.entranceBlip = null;
this.entranceCutscene = "";
this.exitPosition = false;
this.exitRotation = 0.0;
@@ -667,9 +691,12 @@ class HouseData {
this.exitBlipModel = -1;
this.exitPickup = null;
this.exitBlip = null;
this.exitCutscene = "";
this.streamingRadioStation = -1;
this.triggers = [];
if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["house_id"]);
this.description = toString(dbAssoc["house_description"]);
@@ -688,6 +715,7 @@ class HouseData {
this.entranceDimension = toInteger(dbAssoc["house_entrance_vw"]);
this.entrancePickupModel = toInteger(dbAssoc["house_entrance_pickup"]);
this.entranceBlipModel = toInteger(dbAssoc["house_entrance_blip"]);
this.entranceCutscene = toString(dbAssoc["house_entrance_cutscene"]);
this.exitPosition = toVector3(toFloat(dbAssoc["house_exit_pos_x"]), toFloat(dbAssoc["house_exit_pos_y"]), toFloat(dbAssoc["house_exit_pos_z"]));
this.exitRotation = toFloat(dbAssoc["house_exit_rot_z"]);
@@ -695,6 +723,7 @@ class HouseData {
this.exitDimension = toInteger(dbAssoc["house_exit_vw"]);
this.exitPickupModel = toInteger(dbAssoc["house_exit_pickup"]);
this.exitBlipModel = toInteger(dbAssoc["house_exit_blip"]);
this.exitCutscene = toString(dbAssoc["house_exit_cutscene"]);
}
}
};
@@ -934,6 +963,8 @@ class VehicleData {
this.lastActiveTime = false;
this.triggers = [];
if(dbAssoc) {
// General Info
this.databaseId = toInteger(dbAssoc["veh_id"]);
@@ -1003,7 +1034,7 @@ class VehicleData {
};
/**
* @class Representing a command's data. Loaded and saved in the database
* @class Representing a command's data.
*/
class CommandData {
enable() {
@@ -1018,7 +1049,7 @@ class CommandData {
this.enabled = !this.enabled;
}
constructor(command, handlerFunction, syntaxString, requiredStaffFlags, requireLogin, allowOnDiscord, helpDescription) {
constructor(command, handlerFunction, syntaxString = "", requiredStaffFlags = 0, requireLogin = true, allowOnDiscord = false, helpDescription = "") {
this.command = command;
this.handlerFunction = handlerFunction;
this.syntaxString = syntaxString;
@@ -1302,49 +1333,6 @@ class KeyBindData {
}
};
class BlackListedGameScriptData {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.enabled = false
this.serverId = 0;
this.scriptName = "";
this.index = -1;
this.needsSaved = false;
if(dbAssoc) {
this.databaseId = dbAssoc["ac_script_bl_id"];
this.enabled = intToBool(dbAssoc["ac_script_bl_enabled"]);
this.serverId = dbAssoc["ac_script_bl_server"];
this.scriptName = dbAssoc["ac_script_bl_name"];
}
}
};
class WhiteListedGameScriptData {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.enabled = false
this.serverId = 0;
this.scriptName = "";
this.index = -1;
this.needsSaved = false;
if(dbAssoc) {
this.databaseId = dbAssoc["ac_script_wl_id"];
this.enabled = intToBool(dbAssoc["ac_script_wl_enabled"]);
this.serverId = dbAssoc["ac_script_wl_server"];
this.scriptName = dbAssoc["ac_script_wl_name"];
}
}
};
class InteriorTemplateData {
constructor(exitPosition, exitInterior) {
this.exitPosition = exitPosition;
this.exitInterior = exitInterior;
}
};
class RadioStationData {
constructor(dbAssoc = false) {
this.databaseId = 0;
@@ -1486,6 +1474,7 @@ class ItemTypeData {
}
}
};
class NPCData {
constructor(dbAssoc = false) {
this.databaseId = 0;
@@ -1495,8 +1484,10 @@ class NPCData {
this.middleName = "Q";
this.skin = 0;
this.cash = 0;
this.spawnPosition = toVector3(0.0, 0.0, 0.0);
this.spawnHeading = 0.0;
this.position = toVector3(0.0, 0.0, 0.0);
this.rotation = toVector3(0.0, 0.0, 0.0);
this.scale = toVector3(1.0, 1.0, 1.0);
this.heading = 0.0;
this.clan = 0;
this.isWorking = false;
this.jobUniform = this.skin;
@@ -1505,13 +1496,16 @@ class NPCData {
this.weapons = [];
this.interior = 0;
this.dimension = 0;
this.pedScale = toVector3(1.0, 1.0, 1.0);
this.walkStyle = 0;
this.fightStyle = 0;
this.health = 100;
this.armour = 100;
this.currentAction = VRR_NPCACTION_NONE;
this.triggers = [];
this.typeFlags = 0;
this.heedThreats = false;
this.threats = 0;
this.invincible = false;
this.bodyParts = {
hair: [0,0],
@@ -1533,6 +1527,8 @@ class NPCData {
rightFoot: [0,0],
};
this.triggers = [];
if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["npc_id"]);
this.serverId = toInteger(dbAssoc["npc_server"]);
@@ -1541,21 +1537,24 @@ class NPCData {
this.middleName = dbAssoc["npc_name_middle"] || "";
this.skin = toInteger(dbAssoc["npc_skin"]);
this.cash = toInteger(dbAssoc["npc_cash"]);
this.spawnPosition = toVector3(toFloat(dbAssoc["npc_pos_x"]), toFloat(dbAssoc["npc_pos_y"]), toFloat(dbAssoc["npc_pos_z"]));
this.spawnHeading = toFloat(dbAssoc["npc_angle"]);
this.position = toVector3(toFloat(dbAssoc["npc_pos_x"]), toFloat(dbAssoc["npc_pos_y"]), toFloat(dbAssoc["npc_pos_z"]));
this.rotation = toVector3(toFloat(dbAssoc["npc_rot_x"]), toFloat(dbAssoc["npc_rot_y"]), toFloat(dbAssoc["npc_rot_z"]));
this.scale = toVector3(toFloat(dbAssoc["npc_scale_x"]), toFloat(dbAssoc["npc_scale_y"]), toFloat(dbAssoc["npc_scale_z"]));
this.heading = toFloat(dbAssoc["npc_rot_z"]);
this.lastLogin = toInteger(dbAssoc["npc_when_lastlogin"]);
this.clan = toInteger(dbAssoc["npc_clan"]);
this.clanFlags = toInteger(dbAssoc["npc_clan_flags"]);
this.clanRank = toInteger(dbAssoc["npc_clan_rank"]);
this.clanTitle = toInteger(dbAssoc["npc_clan_title"]);
this.rank = toInteger(dbAssoc["npc_rank"]);
this.title = toInteger(dbAssoc["npc_title"]);
this.job = toInteger(dbAssoc["npc_job"]);
this.interior = toInteger(dbAssoc["npc_int"]);
this.dimension = toInteger(dbAssoc["npc_vw"]);
this.pedScale = toVector3(toFloat(dbAssoc["npc_scale_x"]), toFloat(dbAssoc["npc_scale_y"]), toFloat(dbAssoc["npc_scale_z"]));
this.walkStyle = toInteger(dbAssoc["npc_walkstyle"]);
this.fightStyle = toInteger(dbAssoc["npc_fightstyle"]);
this.health = toInteger(dbAssoc["npc_health"]);
this.armour = toInteger(dbAssoc["npc_armour"]);
this.typeFlags = toInteger(dbAssoc["npc_type_flags"]);
this.heedThreats = intToBool(dbAssoc["npc_headthreats"]);
this.threats = toInteger(dbAssoc["npc_threats"]);
this.invincible = intToBool(dbAssoc["npc_invincible"]);
this.bodyParts = {
hair: [toInteger(dbAssoc["npc_hd_part_hair_model"]) || 0, toInteger(dbAssoc["npc_hd_part_hair_texture"]) || 0],
@@ -1656,28 +1655,6 @@ class BanData {
}
}
class DeckCardData {
constructor(imageName, value) {
this.imageName = imageName,
this.value = value;
}
}
class DeckCardGameData {
constructor() {
this.gameType = VRR_DECKCARD_GAME_NONE;
this.playedCards = [];
this.remainingCards = [];
}
}
class DeckCardHandData {
constructor() {
this.cards = [];
this.total = 0;
}
}
class JobRouteData {
constructor(dbAssoc = false) {
this.databaseId = 0;
@@ -1708,7 +1685,7 @@ class JobRouteData {
this.pay = toInteger(dbAssoc["job_route_pay"]);
this.startMessage = toString(dbAssoc["job_route_start_msg"]);
this.finishMessage = toString(dbAssoc["job_route_finish_msg"]);
this.locationArriveMessage = toString(dbAssoc["job_route_loc_arrive_msg"]);
this.locationArriveMessage = toString(dbAssoc["job_route_loc_arrive_msg"]);
this.locationNextMessage = toString(dbAssoc["job_route_loc_next_msg"]);
this.vehicleColour1 = toInteger(dbAssoc["job_route_veh_colour1"]);
this.vehicleColour2 = toInteger(dbAssoc["job_route_veh_colour2"]);
@@ -1724,7 +1701,7 @@ class JobRouteLocationData {
this.routeId = 0;
this.enabled = false;
this.index = -1;
this.jobIndex = -1;
this.jobIndex = -1;
this.routeIndex = -1;
this.needsSaved = false;
this.position = toVector3(0.0, 0.0, 0.0);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -15,6 +15,8 @@ let gameConfig = false;
// ===========================================================================
let globalConfig = {
keyBind: [],
economy: {},
accountPasswordHash: "SHA512",
npcFarProximity: 100,
npcMediumProximity: 40,
@@ -31,7 +33,6 @@ let globalConfig = {
stopWorkingDistance: 10,
spawnCarDistance: 5,
payAndSprayDistance: 5,
keyBind: [],
exitPropertyDistance: 3.0,
enterPropertyDistance: 3.0,
businessDimensionStart: 5000,
@@ -67,10 +68,19 @@ let globalConfig = {
],
vehicleInactiveRespawnDelay: 1800000, // 20 minutes
chatSectionHeaderLength: 96,
economy: {},
locales: [],
accents: [],
useServerSideVehiclePurchaseCheck: false,
useServerSideVehiclePurchaseCheck: true,
businessPickupStreamInDistance: 100,
businessPickupStreamOutDistance: 120,
housePickupStreamInDistance: 100,
housePickupStreamOutDistance: 120,
jobPickupStreamInDistance: 100,
jobPickupStreamOutDistance: 120,
businessBlipStreamInDistance: 200,
businessBlipStreamOutDistance: 220,
houseBlipStreamInDistance: 200,
houseBlipStreamOutDistance: 220,
jobBlipStreamInDistance: 200,
jobBlipStreamOutDistance: 220,
};
// ===========================================================================
@@ -84,20 +94,20 @@ function initConfigScript() {
serverConfig = loadServerConfigFromGameAndPort(server.game, server.port, getMultiplayerMod());
logToConsole(LOG_INFO, "[VRR.Config]: Applying server config ...");
getServerConfig().fallingSnow = intToBool(toInteger(server.getCVar("fallingsnow")));
getServerConfig().groundSnow = intToBool(toInteger(server.getCVar("groundsnow")));
getServerConfig().useGUI = intToBool(toInteger(server.getCVar("gui")));
getServerConfig().fallingSnow = intToBool(toInteger(server.getCVar("vrr_fallingsnow")));
getServerConfig().groundSnow = intToBool(toInteger(server.getCVar("vrr_groundsnow")));
getServerConfig().useGUI = intToBool(toInteger(server.getCVar("vrr_gui")));
getServerConfig().showLogo = false;
getServerConfig().testerOnly = intToBool(toInteger(server.getCVar("testeronly")));
getServerConfig().testerOnly = intToBool(toInteger(server.getCVar("vrr_testeronly")));
getServerConfig().discordEnabled = false;
getServerConfig().createJobPickups = intToBool(toInteger(server.getCVar("jobpickups")));
getServerConfig().createBusinessPickups = intToBool(toInteger(server.getCVar("businesspickups")));
getServerConfig().createHousePickups = intToBool(toInteger(server.getCVar("housepickups")));
getServerConfig().createJobBlips = intToBool(toInteger(server.getCVar("jobblips")));
getServerConfig().createBusinessBlips = intToBool(toInteger(server.getCVar("businessblips")));
getServerConfig().createHouseBlips = intToBool(toInteger(server.getCVar("houseblips")));
getServerConfig().useRealTime = intToBool(toInteger(server.getCVar("realtime")));
getServerConfig().antiCheat.enabled = intToBool(toInteger(server.getCVar("anticheat")));
getServerConfig().createJobPickups = intToBool(toInteger(server.getCVar("vrr_jobpickups")));
getServerConfig().createBusinessPickups = intToBool(toInteger(server.getCVar("vrr_businesspickups")));
getServerConfig().createHousePickups = intToBool(toInteger(server.getCVar("vrr_housepickups")));
getServerConfig().createJobBlips = intToBool(toInteger(server.getCVar("vrr_jobblips")));
getServerConfig().createBusinessBlips = intToBool(toInteger(server.getCVar("vrr_businessblips")));
getServerConfig().createHouseBlips = intToBool(toInteger(server.getCVar("vrr_houseblips")));
getServerConfig().useRealTime = intToBool(toInteger(server.getCVar("vrr_realtime")));
getServerConfig().antiCheat.enabled = intToBool(toInteger(server.getCVar("vrr_anticheat")));
applyConfigToServer(serverConfig);
logToConsole(LOG_DEBUG, "[VRR.Config]: Server config applied successfully!");
@@ -112,6 +122,7 @@ function loadGlobalConfig() {
getGlobalConfig().economy = loadEconomyConfig();
getGlobalConfig().locale = loadLocaleConfig();
getGlobalConfig().accents = loadAccentConfig();
getGlobalConfig().discord = loadDiscordConfig();
}
// ===========================================================================
@@ -124,7 +135,7 @@ function loadServerConfigFromGameAndPort(gameId, port, mpMod) {
if(dbQuery) {
if(dbQuery.numRows > 0) {
let dbAssoc = fetchQueryAssoc(dbQuery);
let tempServerConfigData = new ServerData(dbAssoc);
let tempServerConfigData = new ServerConfigData(dbAssoc);
freeDatabaseQuery(dbQuery);
return tempServerConfigData;
}
@@ -144,7 +155,7 @@ function loadServerConfigFromId(tempServerId) {
if(dbQuery) {
if(dbQuery.numRows > 0) {
let dbAssoc = fetchQueryAssoc(dbQuery);
let tempServerConfigData = new ServerData(dbAssoc);
let tempServerConfigData = new ServerConfigData(dbAssoc);
freeDatabaseQuery(dbQuery);
return tempServerConfigData;
}
@@ -178,7 +189,7 @@ function saveServerConfigToDatabase() {
let dbConnection = connectToDatabase();
if(dbConnection) {
let data = [
["svr_settings", toInteger(getServerConfig().settings)],
//["svr_settings", toInteger(getServerConfig().settings)],
["svr_start_time_hour", getServerConfig().hour],
["svr_start_time_min", getServerConfig().minute],
["svr_start_weather", getServerConfig().weather],
@@ -233,7 +244,7 @@ function saveServerConfigToDatabase() {
/**
*
* @return {ServerData} - Server configuration data
* @return {ServerConfigData} - Server configuration data
*
*/
function getServerConfig() {
@@ -283,24 +294,24 @@ function setTimeCommand(command, params, client) {
if(hour > 23 || hour < 0) {
messagePlayerError(client, "The hour must be between 0 and 23!");
return false;
}
}
if(minute > 59 || minute < 0) {
messagePlayerError(client, "The minute must be between 0 and 59!");
return false;
}
}
getServerConfig().hour = hour;
getServerConfig().minute = minute;
game.time.hour = getServerConfig().hour;
game.time.minute = getServerConfig().minute;
game.time.hour = getServerConfig().hour;
game.time.minute = getServerConfig().minute;
//checkServerGameTime();
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} set the time to ${makeReadableTime(hour, minute)}`);
announceAdminAction("ServerTimeSet", getPlayerName(client), makeReadableTime(hour, minute));
return true;
}
@@ -322,13 +333,13 @@ function setMinuteDurationCommand(command, params, client) {
return false;
}
let minuteDuration = toInteger(params);
let minuteDuration = toInteger(params);
getServerConfig().minuteDuration = minuteDuration;
setTimeMinuteDuration(null, minuteDuration);
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} set the minute duration to ${minuteDuration}ms`);
announceAdminAction("ServerMinuteDurationSet", getPlayerName(client), makeReadableTime(hour, minute));
return true;
}
@@ -354,15 +365,15 @@ function setWeatherCommand(command, params, client) {
if(!weatherId) {
messagePlayerError(client, `That weather ID or name is invalid!`);
return false;
}
}
game.forceWeather(toInteger(weatherId));
game.forceWeather(toInteger(weatherId));
getServerConfig().weather = weatherId;
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} set the weather to {ALTCOLOUR}${getGameConfig().weatherNames[getServerGame()][toInteger(weatherId)]}`);
updateServerRules();
announceAdminAction("ServerWeatherSet", getPlayerName(client), getGameConfig().weatherNames[getServerGame()][toInteger(weatherId)]);
updateServerRules();
return true;
}
@@ -384,7 +395,7 @@ function setSnowingCommand(command, params, client) {
}
let splitParams = params.split(" ");
let falling = toInteger(getParam(params, " ", 1));
let falling = toInteger(getParam(params, " ", 1));
let ground = toInteger(getParam(params, " ", 2));
getServerConfig().fallingSnow = intToBool(falling);
@@ -394,8 +405,8 @@ function setSnowingCommand(command, params, client) {
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned falling snow ${getBoolRedGreenInlineColour(falling)}${getOnOffFromBool(falling)} {MAINCOLOUR}and ground snow ${getBoolRedGreenInlineColour(ground)}${getOnOffFromBool(ground)}`);
updateServerRules();
announceAdminAction("ServerSnowSet", getPlayerName(client), `${getBoolRedGreenInlineColour(falling)}${getOnOffFromBool(falling)}`, `${getBoolRedGreenInlineColour(ground)}${getOnOffFromBool(ground)}`);
updateServerRules();
return true;
}
@@ -417,7 +428,7 @@ function setServerGUIColoursCommand(command, params, client) {
}
let splitParams = params.split(" ");
let colourRed = toInteger(getParam(params, " ", 1)) || 255;
let colourRed = toInteger(getParam(params, " ", 1)) || 255;
let colourGreen = toInteger(getParam(params, " ", 2)) || 255;
let colourBlue = toInteger(getParam(params, " ", 3)) || 255;
@@ -430,8 +441,8 @@ function setServerGUIColoursCommand(command, params, client) {
getServerConfig().needsSaved = true;
//messageAdminAction(`${getPlayerName(client)} ${getInlineChatColourByName("orange")}set the server ${getBoolRedGreenInlineColour(fallingSnow)}${getOnOffFromBool(fallingSnow)} ${getInlineChatColourByName("orange")}and ground snow ${getBoolRedGreenInlineColour(groundSnow)}${getOnOffFromBool(groundSnow)}`);
//updateServerRules();
//announceAdminAction(`${getPlayerName(client)} ${getInlineChatColourByName("orange")}set the server ${getBoolRedGreenInlineColour(fallingSnow)}${getOnOffFromBool(fallingSnow)} ${getInlineChatColourByName("orange")}and ground snow ${getBoolRedGreenInlineColour(groundSnow)}${getOnOffFromBool(groundSnow)}`);
//updateServerRules();
return true;
}
@@ -452,8 +463,8 @@ function toggleServerLogoCommand(command, params, client) {
updatePlayerShowLogoState(null, getServerConfig().useLogo);
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned the server logo image ${getBoolRedGreenInlineColour(doesServerHaveServerLogoEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().useLogo))}`);
updateServerRules();
//announceAdminAction(`${getPlayerName(client)}{MAINCOLOUR}${getBoolRedGreenInlineColour(doesServerHaveServerLogoEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().useLogo))}`);
updateServerRules();
return true;
}
@@ -472,7 +483,7 @@ function toggleServerLogoCommand(command, params, client) {
getServerConfig().createJobBlips = !getServerConfig().createJobBlips;
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned ${getBoolRedGreenInlineColour(doesServerHaveJobBlipsEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().createJobBlips))} {MAINCOLOUR}all job blips`);
announceAdminAction("ServerJobBlipsSet", `{adminRed}${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().createJobBlips)}${toUpperCase(getOnOffFromBool(getServerConfig().createJobBlips))}{MAINCOLOUR}`);
resetAllJobBlips();
return true;
}
@@ -492,7 +503,7 @@ function toggleServerLogoCommand(command, params, client) {
getServerConfig().createJobPickups = !getServerConfig().createJobPickups;
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned ${getBoolRedGreenInlineColour(doesServerHaveJobPickupsEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().createJobPickups))} {MAINCOLOUR}all job pickups`);
announceAdminAction("ServerJobPickupsSet", `{adminRed}${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().createJobPickups)}${toUpperCase(getOnOffFromBool(getServerConfig().createJobPickups))}{MAINCOLOUR}`);
resetAllJobPickups();
return true;
}
@@ -509,10 +520,10 @@ function toggleServerLogoCommand(command, params, client) {
*
*/
function toggleServerBusinessBlipsCommand(command, params, client) {
getServerConfig().createBusinessBlips = !getServerConfig().createBusinessBlips;
getServerConfig().createBusinessBlips = !getServerConfig().createBusinessBlips;
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned ${getBoolRedGreenInlineColour(doesServerHaveBusinessBlipsEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().createBusinessBlips))} {MAINCOLOUR}all business blips`);
announceAdminAction("ServerBusinessBlipsSet", `{adminRed}${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().createBusinessBlips)}${toUpperCase(getOnOffFromBool(getServerConfig().createBusinessBlips))}{MAINCOLOUR}`);
resetAllBusinessBlips();
return true;
}
@@ -529,10 +540,10 @@ function toggleServerLogoCommand(command, params, client) {
*
*/
function toggleServerBusinessPickupsCommand(command, params, client) {
getServerConfig().createBusinessPickups = !getServerConfig().createBusinessPickups;
getServerConfig().createBusinessPickups = !getServerConfig().createBusinessPickups;
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned ${getBoolRedGreenInlineColour(doesServerHaveBusinessPickupsEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().createBusinessPickups))} {MAINCOLOUR}all business pickups`);
announceAdminAction("ServerBusinessPickupsSet", `{adminRed}${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().createBusinessPickups)}${toUpperCase(getOnOffFromBool(getServerConfig().createBusinessPickups))}{MAINCOLOUR}`);
resetAllBusinessPickups();
return true;
}
@@ -549,10 +560,10 @@ function toggleServerLogoCommand(command, params, client) {
*
*/
function toggleServerHouseBlipsCommand(command, params, client) {
getServerConfig().createHouseBlips = !getServerConfig().createHouseBlips;
getServerConfig().createHouseBlips = !getServerConfig().createHouseBlips;
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned ${getBoolRedGreenInlineColour(doesServerHaveHouseBlipsEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().createHouseBlips))} {MAINCOLOUR}all house blips`);
announceAdminAction("ServerHouseBlipsSet", `{adminRed}${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().createHouseBlips)}${toUpperCase(getOnOffFromBool(getServerConfig().createHouseBlips))}{MAINCOLOUR}`);
resetAllHouseBlips();
return true;
}
@@ -572,7 +583,7 @@ function toggleServerLogoCommand(command, params, client) {
getServerConfig().createHousePickups = !getServerConfig().createHousePickups;
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned ${getBoolRedGreenInlineColour(doesServerHaveHousePickupsEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().createHousePickups))} {MAINCOLOUR}all house pickups`);
announceAdminAction("ServerHousePickupsSet", `{adminRed}${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().createHousePickups)}${toUpperCase(getOnOffFromBool(getServerConfig().createHousePickups))}{MAINCOLOUR}`);
resetAllHousePickups();
return true;
}
@@ -593,8 +604,8 @@ function toggleServerGUICommand(command, params, client) {
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned GUI ${toLowerCase(getOnOffFromBool(doesServerHaveGUIEnabled()))} for this server`);
updateServerRules();
announceAdminAction(`${getPlayerName(client)}{MAINCOLOUR} turned GUI ${toLowerCase(getOnOffFromBool(getServerConfig().useGUI))} for this server`);
updateServerRules();
return true;
}
@@ -611,12 +622,12 @@ function toggleServerGUICommand(command, params, client) {
*/
function toggleServerUseRealWorldTimeCommand(command, params, client) {
getServerConfig().useRealTime = !getServerConfig().useRealTime;
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned real-world time ${getServerConfig().useRealTime} for this server (GMT ${addPositiveNegativeSymbol(getServerConfig().realTimeZone)})`);
//announceAdminAction(`${getPlayerName(client)}{MAINCOLOUR} turned real-world time ${getServerConfig().useRealTime} for this server (GMT ${addPositiveNegativeSymbol(getServerConfig().realTimeZone)})`);
updateServerGameTime();
updateServerRules();
updateServerRules();
return true;
}
@@ -637,12 +648,12 @@ function setServerRealWorldTimeZoneCommand(command, params, client) {
return false;
}
getServerConfig().realTimeZone = toInteger(params);
getServerConfig().realTimeZone = toInteger(params);
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}set the time zone for in-game's real-world time to GMT ${addPositiveNegativeSymbol(getServerConfig().realTimeZone)}`);
//announceAdminAction(`${getPlayerName(client)} {MAINCOLOUR}set the time zone for in-game's real-world time to GMT ${addPositiveNegativeSymbol(getServerConfig().realTimeZone)}`);
updateServerGameTime();
updateServerRules();
updateServerRules();
return true;
}
@@ -662,7 +673,7 @@ function reloadServerConfigurationCommand(command, params, client) {
applyConfigToServer(serverConfig);
updateServerRules();
messagePlayerSuccess(client, `You reloaded the server configuration!`);
messagePlayerSuccess(client, `You reloaded the server configuration!`);
return true;
}
@@ -679,7 +690,7 @@ function reloadServerConfigurationCommand(command, params, client) {
*/
function reloadEmailConfigurationCommand(command, params, client) {
emailConfig = loadEmailConfiguration();
messagePlayerSuccess(client, `You reloaded the email configuration!`);
messagePlayerSuccess(client, `You reloaded the email configuration!`);
return true;
}
@@ -746,6 +757,15 @@ function loadAccentConfig() {
// ===========================================================================
function loadDiscordConfig() {
let discordConfig = JSON.parse(loadTextFile(`config/discord.json`));
if(discordConfig != null) {
return discordConfig;
}
}
// ===========================================================================
function doesServerHaveGUIEnabled() {
return getServerConfig().useGUI;
}
@@ -782,7 +802,7 @@ function doesServerHaveJobPickupsEnabled() {
// ===========================================================================
function doesServerHaveBusinesBlipsEnabled() {
function doesServerHaveBusinessBlipsEnabled() {
return getServerConfig().createBusinessBlips;
}

View File

@@ -11,6 +11,7 @@
const VRR_PROMPT_NONE = 0;
const VRR_PROMPT_CREATEFIRSTCHAR = 1;
const VRR_PROMPT_BIZORDER = 2;
const VRR_PROMPT_GIVEVEHTOCLAN = 3;
// Job Types
const VRR_JOB_NONE = 0;
@@ -346,4 +347,9 @@ 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
const VRR_GPS_TYPE_GAMELOC = 5; // Game Location
// Discord Webhook Types
const VRR_DISCORD_WEBHOOK_NONE = 0;
const VRR_DISCORD_WEBHOOK_LOG = 1;
const VRR_DISCORD_WEBHOOK_ADMIN = 2;

View File

@@ -9,7 +9,7 @@
let scriptVersion = "1.0";
let serverStartTime = 0;
let logLevel = LOG_INFO;
let logLevel = LOG_INFO|LOG_DEBUG|LOG_VERBOSE|LOG_WARN|LOG_ERROR;
// ===========================================================================
@@ -31,6 +31,10 @@ let serverData = {
localeStrings: {},
cachedTranslations: [],
cachedTranslationFrom: [],
triggers: [],
npcs: [],
locales: [],
accents: [],
};
// ===========================================================================

View File

@@ -20,4 +20,3 @@ function initDatabaseScript() {
}
// ===========================================================================

View File

@@ -152,7 +152,7 @@ function addLogLevelCommand(command, params, client) {
sendPlayerLogLevel(null, logLevel);
messageAdminAction(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}enabled log level {ALTCOLOUR}${toLowerCase(params)}`);
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}enabled log level {ALTCOLOUR}${toLowerCase(params)}`);
return true;
}
@@ -222,7 +222,7 @@ function removeLogLevelCommand(command, params, client) {
sendPlayerLogLevel(null, logLevel);
messageAdminAction(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}disabled log level {ALTCOLOUR}${toLowerCase(params)}`);
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}disabled log level {ALTCOLOUR}${toLowerCase(params)}`);
return true;
}
@@ -380,15 +380,72 @@ function setPlayerTesterStatusCommand(command, params, client) {
let enabled = hasBitFlag(getPlayerData(targetClient).accountData.flags.moderation, getModerationFlagValue("IsTester"));
messageAdminAction(`{ALTCOLOUR}${client.name} ${getBoolRedGreenInlineColour(enabled)}${toUpperCase(getEnabledDisabledFromBool(enabled))} {ALTCOLOUR}${targetClient.name}'s {MAINCOLOUR}tester status`)
messageAdmins(`{ALTCOLOUR}${client.name} ${getBoolRedGreenInlineColour(enabled)}${toUpperCase(getEnabledDisabledFromBool(enabled))} {ALTCOLOUR}${targetClient.name}'s {MAINCOLOUR}tester status`)
return true;
}
// ===========================================================================
function saveAllServerDataCommand(command, params, client) {
function testPromptGUICommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
let targetClient = getPlayerFromParams(params);
if(!targetClient) {
messagePlayerError(client, getLocaleString(client, "InvalidPlayer"));
return false;
}
showPlayerPromptGUI(targetClient, "Testing the two button prompt GUI", "Testing", "Yes", "No")
return true;
}
// ===========================================================================
function testInfoGUICommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
let targetClient = getPlayerFromParams(params);
if(!targetClient) {
messagePlayerError(client, getLocaleString(client, "InvalidPlayer"));
return false;
}
showPlayerInfoGUI(targetClient, "Testing the info dialog GUI", "Testing", "Ok");
return true;
}
// ===========================================================================
function testErrorGUICommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
let targetClient = getPlayerFromParams(params);
if(!targetClient) {
messagePlayerError(client, getLocaleString(client, "InvalidPlayer"));
return false;
}
showPlayerErrorGUI(targetClient, "Testing the error dialog GUI", "Testing", "Ok");
return true;
}
// ===========================================================================
function saveServerDataCommand(command, params, client) {
messageAdmins(`{clanOrange}Vortrex has forced a manual save of all data. Initiating ...`);
saveAllServerDataToDatabase();
saveServerDataToDatabase();
messageAdmins(`{clanOrange}All server data saved to database successfully!`);
return true;
}
@@ -572,9 +629,9 @@ function streamAudioNameToAllPlayersCommand(command, params, client) {
// ===========================================================================
function fixAllServerBlipsCommand(command, params, client) {
deleteAllBusinessBlips();
deleteAllJobBlips();
deleteAllHouseBlips();
deleteAllBusinessBlips();
deleteAllJobBlips();
deleteAllHouseBlips();
let blips = getElementsByType(ELEMENT_BLIP);
blips.forEach((blip) => {

View File

@@ -16,31 +16,31 @@ function initDiscordScript() {
/*
addEventHandler("OnDiscordCommand", function(command, params, discordUser) {
let commandData = getCommand(command);
let commandData = getCommand(command);
if(!commandData) {
messagePlayerError(discordUser, "That command does not exist!");
return false;
}
if(!commandData) {
messagePlayerError(discordUser, "That command does not exist!");
return false;
}
if(isCommandAllowedOnDiscord(command)) {
messagePlayerError(discordUser, "That command can not be used on Discord!");
return false;
}
if(isCommandAllowedOnDiscord(command)) {
messagePlayerError(discordUser, "That command can not be used on Discord!");
return false;
}
if(doesClientHavePermission(discordUser, getCommandRequiredPermissions(command))) {
messagePlayerError(discordUser, "You do not have permission to use that command!");
return false;
}
if(doesClientHavePermission(discordUser, getCommandRequiredPermissions(command))) {
messagePlayerError(discordUser, "You do not have permission to use that command!");
return false;
}
commandData.handlerFunction(command, params, discordUser);
commandData.handlerFunction(command, params, discordUser);
});
*/
// ===========================================================================
function messageDiscordUser(discordUser, messageText) {
let socketData = JSON.stringify({
let socketData = JSON.stringify({
type: "chat.message.text",
payload: {
author: discordUser.name,
@@ -53,88 +53,82 @@ function messageDiscordUser(discordUser, messageText) {
// ===========================================================================
function sendDiscordSocketData(socketData) {
if(!getDiscordSocket()) {
return false;
}
if(!getDiscordSocket()) {
return false;
}
getDiscordSocket().send(module.hash.encodeBase64(socketData) + "\r\n");
getDiscordSocket().send(module.hash.encodeBase64(socketData) + "\r\n");
}
// ===========================================================================
function isClientFromDiscord(client) {
if(client == null) {
return false;
}
if(client == null) {
return false;
}
if(client instanceof Client) {
return false;
} else {
return true;
}
if(client instanceof Client) {
return false;
} else {
return true;
}
}
// ===========================================================================
function getDiscordSocket() {
return false;
return false;
}
// ===========================================================================
function getDiscordUserData(discordUserId) {
return loadAccountFromDiscordUserId(discordUserId);
return loadAccountFromDiscordUserId(discordUserId);
}
// ===========================================================================
function messageDiscordChatChannel(message) {
if(!getServerConfig().discordConfig.sendChat) {
return false;
}
function messageDiscordChatChannel(messageString) {
if(getServerConfig().devServer) {
return false;
}
message = removeColoursInMessage(message);
console.warn(message);
let payloadData = {
"username": "Chat",
"content": message,
};
if(!getServerConfig().discord.sendChat) {
return false;
}
triggerWebHook(getServerConfig().discordConfig.chatChannelWebHookURL, JSON.stringify(payloadData));
messageString = removeColoursInMessage(messageString);
triggerWebHook(messageString, getServerId(), VRR_DISCORD_WEBHOOK_LOG);
}
// ===========================================================================
function messageDiscordAdminChannel(message) {
if(!getServerConfig().discordConfig.sendAdminEvents) {
return false;
}
function messageDiscordEventChannel(messageString) {
if(getServerConfig().devServer == true) {
return false;
}
message = removeColoursInMessage(message);
console.warn(message);
let payloadData = {
"username": "Admin Event",
"content": message,
};
if(!getServerConfig().discord.sendEvents) {
return false;
}
triggerWebHook(getServerConfig().discordConfig.adminChannelWebHookURL, JSON.stringify(payloadData));
messageString = removeColoursInMessage(messageString);
triggerWebHook(messageString, getServerId(), VRR_DISCORD_WEBHOOK_LOG);
}
// ===========================================================================
function messageDiscordEventChannel(message) {
if(!getServerConfig().discordConfig.sendEvents) {
return false;
}
function messageDiscordAdminChannel(messageString) {
if(getServerConfig().devServer == true) {
return false;
}
message = removeColoursInMessage(message);
console.warn(message);
let payloadData = {
"username": "Event",
"content": message,
};
if(!getServerConfig().discord.sendAdmin) {
return false;
}
triggerWebHook(getServerConfig().discordConfig.eventChannelWebHookURL, JSON.stringify(payloadData));
messageString = removeColoursInMessage(messageString);
triggerWebHook(messageString, getServerId(), VRR_DISCORD_WEBHOOK_ADMIN);
}
// ===========================================================================

View File

@@ -30,12 +30,17 @@ function playerPayDay(client) {
let wealth = calculateWealth(client);
let grossIncome = getPlayerData(client).payDayAmount;
// Passive income
// Passive income
grossIncome = grossIncome + getGlobalConfig().economy.passiveIncomePerPayDay;
// Payday bonus
// Payday bonus
grossIncome = grossIncome*getGlobalConfig().economy.grossIncomeMultiplier;
// Double bonus
if(isDoubleBonusActive()) {
grossIncome = grossIncome*2;
}
let incomeTaxAmount = calculateIncomeTax(wealth);
let netIncome = grossIncome-incomeTaxAmount;
@@ -49,11 +54,11 @@ function playerPayDay(client) {
let canPayNow = totalCash+netIncome;
if(incomeTaxAmount <= canPayNow) {
takePlayerCash(client, canPayNow);
messagePlayerInfo(client, `You covered the remaining taxes with {ALTCOLOUR}$${canPayNow} {MAINCOLOUR}in cash.`);
messagePlayerAlert(client, `{orange}You lost money since your taxes are more than your paycheck!`);
messagePlayerAlert(client, `{orange}If you don't have enough cash to cover taxes on next paycheck, you will lose stuff!`);
messagePlayerInfo(client, `{orange}${getLocaleString(client, "RemainingTaxPaidInCash", `{ALTCOLOUR}${canPayNow}{MAINCOLOUR}`)}`);
messagePlayerAlert(client, `{orange}${getLocaleString(client, "LostMoneyFromTaxes")}`);
messagePlayerAlert(client, `{orange}${getLocaleString(client, "NextPaycheckRepossessionWarning")}`);
} else {
messagePlayerInfo(client, `{orange}You don't have enough cash to pay your taxes!`);
messagePlayerInfo(client, `{orange}${getLocaleString(client, "NotEnoughCashForTax")}`);
takePlayerCash(client, canPayNow);
let vehicleCount = getAllVehiclesOwnedByPlayer(client).length;
@@ -65,7 +70,7 @@ function playerPayDay(client) {
let newVehicleCount = getAllVehiclesOwnedByPlayer(client).length;
let newHouseCount = getAllHousesOwnedByPlayer(client).length;
let newBusinessCount = getAllBusinessesOwnedByPlayer(client).length;
messagePlayerInfo(client, `{orange}You lost ${newVehicleCount-vehicleCount} vehicles, ${newHouseCount-houseCount} houses, and ${newBusinessCount-businessCount} businesses to cover the remaining tax.`);
messagePlayerInfo(client, `{orange}${getLocaleString(client, "AssetsRepossessedForTaxes", newVehicleCount-vehicleCount, newHouseCount-houseCount, newBusinessCount-businessCount)}`);
}
}
@@ -120,14 +125,14 @@ function setPayDayBonusMultiplier(command, params, client) {
let newMultiplier = params;
if(isNaN(newMultiplier)) {
messagePlayerError(client, getLocaleString(client, "AmountNotNumber"));
return false;
}
if(isNaN(newMultiplier)) {
messagePlayerError(client, getLocaleString(client, "AmountNotNumber"));
return false;
}
getGlobalConfig().economy.grossIncomeMultiplier = newMultiplier;
getGlobalConfig().economy.grossIncomeMultiplier = newMultiplier;
messageAdminAction(`${client.name} set payday bonus to ${newMultiplier*100}%`);
announceAdminAction(`PaydayBonusSet`, `{adminRed}${client.name}{MAINCOLOUR}`, `{ALTCOLOUR}${newMultiplier*100}%{MAINCOLOUR}`);
}
// ===========================================================================
@@ -157,6 +162,8 @@ function attemptRepossession(client, totalToPay) {
return true;
}
// ===========================================================================
function repossessFirstAsset(client) {
let vehicles = getAllVehiclesOwnedByPlayer(client);
if(vehicles.length > 0) {
@@ -193,4 +200,16 @@ function getAllBusinessesOwnedByPlayer(client) {
function getAllHousesOwnedByPlayer(client) {
return getServerData().houses.filter((h) => h.ownerType == VRR_HOUSEOWNER_PLAYER && h.ownerId == getPlayerCurrentSubAccount(client).databaseId);
}
}
// ===========================================================================
function isDoubleBonusActive() {
if(isWeekend()) {
return true;
}
return false;
}
// ===========================================================================

View File

@@ -8,47 +8,47 @@
// ===========================================================================
function initEmailScript() {
if(!checkForSMTPModule()) {
return false;
}
if(!checkForSMTPModule()) {
return false;
}
logToConsole(LOG_INFO, "[VRR.Email]: Initializing email script ...");
emailConfig = loadEmailConfiguration();
emailConfig = loadEmailConfiguration();
logToConsole(LOG_INFO, "[VRR.Email]: Email script initialized successfully!");
}
// ===========================================================================
function sendEmail(toEmail, toName, subject, body) {
if(!checkForSMTPModule()) {
return false;
}
if(!checkForSMTPModule()) {
return false;
}
module.smtp.send(
getEmailConfig().smtp.host,
getEmailConfig().smtp.port,
intToBool(getEmailConfig().smtp.useTLS),
getEmailConfig().smtp.username,
getEmailConfig().smtp.password,
toEmail,
toName,
subject,
body,
getEmailConfig().smtp.from,
getEmailConfig().smtp.fromName);
module.smtp.send(
getEmailConfig().smtp.host,
getEmailConfig().smtp.port,
intToBool(getEmailConfig().smtp.useTLS),
getEmailConfig().smtp.username,
getEmailConfig().smtp.password,
toEmail,
toName,
subject,
body,
getEmailConfig().smtp.from,
getEmailConfig().smtp.fromName);
}
// ===========================================================================
function loadEmailConfiguration() {
let emailConfigFile = loadTextFile("config/email.json");
let emailConfigFile = loadTextFile("config/email.json");
return JSON.parse(emailConfigFile);
}
// ===========================================================================
function getEmailConfig() {
return emailConfig;
return emailConfig;
}
// ===========================================================================

View File

@@ -8,59 +8,60 @@
// ===========================================================================
function initEventScript() {
logToConsole(LOG_INFO, "[VRR.Event]: Initializing event script ...");
addAllEventHandlers();
logToConsole(LOG_INFO, "[VRR.Event]: Event script initialized!");
logToConsole(LOG_INFO, "[VRR.Event]: Initializing event script ...");
addAllEventHandlers();
logToConsole(LOG_INFO, "[VRR.Event]: Event script initialized!");
}
// ===========================================================================
function addAllEventHandlers() {
addEventHandler("onResourceStart", onResourceStart);
addEventHandler("onResourceStop", onResourceStop);
addEventHandler("onServerStop", onResourceStop);
addEventHandler("onResourceStart", onResourceStart);
addEventHandler("onResourceStop", onResourceStop);
addEventHandler("onServerStop", onResourceStop);
addEventHandler("onProcess", onProcess);
addEventHandler("onEntityProcess", onEntityProcess);
addEventHandler("onProcess", onProcess);
addEventHandler("onEntityProcess", onEntityProcess);
addEventHandler("onPlayerConnect", onPlayerConnect);
addEventHandler("onPlayerJoin", onPlayerJoin);
addEventHandler("onPlayerJoined", onPlayerJoined);
addEventHandler("onPlayerChat", onPlayerChat);
addEventHandler("onPlayerQuit", onPlayerQuit);
addEventHandler("onElementStreamIn", onElementStreamIn);
addEventHandler("onElementStreamOut", onElementStreamOut);
addEventHandler("onPlayerConnect", onPlayerConnect);
addEventHandler("onPlayerJoin", onPlayerJoin);
addEventHandler("onPlayerJoined", onPlayerJoined);
addEventHandler("onPlayerChat", onPlayerChat);
addEventHandler("onPlayerQuit", onPlayerQuit);
addEventHandler("onElementStreamIn", onElementStreamIn);
addEventHandler("onElementStreamOut", onElementStreamOut);
addEventHandler("onPedSpawn", onPedSpawn);
addEventHandler("onPedEnterVehicle", onPedEnteringVehicle);
addEventHandler("onPedExitVehicle", onPedExitingVehicle);
addEventHandler("onPedSpawn", onPedSpawn);
addEventHandler("onPedEnterVehicle", onPedEnteringVehicle);
addEventHandler("onPedExitVehicle", onPedExitingVehicle);
addEventHandler("onPedEnteringVehicle", onPedEnteringVehicle);
addEventHandler("onPedExitingVehicle", onPedExitingVehicle);
addEventHandler("onPedEnteringVehicle", onPedEnteringVehicle);
addEventHandler("onPedExitingVehicle", onPedExitingVehicle);
addEventHandler("OnPlayerCommand", onPlayerCommand);
//addEventHandler("OnPlayerCommand", onPlayerCommand);
}
// ===========================================================================
function onPlayerConnect(event, ipAddress, port) {
logToConsole(LOG_INFO, `[VRR.Event] Client connecting (IP: ${ipAddress})`);
//if(isIpAddressBanned(ipAddress)) {
// messagePlayerError(client, "You are banned from this server!");
// return false;
//}
logToConsole(LOG_INFO, `[VRR.Event] Client connecting (IP: ${ipAddress})`);
//if(isIpAddressBanned(ipAddress)) {
// messagePlayerError(client, "You are banned from this server!");
// return false;
//}
}
// ===========================================================================
function onPlayerJoin(event, client) {
logToConsole(LOG_INFO, `[VRR.Event] Client ${client.name}[${client.index}] joining from ${client.ip}`);
logToConsole(LOG_INFO, `[VRR.Event] Client ${client.name}[${client.index}] joining from ${client.ip}`);
if(isFadeCameraSupported()) {
fadeCamera(client, true, 1.0);
}
if(isFadeCameraSupported()) {
fadeCamera(client, true, 1.0);
}
messageDiscordEventChannel(`👋 ${getPlayerDisplayForConsole(client)} has joined the server.`);
messageDiscordEventChannel(`👋 ${client.name} is connecting to the server ...`);
//messageDiscordEventChannel(`👋 ${getPlayerDisplayForConsole(client)} has joined the server.`);
}
// ===========================================================================
@@ -72,16 +73,16 @@ function onPlayerJoined(event, client) {
// ===========================================================================
function onElementStreamIn(event, element, client) {
//if(getPlayerDimension(client) != getElementDimension(element)) {
// event.preventDefault();
//}
//if(getPlayerDimension(client) != getElementDimension(element)) {
// event.preventDefault();
//}
if(getPlayerData(getClientFromIndex(element.owner)) != false ) {
if(hasBitFlag(getPlayerData(getClientFromIndex(element.owner)).accountData.flags.moderation, getModerationFlagValue("DontSyncClientElements"))) {
event.preventDefault();
destroyGameElement(element);
}
}
if(getPlayerData(getClientFromIndex(element.owner)) != false ) {
if(hasBitFlag(getPlayerData(getClientFromIndex(element.owner)).accountData.flags.moderation, getModerationFlagValue("DontSyncClientElements"))) {
event.preventDefault();
destroyGameElement(element);
}
}
}
// ===========================================================================
@@ -93,39 +94,44 @@ function onElementStreamOut(event, element, client) {
// ===========================================================================
function onPlayerQuit(event, client, quitReasonId) {
logToConsole(LOG_INFO, `👋 Client ${getPlayerDisplayForConsole(client)} disconnected (${disconnectReasons[quitReasonId]}[${quitReasonId}])`);
updateConnectionLogOnQuit(client, quitReasonId);
logToConsole(LOG_INFO, `👋 Client ${getPlayerDisplayForConsole(client)} disconnected (${disconnectReasons[quitReasonId]}[${quitReasonId}])`);
updateConnectionLogOnQuit(client, quitReasonId);
if(isPlayerLoggedIn(client)) {
messagePlayerNormal(null, `👋 ${getPlayerName(client)} has left the server (${disconnectReasons[quitReasonId]})`, getColourByName("softYellow"));
savePlayerToDatabase(client);
resetClientStuff(client);
getServerData().clients[client.index] = null;
}
if(isPlayerLoggedIn(client)) {
let reasonText = disconnectReasons[quitReasonId];
if(getPlayerData(client).customDisconnectReason != "") {
reasonText = getPlayerData(client).customDisconnectReason;
}
messagePlayerNormal(null, `👋 ${getPlayerName(client)} has left the server (${reasonText})`, getColourByName("softYellow"));
messageDiscordEventChannel(`👋 ${client.name} has left the server (${reasonText})`);
messageDiscordEventChannel(`👋 ${getPlayerDisplayForConsole(client)} has left the server.`);
savePlayerToDatabase(client);
resetClientStuff(client);
getServerData().clients[client.index] = null;
} else {
messageDiscordEventChannel(`👋 ${client.name} has left the server (${disconnectReasons[quitReasonId]}[${quitReasonId}])`);
}
clearTemporaryVehicles();
clearTemporaryPeds();
clearTemporaryVehicles();
clearTemporaryPeds();
}
// ===========================================================================
async function onPlayerChat(event, client, messageText) {
event.preventDefault();
processPlayerChat(client, messageText);
processPlayerChat(client, messageText);
event.preventDefault();
}
// ===========================================================================
function onProcess(event, deltaTime) {
updateServerGameTime();
//checkPlayerSpawning();
//checkPlayerPedState();
//checkVehicleBurning();
updateServerGameTime();
//checkPlayerSpawning();
//checkPlayerPedState();
//checkVehicleBurning();
processVehiclePurchasing();
processVehiclePurchasing();
}
// ===========================================================================
@@ -136,89 +142,89 @@ function onEntityProcess(event, entity) {
// ===========================================================================
function onPedEnteringVehicle(event, ped, vehicle, seat) {
if(ped.isType(ELEMENT_PLAYER)) {
let client = getClientFromPlayerElement(ped);
getPlayerData(client).pedState = VRR_PEDSTATE_ENTERINGVEHICLE;
if(ped.isType(ELEMENT_PLAYER)) {
let client = getClientFromPlayerElement(ped);
getPlayerData(client).pedState = VRR_PEDSTATE_ENTERINGVEHICLE;
if(!getVehicleData(vehicle)) {
return false;
}
if(!getVehicleData(vehicle)) {
return false;
}
if(getVehicleData(vehicle).locked) {
if(doesPlayerHaveVehicleKeys(client, vehicle)) {
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "lock")) {
messagePlayerTip(client, `🔒 This ${getVehicleName(vehicle)} is locked. Press {ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "lock").key))} {MAINCOLOUR}to unlock it.`);
} else {
messagePlayerNormal(client, `🔒 This ${getVehicleName(vehicle)} is locked. Use /lock to unlock it`);
}
} else {
messagePlayerNormal(client, `🔒 This ${getVehicleName(vehicle)} is locked and you don't have the keys to unlock it`);
}
if(getVehicleData(vehicle).locked) {
if(doesPlayerHaveVehicleKeys(client, vehicle)) {
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "lock")) {
messagePlayerTip(client, `🔒 This ${getVehicleName(vehicle)} is locked. Press {ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "lock").key))} {MAINCOLOUR}to unlock it.`);
} else {
messagePlayerNormal(client, `🔒 This ${getVehicleName(vehicle)} is locked. Use /lock to unlock it`);
}
} else {
messagePlayerNormal(client, `🔒 This ${getVehicleName(vehicle)} is locked and you don't have the keys to unlock it`);
}
getPlayerData(client).enteringVehicle = null;
makePlayerStopAnimation(client);
return false;
}
getPlayerData(client).enteringVehicle = null;
makePlayerStopAnimation(client);
return false;
}
getPlayerData(client).enteringVehicle = vehicle;
}
getPlayerData(client).enteringVehicle = vehicle;
}
}
// ===========================================================================
function onPedExitingVehicle(event, ped, vehicle) {
if(!getVehicleData(vehicle)) {
return false;
}
if(!getVehicleData(vehicle)) {
return false;
}
if(ped.isType(ELEMENT_PLAYER)) {
let client = getClientFromPlayerElement(ped);
getPlayerData(client).pedState = VRR_PEDSTATE_EXITINGVEHICLE;
}
if(ped.isType(ELEMENT_PLAYER)) {
let client = getClientFromPlayerElement(ped);
getPlayerData(client).pedState = VRR_PEDSTATE_EXITINGVEHICLE;
}
if(!getVehicleData(vehicle).spawnLocked) {
getVehicleData(vehicle).spawnPosition = getVehiclePosition(vehicle);
getVehicleData(vehicle).spawnRotation = getVehicleHeading(vehicle);
getVehicleData(vehicle).needsSaved = true;
}
if(!getVehicleData(vehicle).spawnLocked) {
getVehicleData(vehicle).spawnPosition = getVehiclePosition(vehicle);
getVehicleData(vehicle).spawnRotation = getVehicleHeading(vehicle);
getVehicleData(vehicle).needsSaved = true;
}
}
// ===========================================================================
function onResourceStart(event, resource) {
logToConsole(LOG_WARN, `[VRR.Event] ${resource.name} started!`);
logToConsole(LOG_WARN, `[VRR.Event] ${resource.name} started!`);
if(resource != thisResource) {
messageAdmins(`{MAINCOLOUR}Resource {ALTCOLOUR}${resource.name} {MAINCOLOUR}started!`);
}
if(resource != thisResource) {
messageAdmins(`{MAINCOLOUR}Resource {ALTCOLOUR}${resource.name} {MAINCOLOUR}started!`);
}
}
// ===========================================================================
function onResourceStop(event, resource) {
logToConsole(LOG_WARN, `[VRR.Event] ${resource.name} stopped!`);
logToConsole(LOG_WARN, `[VRR.Event] ${resource.name} stopped!`);
if(resource != thisResource) {
messageAdmins(`{MAINCOLOUR}Resource {ALTCOLOUR}${resource.name} {MAINCOLOUR}stopped!`);
}
if(resource != thisResource) {
messageAdmins(`{MAINCOLOUR}Resource {ALTCOLOUR}${resource.name} {MAINCOLOUR}stopped!`);
}
if(resource == thisResource) {
saveAllServerDataToDatabase();
clearArray(getServerData().vehicles);
clearArray(getServerData().clients);
clearArray(getServerData().businesses);
clearArray(getServerData().houses);
clearArray(getServerData().factions);
clearArray(getServerData().jobs);
clearArray(getServerData().clans);
clearArray(getServerData().items);
clearArray(getServerData().itemTypes);
clearArray(getServerData().groundItemCache);
clearArray(getServerData().groundPlantCache);
kickAllClients();
}
if(resource == thisResource) {
saveServerDataToDatabase();
clearArray(getServerData().vehicles);
clearArray(getServerData().clients);
clearArray(getServerData().businesses);
clearArray(getServerData().houses);
clearArray(getServerData().factions);
clearArray(getServerData().jobs);
clearArray(getServerData().clans);
clearArray(getServerData().items);
clearArray(getServerData().itemTypes);
clearArray(getServerData().groundItemCache);
clearArray(getServerData().groundPlantCache);
kickAllClients();
}
collectAllGarbage();
collectAllGarbage();
}
// ===========================================================================
@@ -236,183 +242,202 @@ function onPlayerExitedSphere(client, sphere) {
// ===========================================================================
async function onPlayerEnteredVehicle(client, clientVehicle, seat) {
if(client == null) {
return false;
}
if(client == null) {
return false;
}
let vehicle = null;
let vehicle = null;
if(getGame() == VRR_GAME_GTA_IV) {
vehicle = getVehicleFromIVNetworkId(clientVehicle);
} else {
if(client.player == null) {
return false;
}
if(getGame() == VRR_GAME_GTA_IV) {
vehicle = getVehicleFromIVNetworkId(clientVehicle);
} else {
if(getPlayerPed(client) == null) {
return false;
}
await waitUntil(() => client != null && client.player != null && client.player.vehicle != null);
await waitUntil(() => client != null && getPlayerPed(client) != null && getPlayerVehicle(client) != null);
vehicle = client.player.vehicle;
}
vehicle = getPlayerVehicle(client);
}
if(!getVehicleData(vehicle)) {
return false;
}
if(!getVehicleData(vehicle)) {
return false;
}
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} entered a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("vrr.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} entered a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("vrr.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
getPlayerData(client).lastVehicle = vehicle;
getVehicleData(vehicle).lastActiveTime = getCurrentUnixTimestamp();
getPlayerData(client).lastVehicle = vehicle;
getVehicleData(vehicle).lastActiveTime = getCurrentUnixTimestamp();
if(getPlayerVehicleSeat(client) == VRR_VEHSEAT_DRIVER) {
vehicle.engine = getVehicleData(vehicle).engine;
if(getPlayerVehicleSeat(client) == VRR_VEHSEAT_DRIVER) {
vehicle.engine = getVehicleData(vehicle).engine;
if(getVehicleData(vehicle).buyPrice > 0) {
messagePlayerAlert(client, getLocaleString(client, "VehicleForSale", getVehicleName(vehicle), `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).buyPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehbuy{MAINCOLOUR}`));
resetVehiclePosition(vehicle);
} else if(getVehicleData(vehicle).rentPrice > 0) {
if(getVehicleData(vehicle).rentedBy != client) {
messagePlayerAlert(client, getLocaleString(client, "VehicleForRent", getVehicleName(vehicle), `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).rentPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehrent{MAINCOLOUR}`));
resetVehiclePosition(vehicle);
} else {
messagePlayerAlert(client, `You are renting this ${getVehicleName(vehicle)} for {ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).rentPrice)} per minute. {MAINCOLOUR}Use {ALTCOLOUR}/stoprent {MAINCOLOUR}if you want to stop renting it.`);
}
} else {
let ownerName = "Nobody";
let ownerType = "None";
ownerType = toLowerCase(getVehicleOwnerTypeText(getVehicleData(vehicle).ownerType));
switch(getVehicleData(vehicle).ownerType) {
case VRR_VEHOWNER_CLAN:
ownerName = getClanData(getClanIdFromDatabaseId(getVehicleData(vehicle).ownerId)).name;
ownerType = "clan";
break;
if(getVehicleData(vehicle).buyPrice > 0) {
messagePlayerAlert(client, getLocaleString(client, "VehicleForSale", getVehicleName(vehicle), `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).buyPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehbuy{MAINCOLOUR}`));
resetVehiclePosition(vehicle);
} else if(getVehicleData(vehicle).rentPrice > 0) {
if(getVehicleData(vehicle).rentedBy != client) {
messagePlayerAlert(client, getLocaleString(client, "VehicleForRent", getVehicleName(vehicle), `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).rentPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehrent{MAINCOLOUR}`));
resetVehiclePosition(vehicle);
} else {
messagePlayerAlert(client, `You are renting this ${getVehicleName(vehicle)} for {ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).rentPrice)} per minute. {MAINCOLOUR}Use {ALTCOLOUR}/stoprent {MAINCOLOUR}if you want to stop renting it.`);
}
} else {
let ownerName = "Nobody";
let ownerType = "None";
ownerType = toLowerCase(getVehicleOwnerTypeText(getVehicleData(vehicle).ownerType));
switch(getVehicleData(vehicle).ownerType) {
case VRR_VEHOWNER_CLAN:
ownerName = getClanData(getClanIdFromDatabaseId(getVehicleData(vehicle).ownerId)).name;
ownerType = "clan";
break;
case VRR_VEHOWNER_JOB:
ownerName = getJobData(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)).name;
ownerType = "job";
break;
case VRR_VEHOWNER_JOB:
ownerName = getJobData(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)).name;
ownerType = "job";
break;
case VRR_VEHOWNER_PLAYER:
let subAccountData = loadSubAccountFromId(getVehicleData(vehicle).ownerId);
ownerName = `${subAccountData.firstName} ${subAccountData.lastName}`;
ownerType = "player";
break;
case VRR_VEHOWNER_PLAYER:
let subAccountData = loadSubAccountFromId(getVehicleData(vehicle).ownerId);
ownerName = `${subAccountData.firstName} ${subAccountData.lastName}`;
ownerType = "player";
break;
case VRR_VEHOWNER_BIZ:
ownerName = getBusinessData(getVehicleData(vehicle).ownerId).name;
ownerType = "business";
break;
case VRR_VEHOWNER_BIZ:
ownerName = getBusinessData(getVehicleData(vehicle).ownerId).name;
ownerType = "business";
break;
default:
break;
}
messagePlayerAlert(client, `This ${getVehicleName(vehicle)} belongs to {ALTCOLOUR}${ownerName} (${ownerType})`);
}
default:
break;
}
messagePlayerAlert(client, `This ${getVehicleName(vehicle)} belongs to {ALTCOLOUR}${ownerName} (${ownerType})`);
}
if(!getVehicleData(vehicle).engine) {
if(getVehicleData(vehicle).buyPrice == 0 && getVehicleData(vehicle).rentPrice == 0) {
if(doesPlayerHaveVehicleKeys(client, vehicle)) {
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "engine")) {
messagePlayerTip(client, `This ${getVehicleName(vehicle)}'s engine is off. Press {ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "engine").key))} {MAINCOLOUR}to start it.`);
} else {
messagePlayerAlert(client, `This ${getVehicleName(vehicle)}'s engine is off. Use /engine to start it`);
}
} else {
messagePlayerAlert(client, `This ${getVehicleName(vehicle)}'s engine is off and you don't have the keys to start it`);
if(!getVehicleData(vehicle).engine) {
if(getVehicleData(vehicle).buyPrice == 0 && getVehicleData(vehicle).rentPrice == 0) {
if(doesPlayerHaveVehicleKeys(client, vehicle)) {
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "engine")) {
messagePlayerTip(client, `This ${getVehicleName(vehicle)}'s engine is off. Press {ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "engine").key))} {MAINCOLOUR}to start it.`);
} else {
messagePlayerAlert(client, `This ${getVehicleName(vehicle)}'s engine is off. Use /engine to start it`);
}
} else {
messagePlayerAlert(client, `This ${getVehicleName(vehicle)}'s engine is off and you don't have the keys to start it`);
}
}
resetVehiclePosition(vehicle);
}
}
}
resetVehiclePosition(vehicle);
}
let currentSubAccount = getPlayerCurrentSubAccount(client);
let currentSubAccount = getPlayerCurrentSubAccount(client);
if(isPlayerWorking(client)) {
if(getVehicleData(vehicle).ownerType == VRR_VEHOWNER_JOB) {
if(getVehicleData(vehicle).ownerId == getPlayerCurrentSubAccount(client).job) {
getPlayerCurrentSubAccount(client).lastJobVehicle = vehicle;
messagePlayerInfo(client, `Use /startroute to start working in this vehicle`);
}
}
}
if(isPlayerWorking(client)) {
if(getVehicleData(vehicle).ownerType == VRR_VEHOWNER_JOB) {
if(getVehicleData(vehicle).ownerId == getPlayerCurrentSubAccount(client).job) {
getPlayerCurrentSubAccount(client).lastJobVehicle = vehicle;
messagePlayerInfo(client, `Use /startroute to start working in this vehicle`);
}
}
}
if(isPlayerWorking(client)) {
if(isPlayerOnJobRoute(client)) {
if(vehicle == getPlayerJobRouteVehicle(client)) {
stopReturnToJobVehicleCountdown(client);
}
}
}
}
if(isPlayerWorking(client)) {
if(isPlayerOnJobRoute(client)) {
if(vehicle == getPlayerJobRouteVehicle(client)) {
stopReturnToJobVehicleCountdown(client);
}
}
}
}
if(getVehicleData(vehicle).streamingRadioStation != -1) {
if(getPlayerData(client).streamingRadioStation != getVehicleData(vehicle).streamingRadioStation) {
playRadioStreamForPlayer(client, radioStations[getVehicleData(vehicle).streamingRadioStation].url, true, getPlayerStreamingRadioVolume(client));
}
}
if(getVehicleData(vehicle).streamingRadioStation != -1) {
if(getPlayerData(client).streamingRadioStation != getVehicleData(vehicle).streamingRadioStation) {
playRadioStreamForPlayer(client, getServerData().radioStations[getVehicleData(vehicle).streamingRadioStation].url, true, getPlayerStreamingRadioVolume(client));
}
}
}
// ===========================================================================
function onPlayerExitedVehicle(client, vehicle) {
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
stopRadioStreamForPlayer(client);
stopRadioStreamForPlayer(client);
if(!getVehicleData(vehicle)) {
return false;
}
if(!getVehicleData(vehicle)) {
return false;
}
if(isPlayerWorking(client)) {
if(isPlayerOnJobRoute(client)) {
if(vehicle == getPlayerJobRouteVehicle(client)) {
startReturnToJobVehicleCountdown(client);
}
}
}
if(isPlayerWorking(client)) {
if(isPlayerOnJobRoute(client)) {
if(vehicle == getPlayerJobRouteVehicle(client)) {
startReturnToJobVehicleCountdown(client);
}
}
}
getVehicleData(vehicle).lastActiveTime = getCurrentUnixTimestamp();
getVehicleData(vehicle).lastActiveTime = getCurrentUnixTimestamp();
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} exited a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("vrr.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} exited a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("vrr.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
}
// ===========================================================================
function onPlayerDeath(client, position) {
logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} died.`);
getPlayerData(client).pedState = VRR_PEDSTATE_DEAD;
logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} died.`);
getPlayerData(client).pedState = VRR_PEDSTATE_DEAD;
updatePlayerSpawnedState(client, false);
setPlayerControlState(client, false);
setPlayerControlState(client, false);
setTimeout(function() {
if(isFadeCameraSupported()) {
fadeCamera(client, false, 1.0);
}
if(isFadeCameraSupported()) {
fadeCamera(client, false, 1.0);
}
setTimeout(function() {
if(getPlayerCurrentSubAccount(client).inJail) {
let closestJail = getClosestPoliceStation(getPlayerPosition(client));
client.despawnPlayer();
getPlayerCurrentSubAccount(client).interior = closestJail.interior;
getPlayerCurrentSubAccount(client).dimension = closestJail.dimension;
spawnPlayer(client, closestJail.position, closestJail.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]);
let closestJail = getClosestPoliceStation(getPlayerPosition(client));
client.despawnPlayer();
getPlayerCurrentSubAccount(client).interior = closestJail.interior;
getPlayerCurrentSubAccount(client).dimension = closestJail.dimension;
if(isFadeCameraSupported()) {
fadeCamera(client, true, 1.0);
}
updatePlayerSpawnedState(client, true);
makePlayerStopAnimation(client);
setPlayerControlState(client, true);
if(isPlayerWorking(client)) {
stopWorking(client);
}
if(getGame() == VRR_GAME_MAFIA_ONE) {
spawnPlayer(client, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0], closestJail.position, closestJail.heading);
} else {
spawnPlayer(client, closestJail.position, closestJail.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]);
}
if(isFadeCameraSupported()) {
fadeCamera(client, true, 1.0);
}
updatePlayerSpawnedState(client, true);
makePlayerStopAnimation(client);
setPlayerControlState(client, true);
} else {
let closestHospital = getClosestHospital(getPlayerPosition(client));
client.despawnPlayer();
getPlayerCurrentSubAccount(client).interior = closestHospital.interior;
getPlayerCurrentSubAccount(client).dimension = closestHospital.dimension;
spawnPlayer(client, closestHospital.position, closestHospital.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]);
let closestHospital = getClosestHospital(getPlayerPosition(client));
client.despawnPlayer();
getPlayerCurrentSubAccount(client).interior = closestHospital.interior;
getPlayerCurrentSubAccount(client).dimension = closestHospital.dimension;
if(isFadeCameraSupported()) {
fadeCamera(client, true, 1.0);
}
updatePlayerSpawnedState(client, true);
makePlayerStopAnimation(client);
setPlayerControlState(client, true);
if(isPlayerWorking(client)) {
stopWorking(client);
}
if(getGame() == VRR_GAME_MAFIA_ONE) {
spawnPlayer(client, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0], closestHospital.position, closestHospital.heading);
} else {
spawnPlayer(client, closestHospital.position, closestHospital.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]);
}
if(isFadeCameraSupported()) {
fadeCamera(client, true, 1.0);
}
updatePlayerSpawnedState(client, true);
makePlayerStopAnimation(client);
setPlayerControlState(client, true);
}
}, 2000);
}, 1000);
@@ -421,179 +446,191 @@ function onPlayerDeath(client, position) {
// ===========================================================================
function onPedSpawn(ped) {
if(ped.type == ELEMENT_PLAYER) {
//setTimeout(onPlayerSpawn, 250, ped);
onPlayerSpawn();
}
if(ped.type == ELEMENT_PLAYER) {
//setTimeout(onPlayerSpawn, 250, ped);
onPlayerSpawn();
}
}
// ===========================================================================
function onPlayerSpawn(client) {
logToConsole(LOG_DEBUG, `[VRR.Event] Checking for ${getPlayerDisplayForConsole(client)}'s player ped`);
//if(client.player == null) {
// logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player element not set yet. Rechecking ...`);
// setTimeout(onPlayerSpawn, 500, client);
// return false;
//}
logToConsole(LOG_DEBUG, `[VRR.Event] Checking for ${getPlayerDisplayForConsole(client)}'s player ped`);
//if(getPlayerPed(client) == null) {
// logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player element not set yet. Rechecking ...`);
// setTimeout(onPlayerSpawn, 500, client);
// return false;
//}
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player ped is valid. Continuing spawn processing ...`);
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player ped is valid. Continuing spawn processing ...`);
logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s player data`);
if(!getPlayerData(client)) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is invalid. Kicking them from server.`);
client.disconnect();
return false;
}
logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s player data`);
if(!getPlayerData(client)) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is invalid. Kicking them from server.`);
client.disconnect();
return false;
}
logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s login status`);
if(!getPlayerData(client).loggedIn) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} is NOT logged in. Despawning their player.`);
client.disconnect();
return false;
}
logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s login status`);
if(!isPlayerLoggedIn(client)) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} is NOT logged in. Despawning their player.`);
client.disconnect();
return false;
}
logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s selected character status`);
if(getPlayerData(client).currentSubAccount == -1) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} has NOT selected a character. Despawning their player.`);
client.disconnect();
return false;
}
logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s selected character status`);
if(getPlayerData(client).currentSubAccount == -1) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} has NOT selected a character. Despawning their player.`);
client.disconnect();
return false;
}
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is valid. Continuing spawn processing ...`);
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is valid. Continuing spawn processing ...`);
if(getServerGame() == VRR_GAME_GTA_IV) {
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped body parts and props`);
setEntityData(client.player, "vrr.bodyParts", getPlayerCurrentSubAccount(client).bodyParts, true);
setEntityData(client.player, "vrr.bodyProps", getPlayerCurrentSubAccount(client).bodyProps, true);
}
if(getServerGame() == VRR_GAME_GTA_IV) {
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped body parts and props`);
setEntityData(getPlayerPed(client), "vrr.bodyParts", getPlayerCurrentSubAccount(client).bodyParts, true);
setEntityData(getPlayerPed(client), "vrr.bodyProps", getPlayerCurrentSubAccount(client).bodyProps, true);
}
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped scale (${getPlayerCurrentSubAccount(client).pedScale})`);
setEntityData(client.player, "vrr.scale", getPlayerCurrentSubAccount(client).pedScale, true);
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped scale (${getPlayerCurrentSubAccount(client).pedScale})`);
setEntityData(getPlayerPed(client), "vrr.scale", getPlayerCurrentSubAccount(client).pedScale, true);
if(isPlayerSwitchingCharacter(client) || isPlayerCreatingCharacter(client)) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s ped is being used for character selection/creation. No further spawn processing needed'`);
return false;
}
if(isPlayerSwitchingCharacter(client) || isPlayerCreatingCharacter(client)) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s ped is being used for character selection/creation. No further spawn processing needed'`);
return false;
}
if(isCustomCameraSupported()) {
restorePlayerCamera(client);
}
if(isCustomCameraSupported()) {
restorePlayerCamera(client);
}
logToConsole(LOG_DEBUG, `[VRR.Event] Storing ${getPlayerDisplayForConsole(client)} ped in client data `);
if(areServerElementsSupported()) {
getPlayerData(client).ped = client.player;
}
logToConsole(LOG_DEBUG, `[VRR.Event] Storing ${getPlayerDisplayForConsole(client)} ped in client data `);
if(areServerElementsSupported()) {
getPlayerData(client).ped = getPlayerPed(client);
}
logToConsole(LOG_DEBUG, `[VRR.Event] Sending ${getPlayerDisplayForConsole(client)} the 'now playing as' message`);
messagePlayerAlert(client, `You are now playing as: {businessBlue}${getCharacterFullName(client)}`, getColourByName("white"));
messagePlayerNormal(client, "This server is in early development and may restart at any time for updates.", getColourByName("orange"));
messagePlayerNormal(client, "Please report any bugs using /bug and suggestions using /idea", getColourByName("yellow"));
logToConsole(LOG_DEBUG, `[VRR.Event] Sending ${getPlayerDisplayForConsole(client)} the 'now playing as' message`);
messagePlayerAlert(client, `You are now playing as: {businessBlue}${getCharacterFullName(client)}`, getColourByName("white"));
//messagePlayerNormal(client, "This server is in early development and may restart at any time for updates.", getColourByName("orange"));
//messagePlayerNormal(client, "Please report any bugs using /bug and suggestions using /idea", getColourByName("yellow"));
logToConsole(LOG_DEBUG, `[VRR.Event] Updating spawned state for ${getPlayerDisplayForConsole(client)} to true`);
updatePlayerSpawnedState(client, true);
logToConsole(LOG_DEBUG, `[VRR.Event] Updating spawned state for ${getPlayerDisplayForConsole(client)} to true`);
updatePlayerSpawnedState(client, true);
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player interior for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).interior}`);
setPlayerInterior(client, getPlayerCurrentSubAccount(client).interior);
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player interior for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).interior}`);
setPlayerInterior(client, getPlayerCurrentSubAccount(client).interior);
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player dimension for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).dimension}`);
setPlayerDimension(client, getPlayerCurrentSubAccount(client).dimension);
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player dimension for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).dimension}`);
setPlayerDimension(client, getPlayerCurrentSubAccount(client).dimension);
//if(getPlayerCurrentSubAccount(client).interior != 0 || getPlayerCurrentSubAccount(client).dimension != 0) {
// updateAllInteriorVehiclesForPlayer(client, getPlayerCurrentSubAccount(client).interior, getPlayerCurrentSubAccount(client).dimension);
//}
//if(getPlayerCurrentSubAccount(client).interior != 0 || getPlayerCurrentSubAccount(client).dimension != 0) {
// updateAllInteriorVehiclesForPlayer(client, getPlayerCurrentSubAccount(client).interior, getPlayerCurrentSubAccount(client).dimension);
//}
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player health for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).health}`);
setPlayerHealth(client, getPlayerCurrentSubAccount(client).health);
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player health for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).health}`);
setPlayerHealth(client, getPlayerCurrentSubAccount(client).health);
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player armour for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).armour}`);
setPlayerArmour(client, getPlayerCurrentSubAccount(client).armour);
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player armour for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).armour}`);
setPlayerArmour(client, getPlayerCurrentSubAccount(client).armour);
logToConsole(LOG_DEBUG, `[VRR.Event] Sending ${getPlayerDisplayForConsole(client)}'s job type to their client (${getJobIndexFromDatabaseId(getPlayerCurrentSubAccount(client))})`);
sendPlayerJobType(client, getPlayerCurrentSubAccount(client).job);
logToConsole(LOG_DEBUG, `[VRR.Event] Sending ${getPlayerDisplayForConsole(client)}'s job type to their client (${getJobIndexFromDatabaseId(getPlayerCurrentSubAccount(client))})`);
sendPlayerJobType(client, getPlayerCurrentSubAccount(client).job);
logToConsole(LOG_DEBUG, `[VRR.Event] Enabling all rendering states for ${getPlayerDisplayForConsole(client)}`);
setPlayer2DRendering(client, true, true, true, true, true, true);
logToConsole(LOG_DEBUG, `[VRR.Event] Enabling all rendering states for ${getPlayerDisplayForConsole(client)}`);
setPlayer2DRendering(client, true, true, true, true, true, true);
logToConsole(LOG_DEBUG, `[VRR.Event] Sending snow states to ${getPlayerDisplayForConsole(client)}`);
if(isSnowSupported()) {
updatePlayerSnowState(client);
}
logToConsole(LOG_DEBUG, `[VRR.Event] Sending snow states to ${getPlayerDisplayForConsole(client)}`);
if(isSnowSupported()) {
updatePlayerSnowState(client);
}
if(areServerElementsSupported() && getServerGame() == VRR_GAME_GTA_SA) {
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player walk and fightstyle for ${getPlayerDisplayForConsole(client)}`);
setEntityData(client.player, "vrr.walkStyle", getPlayerCurrentSubAccount(client).walkStyle, true);
if(areServerElementsSupported() && getServerGame() == VRR_GAME_GTA_SA) {
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player walk and fightstyle for ${getPlayerDisplayForConsole(client)}`);
setEntityData(getPlayerPed(client), "vrr.walkStyle", getPlayerCurrentSubAccount(client).walkStyle, true);
setPlayerFightStyle(client, getPlayerCurrentSubAccount(client).fightStyle);
}
setPlayerFightStyle(client, getPlayerCurrentSubAccount(client).fightStyle);
}
logToConsole(LOG_DEBUG, `[VRR.Event] Updating logo state for ${getPlayerDisplayForConsole(client)}`);
if(getServerConfig().showLogo && doesPlayerHaveLogoEnabled(client)) {
updatePlayerShowLogoState(client, true);
}
logToConsole(LOG_DEBUG, `[VRR.Event] Updating logo state for ${getPlayerDisplayForConsole(client)}`);
if(getServerConfig().showLogo && doesPlayerHaveLogoEnabled(client)) {
updatePlayerShowLogoState(client, true);
}
logToConsole(LOG_DEBUG, `[VRR.Event] Caching ${getPlayerDisplayForConsole(client)}'s hotbar items`);
cachePlayerHotBarItems(client);
logToConsole(LOG_DEBUG, `[VRR.Event] Caching ${getPlayerDisplayForConsole(client)}'s hotbar items`);
cachePlayerHotBarItems(client);
logToConsole(LOG_DEBUG, `[VRR.Event] Syncing ${getPlayerDisplayForConsole(client)}'s hotbar`);
updatePlayerHotBar(client);
logToConsole(LOG_DEBUG, `[VRR.Event] Syncing ${getPlayerDisplayForConsole(client)}'s hotbar`);
updatePlayerHotBar(client);
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s switchchar state to false`);
getPlayerData(client).switchingCharacter = false;
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s switchchar state to false`);
getPlayerData(client).switchingCharacter = false;
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "enter")) {
let keyId = getPlayerKeyBindForCommand(client, "enter");
logToConsole(LOG_DEBUG, `[VRR.Event] Sending custom enter property key ID (${keyId.key}, ${toUpperCase(getKeyNameFromId(keyId.key))}) to ${getPlayerDisplayForConsole(client)}`);
sendPlayerEnterPropertyKey(client, keyId.key);
}
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "enter")) {
let keyId = getPlayerKeyBindForCommand(client, "enter");
logToConsole(LOG_DEBUG, `[VRR.Event] Sending custom enter property key ID (${keyId.key}, ${toUpperCase(getKeyNameFromId(keyId.key))}) to ${getPlayerDisplayForConsole(client)}`);
sendPlayerEnterPropertyKey(client, keyId.key);
}
//if(isGTAIV()) {
// setEntityData(client.player, "vrr.bodyPartHair", getPlayerCurrentSubAccount(client).bodyParts.hair, true);
// setEntityData(client.player, "vrr.bodyPartHead", getPlayerCurrentSubAccount(client).bodyParts.head, true);
// setEntityData(client.player, "vrr.bodyPartUpper", getPlayerCurrentSubAccount(client).bodyParts.upper, true);
// setEntityData(client.player, "vrr.bodyPartLower", getPlayerCurrentSubAccount(client).bodyParts.lower, true);
// setEntityData(client.player, "vrr.bodyPropHair", getPlayerCurrentSubAccount(client).bodyProps.hair, true);
// setEntityData(client.player, "vrr.bodyPropEyes", getPlayerCurrentSubAccount(client).bodyProps.eyes, true);
// setEntityData(client.player, "vrr.bodyPartHead", getPlayerCurrentSubAccount(client).bodyProps.head, true);
// setEntityData(client.player, "vrr.bodyPartLeftHand", getPlayerCurrentSubAccount(client).bodyProps.leftHand, true);
// setEntityData(client.player, "vrr.bodyPartRightHand", getPlayerCurrentSubAccount(client).bodyProps.rightHand, true);
// setEntityData(client.player, "vrr.bodyPartLeftWrist", getPlayerCurrentSubAccount(client).bodyProps.leftWrist, true);
// setEntityData(client.player, "vrr.bodyPartRightWrist", getPlayerCurrentSubAccount(client).bodyProps.rightWrist, true);
// setEntityData(client.player, "vrr.bodyPartHip", getPlayerCurrentSubAccount(client).bodyProps.hip, true);
// setEntityData(client.player, "vrr.bodyPartLeftFoot", getPlayerCurrentSubAccount(client).bodyProps.leftFoot, true);
// setEntityData(client.player, "vrr.bodyPartRightFoot", getPlayerCurrentSubAccount(client).bodyProps.rightFoot, true);
//}
sendPlayerLocaleStrings(client);
if(isGTAIV()) {
//sendPlayerPedPartsAndProps(client);
}
//if(isGTAIV()) {
// setEntityData(getPlayerPed(client), "vrr.bodyPartHair", getPlayerCurrentSubAccount(client).bodyParts.hair, true);
// setEntityData(getPlayerPed(client), "vrr.bodyPartHead", getPlayerCurrentSubAccount(client).bodyParts.head, true);
// setEntityData(getPlayerPed(client), "vrr.bodyPartUpper", getPlayerCurrentSubAccount(client).bodyParts.upper, true);
// setEntityData(getPlayerPed(client), "vrr.bodyPartLower", getPlayerCurrentSubAccount(client).bodyParts.lower, true);
// setEntityData(getPlayerPed(client), "vrr.bodyPropHair", getPlayerCurrentSubAccount(client).bodyProps.hair, true);
// setEntityData(getPlayerPed(client), "vrr.bodyPropEyes", getPlayerCurrentSubAccount(client).bodyProps.eyes, true);
// setEntityData(getPlayerPed(client), "vrr.bodyPartHead", getPlayerCurrentSubAccount(client).bodyProps.head, true);
// setEntityData(getPlayerPed(client), "vrr.bodyPartLeftHand", getPlayerCurrentSubAccount(client).bodyProps.leftHand, true);
// setEntityData(getPlayerPed(client), "vrr.bodyPartRightHand", getPlayerCurrentSubAccount(client).bodyProps.rightHand, true);
// setEntityData(getPlayerPed(client), "vrr.bodyPartLeftWrist", getPlayerCurrentSubAccount(client).bodyProps.leftWrist, true);
// setEntityData(getPlayerPed(client), "vrr.bodyPartRightWrist", getPlayerCurrentSubAccount(client).bodyProps.rightWrist, true);
// setEntityData(getPlayerPed(client), "vrr.bodyPartHip", getPlayerCurrentSubAccount(client).bodyProps.hip, true);
// setEntityData(getPlayerPed(client), "vrr.bodyPartLeftFoot", getPlayerCurrentSubAccount(client).bodyProps.leftFoot, true);
// setEntityData(getPlayerPed(client), "vrr.bodyPartRightFoot", getPlayerCurrentSubAccount(client).bodyProps.rightFoot, true);
//}
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped state to ready`);
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
if(isGTAIV()) {
//sendPlayerPedPartsAndProps(client);
}
if(areServerElementsSupported()) {
syncPlayerProperties(client);
//setTimeout(function() {
// syncPlayerProperties(client);
//}, 1000);
}
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped state to ready`);
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
logToConsole(LOG_DEBUG, `[VRR.Event] Syncing ${getPlayerDisplayForConsole(client)}'s cash ${getPlayerCurrentSubAccount(client).cash}`);
updatePlayerCash(client);
if(areServerElementsSupported()) {
syncPlayerProperties(client);
//setTimeout(function() {
// syncPlayerProperties(client);
//}, 1000);
}
logToConsole(LOG_DEBUG, `[VRR.Event] Updating all player name tags`);
updateAllPlayerNameTags();
logToConsole(LOG_DEBUG, `[VRR.Event] Syncing ${getPlayerDisplayForConsole(client)}'s cash ${getPlayerCurrentSubAccount(client).cash}`);
updatePlayerCash(client);
if(!areServerElementsSupported()) {
sendAllBusinessesToPlayer(client);
//sendAllHousesToPlayer(client);
//sendAllJobLocationsToPlayer(client);
//sendAllVehiclesToPlayer(client);
logToConsole(LOG_DEBUG, `[VRR.Event] Updating all player name tags`);
updateAllPlayerNameTags();
requestPlayerPedNetworkId(client);
}
if(!areServerElementsSupported()) {
sendAllBusinessesToPlayer(client);
sendAllHousesToPlayer(client);
sendAllJobsToPlayer(client);
//sendAllVehiclesToPlayer(client);
getPlayerData(client).payDayTickStart = sdl.ticks;
requestPlayerPedNetworkId(client);
}
getPlayerData(client).payDayTickStart = sdl.ticks;
messageDiscordEventChannel(`🧍 ${client.name} spawned as ${getCharacterFullName(client)}`);
}
// ===========================================================================
function onPlayerCommand(event, client, command, params) {
if(!doesCommandExist(command)) {
processPlayerCommand(command, params, client);
}
}
// ===========================================================================

View File

@@ -54,7 +54,7 @@ function doesPlayerHaveGateKeys(client, vehicle) {
}
}
if(gateData.ownerType == VRR_GATEOWNER_BUSINESS) {
if(gateData.ownerType == VRR_GATEOWNER_BUSINESS) {
if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageBusinesses"))) {
return true;
}
@@ -64,7 +64,7 @@ function doesPlayerHaveGateKeys(client, vehicle) {
}
}
if(gateData.ownerType == VRR_GATEOWNER_HOUSE) {
if(gateData.ownerType == VRR_GATEOWNER_HOUSE) {
if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) {
return true;
}
@@ -80,11 +80,11 @@ function doesPlayerHaveGateKeys(client, vehicle) {
// ===========================================================================
function getGateData(gateId) {
if(typeof getServerData().gates[gateId] != "undefined") {
return getServerData().gates[gateId];
}
if(typeof getServerData().gates[gateId] != "undefined") {
return getServerData().gates[gateId];
}
return false;
return false;
}
// ===========================================================================

View File

@@ -15,121 +15,148 @@ function initGUIScript() {
// ===========================================================================
function playerPromptAnswerNo(client) {
if(getPlayerData(client).promptType == VRR_PROMPT_NONE) {
return false;
}
if(getPlayerData(client).promptType == VRR_PROMPT_NONE) {
return false;
}
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} answered NO to their prompt (${getPlayerData(client).promptType})`);
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} answered NO to their prompt (${getPlayerData(client).promptType})`);
switch(getPlayerData(client).promptType) {
case VRR_PROMPT_CREATEFIRSTCHAR:
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} chose not to create a first character. Kicking them from the server ...`);
showPlayerErrorGUI(client, "You don't have a character to play. Goodbye!", "No Characters");
setTimeout(function() { client.disconnect(); }, 5000);
break;
switch(getPlayerData(client).promptType) {
case VRR_PROMPT_CREATEFIRSTCHAR:
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} chose not to create a first character. Kicking them from the server ...`);
showPlayerErrorGUI(client, "You don't have a character to play. Goodbye!", "No Characters");
setTimeout(function() { client.disconnect(); }, 5000);
break;
case VRR_PROMPT_BIZORDER:
if(getPlayerData(client).businessOrderAmount > 0) {
if(canPlayerUseGUI(client)) {
showPlayerErrorGUI(client, "You canceled the order.", "Business Order Canceled");
} else {
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} canceled the order of ${getPlayerData(client).businessOrderAmount} ${getPlayerData(client).businessOrderItem} at ${getPlayerData(client).businessOrderCost/getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness)}`);
messagePlayerError(client, "You canceled the order!");
}
} else {
showPlayerErrorGUI(client, "You aren't ordering anything for a business!", "Business Order Canceled");
}
break;
case VRR_PROMPT_BIZORDER:
if(getPlayerData(client).businessOrderAmount > 0) {
if(canPlayerUseGUI(client)) {
showPlayerErrorGUI(client, "You canceled the order.", "Business Order Canceled");
} else {
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} canceled the order of ${getPlayerData(client).businessOrderAmount} ${getPlayerData(client).businessOrderItem} at ${getPlayerData(client).businessOrderCost/getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness)}`);
messagePlayerError(client, "You canceled the order!");
}
} else {
showPlayerErrorGUI(client, "You aren't ordering anything for a business!", "Business Order Canceled");
}
break;
default:
break;
}
default:
break;
}
getPlayerData(client).promptType = VRR_PROMPT_NONE;
getPlayerData(client).promptType = VRR_PROMPT_NONE;
}
// ===========================================================================
function playerPromptAnswerYes(client) {
if(getPlayerData(client).promptType == VRR_PROMPT_NONE) {
return false;
}
if(getPlayerData(client).promptType == VRR_PROMPT_NONE) {
return false;
}
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} answered YES to their prompt (${getPlayerData(client).promptType})`);
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} answered YES to their prompt (${getPlayerData(client).promptType})`);
switch(getPlayerData(client).promptType) {
case VRR_PROMPT_CREATEFIRSTCHAR:
showPlayerNewCharacterGUI(client);
break;
switch(getPlayerData(client).promptType) {
case VRR_PROMPT_CREATEFIRSTCHAR:
showPlayerNewCharacterGUI(client);
break;
case VRR_PROMPT_BIZORDER:
if(getPlayerData(client).businessOrderAmount > 0) {
if(getBusinessData(getPlayerData(client).businessOrderBusiness).till < getPlayerData(client).businessOrderCost) {
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} failed to order ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} at ${getPlayerData(client).businessOrderCost/getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness).name} (Reason: Not enough money in business till)`);
showPlayerErrorGUI(client, "This business doesn't have enough money! Deposit some using /bizdeposit", "Business Order Canceled");
getPlayerData(client).businessOrderAmount = 0;
getPlayerData(client).businessOrderBusiness = false;
getPlayerData(client).businessOrderItem = -1;
getPlayerData(client).businessOrderValue = -1;
} else {
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} successfully ordered ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} at ${getPlayerData(client).businessOrderCost/getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness).name}`);
showPlayerInfoGUI(client, `You ordered ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} (${getItemValueDisplay(getPlayerData(client).businessOrderItem, getPlayerData(client).businessOrderValue)}) for ${getPlayerData(client).businessOrderCost}!`, "Business Order Successful");
createItem(getPlayerData(client).businessOrderItem, getPlayerData(client).businessOrderValue, VRR_ITEM_OWNER_BIZFLOOR, getBusinessData(getPlayerData(client).businessOrderBusiness).databaseId, getPlayerData(client).businessOrderAmount);
cacheBusinessItems(getPlayerData(client).businessOrderBusiness);
getBusinessData(getPlayerData(client).businessOrderBusiness).till -= getPlayerData(client).businessOrderCost;
updateBusinessPickupLabelData(getPlayerData(client).businessOrderBusiness);
getPlayerData(client).businessOrderAmount = 0;
getPlayerData(client).businessOrderBusiness = false;
getPlayerData(client).businessOrderItem = -1;
getPlayerData(client).businessOrderValue = -1;
case VRR_PROMPT_BIZORDER:
if(getPlayerData(client).businessOrderAmount > 0) {
if(getBusinessData(getPlayerData(client).businessOrderBusiness).till < getPlayerData(client).businessOrderCost) {
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} failed to order ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} at ${getPlayerData(client).businessOrderCost/getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness).name} (Reason: Not enough money in business till)`);
showPlayerErrorGUI(client, "This business doesn't have enough money! Deposit some using /bizdeposit", "Business Order Canceled");
getPlayerData(client).businessOrderAmount = 0;
getPlayerData(client).businessOrderBusiness = false;
getPlayerData(client).businessOrderItem = -1;
getPlayerData(client).businessOrderValue = -1;
} else {
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} successfully ordered ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} at ${getPlayerData(client).businessOrderCost/getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness).name}`);
showPlayerInfoGUI(client, `You ordered ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} (${getItemValueDisplay(getPlayerData(client).businessOrderItem, getPlayerData(client).businessOrderValue)}) for ${getPlayerData(client).businessOrderCost}!`, "Business Order Successful");
createItem(getPlayerData(client).businessOrderItem, getPlayerData(client).businessOrderValue, VRR_ITEM_OWNER_BIZFLOOR, getBusinessData(getPlayerData(client).businessOrderBusiness).databaseId, getPlayerData(client).businessOrderAmount);
cacheBusinessItems(getPlayerData(client).businessOrderBusiness);
getBusinessData(getPlayerData(client).businessOrderBusiness).till -= getPlayerData(client).businessOrderCost;
updateBusinessPickupLabelData(getPlayerData(client).businessOrderBusiness);
getPlayerData(client).businessOrderAmount = 0;
getPlayerData(client).businessOrderBusiness = false;
getPlayerData(client).businessOrderItem = -1;
getPlayerData(client).businessOrderValue = -1;
}
} else {
showPlayerErrorGUI(client, `You aren't ordering anything for a business!`, `Business Order Canceled`);
}
break;
}
} else {
showPlayerErrorGUI(client, ``, `Business Order Canceled`);
}
break;
default:
break;
}
case VRR_PROMPT_GIVEVEHTOCLAN:
if(!isPlayerInAnyVehicle(client)) {
messagePlayerError(client, getLocaleString(client, "MustBeInVehicle"));
return false;
}
getPlayerData(client).promptType = VRR_PROMPT_NONE;
if(!getVehicleData(getPlayerVehicle(client))) {
messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled"));
return false;
}
if(getVehicleData(getPlayerVehicle(client)).ownerType != VRR_VEHOWNER_PLAYER) {
messagePlayerError(client, getLocaleString(client, "MustOwnVehicle"));
return false;
}
if(getVehicleData(getPlayerVehicle(client)).ownerId != getPlayerCurrentSubAccount(client).databaseId) {
messagePlayerError(client, getLocaleString(client, "MustOwnVehicle"));
return false;
}
getVehicleData(getPlayerVehicle(client)).ownerType = VRR_VEHOWNER_CLAN;
getVehicleData(getPlayerVehicle(client)).ownerId = getPlayerCurrentSubAccount(client).clan;
messagePlayerSuccess(client, getLocaleString(client, "GaveVehicleToClan"));
//messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)} {MAINCOLOUR}owner to the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan`);
break;
default:
break;
}
getPlayerData(client).promptType = VRR_PROMPT_NONE;
}
// ===========================================================================
function canPlayerUseGUI(client) {
return (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client));
return (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client));
}
// ===========================================================================
function playerPromptAnswerYesCommand(command, params, client) {
playerPromptAnswerYes(client);
playerPromptAnswerYes(client);
}
// ===========================================================================
function playerPromptAnswerNoCommand(command, params, client) {
playerPromptAnswerNo(client);
playerPromptAnswerNo(client);
}
// ===========================================================================
function playerToggledGUI(client) {
toggleAccountGUICommand("gui", "", client);
toggleAccountGUICommand("gui", "", client);
}
// ===========================================================================
function showPlayerChangePasswordGUI(client) {
sendNetworkEventToPlayer("vrr.changePassword", client);
sendNetworkEventToPlayer("vrr.changePassword", client);
}
// ===========================================================================
function showPlayerTwoFactorAuthenticationGUI(client) {
sendNetworkEventToPlayer("vrr.2fa", client);
sendNetworkEventToPlayer("vrr.2fa", client);
}
// ===========================================================================

View File

@@ -15,144 +15,144 @@ function initHelpScript() {
// ===========================================================================
let randomTips = [
`{MAINCOLOUR}Look for yellow dots on your map for job locations.`,
`{MAINCOLOUR}You can set custom key binds. Use {ALTCOLOUR}/help keys {MAINCOLOUR} for details.`,
`{MAINCOLOUR}Use /notips if you don't want to see tips and extra information`,
`{MAINCOLOUR}You can edit your keybinds using {ALTCOLOUR}/bindkey and /unbindkey`,
`{MAINCOLOUR}Press to see your inventory, and use number keys to select an item`,
`{MAINCOLOUR}Use /buy at a business to purchase items.`,
`{MAINCOLOUR}Found a bug? Report it with {ALTCOLOUR}/bug`,
`{MAINCOLOUR}Have an idea or suggestion for the server? Let the devs know using {ALTCOLOUR}/idea`,
`{MAINCOLOUR}Want to buy a business? Use /bizbuy at one for sale`,
`{MAINCOLOUR}Want to buy a house? Use /housebuy at one for sale`,
`{MAINCOLOUR}Want to buy a vehicle? Visit a dealership and enter one for info on how to buy it!`,
`{MAINCOLOUR}Switch to any of your characters with {ALTCOLOUR}/switchchar`,
`{MAINCOLOUR}Use {ALTCOLOUR}/iplogin {MAINCOLOUR}to automatically login when connecting with the same IP`,
`{MAINCOLOUR}Use {ALTCOLOUR}/houselights or /bizlights {MAINCOLOUR}to turn on/off the lights in your house or business`,
`{MAINCOLOUR}Use {ALTCOLOUR}/radiostation {MAINCOLOUR}to play an internet radio station in your car, house, or business`,
//`{MAINCOLOUR}Lower your car windows with /windows {ALTCOLOUR} to play the vehicle's internet radio station {ALTCOLOUR}(/radiostation) {MAINCOLOUR}to nearby players`,
//`{MAINCOLOUR}Lower your car windows with /windows {ALTCOLOUR} to play the vehicle's internet radio station {ALTCOLOUR}(/radiostation) {MAINCOLOUR}to nearby players`,
//`{MAINCOLOUR}Tax is based on your total wealth. This includes money, vehicles, businesses and more.`,
//`{MAINCOLOUR}Don't go broke because of a hospital bill! Get insured today by visiting an insurance agency!`,
//`{MAINCOLOUR}Don't go broke because your car was destroyed. Visit an insurance agency today!`,
//`{MAINCOLOUR}You can find most locations by using {ALTCOLOUR}/gps`,
//`{MAINCOLOUR}Want to advertise your business? Visit the news station and place an /ad today!`,
//`{MAINCOLOUR}You can change your quick item display. Choices are GTAV-style pie menu or Minecraft-style hotbar`,
//`{MAINCOLOUR}Hold [#0066FF]E {MAINCOLOUR}to hail a nearby taxi if you need a ride.`,
//`{MAINCOLOUR}Press [#0066FF]G {MAINCOLOUR}to enter a vehicle as passenger.`,
//`{MAINCOLOUR}Banks can provide loans. Use {ALTCOLOUR}/help loans {MAINCOLOUR} for more details.`,
`{MAINCOLOUR}Want to make a clan? Use {ALTCOLOUR}/help clans {MAINCOLOUR} for details.`,
`{MAINCOLOUR}Legal weapons can be purchased at any ammunation.`,
`{MAINCOLOUR}Look for yellow dots on your map for job locations.`,
`{MAINCOLOUR}You can set custom key binds. Use {ALTCOLOUR}/help keys {MAINCOLOUR} for details.`,
`{MAINCOLOUR}Use /notips if you don't want to see tips and extra information`,
`{MAINCOLOUR}You can edit your keybinds using {ALTCOLOUR}/bindkey and /unbindkey`,
`{MAINCOLOUR}Press to see your inventory, and use number keys to select an item`,
`{MAINCOLOUR}Use /buy at a business to purchase items.`,
`{MAINCOLOUR}Found a bug? Report it with {ALTCOLOUR}/bug`,
`{MAINCOLOUR}Have an idea or suggestion for the server? Let the devs know using {ALTCOLOUR}/idea`,
`{MAINCOLOUR}Want to buy a business? Use /bizbuy at one for sale`,
`{MAINCOLOUR}Want to buy a house? Use /housebuy at one for sale`,
`{MAINCOLOUR}Want to buy a vehicle? Visit a dealership and enter one for info on how to buy it!`,
`{MAINCOLOUR}Switch to any of your characters with {ALTCOLOUR}/switchchar`,
`{MAINCOLOUR}Use {ALTCOLOUR}/iplogin {MAINCOLOUR}to automatically login when connecting with the same IP`,
`{MAINCOLOUR}Use {ALTCOLOUR}/houselights or /bizlights {MAINCOLOUR}to turn on/off the lights in your house or business`,
`{MAINCOLOUR}Use {ALTCOLOUR}/radiostation {MAINCOLOUR}to play an internet radio station in your car, house, or business`,
//`{MAINCOLOUR}Lower your car windows with /windows {ALTCOLOUR} to play the vehicle's internet radio station {ALTCOLOUR}(/radiostation) {MAINCOLOUR}to nearby players`,
//`{MAINCOLOUR}Lower your car windows with /windows {ALTCOLOUR} to play the vehicle's internet radio station {ALTCOLOUR}(/radiostation) {MAINCOLOUR}to nearby players`,
//`{MAINCOLOUR}Tax is based on your total wealth. This includes money, vehicles, businesses and more.`,
//`{MAINCOLOUR}Don't go broke because of a hospital bill! Get insured today by visiting an insurance agency!`,
//`{MAINCOLOUR}Don't go broke because your car was destroyed. Visit an insurance agency today!`,
//`{MAINCOLOUR}You can find most locations by using {ALTCOLOUR}/gps`,
//`{MAINCOLOUR}Want to advertise your business? Visit the news station and place an /ad today!`,
//`{MAINCOLOUR}You can change your quick item display. Choices are GTAV-style pie menu or Minecraft-style hotbar`,
//`{MAINCOLOUR}Hold [#0066FF]E {MAINCOLOUR}to hail a nearby taxi if you need a ride.`,
//`{MAINCOLOUR}Press [#0066FF]G {MAINCOLOUR}to enter a vehicle as passenger.`,
//`{MAINCOLOUR}Banks can provide loans. Use {ALTCOLOUR}/help loans {MAINCOLOUR} for more details.`,
`{MAINCOLOUR}Want to make a clan? Use {ALTCOLOUR}/help clans {MAINCOLOUR} for details.`,
`{MAINCOLOUR}Legal weapons can be purchased at any ammunation.`,
];
// ===========================================================================
function helpCommand(command, params, client) {
if(areParamsEmpty(params)) {
showMainHelpMessage(client);
return false;
}
showMainHelpMessage(client);
return false;
}
let splitParams = params.split(" ");
let splitParams = params.split(" ");
switch(toLowerCase(getParam(params, " ", 1))) {
case "account":
showAccountHelpMessage(client);
break;
switch(toLowerCase(getParam(params, " ", 1))) {
case "account":
showAccountHelpMessage(client);
break;
case "vehicle":
case "veh":
case "vehs":
case "vehicles":
case "car":
case "cars":
showVehicleHelpMessage(client);
break;
case "vehicle":
case "veh":
case "vehs":
case "vehicles":
case "car":
case "cars":
showVehicleHelpMessage(client);
break;
case "dealership":
showVehicleDealershipHelpMessage(client);
break;
case "dealership":
showVehicleDealershipHelpMessage(client);
break;
case "business":
showBusinessHelpMessage(client);
break;
case "business":
showBusinessHelpMessage(client);
break;
case "job":
showJobHelpMessage(client);
break;
case "job":
showJobHelpMessage(client);
break;
case "chat":
showChatHelpMessage(client);
break;
case "chat":
showChatHelpMessage(client);
break;
case "rules":
showRulesHelpMessage(client);
break;
case "rules":
showRulesHelpMessage(client);
break;
case "website":
showWebsiteHelpMessage(client);
break;
case "website":
showWebsiteHelpMessage(client);
break;
case "discord":
showDiscordHelpMessage(client);
break;
case "discord":
showDiscordHelpMessage(client);
break;
case "anim":
case "anims":
case "animation":
case "animations":
showAnimationHelpMessage(client);
break;
case "anim":
case "anims":
case "animation":
case "animations":
showAnimationHelpMessage(client);
break;
case "skin":
case "skins":
case "clothes":
showClothesHelpMessage(client);
break;
case "skin":
case "skins":
case "clothes":
showClothesHelpMessage(client);
break;
case "key":
case "keys":
case "keybinds":
case "keybind":
case "bindkey":
case "bindkeys":
showBindKeysHelpMessage(client);
break;
case "key":
case "keys":
case "keybinds":
case "keybind":
case "bindkey":
case "bindkeys":
showBindKeysHelpMessage(client);
break;
case "command":
case "cmd":
showCommandHelpMessage(client, getParam(params, " ", 2));
break;
case "command":
case "cmd":
showCommandHelpMessage(client, getParam(params, " ", 2));
break;
case "clan":
case "clans":
case "group":
case "groups":
case "faction":
case "factions":
case "family":
case "families":
showClanHelpMessage(client);
break;
case "clan":
case "clans":
case "group":
case "groups":
case "faction":
case "factions":
case "family":
case "families":
showClanHelpMessage(client);
break;
case "radio":
case "radiostations":
case "music":
showRadioHelpMessage(client);
break;
case "radio":
case "radiostations":
case "music":
showRadioHelpMessage(client);
break;
case "economy":
case "wealth":
case "tax":
case "taxes":
case "payday":
showWealthAndTaxHelpMessage(client);
break;
case "economy":
case "wealth":
case "tax":
case "taxes":
case "payday":
showWealthAndTaxHelpMessage(client);
break;
default:
showMainHelpMessage(client);
break;
}
default:
showMainHelpMessage(client);
break;
}
}
// == Account Help =============================
@@ -184,188 +184,188 @@ function helpCommand(command, params, client) {
// ===========================================================================
function showMainHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderHelpMainList")));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Use /help <category> for commands and info. Example: {ALTCOLOUR}/help vehicle`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Help Categories: [#A9A9A9]account, command, vehicle, job, chat, rules, website, animation`);
messagePlayerNormal(client, `{clanOrange}• [#A9A9A9]skin, mechanic, dealership, discord, colour, keybind`);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderHelpMainList")));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Use /help <category> for commands and info. Example: {ALTCOLOUR}/help vehicle`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Help Categories: [#A9A9A9]account, command, vehicle, job, chat, rules, website, animation`);
messagePlayerNormal(client, `{clanOrange}• [#A9A9A9]skin, mechanic, dealership, discord, colour, keybind`);
}
// ===========================================================================
function showAccountHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderAccountHelp")));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Do not share your password with anybody else.`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Use {ALTCOLOUR}/changepass{MAINCOLOUR} to change your password.`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Some settings you can use: {ALTCOLOUR}/gui, /logo, /iplogin, /autolastchar, /2fa, /loginalert`);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderAccountHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "AccountHelp", 0));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "AccountHelp", 1, `{ALTCOLOUR}/changepass{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "AccountHelp", 2, `{ALTCOLOUR}/gui, /logo, /iplogin, /autolastchar, /2fa, /loginalert{MAINCOLOUR}`));
}
// ===========================================================================
function showVehicleHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderVehicleHelp")));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Visit dealerships to buy new vehicles (Use {ALTCOLOUR}/help dealership {MAINCOLOUR}for more info.)`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Some commands: {ALTCOLOUR}/lock, /engine, /lights, /trunk, /rentveh, /buyveh, /rentprice, /buyprice`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Your personal vehicles will save wherever you or somebody else leaves them!`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Visit a mechanic garage to repair, colour, and tune up your car! {ALTCOLOUR}/help mechanic {MAINCOLOUR} for info`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Don't forget to register and insure your vehicle! Use {ALTCOLOUR}/gps {MAINCOLOUR}to find a DMV for this.`);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderVehicleHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleHelp", 0, `{ALTCOLOUR}/help dealership{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleHelp", 1, `{ALTCOLOUR}/lock, /engine, /lights, /trunk, /rentveh, /buyveh, /rentprice, /buyprice{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleHelp", 2));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleHelp", 3, `{ALTCOLOUR}/help mechanic{MAINCOLOUR}`));
}
// ===========================================================================
function showVehicleDealershipHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderVehicleDealershipHelp")));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Visit a vehicle dealer to buy new vehicles. Use {ALTCOLOUR}/gps {MAINCOLOUR}to find one.`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}At the dealer, simply enter a car you want to buy, and the price will be shown to you`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}If you want to buy the vehicle and have enough money, use {ALTCOLOUR}/buyveh {MAINCOLOUR}and you will be given keys`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}A new car for sale will appear when you drive away from the dealer.`);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderVehicleDealershipHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleDealershipHelp", 0, `{ALTCOLOUR}/gps{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleDealershipHelp", 1));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleDealershipHelp", 1, `{ALTCOLOUR}/buyveh{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleDealershipHelp", 2));
}
// ===========================================================================
function showJobHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderJobHelp")));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Visit job locations get a job and earn money. Look for yellow spots on the map`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}At a job location, use {ALTCOLOUR}/takejob {MAINCOLOUR}to get the job. Use {ALTCOLOUR}/quitjob {MAINCOLOUR}to quit your job`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Use {ALTCOLOUR}/startwork {MAINCOLOUR}to begin working. You can also get a job {ALTCOLOUR}/uniform and {ALTCOLOUR}/equipment`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Most job vehicles are locked. Use {ALTCOLOUR}/lock {MAINCOLOUR}near one to enter it.`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}When entering a job vehicle, information on how to do the job will be shown to you.`);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderJobHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "JobHelp", 0));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "JobHelp", 1, `{ALTCOLOUR}/takejob{MAINCOLOUR}`, `{ALTCOLOUR}/quitjob{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "JobHelp", 2, `{ALTCOLOUR}/lock{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "JobHelp", 3));
}
// ===========================================================================
function showChatHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderChatHelp")));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}There are two main types of chat: out-of-character (OOC) and in-character (IC)`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Mixing these two types is not proper roleplay. See {ALTCOLOUR}/rules {MAINCOLOUR}for info.`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Some chat commands: {ALTCOLOUR}/dm /whisper /talk /shout /me.`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Some have shorter names available ({ALTCOLOUR}/t {MAINCOLOUR}for talk, {ALTCOLOUR}/s {MAINCOLOUR}for shout, etc)`);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderChatHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "ChatHelp", 0, `{ALTCOLOUR}/buy {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "ChatHelp", 1, `{ALTCOLOUR}/rules{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "ChatHelp", 2, `{ALTCOLOUR}/dm /whisper /talk /shout /me{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "ChatHelp", 3, `{ALTCOLOUR}/t{MAINCOLOUR}`, `{ALTCOLOUR}/s{MAINCOLOUR}`));
}
// ===========================================================================
function showRulesHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderServerRulesList")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 0));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 1));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 2));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 3));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 4), `{ALTCOLOUR}/help language {MAINCOLOUR}`);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderServerRulesList")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 0));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 1));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 2));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 3));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 4), `{ALTCOLOUR}/help language {MAINCOLOUR}`);
}
// ===========================================================================
function showWebsiteHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderWebsiteInfo")));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}${server.getRule("Website")}`);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderWebsiteInfo")));
messagePlayerHelpContent(client, `{MAINCOLOUR}${server.getRule("Website")}`);
}
// ===========================================================================
function showDiscordHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderDiscordInfo")));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}${server.getRule("Website")}`);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderDiscordInfo")));
messagePlayerHelpContent(client, `{MAINCOLOUR}${server.getRule("Discord")}`);
}
// ===========================================================================
function showAnimationHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderAnimationHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "AnimationHelp", 0, `{ALTCOLOUR}/buy {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "AnimationHelp", 1, `{ALTCOLOUR}/an {MAINCOLOUR}`, `{ALTCOLOUR}/anim {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "AnimationHelp", 2, `{ALTCOLOUR}/animlist {MAINCOLOUR}`));
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderAnimationHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "AnimationHelp", 0, `{ALTCOLOUR}/buy {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "AnimationHelp", 1, `{ALTCOLOUR}/an {MAINCOLOUR}`, `{ALTCOLOUR}/anim {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "AnimationHelp", 2, `{ALTCOLOUR}/animlist {MAINCOLOUR}`));
}
// ===========================================================================
function showClothesHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderSkinHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "SkinHelp", 0, `{ALTCOLOUR}/buy {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "SkinHelp", 1, `{ALTCOLOUR}/help items {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "SkinHelp", 2));
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderSkinHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "SkinHelp", 0, `{ALTCOLOUR}/buy {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "SkinHelp", 1, `{ALTCOLOUR}/help items {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "SkinHelp", 2));
}
// ===========================================================================
function showBindKeysHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBindableKeysHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "KeyBindHelp", 0, `{ALTCOLOUR}/keybinds {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "KeyBindHelp", 1, `{ALTCOLOUR}/bindkey {MAINCOLOUR}`, `{ALTCOLOUR}/unbindkey {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "KeyBindHelp", 2, `{ALTCOLOUR}K {MAINCOLOUR}`, `{ALTCOLOUR}L {MAINCOLOUR}`, `{ALTCOLOUR}J {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "KeyBindHelp", 3, `{ALTCOLOUR}I {MAINCOLOUR}`, `{ALTCOLOUR}1-9 {MAINCOLOUR}`, `{ALTCOLOUR}0 {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "KeyBindHelp", 4, `{ALTCOLOUR}U {MAINCOLOUR}`, `{ALTCOLOUR}O {MAINCOLOUR}`, `{ALTCOLOUR}P {MAINCOLOUR}`));
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBindableKeysHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "KeyBindHelp", 0, `{ALTCOLOUR}/keybinds {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "KeyBindHelp", 1, `{ALTCOLOUR}/bindkey {MAINCOLOUR}`, `{ALTCOLOUR}/unbindkey {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "KeyBindHelp", 2, `{ALTCOLOUR}K{MAINCOLOUR}`, `{ALTCOLOUR}L{MAINCOLOUR}`, `{ALTCOLOUR}J{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "KeyBindHelp", 3, `{ALTCOLOUR}I{MAINCOLOUR}`, `{ALTCOLOUR}1-9{MAINCOLOUR}`, `{ALTCOLOUR}0{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "KeyBindHelp", 4, `{ALTCOLOUR}U{MAINCOLOUR}`, `{ALTCOLOUR}O{MAINCOLOUR}`, `{ALTCOLOUR}P{MAINCOLOUR}`));
}
// ===========================================================================
function showBusinessHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBusinessHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "BusinessHelp", 0));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "BusinessHelp", 1));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "BusinessHelp", 2, `{ALTCOLOUR}/bizorder, /bizlock, /bizlights, /radiostation, /bizitemprice, /bizbuyprice, /bizfee, /biztill, /bizwithdraw, /bizdeposit`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "BusinessHelp", 3));
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBusinessHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "BusinessHelp", 0));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "BusinessHelp", 1));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "BusinessHelp", 2, `{ALTCOLOUR}/bizorder, /bizlock, /bizlights, /radiostation, /bizitemprice, /bizbuyprice, /bizfee, /biztill, /bizwithdraw, /bizdeposit`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "BusinessHelp", 3));
}
// ===========================================================================
function showClanHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderClanHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "ClanHelp", 0));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "ClanHelp", 1));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "ClanHelp", 2, `{ALTCOLOUR}/clan, /clanmotd, /clanname, /clanowner, /clanhouse, /clanbiz, /claninvite, /clanuninvite, /clansetrank`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "ClanHelp", 3, `{ALTCOLOUR}/clanranks, /clanflags, /clanaddrank, /clandelrank, /clanaddrankflag, /clandelrankflag, /clanaddmemberflag, /clandelmemberflag`));
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderClanHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "ClanHelp", 0));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "ClanHelp", 1));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "ClanHelp", 2, `{ALTCOLOUR}/clan, /clanmotd, /clanname, /clanowner, /clanhouse, /clanbiz, /claninvite, /clanuninvite, /clansetrank`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "ClanHelp", 3, `{ALTCOLOUR}/clanranks, /clanflags, /clanaddrank, /clandelrank, /clanaddrankflag, /clandelrankflag, /clanaddmemberflag, /clandelmemberflag`));
}
// ===========================================================================
function showRadioHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderRadioHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RadioHelp", 0, `{ALTCOLOUR}/radiostation {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RadioHelp", 1, `{ALTCOLOUR}/radiostations {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RadioHelp", 2, `{ALTCOLOUR}/radiovolume {MAINCOLOUR}`));
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderRadioHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RadioHelp", 0, `{ALTCOLOUR}/radiostation {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RadioHelp", 1, `{ALTCOLOUR}/radiostations {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RadioHelp", 2, `{ALTCOLOUR}/radiovolume {MAINCOLOUR}`));
}
// ===========================================================================
function showWealthAndTaxHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderWealthandTaxHelp")));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Your taxes on payday are ${100*getGlobalConfig().economy.incomeTaxRate}% of your calculated wealth.`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Your calculated wealth is a total sum based on how many vehicles, houses, and businesses you have.`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Each vehicle is {ALTCOLOUR}${getGlobalConfig().economy.upKeepCosts.upKeepPerVehicle}, {MAINCOLOUR}each house is {ALTCOLOUR}${getGlobalConfig().economy.upKeepCosts.upKeepPerHouse}, {MAINCOLOUR}and each business is {ALTCOLOUR}${getGlobalConfig().economy.upKeepCosts.upKeepPerBusiness}`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Use {ALTCOLOUR}/wealth {MAINCOLOUR}to see your current wealth, and {ALTCOLOUR}/tax {MAINCOLOUR}to see how much you'll pay in tax each payday`);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderWealthandTaxHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "WealthAndTaxHelp", 0, `{ALTCOLOUR}${100*getGlobalConfig().economy.incomeTaxRate}%{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "WealthAndTaxHelp", 1));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "WealthAndTaxHelp", 2, `{ALTCOLOUR}${getGlobalConfig().economy.upKeepCosts.upKeepPerVehicle}{MAINCOLOUR}`, `{ALTCOLOUR}${getGlobalConfig().economy.upKeepCosts.upKeepPerHouse}{MAINCOLOUR}`, `{ALTCOLOUR}${getGlobalConfig().economy.upKeepCosts.upKeepPerBusiness}{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "WealthAndTaxHelp", 3, `{ALTCOLOUR}/wealth{MAINCOLOUR}`, `{ALTCOLOUR}/tax{MAINCOLOUR}`));
}
// ===========================================================================
function showCommandHelpMessage(client, commandName) {
if(!commandName) {
messagePlayerSyntax(client, `${getCommandSyntaxText("help")}command <command name>`);
return false;
}
if(!commandName) {
messagePlayerSyntax(client, `${getCommandSyntaxText("help")}command <command name>`);
return false;
}
commandName = toLowerCase(commandName);
commandName = commandName.trim();
commandName = toLowerCase(commandName);
commandName = commandName.trim();
if(commandName.slice(0, 1) == "/") {
commandName = commandName.slice(1);
}
if(commandName.slice(0, 1) == "/") {
commandName = commandName.slice(1);
}
let command = getCommandData(commandName);
let aliases = getCommandAliasesNames(command);
let command = getCommandData(commandName);
let aliases = getCommandAliasesNames(command);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderCommandInfo", commandName)));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Description: ${command.description}`);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderCommandInfo", commandName)));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Description: ${command.helpDescription}`);
if(aliases.length > 0) {
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Aliases: ${aliases.join(", ")}`);
} else {
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Aliases: (None)`);
}
if(aliases.length > 0) {
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Aliases: ${aliases.join(", ")}`);
} else {
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Aliases: (None)`);
}
//messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Usable on Discord: ${getYesNoFromBool(command.allowOnDiscord)}`);
//messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Usable on Discord: ${getYesNoFromBool(command.allowOnDiscord)}`);
//if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("BasicModeration"))) {
// messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Usable on Discord: ${getYesNoFromBool(command.allowOnDiscord)}`);
//}
//if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("BasicModeration"))) {
// messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Usable on Discord: ${getYesNoFromBool(command.allowOnDiscord)}`);
//}
}
// ===========================================================================
@@ -380,7 +380,7 @@ function showCommandHelpMessage(client, commandName) {
*
*/
function helpGetCarCommand(command, params, client) {
messagePlayerAlert(client, `You can buy a car by visiting a vehicle dealership. Use {ALTCOLOUR}/help vehicle {MAINCOLOUR}for more info.`);
messagePlayerAlert(client, getLocaleString(client, "CarCommandHelp", `{ALTCOLOUR}/help vehicle{MAINCOLOUR}`));
}
// ===========================================================================
@@ -395,7 +395,8 @@ function helpGetCarCommand(command, params, client) {
*
*/
function helpGetSkinCommand(command, params, client) {
messagePlayerAlert(client, `You can change your skin by visiting a clothes store. Use {ALTCOLOUR}/help skin {MAINCOLOUR}for more info.`);
messagePlayerAlert(client, getLocaleString(client, "SkinCommandHelp", `{ALTCOLOUR}/help skin{MAINCOLOUR}`));
messagePlayerAlert(client, ``);
}
// ===========================================================================

View File

@@ -9,7 +9,9 @@
function initHouseScript() {
logToConsole(LOG_INFO, "[VRR.House]: Initializing house script ...");
getServerData().houses = loadHousesFromDatabase();
if(!getServerConfig().devServer) {
getServerData().houses = loadHousesFromDatabase();
}
if(getServerConfig().createHousePickups) {
createAllHousePickups();
@@ -219,7 +221,7 @@ function setHouseOwnerCommand(command, params, client) {
if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) {
if(getHouseData(houseId).ownerType == VRR_HOUSEOWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
messagePlayerError(client, "You don't own this house!");
messagePlayerError(client, getLocaleString(client, "CantModifyHouse"));
return false;
}
}
@@ -259,7 +261,7 @@ function setHouseClanCommand(command, params, client) {
if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) {
if(getHouseData(houseId).ownerType == VRR_HOUSEOWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
messagePlayerError(client, "You don't own this house!");
messagePlayerError(client, getLocaleString(client, "CantModifyHouse"));
return false;
}
}
@@ -305,7 +307,7 @@ function setHouseClanCommand(command, params, client) {
}
if(doesPlayerHaveClanPermission(client, getClanFlagValue("ManageHouses"))) {
messagePlayerError(client, "You can't set clan house ranks!");
messagePlayerError(client, getLocaleString(client, "CantModifyHouse"));
return false;
}
@@ -496,7 +498,7 @@ function moveHouseEntranceCommand(command, params, client) {
let houseId = getPlayerHouse(client);
if(!getHouseData(houseId)) {
messagePlayer(client, "You need to be near or inside a house!");
messagePlayer(client, getLocaleString(client, "InvalidHouse"));
return false;
}
@@ -532,7 +534,7 @@ function moveHouseExitCommand(command, params, client) {
let houseId = getPlayerHouse(client);
if(!getHouseData(houseId)) {
messagePlayer(client, "You need to be near or inside a house!");
messagePlayer(client, getLocaleString(client, "InvalidHouse"));
return false;
}
@@ -718,7 +720,11 @@ function getPlayerHouse(client) {
// ===========================================================================
function saveAllHousesToDatabase() {
function saveHousesToDatabase() {
if(getServerConfig().devServer) {
return false;
}
logToConsole(LOG_INFO, `[VRR.House]: Saving all server houses to database ...`);
for(let i in getServerData().houses) {
if(getServerData().houses[i].needsSaved) {
@@ -737,6 +743,8 @@ function saveHouseToDatabase(houseId) {
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeHouseDescription = escapeDatabaseString(dbConnection, tempHouseData.description);
let safeExitCutscene = escapeDatabaseString(dbConnection, tempHouseData.exitCutscene);
let safeEntranceCutscene = escapeDatabaseString(dbConnection, tempHouseData.entranceCutscene);
let data = [
["house_server", getServerId()],
@@ -753,6 +761,7 @@ function saveHouseToDatabase(houseId) {
["house_entrance_vw", tempHouseData.entranceDimension],
["house_entrance_pickup", tempHouseData.entrancePickupModel],
["house_entrance_blip", tempHouseData.entranceBlipModel],
["house_entrance_cutscene", safeEntranceCutscene],
["house_exit_pos_x", tempHouseData.exitPosition.x],
["house_exit_pos_y", tempHouseData.exitPosition.y],
["house_exit_pos_z", tempHouseData.exitPosition.z],
@@ -761,10 +770,12 @@ function saveHouseToDatabase(houseId) {
["house_exit_vw", tempHouseData.exitDimension],
["house_exit_pickup", tempHouseData.exitPickupModel],
["house_exit_blip", tempHouseData.exitBlipModel],
["house_exit_cutscene", safeExitCutscene],
["house_buy_price", tempHouseData.buyPrice],
["house_rent_price", tempHouseData.rentPrice],
["house_has_interior", boolToInt(tempHouseData.hasInterior)],
["house_interior_lights", boolToInt(tempHouseData.interiorLights)],
];
let dbQuery = null;
@@ -874,10 +885,18 @@ function createHouseEntrancePickup(houseId) {
}
if(areServerElementsSupported()) {
getHouseData(houseId).entrancePickup = createGamePickup(pickupModelId, getHouseData(houseId).entrancePosition, getGameConfig().pickupTypes[getServerGame()].house);
setElementOnAllDimensions(getHouseData(houseId).entrancePickup, false);
setElementDimension(getHouseData(houseId).entrancePickup, getHouseData(houseId).entranceDimension);
addToWorld(getHouseData(houseId).entrancePickup);
let entrancePickup = createGamePickup(pickupModelId, getHouseData(houseId).entrancePosition, getGameConfig().pickupTypes[getServerGame()].house);
if(entrancePickup != null) {
setElementOnAllDimensions(entrancePickup, false);
setElementDimension(entrancePickup, getHouseData(houseId).entranceDimension);
setElementStreamInDistance(entrancePickup, getGlobalConfig().housePickupStreamInDistance);
setElementStreamOutDistance(entrancePickup, getGlobalConfig().housePickupStreamOutDistance);
setElementTransient(entrancePickup, false);
addToWorld(entrancePickup);
getHouseData(houseId).entrancePickup = entrancePickup;
updateHousePickupLabelData(houseId);
}
}
updateHousePickupLabelData(houseId);
}
@@ -898,14 +917,19 @@ function createHouseEntranceBlip(houseId) {
}
if(areServerElementsSupported()) {
getHouseData(houseId).entranceBlip = createGameBlip(getHouseData(houseId).entrancePosition, blipModelId, 1, getColourByName("houseGreen"));
setElementDimension(getHouseData(houseId).entranceBlip, getHouseData(houseId).entranceDimension);
setElementOnAllDimensions(getHouseData(houseId).entranceBlip, false);
//getHouseData(houseId).entranceBlip.streamInDistance = 300;
//getHouseData(houseId).entranceBlip.streamOutDistance = 350;
setEntityData(getHouseData(houseId).entranceBlip, "vrr.owner.type", VRR_BLIP_HOUSE_ENTRANCE, false);
setEntityData(getHouseData(houseId).entranceBlip, "vrr.owner.id", houseId, false);
addToWorld(getHouseData(houseId).entranceBlip);
let entranceBlip = createGameBlip(getHouseData(houseId).entrancePosition, blipModelId, 1, getColourByName("houseGreen"));
if(entranceBlip != null) {
setElementDimension(entranceBlip, getHouseData(houseId).entranceDimension);
setElementOnAllDimensions(entranceBlip, false);
setElementStreamInDistance(entranceBlip, getGlobalConfig().houseBlipStreamInDistance);
setElementStreamOutDistance(entranceBlip, getGlobalConfig().houseBlipStreamOutDistance);
setElementTransient(entranceBlip, false);
setEntityData(entranceBlip, "vrr.owner.type", VRR_BLIP_HOUSE_ENTRANCE, false);
setEntityData(entranceBlip, "vrr.owner.id", houseId, false);
addToWorld(entranceBlip);
getHouseData(houseId).entranceBlip = entranceBlip;
}
}
}
}
@@ -926,10 +950,18 @@ function createHouseExitPickup(houseId) {
}
if(areServerElementsSupported()) {
getHouseData(houseId).exitPickup = createGamePickup(pickupModelId, getHouseData(houseId).exitPosition, getGameConfig().pickupTypes[getServerGame()].house);
setElementDimension(getHouseData(houseId).exitPickup, getHouseData(houseId).exitDimension);
setElementOnAllDimensions(getHouseData(houseId).exitPickup, false);
addToWorld(getHouseData(houseId).exitPickup);
let exitPickup = createGamePickup(pickupModelId, getHouseData(houseId).exitPosition, getGameConfig().pickupTypes[getServerGame()].house);
if(exitPickup != null) {
setElementDimension(exitPickup, getHouseData(houseId).exitDimension);
setElementOnAllDimensions(exitPickup, false);
setElementStreamInDistance(exitPickup, getGlobalConfig().housePickupStreamInDistance);
setElementStreamOutDistance(exitPickup, getGlobalConfig().housePickupStreamOutDistance);
setElementTransient(exitPickup, false);
addToWorld(exitPickup);
getHouseData(houseId).exitPickup = exitPickup;
updateHousePickupLabelData(houseId);
}
}
updateHousePickupLabelData(houseId);
}
@@ -952,12 +984,19 @@ function createHouseExitBlip(houseId) {
}
if(areServerElementsSupported()) {
getHouseData(houseId).exitBlip = createGameBlip(blipModelId, getHouseData(houseId).exitPosition, 1, getColourByName("houseGreen"));
setElementDimension(getHouseData(houseId).exitBlip, getHouseData(houseId).entranceDimension);
setElementOnAllDimensions(getHouseData(houseId).exitBlip, false);
setEntityData(getHouseData(houseId).exitBlip, "vrr.owner.type", VRR_BLIP_HOUSE_EXIT, false);
setEntityData(getHouseData(houseId).exitBlip, "vrr.owner.id", houseId, false);
addToWorld(getHouseData(houseId).exitBlip);
let exitBlip = createGameBlip(blipModelId, getHouseData(houseId).exitPosition, 1, getColourByName("houseGreen"));
if(exitBlip != null) {
setElementDimension(exitBlip, getHouseData(houseId).entranceDimension);
setElementOnAllDimensions(exitBlip, false);
setElementStreamInDistance(exitBlip, getGlobalConfig().houseBlipStreamInDistance);
setElementStreamOutDistance(exitBlip, getGlobalConfig().houseBlipStreamOutDistance);
setElementTransient(exitBlip, false);
setEntityData(exitBlip, "vrr.owner.type", VRR_BLIP_HOUSE_EXIT, false);
setEntityData(exitBlip, "vrr.owner.id", houseId, false);
addToWorld(exitBlip);
getHouseData(houseId).exitBlip = exitBlip;
}
}
}
}
@@ -989,6 +1028,15 @@ function getHouseOwnerTypeText(ownerType) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function getHouseInfoCommand(command, params, client) {
let houseId = getPlayerHouse(client);
@@ -1030,6 +1078,15 @@ function getHouseInfoCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function setHouseBuyPriceCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -1058,6 +1115,15 @@ function setHouseBuyPriceCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function setHouseRentPriceCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -1086,6 +1152,15 @@ function setHouseRentPriceCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function buyHouseCommand(command, params, client) {
let houseId = getPlayerHouse(client);
@@ -1195,6 +1270,15 @@ function deleteHouseExitBlip(houseId) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function reloadAllHousesCommand(command, params, client) {
let clients = getClients();
for(let i in clients) {
@@ -1215,7 +1299,7 @@ function reloadAllHousesCommand(command, params, client) {
createAllHousePickups();
createAllHouseBlips();
messageAdminAction(`All houses have been reloaded by an admin!`);
announceAdminAction(`HousesReloaded`);
}
// ===========================================================================
@@ -1431,30 +1515,30 @@ function updateHousePickupLabelData(houseId) {
return false;
}
let houseData = getHouseData(houseId);
let houseData = getHouseData(houseId);
if(houseData.entrancePickup != null) {
setEntityData(houseData.entrancePickup, "vrr.owner.type", VRR_PICKUP_HOUSE_ENTRANCE, false);
setEntityData(houseData.entrancePickup, "vrr.owner.id", houseId, false);
setEntityData(houseData.entrancePickup, "vrr.label.type", VRR_LABEL_HOUSE, true);
//setEntityData(houseData.entrancePickup, "vrr.label.name", houseData.description, true);
setEntityData(houseData.entrancePickup, "vrr.label.locked", houseData.locked, true);
if(houseData.buyPrice > 0) {
setEntityData(houseData.entrancePickup, "vrr.label.price", houseData.buyPrice, true);
setEntityData(houseData.entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_BUYHOUSE, true);
} else {
if(houseData.rentPrice > 0) {
setEntityData(houseData.entrancePickup, "vrr.label.rentprice", houseData.rentPrice, true);
setEntityData(houseData.entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_RENTHOUSE, true);
}
}
}
if(houseData.entrancePickup != null) {
setEntityData(houseData.entrancePickup, "vrr.owner.type", VRR_PICKUP_HOUSE_ENTRANCE, false);
setEntityData(houseData.entrancePickup, "vrr.owner.id", houseId, false);
setEntityData(houseData.entrancePickup, "vrr.label.type", VRR_LABEL_HOUSE, true);
//setEntityData(houseData.entrancePickup, "vrr.label.name", houseData.description, true);
setEntityData(houseData.entrancePickup, "vrr.label.locked", houseData.locked, true);
if(houseData.buyPrice > 0) {
setEntityData(houseData.entrancePickup, "vrr.label.price", houseData.buyPrice, true);
setEntityData(houseData.entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_BUYHOUSE, true);
} else {
if(houseData.rentPrice > 0) {
setEntityData(houseData.entrancePickup, "vrr.label.rentprice", houseData.rentPrice, true);
setEntityData(houseData.entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_RENTHOUSE, true);
}
}
}
if(houseData.exitPickup != null) {
setEntityData(houseData.exitPickup, "vrr.owner.type", VRR_PICKUP_HOUSE_EXIT, false);
setEntityData(houseData.exitPickup, "vrr.owner.id", houseId, false);
setEntityData(houseData.exitPickup, "vrr.label.type", VRR_LABEL_EXIT, true);
}
if(houseData.exitPickup != null) {
setEntityData(houseData.exitPickup, "vrr.owner.type", VRR_PICKUP_HOUSE_EXIT, false);
setEntityData(houseData.exitPickup, "vrr.owner.id", houseId, false);
setEntityData(houseData.exitPickup, "vrr.label.type", VRR_LABEL_EXIT, true);
}
}
// ===========================================================================

View File

@@ -10,7 +10,9 @@
function initItemScript() {
logToConsole(LOG_INFO, "[VRR.Item]: Initializing item script ...");
getServerData().itemTypes = loadItemTypesFromDatabase();
getServerData().items = loadItemsFromDatabase();
if(!getServerConfig().devServer) {
getServerData().items = loadItemsFromDatabase();
}
setItemTypeDataIndexes();
setItemDataIndexes();
@@ -132,6 +134,15 @@ function deleteGroundItemObject(itemId) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function createGroundItemCommand(command, params, client) {
let splitParams = params.split(" ");
let itemType = getItemTypeFromParams(splitParams.slice(0, -1).join(" "));
@@ -154,13 +165,22 @@ function createGroundItemCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function createItemCommand(command, params, client) {
let splitParams = params.split(" ");
let itemType = getItemTypeFromParams(splitParams.slice(0, -1).join(" "));
let value = splitParams.slice(-1) || 1;
if(!getItemTypeData(itemType)) {
messagePlayerError(client, getLocaleString("InvalidItemType"));
messagePlayerError(client, getLocaleString(client, "InvalidItemType"));
return false;
}
@@ -176,6 +196,15 @@ function createItemCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function useItemCommand(command, params, client) {
clearPlayerItemActionState(client);
@@ -230,6 +259,15 @@ function useItemCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function deleteGroundItemCommand(command, params, client) {
let itemId = getClosestItemOnGround(getPlayerPosition(client));
@@ -252,6 +290,15 @@ function deleteGroundItemCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function pickupItemCommand(command, params, client) {
clearPlayerItemActionState(client);
@@ -303,6 +350,15 @@ function pickupItemCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function dropItemCommand(command, params, client) {
clearPlayerItemActionState(client);
@@ -364,6 +420,15 @@ function dropItemCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function putItemCommand(command, params, client) {
clearPlayerItemActionState(client);
@@ -411,6 +476,15 @@ function putItemCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function takeItemCommand(command, params, client) {
clearPlayerItemActionState(client);
@@ -458,6 +532,15 @@ function takeItemCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function createItemTypeCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -470,6 +553,15 @@ function createItemTypeCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function setItemTypeDropModelCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -490,6 +582,15 @@ function setItemTypeDropModelCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function setItemTypeOrderPriceCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -510,6 +611,15 @@ function setItemTypeOrderPriceCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function setItemTypeRiskMultiplierCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -530,6 +640,15 @@ function setItemTypeRiskMultiplierCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function toggleItemTypeEnabledCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -549,6 +668,15 @@ function toggleItemTypeEnabledCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function setItemTypeUseTypeCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -569,6 +697,15 @@ function setItemTypeUseTypeCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function setItemTypeUseValueCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -663,7 +800,7 @@ function playerUseItem(client, hotBarSlot) {
break;
case VRR_ITEM_USETYPE_ROPE:
closestPlayer = getClosestPlayer(getPlayerPosition(client), client.player);
closestPlayer = getClosestPlayer(getPlayerPosition(client), getPlayerPed(client));
if(!getPlayerData(closestPlayer)) {
messagePlayerError(client, "There isn't anyone close enough to tie up!");
@@ -1063,16 +1200,16 @@ function playerSwitchItem(client, newHotBarSlot) {
setPlayerWeaponDamageEnabled(client, true);
setPlayerWeaponDamageEvent(client, VRR_WEAPON_DAMAGE_EVENT_NORMAL);
} else {
let ammoItemSlot = getPlayerFirstAmmoItemForWeapon(client, getItemTypeData(getItemData(newHotBarItem).itemTypeIndex).useId);
if(ammoItemSlot != false) {
getItemData(newHotBarItem).value = getItemData(getPlayerData(client).hotBarItems[ammoItemSlot]).value;
givePlayerWeapon(client, toInteger(getItemTypeData(getItemData(newHotBarItem).itemTypeIndex).useId), toInteger(getItemData(newHotBarItem).value), true, true);
setPlayerWeaponDamageEnabled(client, true);
setPlayerWeaponDamageEvent(client, VRR_WEAPON_DAMAGE_EVENT_NORMAL);
deleteItem(getPlayerData(client).hotBarItems[ammoItemSlot]);
} else {
messagePlayerError(client, getLocaleString(client, "ItemUnequippableNoAmmo", getItemName(newHotBarItem), newHotBarSlot));
}
let ammoItemSlot = getPlayerFirstAmmoItemForWeapon(client, getItemTypeData(getItemData(newHotBarItem).itemTypeIndex).useId);
if(ammoItemSlot != false) {
getItemData(newHotBarItem).value = getItemData(getPlayerData(client).hotBarItems[ammoItemSlot]).value;
givePlayerWeapon(client, toInteger(getItemTypeData(getItemData(newHotBarItem).itemTypeIndex).useId), toInteger(getItemData(newHotBarItem).value), true, true);
setPlayerWeaponDamageEnabled(client, true);
setPlayerWeaponDamageEvent(client, VRR_WEAPON_DAMAGE_EVENT_NORMAL);
deleteItem(getPlayerData(client).hotBarItems[ammoItemSlot]);
} else {
messagePlayerError(client, getLocaleString(client, "ItemUnequippableNoAmmo", getItemName(newHotBarItem), newHotBarSlot));
}
}
} else if(getItemTypeData(getItemData(newHotBarItem).itemTypeIndex).useType == VRR_ITEM_USETYPE_TAZER) {
if(getItemData(newHotBarItem).value > 0) {
@@ -1105,6 +1242,15 @@ function playerSwitchItem(client, newHotBarSlot) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function playerSwitchHotBarSlotCommand(command, params, client) {
clearPlayerItemActionState(client);
@@ -1394,12 +1540,30 @@ function getBestItemToTake(client, slot) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function listPlayerInventoryCommand(command, params, client) {
showPlayerInventoryToPlayer(client, client);
}
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function listBusinessStorageInventoryCommand(command, params, client) {
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
@@ -1418,6 +1582,15 @@ function listBusinessStorageInventoryCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function listBusinessFloorInventoryCommand(command, params, client) {
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
@@ -1436,6 +1609,15 @@ function listBusinessFloorInventoryCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function listHouseInventoryCommand(command, params, client) {
let houseId = (isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client));
@@ -1454,6 +1636,15 @@ function listHouseInventoryCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function listItemInventoryCommand(command, params, client) {
let itemId = getClosestItemOnGround(getPlayerPosition(client));
@@ -1472,6 +1663,10 @@ function listItemInventoryCommand(command, params, client) {
// ===========================================================================
/**
* @param {number} itemId - The data index of the item
* @return {ItemData} The item's data (class instance)
*/
function getItemData(itemId) {
if(typeof getServerData().items[itemId] != "undefined") {
return getServerData().items[itemId];
@@ -1481,37 +1676,54 @@ function getItemData(itemId) {
// ===========================================================================
/**
* @param {number} itemTypeId - The data index of the item type
* @return {ItemTypeData} The item type's data (class instance)
*/
function getItemTypeData(itemTypeId) {
return getServerData().itemTypes[itemTypeId];
}
// ===========================================================================
function saveAllItemsToDatabase() {
function saveItemsToDatabase() {
if(getServerConfig().devServer) {
return false;
}
for(let i in getServerData().items) {
if(getServerData().items[i].needsSaved) {
if(getServerData().items[i].databaseId != -1) {
saveItemToDatabase(getServerData().items[i]);
}
}
saveItemToDatabase(i);
}
}
// ===========================================================================
function saveAllItemTypesToDatabase() {
function saveItemTypesToDatabase() {
if(getServerConfig().devServer) {
return false;
}
for(let i in getServerData().itemTypes) {
if(getServerData().itemTypes[i].needsSaved) {
if(getServerData().itemTypes[i].databaseId != -1) {
saveItemTypeToDatabase(getServerData().itemTypes[i]);
}
}
saveItemTypeToDatabase(i);
}
}
// ===========================================================================
function saveItemToDatabase(itemData) {
function saveItemToDatabase(itemId) {
let itemData = getItemData(itemId);
if(itemData == false) {
return false;
}
if(itemData.databaseId == -1) {
return false;
}
if(!itemData.needsSaved) {
return false;
}
logToConsole(LOG_VERBOSE, `[VRR.Item]: Saving item '${itemData.index}' to database ...`);
let dbConnection = connectToDatabase();
@@ -1553,15 +1765,36 @@ function saveItemToDatabase(itemData) {
// ===========================================================================
function saveItemTypeToDatabase(itemTypeData) {
function saveItemTypeToDatabase(itemTypeId) {
let itemTypeData = getItemTypeData(itemTypeId);
if(itemTypeData == false) {
return false;
}
if(itemTypeData.databaseId == -1) {
return false;
}
if(!itemTypeData.needsSaved) {
return false;
}
logToConsole(LOG_VERBOSE, `[VRR.Item]: Saving item type '${itemTypeData.name}' to database ...`);
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeItemTypeName = escapeDatabaseString(dbConnection, itemTypeData.name);
let safeAnimationUse = escapeDatabaseString(dbConnection, itemTypeData.useAnimationName);
let safeAnimationDrop = escapeDatabaseString(dbConnection, itemTypeData.dropAnimationName);
let safeAnimationPickup = escapeDatabaseString(dbConnection, itemTypeData.pickupAnimationName);
let safeAnimationGive = escapeDatabaseString(dbConnection, itemTypeData.giveAnimationName);
let safeAnimationTake = escapeDatabaseString(dbConnection, itemTypeData.takeAnimationName);
let safeAnimationSwitch = escapeDatabaseString(dbConnection, itemTypeData.switchAnimationName);
let data = [
["item_type_id", itemTypeData.databaseId],
["item_type_server", itemTypeData.serverId],
["item_type_name", itemTypeData.name],
["item_type_name", safeItemTypeName],
["item_type_enabled", itemTypeData.enabled],
["item_type_use_type", itemTypeData.useType],
["item_type_drop_type", itemTypeData.dropType],
@@ -1592,6 +1825,12 @@ function saveItemTypeToDatabase(itemTypeData) {
["item_type_delay_take", itemTypeData.takeDelay],
["item_type_delay_give", itemTypeData.giveDelay],
["item_type_delay_drop", itemTypeData.dropDelay],
["item_type_anim_use", safeAnimationUse],
["item_type_anim_drop", safeAnimationDrop],
["item_type_anim_pickup", safeAnimationPickup],
["item_type_anim_give", safeAnimationGive],
["item_type_anim_take", safeAnimationTake],
["item_type_anim_switch", safeAnimationSwitch],
];
let dbQuery = null;
@@ -1698,7 +1937,7 @@ function playerItemActionDelayComplete(client) {
break;
}
clearPlayerItemActionState(client);
clearPlayerItemActionState(client);
}
// ===========================================================================
@@ -1757,6 +1996,15 @@ function getPlayerFirstItemSlotByUseType(client, useType) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function toggleItemEnabledCommand(command, params, client) {
if(!getPlayerActiveItem(client)) {
messagePlayerError(client, `You aren't holding anything!`);
@@ -1774,6 +2022,15 @@ function toggleItemEnabledCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function deleteItemInPlayerInventoryCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -1815,6 +2072,15 @@ function deleteItemInPlayerInventoryCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function deleteAllItemsInPlayerInventoryCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -2084,19 +2350,19 @@ function getItemTypeFromParams(params) {
// ===========================================================================
function getPlayerFirstAmmoItemForWeapon(client, weaponId) {
for(let i in getPlayerData(client).hotBarItems) {
if(getPlayerData(client).hotBarItems[i] != -1) {
if(getItemData(getPlayerData(client).hotBarItems[i]) != false) {
if(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[i]).itemTypeIndex).useType == VRR_ITEM_USETYPE_AMMO_CLIP) {
if(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[i]).itemTypeIndex).useId == weaponId) {
return i;
}
}
}
}
}
for(let i in getPlayerData(client).hotBarItems) {
if(getPlayerData(client).hotBarItems[i] != -1) {
if(getItemData(getPlayerData(client).hotBarItems[i]) != false) {
if(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[i]).itemTypeIndex).useType == VRR_ITEM_USETYPE_AMMO_CLIP) {
if(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[i]).itemTypeIndex).useId == weaponId) {
return i;
}
}
}
}
}
return false;
return false;
}
// ===========================================================================

View File

@@ -10,27 +10,27 @@
// ===========================================================================
function isPlayerHandCuffed(client) {
return (getPlayerData(client).pedState == VRR_PEDSTATE_BINDED);
return (getPlayerData(client).pedState == VRR_PEDSTATE_BINDED);
}
// ===========================================================================
function handCuffPlayer(client) {
getPlayerData(client).pedState = VRR_PEDSTATE_BINDED;
setPlayerControlState(client, false);
getPlayerData(client).pedState = VRR_PEDSTATE_BINDED;
setPlayerControlState(client, false);
}
// ===========================================================================
function unHandCuffPlayer(client) {
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
setPlayerControlState(client, true);
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
setPlayerControlState(client, true);
}
// ===========================================================================
function isPlayerSurrendered(client) {
return true; //(getPlayerData(client).pedState == VRR_PEDSTATE_TAZED || getPlayerData(client).pedState == VRR_PEDSTATE_HANDSUP);
return true; //(getPlayerData(client).pedState == VRR_PEDSTATE_TAZED || getPlayerData(client).pedState == VRR_PEDSTATE_HANDSUP);
}
// ===========================================================================

View File

@@ -8,48 +8,48 @@
// ===========================================================================
function getItemWithPhoneNumber(phoneNumber) {
for(let i in getServerData().items) {
if(getItemTypeData(getItemData(i).itemTypeIndex).useType == VRR_ITEM_USETYPE_PHONE) {
if(getItemData(i).value == phoneNumber) {
return i;
}
}
}
return -1;
for(let i in getServerData().items) {
if(getItemTypeData(getItemData(i).itemTypeIndex).useType == VRR_ITEM_USETYPE_PHONE) {
if(getItemData(i).value == phoneNumber) {
return i;
}
}
}
return -1;
}
// ===========================================================================
function isPhoneItemEnabled(itemIndex) {
return getItemData(itemIndex).enabled;
return getItemData(itemIndex).enabled;
}
// ===========================================================================
function ringPhoneForNearbyPlayers(itemIndex) {
/*
if(isPhoneItemEnabled(itemIndex)) {
switch(getItemData(itemIndex).ownerType) {
case VRR_ITEM_OWNER_GROUND:
playRingtoneForPlayersInRange(getItemData(itemIndex).position, getItemData(i).extra);
break;
/*
if(isPhoneItemEnabled(itemIndex)) {
switch(getItemData(itemIndex).ownerType) {
case VRR_ITEM_OWNER_GROUND:
playRingtoneForPlayersInRange(getItemData(itemIndex).position, getItemData(i).extra);
break;
case VRR_ITEM_OWNER_VEHTRUNK:
playRingtoneForPlayersInRange(getVehiclePosition(getItemData(itemIndex).ownerId), getItemData(i).extra);
break;
case VRR_ITEM_OWNER_VEHTRUNK:
playRingtoneForPlayersInRange(getVehiclePosition(getItemData(itemIndex).ownerId), getItemData(i).extra);
break;
case VRR_ITEM_OWNER_VEHDASH:
playRingtoneForPlayersInRange(getVehiclePosition(getItemData(itemIndex).ownerId), getItemData(i).extra);
break;
}
}
*/
case VRR_ITEM_OWNER_VEHDASH:
playRingtoneForPlayersInRange(getVehiclePosition(getItemData(itemIndex).ownerId), getItemData(i).extra);
break;
}
}
*/
}
// ===========================================================================
function phoneTransmit(radioFrequency, messageText, transmittingPlayer) {
phoneOutgoingToNearbyPlayers(transmittingPlayer, messageText);
phoneOutgoingToNearbyPlayers(transmittingPlayer, messageText);
}
// ===========================================================================

View File

@@ -10,21 +10,21 @@
// ===========================================================================
function isPlayerTied(client) {
return (getPlayerData(client).pedState == VRR_PEDSTATE_BINDED);
return (getPlayerData(client).pedState == VRR_PEDSTATE_BINDED);
}
// ===========================================================================
function ropeTiePlayer(client) {
getPlayerData(client).pedState = VRR_PEDSTATE_BINDED;
setPlayerControlState(client, false);
getPlayerData(client).pedState = VRR_PEDSTATE_BINDED;
setPlayerControlState(client, false);
}
// ===========================================================================
function ropeUnTiePlayer(client) {
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
setPlayerControlState(client, true);
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
setPlayerControlState(client, true);
}
// ===========================================================================

View File

@@ -10,34 +10,34 @@
// ===========================================================================
function isPlayerTazed(client) {
return (getPlayerData(client).pedState == VRR_PEDSTATE_TAZED);
return (getPlayerData(client).pedState == VRR_PEDSTATE_TAZED);
}
// ===========================================================================
function tazePlayer(client) {
getPlayerData(client).pedState = VRR_PEDSTATE_TAZED;
setPlayerControlState(client, false);
getPlayerData(client).pedState = VRR_PEDSTATE_TAZED;
setPlayerControlState(client, false);
let animationId = getAnimationFromParams("tazed");
if(animationId != false) {
forcePlayerPlayAnimation(client, animationId);
}
let animationId = getAnimationFromParams("tazed");
if(animationId != false) {
forcePlayerPlayAnimation(client, animationId);
}
setTimeout(function() {
unTazePlayer(client);
doActionToNearbyPlayers(client, `The tazer effect wears off`);
}, getGlobalConfig().tazerEffectDuration);
setTimeout(function() {
unTazePlayer(client);
doActionToNearbyPlayers(client, `The tazer effect wears off`);
}, getGlobalConfig().tazerEffectDuration);
}
// ===========================================================================
function unTazePlayer(client) {
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
setPlayerControlState(client, true);
setPlayerPosition(client, getPlayerData(client).currentAnimationPositionReturnTo);
makePedStopAnimation(getPlayerData(client).ped);
setPlayerControlState(client, true);
setPlayerPosition(client, getPlayerData(client).currentAnimationPositionReturnTo);
makePedStopAnimation(getPlayerData(client).ped);
}

View File

@@ -16,15 +16,15 @@ function getPlayerActiveWalkieTalkieFrequency(client) {
return getItemData(getPlayerData(client).hotBarItems[walkieTalkieSlot]).value;
}
}
}
}
return false;
return false;
}
// ===========================================================================
function walkieTalkieTransmit(radioFrequency, messageText, transmittingPlayer) {
walkieTalkieOutgoingToNearbyPlayers(transmittingPlayer, messageText);
walkieTalkieOutgoingToNearbyPlayers(transmittingPlayer, messageText);
//let clients = getServerData().items;
//for(let i in clients) {

View File

@@ -617,9 +617,9 @@ function stopWorking(client) {
let jobVehicle = getPlayerData(client).lastJobVehicle;
if(jobVehicle) {
if(client.player.vehicle) {
if(getPlayerVehicle(client) == jobVehicle) {
removePlayerFromVehicle(client);
//client.player.removeFromVehicle();
//getPlayerPed(client).removeFromVehicle();
}
respawnVehicle(jobVehicle);
@@ -631,7 +631,7 @@ function stopWorking(client) {
deleteJobItems(client);
restorePlayerJobLockerItems(client);
respawnJobVehicle(client);
sendPlayerStopJobRoute(client);
sendPlayerStopJobRoute(client);
let jobId = getPlayerJob(client);
switch(getJobType(jobId)) {
@@ -665,9 +665,9 @@ function stopWorking(client) {
case VRR_JOB_DRUG:
break;
case VRR_JOB_GENERIC:
messagePlayerInfo(client, "Your vehicle has been respawned at your job location");
break;
case VRR_JOB_GENERIC:
messagePlayerInfo(client, "Your vehicle has been respawned at your job location");
break;
default:
break;
@@ -753,13 +753,13 @@ function jobUniformCommand(command, params, client) {
return false;
}
if(uniformId == 0) {
setPlayerSkin(client, getPlayerCurrentSubAccount(client).skin);
meActionToNearbyPlayers(client, `takes off their uniform`);
} else {
setPlayerSkin(client, jobData.uniforms[uniformId-1].skin);
meActionToNearbyPlayers(client, `puts on ${getProperDeterminerForName(jobData.uniforms[uniformId-1].name)} ${jobData.uniforms[uniformId-1].name} uniform`);
}
if(uniformId == 0) {
setPlayerSkin(client, getPlayerCurrentSubAccount(client).skin);
meActionToNearbyPlayers(client, `takes off their uniform`);
} else {
setPlayerSkin(client, jobData.uniforms[uniformId-1].skin);
meActionToNearbyPlayers(client, `puts on ${getProperDeterminerForName(jobData.uniforms[uniformId-1].name)} ${jobData.uniforms[uniformId-1].name} uniform`);
}
}
// ===========================================================================
@@ -942,7 +942,7 @@ function reloadAllJobsCommand(command, params, client) {
}
}
messageAdminAction(`All server jobs have been reloaded by an admin!`);
announceAdminAction("AllJobsReloaded");
}
// ===========================================================================
@@ -966,8 +966,8 @@ function createJob(name) {
tempJobData.pickupModel = getGameConfig().pickupModels[getGame()].job;
getServerData().jobs.push(tempJobData);
saveJobToDatabase(tempJobData);
setAllJobDataIndexes();
saveJobToDatabase(tempJobData);
setAllJobDataIndexes();
}
// ===========================================================================
@@ -1213,17 +1213,17 @@ function setJobRouteAllLocationDelaysCommand(command, params, client) {
let jobId = getPlayerJob(client);
let jobRoute = getPlayerJobRoute(client);
let delay = getParam(params, " ", 1);
let delay = getParam(params, " ", 1);
if(isNaN(delay)) {
messagePlayerError(client, getLocaleString(client, "TimeNotNumber"))
return false;
}
if(isNaN(delay)) {
messagePlayerError(client, getLocaleString(client, "TimeNotNumber"))
return false;
}
for(let i in getJobData(jobId).routes[jobRoute].locations) {
getJobData(jobId).routes[jobRoute].locations[i].stopDelay = delay;
getJobData(jobId).routes[jobRoute].locations[i].needsSaved = true;
}
getJobData(jobId).routes[jobRoute].locations[i].stopDelay = delay;
getJobData(jobId).routes[jobRoute].locations[i].needsSaved = true;
}
messageAdmins(`${getPlayerName(client)} {MAINCOLOUR}${getEnabledDisabledFromBool(getJobData(jobId).enabled)}{MAINCOLOUR} set route {ALTCOLOUR}${oldName}{MAINCOLOUR} location's stop delays to {ALTCOLOUR}${delay/1000}{MAINCOLOUR} seconds for the {jobYellow}${getJobData(jobId).name}{MAINCOLOUR} job`);
}
@@ -1569,40 +1569,40 @@ function forceAllPlayersToStopWorking() {
// ===========================================================================
function jobStartRouteCommand(command, params, client) {
if(!canPlayerUseJobs(client)) {
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
return false;
}
if(!isPlayerWorking(client)) {
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You aren't working yet! Use /startwork first.");
return false;
}
return false;
}
if(getJobData(getPlayerJob(client)).routes.length == 0) {
if(getJobData(getPlayerJob(client)).routes.length == 0) {
messagePlayerError(client, "Your job doesn't have any routes for this location!");
return false;
return false;
}
if(!isPlayerInJobVehicle(client)) {
messagePlayerError(client, "You need to be in a vehicle that belongs to your job!");
return false;
return false;
}
if(isPlayerOnJobRoute(client)) {
if(isPlayerOnJobRoute(client)) {
messagePlayerError(client, "You're already on a job route! Finish the route or use /stoproute");
return false;
return false;
}
let forceRoute = -1;
if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageJobs"))) {
if(!areParamsEmpty(params)) {
let tempRoute = getJobRouteFromParams(params, getPlayerJob(client));
if(tempRoute != false) {
forceRoute = tempRoute;
}
}
}
let forceRoute = -1;
if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageJobs"))) {
if(!areParamsEmpty(params)) {
let tempRoute = getJobRouteFromParams(params, getPlayerJob(client));
if(tempRoute != false) {
forceRoute = tempRoute;
}
}
}
startJobRoute(client, forceRoute);
return true;
@@ -1611,24 +1611,24 @@ function jobStartRouteCommand(command, params, client) {
// ===========================================================================
function jobStopRouteCommand(command, params, client) {
if(!canPlayerUseJobs(client)) {
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
return false;
}
if(!isPlayerWorking(client)) {
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You aren't working yet! Use /startwork first.");
return false;
}
return false;
}
//if(!doesPlayerHaveJobType(client, VRR_JOB_BUS) && !doesPlayerHaveJobType(client, VRR_JOB_GARBAGE)) {
//if(!doesPlayerHaveJobType(client, VRR_JOB_BUS) && !doesPlayerHaveJobType(client, VRR_JOB_GARBAGE)) {
// messagePlayerError(client, "Your job doesn't use a route!");
// return false;
// return false;
//}
if(!isPlayerOnJobRoute(client)) {
messagePlayerError(client, "You aren't on a job route!");
return false;
return false;
}
stopJobRoute(client, false, false);
@@ -1660,21 +1660,21 @@ function isPlayerWorking(client) {
// ===========================================================================
function startJobRoute(client, forceRoute = -1) {
let jobId = getPlayerJob(client);
let jobRoute = 0;
let jobId = getPlayerJob(client);
let jobRoute = 0;
if(forceRoute == -1) {
jobRoute = getRandomJobRouteForLocation(getClosestJobLocationForJob(getPlayerPosition(client), jobId));
} else {
jobRoute = forceRoute;
}
if(forceRoute == -1) {
jobRoute = getRandomJobRouteForLocation(getClosestJobLocationForJob(getPlayerPosition(client), jobId));
} else {
jobRoute = forceRoute;
}
if(jobRoute == -1) {
messagePlayerError(client, `There are no routes for this location.`);
return false;
}
if(jobRoute == -1) {
messagePlayerError(client, `There are no routes for this location.`);
return false;
}
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} is starting job route ${jobRoute} for job ${jobId}`);
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} is starting job route ${jobRoute} for job ${jobId}`);
getPlayerData(client).jobRoute = jobRoute;
getPlayerData(client).jobRouteLocation = 0;
@@ -1684,26 +1684,26 @@ function startJobRoute(client, forceRoute = -1) {
getPlayerVehicle(client).colour2 = getJobRouteData(jobId, jobRoute).vehicleColour2;
messagePlayerNormal(client, replaceJobRouteStringsInMessage(getJobRouteData(jobId, jobRoute).startMessage, jobId, jobRoute));
if(getJobRouteData(jobId, jobRoute).locations.length > 0) {
if(getJobRouteData(jobId, jobRoute).locations.length > 0) {
showCurrentJobLocation(client);
} else {
messagePlayerError(client, `There are no locations for this route.`);
}
messagePlayerError(client, `There are no locations for this route.`);
}
}
// ===========================================================================
function stopJobRoute(client, successful = false, alertPlayer = true) {
let jobId = getPlayerJob(client);
let jobId = getPlayerJob(client);
if(alertPlayer) {
messagePlayerAlert(client, replaceJobRouteStringsInMessage(getJobRouteData(jobId, getPlayerJobRoute(client)).finishMessage), jobId, getPlayerJobRoute(client));
}
if(successful == true) {
finishSuccessfulJobRoute(client);
return false;
}
if(successful == true) {
finishSuccessfulJobRoute(client);
return false;
}
stopReturnToJobVehicleCountdown(client);
sendPlayerStopJobRoute(client);
@@ -1797,26 +1797,26 @@ function deleteJobLocation(jobLocationData) {
quickDatabaseQuery(`DELETE FROM job_loc WHERE job_loc_id = ${jobLocationData.databaseId}`);
}
deleteJobLocationBlip(tempJob, tempLocation);
deleteJobLocationPickup(tempJob, tempLocation);
deleteJobLocationBlip(tempJob, tempLocation);
deleteJobLocationPickup(tempJob, tempLocation);
getJobData(getJobIdFromDatabaseId(tempJob)).locations.splice(tempLocation, 1);
setAllJobDataIndexes();
setAllJobDataIndexes();
}
// ===========================================================================
function freezePlayerJobVehicleForRouteLocation(client) {
getVehicleData(getPlayerVehicle(client)).engine = false;
getVehicleData(getPlayerVehicle(client)).engine = false;
setVehicleEngine(getPlayerVehicle(client), getVehicleData(getPlayerVehicle(client)).engine);
//setPlayerControlState(client, false);
//setPlayerControlState(client, false);
}
// ===========================================================================
function unFreezePlayerJobVehicleForRouteLocation(client) {
getVehicleData(getPlayerVehicle(client)).engine = true;
getVehicleData(getPlayerVehicle(client)).engine = true;
setVehicleEngine(getPlayerVehicle(client), getVehicleData(getPlayerVehicle(client)).engine);
//setPlayerControlState(client, true);
//setPlayerControlState(client, true);
}
// ===========================================================================
@@ -2236,7 +2236,7 @@ function saveJobUniformToDatabase(jobUniformData) {
// ===========================================================================
function saveAllJobsToDatabase() {
function saveJobsToDatabase() {
for(let i in getServerData().jobs) {
saveJobToDatabase(getServerData().jobs[i]);
@@ -2291,24 +2291,33 @@ function createJobLocationPickup(jobId, locationId) {
return false;
}
if(getJobData(jobId).pickupModel != -1) {
let tempJobData = getJobData(jobId);
if(tempJobData.pickupModel != -1) {
let pickupModelId = getGameConfig().pickupModels[getServerGame()].Job;
if(getJobData(jobId).pickupModel != 0) {
pickupModelId = getJobData(jobId).pickupModel;
if(tempJobData.pickupModel != 0) {
pickupModelId = tempJobData.pickupModel;
}
logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating pickup for location ${locationId} of the ${getServerData().jobs[jobId].name} job`);
logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating pickup for location ${locationId} of the ${tempJobData.name} job`);
getJobData(jobId).locations[locationId].pickup = createGamePickup(pickupModelId, getJobData(jobId).locations[locationId].position, getGameConfig().pickupTypes[getServerGame()].job);
setElementDimension(getJobData(jobId).locations[locationId].pickup, getJobData(jobId).locations[locationId].dimension);
setElementOnAllDimensions(getJobData(jobId).locations[locationId].pickup, false);
setEntityData(getServerData().jobs[jobId].locations[locationId].pickup, "vrr.owner.type", VRR_PICKUP_JOB, false);
setEntityData(getServerData().jobs[jobId].locations[locationId].pickup, "vrr.owner.id", locationId, false);
setEntityData(getServerData().jobs[jobId].locations[locationId].pickup, "vrr.label.type", VRR_LABEL_JOB, true);
setEntityData(getServerData().jobs[jobId].locations[locationId].pickup, "vrr.label.name", getJobData(jobId).name, true);
setEntityData(getServerData().jobs[jobId].locations[locationId].pickup, "vrr.label.jobType", getJobData(jobId).databaseId, true);
addToWorld(getJobData(jobId).locations[locationId].pickup);
if(areServerElementsSupported()) {
let pickup = createGamePickup(pickupModelId, tempJobData.locations[locationId].position, getGameConfig().pickupTypes[getServerGame()].job);
if(pickup != false) {
tempJobData.locations[locationId].pickup = pickup;
setElementDimension(pickup, tempJobData.locations[locationId].dimension);
setElementOnAllDimensions(pickup, false);
setEntityData(pickup, "vrr.owner.type", VRR_PICKUP_JOB, false);
setEntityData(pickup, "vrr.owner.id", locationId, false);
setEntityData(pickup, "vrr.label.type", VRR_LABEL_JOB, true);
setEntityData(pickup, "vrr.label.name", tempJobData.name, true);
setEntityData(pickup, "vrr.label.jobType", tempJobData.databaseId, true);
addToWorld(pickup);
}
} else {
// sendJobToPlayer(null, jobId, tempJobData.name, tempJobData.locations[locationId].position, pickupModel);
}
}
}
@@ -2319,6 +2328,8 @@ function createJobLocationBlip(jobId, locationId) {
return false;
}
let tempJobData = getJobData(jobId);
if(getJobData(jobId).blipModel != -1) {
let blipModelId = getGameConfig().blipSprites[getServerGame()].Job;
@@ -2326,12 +2337,17 @@ function createJobLocationBlip(jobId, locationId) {
blipModelId = getJobData(jobId).blipModel;
}
getJobData(jobId).locations[locationId].blip = createGameBlip(getJobData(jobId).locations[locationId].position, blipModelId, getColourByType("job"));
//setElementStreamInDistance(getServerData().jobs[i].locations[j].blip, 30);
//setElementStreamOutDistance(getServerData().jobs[i].locations[j].blip, 40);
setElementOnAllDimensions(getJobData(jobId).locations[locationId].blip, false);
setElementDimension(getJobData(jobId).locations[locationId].blip, getJobData(jobId).locations[locationId].dimension);
addToWorld(getJobData(jobId).locations[locationId].blip);
if(areServerElementsSupported()) {
let blip = createGameBlip(tempJobData.locations[locationId].position, blipModelId, getColourByType("job"));
if(blip != false) {
tempJobData.locations[locationId].blip = blip;
}
setElementOnAllDimensions(blip, false);
setElementDimension(blip, tempJobData.locations[locationId].dimension);
addToWorld(blip);
} else {
sendJobToPlayer(null, jobId, tempJobData.name, tempJobData.locations[locationId].position, blipModelId);
}
}
}
@@ -2408,31 +2424,31 @@ function isPlayerOnJobBlackList(client, jobId) {
// ===========================================================================
function playerArrivedAtJobRouteLocation(client) {
let jobId = getPlayerJob(client);
let jobId = getPlayerJob(client);
if(!isPlayerOnJobRoute(client)) {
return false;
}
if(isLastLocationOnJobRoute(jobId, getPlayerJobRoute(client), getPlayerJobRouteLocation(client))) {
finishSuccessfulJobRoute(client);
return false;
}
if(isLastLocationOnJobRoute(jobId, getPlayerJobRoute(client), getPlayerJobRouteLocation(client))) {
finishSuccessfulJobRoute(client);
return false;
}
showGameMessage(client, replaceJobRouteStringsInMessage(removeColoursInMessage(getJobRouteData(jobId, getPlayerJobRoute(client)).locationArriveMessage), jobId, getPlayerJobRoute(client)), getJobData(jobId).colour, 3500);
if(getJobRouteLocationData(jobId, getPlayerJobRoute(client),getPlayerJobRouteLocation(client)).stopDelay > 0) {
freezePlayerJobVehicleForRouteLocation(client);
getPlayerData(client).jobRouteLocation = getNextLocationOnJobRoute(jobId, getPlayerJobRoute(client), getPlayerJobRouteLocation(client));
setTimeout(function() {
showCurrentJobLocation(client);
showGameMessage(client, replaceJobRouteStringsInMessage(removeColoursInMessage(getJobRouteData(jobId, getPlayerJobRoute(client)).locationNextMessage), jobId, getPlayerJobRoute(client)), getJobData(jobId).colour, 3500);
unFreezePlayerJobVehicleForRouteLocation(client);
}, getJobRouteLocationData(jobId, getPlayerJobRoute(client),getPlayerJobRouteLocation(client)).stopDelay);
} else {
getPlayerData(client).jobRouteLocation = getNextLocationOnJobRoute(jobId, getPlayerJobRoute(client), getPlayerJobRouteLocation(client));
showCurrentJobLocation(client);
showGameMessage(client, replaceJobRouteStringsInMessage(removeColoursInMessage(getJobRouteData(jobId, getPlayerJobRoute(client)).locationNextMessage), jobId, getPlayerJobRoute(client)), getJobData(jobId).colour, 3500);
}
showGameMessage(client, replaceJobRouteStringsInMessage(removeColoursInMessage(getJobRouteData(jobId, getPlayerJobRoute(client)).locationArriveMessage), jobId, getPlayerJobRoute(client)), getJobData(jobId).colour, 3500);
if(getJobRouteLocationData(jobId, getPlayerJobRoute(client),getPlayerJobRouteLocation(client)).stopDelay > 0) {
freezePlayerJobVehicleForRouteLocation(client);
getPlayerData(client).jobRouteLocation = getNextLocationOnJobRoute(jobId, getPlayerJobRoute(client), getPlayerJobRouteLocation(client));
setTimeout(function() {
showCurrentJobLocation(client);
showGameMessage(client, replaceJobRouteStringsInMessage(removeColoursInMessage(getJobRouteData(jobId, getPlayerJobRoute(client)).locationNextMessage), jobId, getPlayerJobRoute(client)), getJobData(jobId).colour, 3500);
unFreezePlayerJobVehicleForRouteLocation(client);
}, getJobRouteLocationData(jobId, getPlayerJobRoute(client),getPlayerJobRouteLocation(client)).stopDelay);
} else {
getPlayerData(client).jobRouteLocation = getNextLocationOnJobRoute(jobId, getPlayerJobRoute(client), getPlayerJobRouteLocation(client));
showCurrentJobLocation(client);
showGameMessage(client, replaceJobRouteStringsInMessage(removeColoursInMessage(getJobRouteData(jobId, getPlayerJobRoute(client)).locationNextMessage), jobId, getPlayerJobRoute(client)), getJobData(jobId).colour, 3500);
}
}
// ===========================================================================
@@ -2579,14 +2595,14 @@ function createJobRoute(routeName, closestJobLocation) {
tempJobRouteData.vehicleColour1 = 1;
tempJobRouteData.vehicleColour2 = 1;
tempJobRouteData.pay = 500;
tempJobRouteData.jobIndex = closestJobLocation.jobIndex;
tempJobRouteData.jobIndex = closestJobLocation.jobIndex;
tempJobRouteData.startMessage = `You are now on route {ALTCOLOUR}{JOBROUTENAME}{MAINCOLOUR} for the {jobYellow}{JOBNAME}{MAINCOLOUR} job!`;
tempJobRouteData.finishMessage = `You have finished the {ALTCOLOUR}{JOBROUTENAME}{MAINCOLOUR} route and {ALTCOLOUR}{JOBROUTEPAY}{MAINCOLOUR} has been added to your next paycheck!`;
tempJobRouteData.locationArriveMessage = `You arrived at a stop.`;
tempJobRouteData.locationNextMessage = `Drive to the next stop.`;
getJobData(closestJobLocation.jobIndex).routes.push(tempJobRouteData);
saveJobRouteToDatabase(tempJobRouteData);
saveJobRouteToDatabase(tempJobRouteData);
setAllJobDataIndexes();
}
@@ -2599,10 +2615,10 @@ function createJobRouteLocation(routeLocationName, position, jobRouteData) {
tempJobRouteLocationData.enabled = true;
tempJobRouteLocationData.needsSaved = true;
tempJobRouteLocationData.position = position;
tempJobRouteLocationData.routeIndex = jobRouteData.index;
tempJobRouteLocationData.routeIndex = jobRouteData.index;
getJobData(jobRouteData.jobIndex).routes[jobRouteData.index].locations.push(tempJobRouteLocationData);
saveJobRouteLocationToDatabase(tempJobRouteLocationData);
saveJobRouteLocationToDatabase(tempJobRouteLocationData);
setAllJobDataIndexes();
}
@@ -2622,7 +2638,7 @@ function deleteJobRouteLocationCommand(command, params, client) {
getJobData(getJobIdFromDatabaseId(tempJob)).routes[tempJobRoute].locations.splice(tempIndex, 1);
setAllJobDataIndexes();
collectAllGarbage();
collectAllGarbage();
}
// ===========================================================================
@@ -2631,9 +2647,9 @@ function deleteJobRouteCommand(command, params, client) {
let jobId = getPlayerJob(client);
let jobRoute = getPlayerData(client).jobRoute;
if(!areParamsEmpty(client)) {
jobRoute = getJobRouteFromParams(params, jobId);
}
if(!areParamsEmpty(client)) {
jobRoute = getJobRouteFromParams(params, jobId);
}
let jobRouteData = getServerData().jobs[jobId].routes[jobRoute];
@@ -2651,10 +2667,10 @@ function deleteJobRouteCommand(command, params, client) {
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)}{MAINCOLOUR} deleted route {ALTCOLOUR}${jobRouteData.name} (DB ID ${jobRouteData.databaseId}) {MAINCOLOUR}for the {jobYellow}${getJobData(jobId).name}{MAINCOLOUR} job`);
if(jobRouteData.databaseId > 0) {
quickDatabaseQuery(`DELETE FROM job_route WHERE job_route_id = ${jobRouteData.databaseId}`);
quickDatabaseQuery(`DELETE FROM job_route_loc WHERE job_route_loc_route = ${jobRouteData.databaseId}`);
}
if(jobRouteData.databaseId > 0) {
quickDatabaseQuery(`DELETE FROM job_route WHERE job_route_id = ${jobRouteData.databaseId}`);
quickDatabaseQuery(`DELETE FROM job_route_loc WHERE job_route_loc_route = ${jobRouteData.databaseId}`);
}
clearArray(getServerData().jobs[jobId].routes[jobRoute].locations);
getServerData().jobs[jobId].routes.splice(jobRoute, 1);
@@ -2728,7 +2744,7 @@ function getJobPointsInRange(position, distance) {
// ===========================================================================
function respawnJobVehicle(client) {
respawnVehicle(getPlayerJobVehicle(client));
respawnVehicle(getPlayerJobVehicle(client));
}
// ===========================================================================
@@ -2740,12 +2756,12 @@ function getPlayerJobVehicle(client) {
// ===========================================================================
function getRandomJobRouteForLocation(closestJobLocation) {
if(closestJobLocation.routeCache.length > 0) {
let randomRoute = getRandom(0, closestJobLocation.routeCache.length-1);
let routeId = closestJobLocation.routeCache[randomRoute];
return getJobRouteData(closestJobLocation.jobIndex, routeId).index;
}
return -1;
if(closestJobLocation.routeCache.length > 0) {
let randomRoute = getRandom(0, closestJobLocation.routeCache.length-1);
let routeId = closestJobLocation.routeCache[randomRoute];
return getJobRouteData(closestJobLocation.jobIndex, routeId).index;
}
return -1;
}
// ===========================================================================
@@ -2785,58 +2801,58 @@ function getClosestJobLocationForJob(position, jobId) {
// ===========================================================================
function getPlayerJobRoute(client) {
return getPlayerData(client).jobRoute;
return getPlayerData(client).jobRoute;
}
// ===========================================================================
function getPlayerJobRouteLocation(client) {
return getPlayerData(client).jobRouteLocation;
return getPlayerData(client).jobRouteLocation;
}
// ===========================================================================
function showCurrentJobLocation(client) {
let jobId = getPlayerJob(client);
sendJobRouteLocationToPlayer(client, getJobRouteLocationData(jobId, getPlayerJobRoute(client), getPlayerJobRouteLocation(client)).position, getJobData(jobId).colour);
let jobId = getPlayerJob(client);
sendJobRouteLocationToPlayer(client, getJobRouteLocationData(jobId, getPlayerJobRoute(client), getPlayerJobRouteLocation(client)).position, getJobData(jobId).colour);
}
// ===========================================================================
function finishSuccessfulJobRoute(client) {
let jobId = getPlayerJob(client);
let jobRouteData = getJobRouteData(jobId, getPlayerJobRoute(client));
let payout = toInteger(applyServerInflationMultiplier(jobRouteData.pay));
getPlayerData(client).payDayAmount = getPlayerData(client).payDayAmount + payout;
let jobId = getPlayerJob(client);
let jobRouteData = getJobRouteData(jobId, getPlayerJobRoute(client));
let payout = toInteger(applyServerInflationMultiplier(jobRouteData.pay));
getPlayerData(client).payDayAmount = getPlayerData(client).payDayAmount + payout;
messagePlayerSuccess(client, replaceJobRouteStringsInMessage(jobRouteData.finishMessage, jobId, jobRouteData.index));
messagePlayerSuccess(client, replaceJobRouteStringsInMessage(jobRouteData.finishMessage, jobId, jobRouteData.index));
stopReturnToJobVehicleCountdown(client);
sendPlayerStopJobRoute(client);
respawnVehicle(getPlayerData(client).jobRouteVehicle);
stopReturnToJobVehicleCountdown(client);
sendPlayerStopJobRoute(client);
respawnVehicle(getPlayerData(client).jobRouteVehicle);
getPlayerData(client).jobRouteVehicle = false;
getPlayerData(client).jobRoute = -1;
getPlayerData(client).jobRouteLocation = -1;
getPlayerData(client).jobRouteVehicle = false;
getPlayerData(client).jobRoute = -1;
getPlayerData(client).jobRouteLocation = -1;
}
// ===========================================================================
function getNextLocationOnJobRoute(jobId, routeId, currentLocationId) {
if(!isLastLocationOnJobRoute(jobId, routeId, currentLocationId)) {
return currentLocationId+1;
} else {
return getJobRouteData(jobId, routeId).locations.length-1;
}
if(!isLastLocationOnJobRoute(jobId, routeId, currentLocationId)) {
return currentLocationId+1;
} else {
return getJobRouteData(jobId, routeId).locations.length-1;
}
}
// ===========================================================================
function isLastLocationOnJobRoute(jobId, routeId, currentLocationId) {
if(currentLocationId == getJobRouteData(jobId, routeId).locations.length-1) {
return true;
}
return false;
if(currentLocationId == getJobRouteData(jobId, routeId).locations.length-1) {
return true;
}
return false;
}
// ===========================================================================
@@ -2860,21 +2876,21 @@ function getJobRouteFromParams(params, jobId) {
// ===========================================================================
function replaceJobRouteStringsInMessage(messageText, jobId, jobRouteId) {
let tempJobRouteData = getJobRouteData(jobId, jobRouteId);
let tempJobRouteData = getJobRouteData(jobId, jobRouteId);
let tempFind = `{JOBROUTENAME}`;
let tempRegex = new RegExp(tempFind, 'g');
messageText = messageText.replace(tempRegex, tempJobRouteData.name);
tempFind = `{JOBROUTEPAY}`;
tempFind = `{JOBROUTEPAY}`;
tempRegex = new RegExp(tempFind, 'g');
messageText = messageText.replace(tempRegex, `$${tempJobRouteData.pay}`);
tempFind = `{JOBNAME}`;
tempFind = `{JOBNAME}`;
tempRegex = new RegExp(tempFind, 'g');
messageText = messageText.replace(tempRegex, getJobData(tempJobRouteData.jobIndex).name);
return messageText;
return messageText;
}
// ===========================================================================

View File

@@ -8,157 +8,157 @@
// ===========================================================================
function policeTazerCommand(command, params, client) {
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
if(!canPlayerUsePoliceJob(client)) {
messagePlayerError(client, "You are not allowed to use the police job.");
return false;
}
if(!canPlayerUsePoliceJob(client)) {
messagePlayerError(client, "You are not allowed to use the police job.");
return false;
}
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You are not working! Use /startwork first.");
return false;
}
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You are not working! Use /startwork first.");
return false;
}
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
messagePlayerError(client, "You don't have a police job.");
return false;
}
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
messagePlayerError(client, "You don't have a police job.");
return false;
}
return true;
return true;
}
// ===========================================================================
function policeCuffCommand(command, params, client) {
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
if(!canPlayerUsePoliceJob(client)) {
messagePlayerError(client, "You are not allowed to use the police job.");
return false;
}
if(!canPlayerUsePoliceJob(client)) {
messagePlayerError(client, "You are not allowed to use the police job.");
return false;
}
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You are not working! Use /startwork first.");
return false;
}
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You are not working! Use /startwork first.");
return false;
}
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
messagePlayerError(client, "You don't have a police job.");
return false;
}
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
messagePlayerError(client, "You don't have a police job.");
return false;
}
return true;
return true;
}
// ===========================================================================
function policeArrestCommand(command, params, client) {
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
if(!canPlayerUsePoliceJob(client)) {
messagePlayerError(client, "You are not allowed to use the police job.");
return false;
}
if(!canPlayerUsePoliceJob(client)) {
messagePlayerError(client, "You are not allowed to use the police job.");
return false;
}
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You are not working! Use /startwork first.");
return false;
}
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You are not working! Use /startwork first.");
return false;
}
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
messagePlayerError(client, "You don't have a police job.");
return false;
}
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
messagePlayerError(client, "You don't have a police job.");
return false;
}
return true;
return true;
}
// ===========================================================================
function policeSearchCommand(command, params, client) {
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
if(!canPlayerUsePoliceJob(client)) {
messagePlayerError(client, "You are not allowed to use the police job.");
return false;
}
if(!canPlayerUsePoliceJob(client)) {
messagePlayerError(client, "You are not allowed to use the police job.");
return false;
}
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You are not working! Use /startwork first.");
return false;
}
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You are not working! Use /startwork first.");
return false;
}
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
messagePlayerError(client, "You don't have a police job.");
return false;
}
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
messagePlayerError(client, "You don't have a police job.");
return false;
}
return true;
return true;
}
// ===========================================================================
function policeDragCommand(command, params, client) {
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
if(!canPlayerUsePoliceJob(client)) {
messagePlayerError(client, "You are not allowed to use the police job.");
return false;
}
if(!canPlayerUsePoliceJob(client)) {
messagePlayerError(client, "You are not allowed to use the police job.");
return false;
}
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You are not working! Use /startwork first.");
return false;
}
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You are not working! Use /startwork first.");
return false;
}
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
messagePlayerError(client, "You don't have a police job.");
return false;
}
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
messagePlayerError(client, "You don't have a police job.");
return false;
}
return true;
return true;
}
// ===========================================================================
function policeDetainCommand(command, params, client) {
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
if(!canPlayerUsePoliceJob(client)) {
messagePlayerError(client, "You are not allowed to use the police job.");
return false;
}
if(!canPlayerUsePoliceJob(client)) {
messagePlayerError(client, "You are not allowed to use the police job.");
return false;
}
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You are not working! Use /startwork first.");
return false;
}
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You are not working! Use /startwork first.");
return false;
}
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
messagePlayerError(client, "You don't have a police job.");
return false;
}
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
messagePlayerError(client, "You don't have a police job.");
return false;
}
return true;
return true;
}
// ===========================================================================

View File

@@ -8,25 +8,25 @@
// ===========================================================================
function taxiSetFareCommand(command, params, client) {
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
if(!canPlayerUseTaxiJob(client)) {
messagePlayerError(client, "You are not allowed to use the taxi job.");
return false;
}
if(!canPlayerUseTaxiJob(client)) {
messagePlayerError(client, "You are not allowed to use the taxi job.");
return false;
}
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You are not working! Use /startwork first.");
return false;
}
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You are not working! Use /startwork first.");
return false;
}
if(!doesPlayerHaveJobType(client, VRR_JOB_TAXI)) {
messagePlayerError(client, "You don't have a taxi job.");
return false;
}
if(!doesPlayerHaveJobType(client, VRR_JOB_TAXI)) {
messagePlayerError(client, "You don't have a taxi job.");
return false;
}
return true;
}

View File

@@ -1,16 +1,16 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"moduleResolution": "classic"
"module": "commonjs",
"target": "es6",
"moduleResolution": "classic"
},
"include": [
"*.js",
"job/*.js",
"business/*.js",
"item/*.js",
"npc/*.js",
"native/*.js",
"../shared/*.js"
"*.js",
"job/*.js",
"business/*.js",
"item/*.js",
"npc/*.js",
"native/*.js",
"../shared/*.js"
]
}

View File

@@ -10,190 +10,187 @@
function initKeyBindScript() {
logToConsole(LOG_INFO, "[VRR.KeyBind]: Initializing key bind script ...");
getGlobalConfig().keyBind = loadKeyBindConfiguration();
getGlobalConfig().keyBind = loadKeyBindConfiguration();
logToConsole(LOG_INFO, "[VRR.KeyBind]: Key bind script initialized!");
}
// ===========================================================================
function addKeyBindCommand(command, params, client) {
let splitParams = params.split(" ");
let splitParams = params.split(" ");
let keyId = getKeyIdFromParams(getParam(params, " ", 1));
let tempCommand = getParam(params, " ", 2);
let tempParams = (splitParams.length > 2) ? splitParams.slice(2).join(" ") : "";
let keys = getKeysInComboName(getParam(params, " ", 1));
let tempCommand = getParam(params, " ", 2);
let tempParams = (splitParams.length > 2) ? splitParams.slice(2).join(" ") : "";
if(!keyId) {
messagePlayerError(client, "The key ID or name you input is invalid!");
messagePlayerTip(client, "Use simple key names, letters, or numbers. Don't add spaces.");
messagePlayerInfo(client, `Examples: {ALTCOLOUR}1, 2, a, b, numplus, num1, f1, f2, pageup, delete, insert, rightshift, leftctrl`);
return false;
}
if(keys.indexOf(false) != -1) {
messagePlayerError(client, "One of the key names you input is invalid!");
messagePlayerTip(client, "Use simple key names, letters, or numbers. Don't add spaces. Must be lowercase.");
messagePlayerTip(client, "No actual symbols, use a name for those if needed like ampersand, hashtag, tilde, etc");
messagePlayerInfo(client, `Examples: {ALTCOLOUR}1, 2, a, b, numplus, num1, f1, f2, pageup, delete, insert, rightshift, leftctrl`);
messagePlayerInfo(client, `For combos, use a plus sign between the keys. No spaces! Example: {ALTCOLOUR}rightctrl+num3{MAINCOLOUR}`);
return false;
}
if(!keyId) {
messagePlayerError(client, "That key name/id is invalid!");
return false;
}
if(areParamsEmpty(tempCommand)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
if(areParamsEmpty(tempCommand)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
addPlayerKeyBind(client, keyId, tempCommand, tempParams);
messagePlayerSuccess(client, `You binded the {ALTCOLOUR}${toUpperCase(getKeyNameFromId(keyId))} {MAINCOLOUR}key to command: {ALTCOLOUR}/${tempCommand} ${tempParams}`);
addPlayerKeyBind(client, keyId, tempCommand, tempParams);
messagePlayerSuccess(client, `You binded the {ALTCOLOUR}${toUpperCase(keys.join(" + "))} {MAINCOLOUR}keys to command: {ALTCOLOUR}/${tempCommand} ${tempParams}`);
}
// ===========================================================================
function removeKeyBindCommand(command, params, client) {
let splitParams = params.split(" ");
let keyId = getKeyIdFromParams(getParam(params, " ", 1));
let keyId = getKeyIdFromParams(getParam(params, " ", 1));
if(!keyId) {
messagePlayerError(client, "The key ID or name you input is invalid!");
messagePlayerTip(client, "Use simple key names, letters, or numbers. Don't add spaces.");
messagePlayerInfo(client, `Examples: {ALTCOLOUR}1, 2, a, b, numplus, num1, f1, f2, pageup, delete, insert, rightshift, leftctrl`);
return false;
}
if(!keyId) {
messagePlayerError(client, "The key ID or name you input is invalid!");
messagePlayerTip(client, "Use simple key names, letters, or numbers. Don't add spaces.");
messagePlayerInfo(client, `Examples: {ALTCOLOUR}1, 2, a, b, numplus, num1, f1, f2, pageup, delete, insert, rightshift, leftctrl`);
return false;
}
if(!keyId) {
messagePlayerError(client, "That key name/id is invalid!");
return false;
}
if(!keyId) {
messagePlayerError(client, "That key name/id is invalid!");
return false;
}
removePlayerKeyBind(client, keyId);
messagePlayerSuccess(client, `You removed the keybind for the {ALTCOLOUR}${toUpperCase(getKeyNameFromId(keyId))} {MAINCOLOUR}key`);
removePlayerKeyBind(client, keyId);
messagePlayerSuccess(client, `You removed the keybind for the {ALTCOLOUR}${toUpperCase(getKeyNameFromId(keyId))} {MAINCOLOUR}key`);
}
// ===========================================================================
function addPlayerKeyBind(client, keys, command, params, tempKey = false) {
let keyBindData = new KeyBindData(false, keys, `${command} ${params}`);
if(tempKey == true) {
keyBindData.databaseId = -1;
}
let keyBindData = new KeyBindData(false, keys, `${command} ${params}`);
if(tempKey == true) {
keyBindData.databaseId = -1;
}
getPlayerData(client).keyBinds.push(keyBindData);
sendAddAccountKeyBindToClient(client, keys, (keys.length > 1) ? VRR_KEYSTATE_COMBO : VRR_KEYSTATE_UP);
keyBindData.needsSaved = true;
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "enter")) {
let keyId = getPlayerKeyBindForCommand(client, "enter");
logToConsole(LOG_DEBUG, `[VRR.Event] Sending custom enter property key ID (${keyId.key}, ${toUpperCase(getKeyNameFromId(keyId.key))}) to ${getPlayerDisplayForConsole(client)}`);
sendPlayerEnterPropertyKey(client, keyId.key);
} else {
sendPlayerEnterPropertyKey(client, false);
}
getPlayerData(client).keyBinds.push(keyBindData);
sendAddAccountKeyBindToClient(client, keys, (keys.length > 1) ? VRR_KEYSTATE_COMBO : VRR_KEYSTATE_UP);
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "enter")) {
let keyId = getPlayerKeyBindForCommand(client, "enter");
logToConsole(LOG_DEBUG, `[VRR.Event] Sending custom enter property key ID (${keyId.key}, ${toUpperCase(getKeyNameFromId(keyId.key))}) to ${getPlayerDisplayForConsole(client)}`);
sendPlayerEnterPropertyKey(client, keyId.key);
} else {
sendPlayerEnterPropertyKey(client, false);
}
}
// ===========================================================================
function removePlayerKeyBind(client, keyId) {
if(isPlayerLoggedIn(client)) {
quickDatabaseQuery(`DELETE FROM acct_hotkey WHERE acct_hotkey_acct = ${getPlayerData(client).accountData.databaseId} AND acct_hotkey_key = ${keyId}`);
}
if(isPlayerLoggedIn(client)) {
quickDatabaseQuery(`DELETE FROM acct_hotkey WHERE acct_hotkey_acct = ${getPlayerData(client).accountData.databaseId} AND acct_hotkey_key = ${keyId}`);
}
for(let i in getPlayerData(client).keyBinds) {
if(getPlayerData(client).keyBinds[i].key == keyId) {
getPlayerData(client).keyBinds.splice(i, 1);
}
}
sendRemoveAccountKeyBindToClient(client, keyId);
for(let i in getPlayerData(client).keyBinds) {
if(getPlayerData(client).keyBinds[i].key == keyId) {
getPlayerData(client).keyBinds.splice(i, 1);
}
}
sendRemoveAccountKeyBindToClient(client, keyId);
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "enter")) {
let keyId = getPlayerKeyBindForCommand(client, "enter");
logToConsole(LOG_DEBUG, `[VRR.Event] Sending custom enter property key ID (${keyId.key}, ${toUpperCase(getKeyNameFromId(keyId.key))}) to ${getPlayerDisplayForConsole(client)}`);
sendPlayerEnterPropertyKey(client, keyId.key);
} else {
sendPlayerEnterPropertyKey(client, false);
}
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "enter")) {
let keyId = getPlayerKeyBindForCommand(client, "enter");
logToConsole(LOG_DEBUG, `[VRR.Event] Sending custom enter property key ID (${keyId.key}, ${toUpperCase(getKeyNameFromId(keyId.key))}) to ${getPlayerDisplayForConsole(client)}`);
sendPlayerEnterPropertyKey(client, keyId.key);
} else {
sendPlayerEnterPropertyKey(client, false);
}
}
// ===========================================================================
function doesPlayerHaveKeyBindForCommand(client, command) {
for(let i in getPlayerData(client).keyBinds) {
if(toLowerCase(getPlayerData(client).keyBinds[i].commandString.split(" ")[0]) == toLowerCase(command)) {
return true;
}
}
return false;
for(let i in getPlayerData(client).keyBinds) {
if(toLowerCase(getPlayerData(client).keyBinds[i].commandString.split(" ")[0]) == toLowerCase(command)) {
return true;
}
}
return false;
}
// ===========================================================================
function getPlayerKeyBindForCommand(client, command) {
for(let i in getPlayerData(client).keyBinds) {
if(toLowerCase(getPlayerData(client).keyBinds[i].commandString.split(" ")[0]) == toLowerCase(command)) {
return getPlayerData(client).keyBinds[i];
}
}
return false;
for(let i in getPlayerData(client).keyBinds) {
if(toLowerCase(getPlayerData(client).keyBinds[i].commandString.split(" ")[0]) == toLowerCase(command)) {
return getPlayerData(client).keyBinds[i];
}
}
return false;
}
// ===========================================================================
function doesPlayerHaveKeyBindForKey(client, key) {
for(let i in getPlayerData(client).keyBinds) {
if(getPlayerData(client).keyBinds[i].key == key) {
return true;
}
}
return false;
for(let i in getPlayerData(client).keyBinds) {
if(getPlayerData(client).keyBinds[i].key == key) {
return true;
}
}
return false;
}
// ===========================================================================
function doesPlayerHaveKeyBindsDisabled(client) {
return hasBitFlag(getPlayerData(client).accountData.settings, getAccountSettingsFlagValue("NoKeyBinds"));
return hasBitFlag(getPlayerData(client).accountData.settings, getAccountSettingsFlagValue("NoKeyBinds"));
}
// ===========================================================================
function getPlayerKeyBindForKey(client, key) {
for(let i in getPlayerData(client).keyBinds) {
if(getPlayerData(client).keyBinds[i].key == key) {
return getPlayerData(client).keyBinds[i];
}
}
return false;
for(let i in getPlayerData(client).keyBinds) {
if(getPlayerData(client).keyBinds[i].key == key) {
return getPlayerData(client).keyBinds[i];
}
}
return false;
}
// ===========================================================================
function playerUsedKeyBind(client, key) {
if(!isPlayerLoggedIn(client)) {
return false;
}
if(!isPlayerLoggedIn(client)) {
return false;
}
if(!isPlayerSpawned(client)) {
return false;
}
if(!isPlayerSpawned(client)) {
return false;
}
logToConsole(LOG_DEBUG, `[VRR.KeyBind] ${getPlayerDisplayForConsole(client)} used keybind ${toUpperCase(getKeyNameFromId(key))} (${key})`);
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForKey(client, key)) {
let keyBindData = getPlayerKeyBindForKey(client, key);
if(keyBindData.enabled) {
let splitCommandString = keyBindData.commandString.split(" ");
let tempCommand = splitCommandString[0];
let tempParams = "";
if(splitCommandString.length > 1) {
tempParams = splitCommandString.slice(1).join(" ");
}
getCommand(toLowerCase(tempCommand)).handlerFunction(tempCommand, tempParams, client);
//triggerEvent("OnPlayerCommand", null, tempCommand, tempParams, client);
}
}
logToConsole(LOG_DEBUG, `[VRR.KeyBind] ${getPlayerDisplayForConsole(client)} used keybind ${toUpperCase(getKeyNameFromId(key))} (${key})`);
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForKey(client, key)) {
let keyBindData = getPlayerKeyBindForKey(client, key);
if(keyBindData.enabled) {
let splitCommandString = keyBindData.commandString.split(" ");
let tempCommand = splitCommandString[0];
let tempParams = "";
if(splitCommandString.length > 1) {
tempParams = splitCommandString.slice(1).join(" ");
}
getCommand(toLowerCase(tempCommand)).handlerFunction(tempCommand, tempParams, client);
//triggerEvent("OnPlayerCommand", null, tempCommand, tempParams, client);
}
}
}
// ===========================================================================
function sendAccountKeyBindsToClient(client) {
sendClearKeyBindsToClient(client);
for(let i in getPlayerData(client).keyBinds) {
sendAddAccountKeyBindToClient(client, getPlayerData(client).keyBinds[i].key, getPlayerData(client).keyBinds[i].keyState);
}
sendClearKeyBindsToClient(client);
for(let i in getPlayerData(client).keyBinds) {
sendAddAccountKeyBindToClient(client, getPlayerData(client).keyBinds[i].key, getPlayerData(client).keyBinds[i].keyState);
}
}
// ===========================================================================
@@ -217,4 +214,29 @@ function showKeyBindListCommand(command, params, client) {
}
}
// ===========================================================================
function getKeyNamesInComboName(comboName) {
if(comboName.indexOf("+") != -1) {
return comboName.split("+");
} else {
return [comboName];
}
}
// ===========================================================================
function getKeysInComboName(comboName) {
let keyNames = getKeyNamesInComboName(comboName);
let keys = [];
for(let i in keyNames) {
if(getKeyIdFromParams(keyNames[i])) {
keys.push(getKeyIdFromParams(keyNames[i]));
} else {
keys.push(false);
}
}
return keys
}
// ===========================================================================

View File

@@ -12,16 +12,16 @@ let translateURL = "http://api.mymemory.translated.net/get?de={3}&q={0}&langpair
// ===========================================================================
function initLocaleScript() {
logToConsole(LOG_INFO, "[VRR.Locale]: Initializing locale script ...");
getServerData().localeStrings = loadAllLocaleStrings();
logToConsole(LOG_INFO, "[VRR.Locale]: Initializing locale script ...");
getServerData().localeStrings = loadAllLocaleStrings();
// Translation Cache
getServerData().cachedTranslations = new Array(getGlobalConfig().locale.locales.length);
getServerData().cachedTranslationFrom = new Array(getGlobalConfig().locale.locales.length);
getServerData().cachedTranslationFrom.fill([]);
getServerData().cachedTranslations.fill(getServerData().cachedTranslationFrom);
// Translation Cache
getServerData().cachedTranslations = new Array(getGlobalConfig().locale.locales.length);
getServerData().cachedTranslationFrom = new Array(getGlobalConfig().locale.locales.length);
getServerData().cachedTranslationFrom.fill([]);
getServerData().cachedTranslations.fill(getServerData().cachedTranslationFrom);
getGlobalConfig().locale.defaultLanguageId = getLocaleFromParams(getGlobalConfig().locale.defaultLanguageId);
getGlobalConfig().locale.defaultLanguageId = getLocaleFromParams(getGlobalConfig().locale.defaultLanguageId);
logToConsole(LOG_INFO, "[VRR.Locale]: Locale script initialized!");
}
@@ -29,68 +29,83 @@ function initLocaleScript() {
// ===========================================================================
function getLocaleString(client, stringName, ...args) {
let tempString = getRawLocaleString(stringName, getPlayerData(client).locale);
if(tempString == "") {
submitBugReport(client, `(AUTOMATED REPORT) Locale string "${stringName}" is missing for "${getPlayerLocaleName(client)}"`);
}
let tempString = getRawLocaleString(stringName, getPlayerData(client).locale);
if(tempString == "") {
submitBugReport(client, `(AUTOMATED REPORT) Locale string "${stringName}" is missing for "${getPlayerLocaleName(client)}"`);
}
for(let i = 1; i <= args.length; i++) {
tempString = tempString.replace(`{${i}}`, args[i-1]);
}
for(let i = 1; i <= args.length; i++) {
tempString = tempString.replace(`{${i}}`, args[i-1]);
}
return tempString;
return tempString;
}
// ===========================================================================
function getLanguageLocaleString(localeId, stringName, ...args) {
let tempString = getRawLocaleString(stringName, localeId);
if(tempString == "") {
submitBugReport(client, `(AUTOMATED REPORT) Locale string "${stringName}" is missing for "${getPlayerLocaleName(client)}"`);
}
for(let i = 1; i <= args.length; i++) {
tempString = tempString.replace(`{${i}}`, args[i-1]);
}
return tempString;
}
// ===========================================================================
function getGroupedLocaleString(client, stringName, index, ...args) {
let tempString = getRawGroupedLocaleString(stringName, getPlayerData(client).locale, index);
let tempString = getRawGroupedLocaleString(stringName, getPlayerData(client).locale, index);
for(let i = 1; i <= args.length; i++) {
tempString = tempString.replace(`{${i}}`, args[i-1]);
}
for(let i = 1; i <= args.length; i++) {
tempString = tempString.replace(`{${i}}`, args[i-1]);
}
return tempString;
return tempString;
}
// ===========================================================================
function getRawLocaleString(stringName, localeName) {
return getLocaleStrings()[localeName][stringName];
function getRawLocaleString(stringName, localeId) {
return getLocaleStrings()[localeId][stringName];
}
// ===========================================================================
function getRawGroupedLocaleString(stringName, localeName, index) {
return getLocaleStrings()[localeName][stringName][index];
function getRawGroupedLocaleString(stringName, localeId, index) {
return getLocaleStrings()[localeId][stringName][index];
}
// ===========================================================================
function getPlayerLocaleName(client) {
let localeId = getPlayerData(client).locale;
return getLocales()[localeId][0];
let localeId = getPlayerData(client).locale;
return getLocales()[localeId].englishName;
}
// ===========================================================================
function loadAllLocaleStrings() {
let tempLocaleStrings = {};
let tempLocaleStrings = {};
let locales = getGlobalConfig().locale.locales;
for(let i in locales) {
let localeData = locales[i];
let localeFile = JSON.parse(loadTextFile(`locale/${localeData[1]}.json`));
tempLocaleStrings[i] = localeFile;
}
let locales = getGlobalConfig().locale.locales;
for(let i in locales) {
let localeData = locales[i];
let localeFile = JSON.parse(loadTextFile(`locale/${localeData.stringsFile}`));
tempLocaleStrings[i] = localeFile;
}
return tempLocaleStrings;
return tempLocaleStrings;
}
// ===========================================================================
function getLocaleStrings() {
return getServerData().localeStrings;
return getServerData().localeStrings;
}
// ===========================================================================
@@ -99,11 +114,11 @@ function getLocaleFromParams(params) {
let locales = getLocales();
if(isNaN(params)) {
for(let i in locales) {
if(toLowerCase(locales[i][2]).indexOf(toLowerCase(params)) != -1) {
if(toLowerCase(locales[i].isoCode).indexOf(toLowerCase(params)) != -1) {
return i;
}
if(toLowerCase(locales[i][0]).indexOf(toLowerCase(params)) != -1) {
if(toLowerCase(locales[i].englishName).indexOf(toLowerCase(params)) != -1) {
return i;
}
}
@@ -115,7 +130,7 @@ function getLocaleFromParams(params) {
// ===========================================================================
function getLocales() {
return getGlobalConfig().locale.locales;
return getGlobalConfig().locale.locales;
}
// ===========================================================================
@@ -138,41 +153,42 @@ function setLocaleCommand(command, params, client) {
return false;
}
let localeId = getLocaleFromParams(params);
let localeId = getLocaleFromParams(params);
if(!getLocaleData(localeId)) {
messagePlayerInfo(client, getLocaleString(client, "InvalidLocale"));
return false;
}
if(!getLocaleData(localeId)) {
messagePlayerInfo(client, getLocaleString(client, "InvalidLocale"));
return false;
}
getPlayerData(client).accountData.locale = localeId;
getPlayerData(client).locale = localeId;
messagePlayerSuccess(client, getLocaleString(client, "LocaleChanged1"), getLocaleString(client, "LocaleNativeName"));
getPlayerData(client).accountData.locale = localeId;
getPlayerData(client).locale = localeId;
messagePlayerSuccess(client, getLocaleString(client, "LocaleChanged1", getLocaleString(client, "LocaleNativeName")));
sendPlayerLocaleStrings(client);
}
// ===========================================================================
function getLocaleData(localeId) {
if(typeof getLocales()[localeId] != "undefined") {
return getLocales()[localeId];
}
if(typeof getLocales()[localeId] != "undefined") {
return getLocales()[localeId];
}
return false;
return false;
}
// ===========================================================================
function reloadLocaleConfigurationCommand(command, params, client) {
getGlobalConfig().locale = loadLocaleConfig();
getServerData().localeStrings = loadAllLocaleStrings();
getServerData().localeStrings = loadAllLocaleStrings();
// Translation Cache
getServerData().cachedTranslations = new Array(getGlobalConfig().locale.locales.length);
getServerData().cachedTranslationFrom = new Array(getGlobalConfig().locale.locales.length);
getServerData().cachedTranslationFrom.fill([]);
getServerData().cachedTranslations.fill(getServerData().cachedTranslationFrom);
// Translation Cache
getServerData().cachedTranslations = new Array(getGlobalConfig().locale.locales.length);
getServerData().cachedTranslationFrom = new Array(getGlobalConfig().locale.locales.length);
getServerData().cachedTranslationFrom.fill([]);
getServerData().cachedTranslations.fill(getServerData().cachedTranslationFrom);
getGlobalConfig().locale.defaultLanguageId = getLocaleFromParams(getGlobalConfig().locale.defaultLanguage);
getGlobalConfig().locale.defaultLanguageId = getLocaleFromParams(getGlobalConfig().locale.defaultLanguage);
messageAdmins(`${client.name}{MAINCOLOUR} has reloaded the locale settings and texts`);
}
@@ -181,18 +197,19 @@ function reloadLocaleConfigurationCommand(command, params, client) {
async function translateMessage(messageText, translateFrom = getGlobalConfig().locale.defaultLanguageId, translateTo = getGlobalConfig().locale.defaultLanguageId) {
return new Promise(resolve => {
if(translateFrom == translateTo) {
resolve(messageText);
}
if(translateFrom == translateTo) {
resolve(messageText);
}
for(let i in cachedTranslations[translateFrom][translateTo]) {
if(cachedTranslations[translateFrom][translateTo][i][0] == messageText) {
logToConsole(LOG_DEBUG, `[Translate]: Using existing translation for ${getGlobalConfig().locale.locales[translateFrom][0]} to ${getGlobalConfig().locale.locales[translateTo][0]} - (${messageText}), (${cachedTranslations[translateFrom][translateTo][i][1]})`);
logToConsole(LOG_DEBUG, `[Translate]: Using existing translation for ${getGlobalConfig().locale.locales[translateFrom].englishName} to ${getGlobalConfig().locale.locales[translateTo].englishName} - (${messageText}), (${cachedTranslations[translateFrom][translateTo][i][1]})`);
resolve(cachedTranslations[translateFrom][translateTo][i][1]);
return true;
}
}
let thisTranslationURL = translateURL.format(encodeURI(messageText), toUpperCase(getGlobalConfig().locale.locales[translateFrom][2]), toUpperCase(getGlobalConfig().locale.locales[translateTo][2]), getGlobalConfig().locale.apiEmail);
let thisTranslationURL = translateURL.format(encodeURI(messageText), toUpperCase(getGlobalConfig().locale.locales[translateFrom].isoCode), toUpperCase(getGlobalConfig().locale.locales[translateTo].isoCode), getGlobalConfig().locale.apiEmail);
httpGet(
thisTranslationURL,
"",

View File

@@ -14,11 +14,14 @@ function initMessagingScript() {
// ===========================================================================
function messageAdminAction(messageText) {
messagePlayerNormal(null, `⚠️ ${messageText}`, getColourByName("orange"));
if(getServerConfig().discordEnabled) {
messageDiscord(`:warning: ${messageText}`);
}
function announceAdminAction(localeString, ...args) {
let clients = getClients();
for(let i in clients) {
let messageText = getLocaleString.apply(null, [clients[i], localeString, args]);
messagePlayerNormal(clients[i], `⚠️ ${messageText}`, getColourByName("orange"));
}
messageDiscordEventChannel(getLanguageLocaleString.apply(null, [0, localeString, args]));
}
// ===========================================================================
@@ -33,196 +36,195 @@ function messageAdminAction(messageText) {
*
*/
function messagePlayerNormal(client, messageText, colour = COLOUR_WHITE) {
//if(isConsole(client) || client == null) {
// logToConsole(LOG_INFO, `${removeColoursInMessage(messageText)}`);
//}
//if(isConsole(client) || client == null) {
// logToConsole(LOG_INFO, `${removeColoursInMessage(messageText)}`);
//}
messageText = replaceColoursInMessage(messageText);
//messageText = replaceColoursInMessage(messageText);
if(client == null) {
message(messageText, colour);
} else {
messageClient(messageText, client, colour);
}
//if(client == null) {
// message(messageText, colour);
//} else {
// messageClient(messageText, client, colour);
//}
//sendChatBoxMessageToPlayer(client, messageText, colour);
return true;
sendChatBoxMessageToPlayer(client, messageText, colour);
return true;
}
// ===========================================================================
function messageAdmins(messageText, colour = getColourByName("softRed")) {
//let plainMessage = removeColoursInMessage(messageText);
//console.warn(`🛡️ ${plainMessage}`);
//
//console.warn(`🛡️ ${plainMessage}`);
let clients = getClients();
for(let i in clients) {
if(doesPlayerHaveStaffPermission(clients[i], getStaffFlagValue("BasicModeration"))) {
messagePlayerNormal(clients[i], `🛡️ ${messageText}`, colour);
}
}
let clients = getClients();
for(let i in clients) {
if(doesPlayerHaveStaffPermission(clients[i], getStaffFlagValue("BasicModeration"))) {
messagePlayerNormal(clients[i], `🛡️ ${messageText}`, colour);
}
}
//if(getServerConfig().discordConfig.sendAdminEvents) {
// messageDiscordAdminChannel(plainMessage);
//}
let plainMessage = removeColoursInMessage(messageText);
messageDiscordAdminChannel(plainMessage);
}
// ===========================================================================
function messagePlayerError(client, messageText) {
if(isConsole(client)) {
logToConsole(LOG_INFO, `${messageText}`);
return true;
}
if(isConsole(client)) {
logToConsole(LOG_INFO, `${messageText}`);
return true;
}
if(!isClientFromDiscord(client)) {
messagePlayerNormal(client, `${messageText}`, getColourByName("white"));
} else {
messageDiscordUser(client, `${messageText}`);
}
if(!isClientFromDiscord(client)) {
messagePlayerNormal(client, `${messageText}`, getColourByName("white"));
} else {
messageDiscordUser(client, `${messageText}`);
}
}
// ===========================================================================
function messagePlayerSyntax(client, messageText) {
if(isConsole(client)) {
logToConsole(LOG_INFO, `⌨️ ${messageText}`);
return true;
}
if(isConsole(client)) {
logToConsole(LOG_INFO, `⌨️ ${messageText}`);
return true;
}
if(!isClientFromDiscord(client)) {
messagePlayerNormal(client, `⌨️ USAGE: {MAINCOLOUR} ${messageText}`, getColourByType("syntaxMessage"));
} else {
messageDiscordUser(client, `⌨️ ${messageText}`);
}
if(!isClientFromDiscord(client)) {
messagePlayerNormal(client, `⌨️ USAGE: {MAINCOLOUR} ${messageText}`, getColourByType("syntaxMessage"));
} else {
messageDiscordUser(client, `⌨️ ${messageText}`);
}
}
// ===========================================================================
function messagePlayerAlert(client, messageText) {
if(isConsole(client)) {
logToConsole(LOG_INFO, `⚠️ ${messageText}`);
return true;
}
if(isConsole(client)) {
logToConsole(LOG_INFO, `⚠️ ${messageText}`);
return true;
}
if(!isClientFromDiscord(client)) {
messagePlayerNormal(client, `⚠️ ${messageText}`, getColourByName("white"));
} else {
messageDiscordUser(client, `⚠️ ${messageText}`);
}
if(!isClientFromDiscord(client)) {
messagePlayerNormal(client, `⚠️ ${messageText}`, getColourByName("white"));
} else {
messageDiscordUser(client, `⚠️ ${messageText}`);
}
}
// ===========================================================================
function messagePlayerSuccess(client, messageText) {
if(isConsole(client)) {
logToConsole(LOG_INFO, `✔️ ${messageText}`);
return true;
}
if(isConsole(client)) {
logToConsole(LOG_INFO, `✔️ ${messageText}`);
return true;
}
if(!isClientFromDiscord(client)) {
messagePlayerNormal(client, `✔️ ${messageText}`, getColourByName("white"));
} else {
messageDiscordUser(client, `✔️ ${messageText}`);
}
if(!isClientFromDiscord(client)) {
messagePlayerNormal(client, `✔️ ${messageText}`, getColourByName("white"));
} else {
messageDiscordUser(client, `✔️ ${messageText}`);
}
}
// ===========================================================================
function messagePlayerInfo(client, messageText) {
if(isConsole(client)) {
logToConsole(LOG_INFO, ` ${messageText}`);
return true;
}
if(isConsole(client)) {
logToConsole(LOG_INFO, ` ${messageText}`);
return true;
}
if(!isClientFromDiscord(client)) {
messagePlayerNormal(client, ` ${messageText}`, getColourByName("white"));
} else {
messageDiscordUser(client, `:information_source: ${messageText}`);
}
if(!isClientFromDiscord(client)) {
messagePlayerNormal(client, ` ${messageText}`, getColourByName("white"));
} else {
messageDiscordUser(client, `:information_source: ${messageText}`);
}
}
// ===========================================================================
function messagePlayerTip(client, messageText) {
if(isConsole(client)) {
logToConsole(LOG_INFO, ` ${messageText}`);
return true;
}
if(isConsole(client)) {
logToConsole(LOG_INFO, ` ${messageText}`);
return true;
}
if(!isClientFromDiscord(client)) {
messagePlayerNormal(client, ` ${messageText}`, getColourByName("white"));
} else {
messageDiscordUser(client, `:information_source: ${messageText}`);
}
if(!isClientFromDiscord(client)) {
messagePlayerNormal(client, ` ${messageText}`, getColourByName("white"));
} else {
messageDiscordUser(client, `:information_source: ${messageText}`);
}
}
// ===========================================================================
function messagePlayerTalk(client, talkingClient, messageText) {
messagePlayerNormal(client, `🗣️ ${getPlayerAccentInlineOutput(talkingClient)}${getClientSubAccountName(talkingClient)} says: ${messageText}`, getColourByType("talkMessage"));
messagePlayerNormal(client, `🗣️ ${getPlayerAccentInlineOutput(talkingClient)}${getClientSubAccountName(talkingClient)} says: ${messageText}`, getColourByType("talkMessage"));
}
// ===========================================================================
function messagePlayerWhisper(client, whisperingClient, messageText) {
messagePlayerNormal(client, `🤫 ${getPlayerAccentInlineOutput(whisperingClient)}${getClientSubAccountName(whisperingClient)} whispers: ${messageText}`, getColourByType("whisperMessage"));
messagePlayerNormal(client, `🤫 ${getPlayerAccentInlineOutput(whisperingClient)}${getClientSubAccountName(whisperingClient)} whispers: ${messageText}`, getColourByType("whisperMessage"));
}
// ===========================================================================
function messagePlayerMegaPhone(client, shoutingClient, messageText) {
messagePlayerNormal(client, `📢 ${getPlayerAccentInlineOutput(shoutingClient)}${getClientSubAccountName(shoutingClient)} (megaphone): ${messageText}!`, getColourByType("yellow"));
messagePlayerNormal(client, `📢 ${getPlayerAccentInlineOutput(shoutingClient)}${getClientSubAccountName(shoutingClient)} (megaphone): ${messageText}!`, getColourByType("yellow"));
}
// ===========================================================================
function messagePlayerShout(client, shoutingClient, messageText) {
messagePlayerNormal(client, `🗣️ ${getPlayerAccentInlineOutput(shoutingClient)}${getClientSubAccountName(shoutingClient)} shouts: ${messageText}!`, getColourByType("shoutMessage"));
messagePlayerNormal(client, `🗣️ ${getPlayerAccentInlineOutput(shoutingClient)}${getClientSubAccountName(shoutingClient)} shouts: ${messageText}!`, getColourByType("shoutMessage"));
}
// ===========================================================================
function messagePlayerDoAction(client, doingActionClient, messageText) {
if(!isClientFromDiscord(client)) {
messagePlayerNormal(client, `${messageText} * (${getClientSubAccountName(doingActionClient)})`, getColourByType("doActionMessage"));
}
if(!isClientFromDiscord(client)) {
messagePlayerNormal(client, `${messageText} * (${getClientSubAccountName(doingActionClient)})`, getColourByType("doActionMessage"));
}
}
// ===========================================================================
function messagePlayerMeAction(client, doingActionClient, messageText) {
messagePlayerNormal(client, `${getClientSubAccountName(doingActionClient)} ${messageText}`, getColourByType("meActionMessage"));
messagePlayerNormal(client, `${getClientSubAccountName(doingActionClient)} ${messageText}`, getColourByType("meActionMessage"));
}
// ===========================================================================
function messagePlayerClanChat(client, clanChattingClient, messageText) {
messagePlayerNormal(client, `👥 ${getInlineChatColourByName("clanOrange")}${(getPlayerClanRankName(clanChattingClient) != false) ? getPlayerClanRankName(clanChattingClient) : "No Rank"} ${getCharacterFullName(clanChattingClient)} {MAINCOLOUR}says (clan): {ALTCOLOUR}${messageText}`, getColourByType("clanChatMessage"));
messagePlayerNormal(client, `👥 ${getInlineChatColourByName("clanOrange")}${(getPlayerClanRankName(clanChattingClient) != false) ? getPlayerClanRankName(clanChattingClient) : "No Rank"} ${getCharacterFullName(clanChattingClient)} {MAINCOLOUR}says (clan): {ALTCOLOUR}${messageText}`, getColourByType("clanChatMessage"));
}
// ===========================================================================
function messagePlayerAdminChat(client, adminChattingClient, messageText) {
messagePlayerNormal(client, `🛡️ [ADMIN CHAT] {ALTCOLOUR}${getPlayerData(adminChattingClient).accountData.staffTitle} [#CCCCCC]${getPlayerData(adminChattingClient).accountData.name}: {MAINCOLOUR}${messageText}`, getColourByType("orange"));
messagePlayerNormal(client, `🛡️ [ADMIN CHAT] {ALTCOLOUR}${getPlayerData(adminChattingClient).accountData.staffTitle} [#CCCCCC]${getPlayerData(adminChattingClient).accountData.name}: {MAINCOLOUR}${messageText}`, getColourByType("orange"));
}
// ===========================================================================
function messagePlayerNewbieTip(client, message) {
if(!hasBitFlag(getPlayerData(client).accountData.settings, getAccountSettingsFlagValue("NoActionTips"))) {
messagePlayerNormal(client, `💡 ${message}`);
}
if(!hasBitFlag(getPlayerData(client).accountData.settings, getAccountSettingsFlagValue("NoActionTips"))) {
messagePlayerNormal(client, `💡 ${message}`);
}
}
// ===========================================================================
function messagePlayerTimedRandomTip(client, message) {
if(isPlayerLoggedIn(client) && isPlayerSpawned(client)) {
if(!hasBitFlag(getPlayerData(client).accountData.settings, getAccountSettingsFlagValue("NoRandomTips"))) {
messagePlayerNormal(client, `💡 ${message}`);
}
}
if(isPlayerLoggedIn(client) && isPlayerSpawned(client)) {
if(!hasBitFlag(getPlayerData(client).accountData.settings, getAccountSettingsFlagValue("NoRandomTips"))) {
messagePlayerNormal(client, `💡 ${message}`);
}
}
}
// ===========================================================================
@@ -245,7 +247,7 @@ function clearChatBox(client) {
// ===========================================================================
function messagePlayerHelpContent(client, messageString) {
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}${messageString}`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}${messageString}`);
}
// ===========================================================================

View File

@@ -35,19 +35,23 @@ function toggleMouseCursorCommand(command, params, client) {
// ===========================================================================
function toggleMouseCameraCommand(command, params, client) {
sendPlayerMouseCameraToggle(client);
if(getGame() != VRR_GAME_GTA_VC) {
sendPlayerMouseCameraToggle(client);
}
return true;
}
// ===========================================================================
function setNewCharacterSpawnPositionCommand(command, params, client) {
let position = client.player.position;
let position = getPlayerPosition(client);
let heading = getPlayerHeading(client);
getServerConfig().newCharacter.spawnPosition = position;
getServerConfig().newCharacter.spawnHeading = client.player.heading;
getServerConfig().newCharacter.spawnHeading = heading;
getServerConfig().needsSaved = true;
messagePlayerNormal(client, `The new character spawn position has been set to ${position.x.toFixed(2)}, ${position.y.toFixed(2)}, ${position.z.toFixed(2)}`)
messagePlayerNormal(client, `The new character spawn position has been set to ${position.x.toFixed(2)}, ${position.y.toFixed(2)}, ${position.z.toFixed(2)}`)
return true;
}
@@ -64,7 +68,7 @@ let amount = toInteger(getParam(params, " ", 1)) || 1000;
getServerConfig().newCharacter.cash = amount;
getServerConfig().needsSaved = true;
messagePlayerNormal(client, `The new character money has been set to $${amount}`);
messagePlayerNormal(client, `The new character money has been set to $${amount}`);
return true;
}
@@ -81,7 +85,7 @@ function setNewCharacterSkinCommand(command, params, client) {
getServerConfig().newCharacter.skin = skinId;
getServerConfig().needsSaved = true;
messagePlayerNormal(client, `The new character skin has been set to ${getSkinNameFromModel(skinId)} (Index ${skinId})`);
messagePlayerNormal(client, `The new character skin has been set to ${getSkinNameFromModel(skinId)} (Index ${skinId})`);
return true;
}
@@ -95,7 +99,7 @@ function submitIdeaCommand(command, params, client) {
submitIdea(client, params);
messagePlayerNormal(client, `Your suggestion/idea has been sent to the developers!`);
messagePlayerNormal(client, `Your suggestion/idea has been sent to the developers!`);
return true;
}
@@ -109,7 +113,7 @@ function submitBugReportCommand(command, params, client) {
submitBugReport(client, params);
messagePlayerNormal(client, `Your bug report has been sent to the developers!`);
messagePlayerNormal(client, `Your bug report has been sent to the developers!`);
return true;
}
@@ -127,47 +131,47 @@ function enterExitPropertyCommand(command, params, client) {
let ownerType = getEntityData(getPlayerData(client).currentPickup, "vrr.owner.type");
let ownerId = getEntityData(getPlayerData(client).currentPickup, "vrr.owner.id");
switch(ownerType) {
case VRR_PICKUP_BUSINESS_ENTRANCE:
isBusiness = true;
isEntrance = true;
closestProperty = getServerData().businesses[ownerId];
break;
case VRR_PICKUP_BUSINESS_EXIT:
isBusiness = true;
isEntrance = false;
closestProperty = getServerData().businesses[ownerId];
break;
case VRR_PICKUP_HOUSE_ENTRANCE:
isBusiness = false;
isEntrance = true;
closestProperty = getServerData().houses[ownerId];
break;
case VRR_PICKUP_HOUSE_EXIT:
isBusiness = false;
isEntrance = false;
closestProperty = getServerData().houses[ownerId];
break;
default:
return false;
}
}
} else {
for(let i in getServerData().businesses) {
if(getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()] && getPlayerInterior(client) == getGameConfig().mainWorldInterior[getGame()]) {
let businessId = getClosestBusinessEntrance(getPlayerPosition(client), getPlayerDimension(client));
isBusiness = true;
isEntrance = true;
closestProperty = getServerData().businesses[businessId];
closestProperty = getServerData().businesses[businessId];
} else {
let businessId = getClosestBusinessExit(getPlayerPosition(client), getPlayerDimension(client));
isBusiness = true;
isEntrance = false;
closestProperty = getServerData().businesses[businessId];
closestProperty = getServerData().businesses[businessId];
}
}
@@ -176,12 +180,12 @@ function enterExitPropertyCommand(command, params, client) {
let houseId = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client));
isBusiness = false;
isEntrance = true;
closestProperty = getServerData().businesses[houseId];
closestProperty = getServerData().businesses[houseId];
} else {
let houseId = getClosestHouseExit(getPlayerPosition(client), getPlayerDimension(client));
isBusiness = false;
isEntrance = false;
closestProperty = getServerData().businesses[houseId];
closestProperty = getServerData().businesses[houseId];
}
}
}
@@ -213,6 +217,7 @@ function enterExitPropertyCommand(command, params, client) {
}
setTimeout(function() {
setPlayerInCutsceneInterior(client, closestProperty.exitCutscene);
setPlayerPosition(client, closestProperty.exitPosition);
setPlayerHeading(client, closestProperty.exitRotation);
setPlayerDimension(client, closestProperty.exitDimension);
@@ -223,6 +228,7 @@ function enterExitPropertyCommand(command, params, client) {
}
updateInteriorLightsForPlayer(client, closestProperty.interiorLights);
}, 1000);
//setPlayerInCutsceneInterior(client, closestProperty.exitCutscene);
//updateAllInteriorVehiclesForPlayer(client, closestProperty.exitInterior, closestProperty.exitDimension);
}, 1100);
if(closestProperty.streamingRadioStation != -1) {
@@ -249,6 +255,7 @@ function enterExitPropertyCommand(command, params, client) {
disableCityAmbienceForPlayer(client, true);
setTimeout(function() {
setPlayerInCutsceneInterior(client, closestProperty.entranceCutscene);
setPlayerPosition(client, closestProperty.entrancePosition);
setPlayerHeading(client, closestProperty.entranceRotation);
setPlayerDimension(client, closestProperty.entranceDimension);
@@ -257,11 +264,14 @@ function enterExitPropertyCommand(command, params, client) {
if(isFadeCameraSupported()) {
fadeCamera(client, true, 1.0);
}
updateInteriorLightsForPlayer(client, true);
}, 1000);
}, 1100);
//setPlayerInCutsceneInterior(client, closestProperty.entranceCutscene);
stopRadioStreamForPlayer(client);
getPlayerData(client).streamingRadioStation = -1;
//logToConsole(LOG_DEBUG, `[VRR.Misc] ${getPlayerDisplayForConsole(client)} exited business ${inBusiness.name}[${inBusiness.index}/${inBusiness.databaseId}]`);
return true;
}
@@ -301,7 +311,6 @@ function getPlayerInfoCommand(command, params, client) {
`{MAINCOLOUR}Skin: {ALTCOLOUR}${getSkinNameFromModel(getPlayerCurrentSubAccount(targetClient).skin)}[${getPlayerCurrentSubAccount(targetClient).skin}]`,
`{MAINCOLOUR}Clan: {ALTCOLOUR}${clan}`,
`{MAINCOLOUR}Job: {ALTCOLOUR}${job}`,
]
let chunkedList = splitArrayIntoChunks(stats, 6);
@@ -313,7 +322,7 @@ function getPlayerInfoCommand(command, params, client) {
// ===========================================================================
function playerChangeAFKState(client, afkState) {
getPlayerData(client).afk = afkState;
getPlayerData(client).afk = afkState;
updateAllPlayerNameTags();
}
@@ -324,7 +333,7 @@ function checkPlayerSpawning() {
for(let i in clients) {
if(!isConsole(clients[i])) {
if(getPlayerData(clients[i])) {
if(getPlayerData(clients[i]).loggedIn) {
if(isPlayerLoggedIn(clients[i])) {
if(!getPlayerData(clients[i]).ped) {
if(clients[i].player != null) {
//getPlayerData(clients[i]).ped = clients[i].player;
@@ -475,15 +484,15 @@ function gpsCommand(command, params, client) {
default: {
let itemTypeId = getItemTypeFromParams(params);
if(getItemTypeData(itemTypeId) != false) {
locationType = VRR_GPS_TYPE_BUSINESS;
blipColour = "businessBlue";
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]
}
}
let gameLocationId = getGameLocationFromParams(params);
if(gameLocationId != false) {
position = getGameConfig().locations[getServerGame()][gameLocationId][1]
}
}
}
}
@@ -504,87 +513,98 @@ function gpsCommand(command, params, client) {
return false;
}
hideAllBlipsForPlayerGPS(client);
hideAllBlipsForPlayerGPS(client);
blinkGenericGPSBlipForPlayer(client, getBusinessData(businessId).entrancePosition, getBusinessData(businessId).entranceBlipModel, getColourByType(blipColour), 10);
messagePlayerSuccess(client, "Look for the blinking icon on your mini map");
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;
}
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;
}
}
// ===========================================================================
function stuckPlayerCommand(command, params, client) {
if((getCurrentUnixTimestamp()-getPlayerData(client).lastStuckCommand) < getGlobalConfig().stuckCommandInterval) {
messagePlayerError(client, "CantUseCommandYet");
return false;
}
if((getCurrentUnixTimestamp()-getPlayerData(client).lastStuckCommand) < getGlobalConfig().stuckCommandInterval) {
messagePlayerError(client, "CantUseCommandYet");
return false;
}
let dimension = getPlayerDimension(client);
let interior = getPlayerInterior(client);
let dimension = getPlayerDimension(client);
let interior = getPlayerInterior(client);
messagePlayerAlert(client, getLocaleString(client, "FixingStuck"));
messagePlayerAlert(client, getLocaleString(client, "FixingStuck"));
if(getGameConfig().skinChangePosition[getServerGame()].length > 0) {
if(getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType == VRR_RETURNTO_TYPE_SKINSELECT) {
messagePlayerAlert(client, "You canceled the skin change.");
restorePlayerCamera(client);
if(getGameConfig().skinChangePosition[getServerGame()].length > 0) {
if(getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType == VRR_RETURNTO_TYPE_SKINSELECT) {
messagePlayerAlert(client, "You canceled the skin change.");
restorePlayerCamera(client);
setPlayerPosition(client, getPlayerData(client).returnToPosition);
setPlayerHeading(client, getPlayerData(client).returnToHeading);
setPlayerInterior(client, getPlayerData(client).returnToInterior);
setPlayerDimension(client, getPlayerData(client).returnToDimension);
setPlayerPosition(client, getPlayerData(client).returnToPosition);
setPlayerHeading(client, getPlayerData(client).returnToHeading);
setPlayerInterior(client, getPlayerData(client).returnToInterior);
setPlayerDimension(client, getPlayerData(client).returnToDimension);
getPlayerData(client).returnToPosition = null;
getPlayerData(client).returnToHeading = null;
getPlayerData(client).returnToInterior = null;
getPlayerData(client).returnToDimension = null;
getPlayerData(client).returnToPosition = null;
getPlayerData(client).returnToHeading = null;
getPlayerData(client).returnToInterior = null;
getPlayerData(client).returnToDimension = null;
getPlayerData(client).returnToType = VRR_RETURNTO_TYPE_NONE;
}
}
getPlayerData(client).returnToType = VRR_RETURNTO_TYPE_NONE;
}
}
//if(getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType == VRR_RETURNTO_TYPE_ADMINGET) {
// messagePlayerError(client, `You were teleported by an admin and can't use the stuck command`);
// return false;
//}
//if(getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType == VRR_RETURNTO_TYPE_ADMINGET) {
// messagePlayerError(client, `You were teleported by an admin and can't use the stuck command`);
// return false;
//}
if(dimension > 0) {
let businesses = getServerData().businesses;
for(let i in businesses) {
if(businesses[i].exitDimension == dimension) {
setPlayerPosition(client, businesses[i].entrancePosition);
setPlayerDimension(client, businesses[i].entranceDimension);
setPlayerInterior(client, businesses[i].entranceInterior);
if(dimension > 0) {
let businesses = getServerData().businesses;
for(let i in businesses) {
if(businesses[i].exitDimension == dimension) {
setPlayerPosition(client, businesses[i].entrancePosition);
setPlayerDimension(client, businesses[i].entranceDimension);
setPlayerInterior(client, businesses[i].entranceInterior);
return true;
}
}
return true;
}
}
let houses = getServerData().houses;
for(let i in houses) {
if(houses[i].exitDimension == dimension) {
setPlayerPosition(client, houses[i].entrancePosition);
setPlayerDimension(client, houses[i].entranceDimension);
setPlayerInterior(client, houses[i].entranceInterior);
let houses = getServerData().houses;
for(let i in houses) {
if(houses[i].exitDimension == dimension) {
setPlayerPosition(client, houses[i].entrancePosition);
setPlayerDimension(client, houses[i].entranceDimension);
setPlayerInterior(client, houses[i].entranceInterior);
return true;
}
}
} else {
setPlayerDimension(client, 1);
setPlayerDimension(client, getGameConfig().mainWorldDimension[getGame()]);
setPlayerInterior(client, getGameConfig().mainWorldInterior[getGame()]);
setPlayerPosition(client, getPosAbovePos(getPlayerPosition(client), 2.0));
}
return true;
}
}
} else {
setPlayerDimension(client, 1);
setPlayerDimension(client, getGameConfig().mainWorldDimension[getGame()]);
setPlayerInterior(client, getGameConfig().mainWorldInterior[getGame()]);
setPlayerPosition(client, getPosAbovePos(getPlayerPosition(client), 2.0));
}
setPlayerInterior(client, 0);
setPlayerDimension(client, 0);
setPlayerInterior(client, 0);
setPlayerDimension(client, 0);
}
// ===========================================================================
function playerPedSpeakCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
makePlayerPedSpeak(client, params);
}
// ===========================================================================

View File

@@ -7,93 +7,106 @@
// TYPE: Server (JavaScript)
// ===========================================================================
let builtInCommands = [
"refresh",
"restart",
"stop",
"start",
"reconnect",
"setname",
"connect",
"disconnect",
"say",
"dumpdoc",
];
// ===========================================================================
function getPlayerPosition(client) {
if(!areServerElementsSupported()) {
return getPlayerData(client).syncPosition;
} else {
if(client.player != null) {
return client.player.position;
}
}
if(!areServerElementsSupported()) {
return getPlayerData(client).syncPosition;
} else {
if(getPlayerPed(client) != null) {
return getPlayerPed(client).position;
}
}
}
// ===========================================================================
function setPlayerPosition(client, position) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s position to ${position.x}, ${position.y}, ${position.z}`);
sendPlayerSetPosition(client, position);
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s position to ${position.x}, ${position.y}, ${position.z}`);
sendPlayerSetPosition(client, position);
}
// ===========================================================================
function getPlayerHeading(client) {
if(!areServerElementsSupported()) {
return getPlayerData(client).syncHeading;
} else {
if(client.player != null) {
return client.player.heading;
}
}
if(!areServerElementsSupported()) {
return getPlayerData(client).syncHeading;
} else {
if(getPlayerPed(client) != null) {
return getPlayerPed(client).heading;
}
}
}
// ===========================================================================
function setPlayerHeading(client, heading) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s heading to ${heading}`);
sendPlayerSetHeading(client, heading);
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s heading to ${heading}`);
sendPlayerSetHeading(client, heading);
}
// ===========================================================================
function getPlayerVehicle(client) {
if(!areServerElementsSupported()) {
return getPlayerData().syncVehicle;
} else {
if(client.player.vehicle) {
return client.player.vehicle;
}
}
return false;
if(!areServerElementsSupported()) {
return getPlayerData().syncVehicle;
} else {
if(getPlayerPed(client).vehicle) {
return getPlayerPed(client).vehicle;
}
}
return false;
}
// ===========================================================================
function getPlayerDimension(client) {
if(!areServerElementsSupported()) {
return getPlayerData(client).syncDimension;
} else {
if(client.player != null) {
return client.player.dimension;
}
}
if(!areServerElementsSupported()) {
return getPlayerData(client).syncDimension;
} else {
if(getPlayerPed(client) != null) {
return getPlayerPed(client).dimension;
}
}
}
// ===========================================================================
function getPlayerInterior(client) {
return getPlayerCurrentSubAccount(client).interior || 0;
return getPlayerCurrentSubAccount(client).interior || 0;
}
// ===========================================================================
function setPlayerDimension(client, dimension) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s dimension to ${dimension}`);
if(!areServerElementsSupported()) {
getPlayerData(client).syncDimension = dimension;
} else {
if(client.player != null) {
client.player.dimension = dimension;
}
}
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s dimension to ${dimension}`);
if(!areServerElementsSupported()) {
getPlayerData(client).syncDimension = dimension;
} else {
if(getPlayerPed(client) != null) {
getPlayerPed(client).dimension = dimension;
}
}
}
// ===========================================================================
function setPlayerInterior(client, interior) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s interior to ${interior}`);
sendPlayerSetInterior(client, interior);
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s interior to ${interior}`);
sendPlayerSetInterior(client, interior);
if(isPlayerLoggedIn(client) && isPlayerSpawned(client)) {
getPlayerCurrentSubAccount(client).interior = interior;
}
@@ -102,139 +115,171 @@ function setPlayerInterior(client, interior) {
// ===========================================================================
function isPlayerInAnyVehicle(client) {
if(!areServerElementsSupported()) {
return (getPlayerData().syncVehicle != null);
} else {
return (client.player.vehicle != null);
}
if(!areServerElementsSupported()) {
return (getPlayerData().syncVehicle != null);
} else {
return (getPlayerPed(client).vehicle != null);
}
}
// ===========================================================================
function getPlayerVehicleSeat(client) {
if(!isPlayerInAnyVehicle(client)) {
return false;
}
if(!isPlayerInAnyVehicle(client)) {
return false;
}
if(!areServerElementsSupported()) {
return getPlayerData().syncVehicleSeat;
} else {
for(let i = 0 ; i <= 8 ; i++) {
if(getPlayerVehicle(client).getOccupant(i) == client.player) {
if(getPlayerVehicle(client).getOccupant(i) == getPlayerPed(client)) {
return i;
}
}
}
return false;
return false;
}
// ===========================================================================
function isPlayerSpawned(client) {
return getPlayerData(client).spawned;
return getPlayerData(client).spawned;
}
// ===========================================================================
function getVehiclePosition(vehicle) {
return vehicle.position;
return vehicle.position;
}
// ===========================================================================
function getVehicleHeading(vehicle) {
return vehicle.heading;
return vehicle.heading;
}
// ===========================================================================
function setVehicleHeading(vehicle, heading) {
return vehicle.heading = heading;
if(getGame() == VRR_GAME_GTA_IV) {
return sendNetworkEventToPlayer("vrr.vehPosition", null, getVehicleForNetworkEvent(vehicle), heading);
}
return vehicle.heading = heading;
}
// ===========================================================================
function getElementTransient(element) {
if(typeof element.transient != "undefined") {
return element.transient;
}
return false;
}
// ===========================================================================
function setElementTransient(element, state) {
if(typeof element.transient != "undefined") {
element.transient = state;
return true;
}
return false;
}
// ===========================================================================
function getVehicleSyncer(vehicle) {
return getElementSyncer(vehicle);
return getElementSyncer(vehicle);
}
// ===========================================================================
function getVehicleForNetworkEvent(vehicle) {
return vehicle;
if(getGame() == VRR_GAME_GTA_IV) {
if(getVehicleData(vehicle).ivNetworkId != -1) {
return getVehicleData(vehicle).ivNetworkId;
}
return -1;
}
return vehicle.id;
}
// ===========================================================================
function deleteGameElement(element) {
try {
if(element != null) {
destroyElement(element);
return true;
}
} catch(error) {
return false;
}
try {
if(element != null) {
destroyElement(element);
return true;
}
} catch(error) {
return false;
}
}
// ===========================================================================
function isPlayerInFrontVehicleSeat(client) {
return (getPlayerVehicleSeat(client) == 0 || getPlayerVehicleSeat(client) == 1);
return (getPlayerVehicleSeat(client) == 0 || getPlayerVehicleSeat(client) == 1);
}
// ===========================================================================
function removePlayerFromVehicle(client) {
logToConsole(LOG_DEBUG, `Removing ${getPlayerDisplayForConsole(client)} from their vehicle`);
sendPlayerRemoveFromVehicle(client);
return true;
logToConsole(LOG_DEBUG, `Removing ${getPlayerDisplayForConsole(client)} from their vehicle`);
sendPlayerRemoveFromVehicle(client);
return true;
}
// ===========================================================================
function setPlayerSkin(client, skinIndex) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s skin to ${getGameConfig().skins[getGame()][skinIndex][0]} (Index: ${skinIndex}, Name: ${getGameConfig().skins[getGame()][skinIndex][1]})`);
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s skin to ${getGameConfig().skins[getGame()][skinIndex][0]} (Index: ${skinIndex}, Name: ${getGameConfig().skins[getGame()][skinIndex][1]})`);
if(getGame() == VRR_GAME_GTA_IV) {
triggerNetworkEvent("vrr.localPlayerSkin", client, getGameConfig().skins[getGame()][skinIndex][0]);
} else {
client.player.modelIndex = getGameConfig().skins[getGame()][skinIndex][0];
getPlayerPed(client).modelIndex = getGameConfig().skins[getGame()][skinIndex][0];
}
}
// ===========================================================================
function getPlayerSkin(client) {
return getSkinIndexFromModel(client.player.modelIndex);
return getSkinIndexFromModel(client.player.modelIndex);
}
// ===========================================================================
function setPlayerHealth(client, health) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s health to ${health}`);
sendPlayerSetHealth(client, health);
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s health to ${health}`);
sendPlayerSetHealth(client, health);
getServerData(client).health = health;
}
// ===========================================================================
function getPlayerHealth(client) {
return getServerData(client).health;
return getServerData(client).health;
}
// ===========================================================================
function setPlayerArmour(client, armour) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s armour to ${armour}`);
sendPlayerSetArmour(client, armour);
//client.player.armour = armour;
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s armour to ${armour}`);
sendPlayerSetArmour(client, armour);
//client.player.armour = armour;
}
// ===========================================================================
function getPlayerArmour(client) {
return client.player.armour;
if(areServerElementsSupported(client)) {
return getPlayerPed(client).armour;
} else {
return getPlayerData(client).syncArmour;
}
}
// ===========================================================================
@@ -244,9 +289,9 @@ function setPlayerCash(client, amount) {
return false;
}
if(isNaN(amount)) {
return false;
}
if(isNaN(amount)) {
return false;
}
getPlayerCurrentSubAccount(client).cash = toInteger(amount);
updatePlayerCash(client);
@@ -259,9 +304,9 @@ function givePlayerCash(client, amount) {
return false;
}
if(isNaN(amount)) {
return false;
}
if(isNaN(amount)) {
return false;
}
getPlayerCurrentSubAccount(client).cash = getPlayerCurrentSubAccount(client).cash + toInteger(amount);
updatePlayerCash(client);
@@ -274,9 +319,9 @@ function takePlayerCash(client, amount) {
return false;
}
if(isNaN(amount)) {
return false;
}
if(isNaN(amount)) {
return false;
}
getPlayerCurrentSubAccount(client).cash = getPlayerCurrentSubAccount(client).cash - toInteger(amount);
updatePlayerCash(client);
@@ -285,173 +330,185 @@ function takePlayerCash(client, amount) {
// ===========================================================================
function disconnectPlayer(client) {
logToConsole(LOG_DEBUG, `Disconnecting (kicking) ${getPlayerDisplayForConsole(client)}`);
client.disconnect();
return false;
logToConsole(LOG_DEBUG, `Disconnecting (kicking) ${getPlayerDisplayForConsole(client)}`);
client.disconnect();
return false;
}
// ===========================================================================
function getElementSyncer(element) {
return getClients()[element.syncer];
return getClients()[element.syncer];
}
// ===========================================================================
function getPlayerWeaponAmmo(client) {
return client.player.weaponAmmunition;
return getPlayerPed(client).weaponAmmunition;
}
// ===========================================================================
function setPlayerVelocity(client, velocity) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s velocity to ${velocity.x}, ${velocity.y}, ${velocity.z}`);
if(typeof client.player.velocity != "undefined") {
client.player.velocity = velocity;
}
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s velocity to ${velocity.x}, ${velocity.y}, ${velocity.z}`);
if(typeof getPlayerPed(client).velocity != "undefined") {
getPlayerPed(client).velocity = velocity;
}
}
// ===========================================================================
function getPlayerVelocity(client, velocity) {
if(typeof client.player.velocity != "undefined") {
return client.player.velocity;
}
return toVector3(0.0, 0.0, 0.0);
function getPlayerVelocity(client) {
if(typeof getPlayerPed(client).velocity != "undefined") {
return getPlayerPed(client).velocity;
}
return toVector3(0.0, 0.0, 0.0);
}
// ===========================================================================
function getElementDimension(element) {
if(typeof element.dimension != "undefined") {
return element.dimension;
}
return 0;
if(typeof element.dimension != "undefined") {
return element.dimension;
}
return 0;
}
// ===========================================================================
function setElementDimension(element, dimension) {
if(typeof element.dimension != "undefined") {
element.dimension = dimension;
return true;
}
return false;
if(typeof element.dimension != "undefined") {
element.dimension = dimension;
return true;
}
return false;
}
// ===========================================================================
function setElementRotation(element, rotation) {
return element.setRotation(rotation);
if(typeof element.setRotation != "undefined") {
element.setRotation(rotation);
} else {
return element.rotation = rotation;
}
}
// ===========================================================================
function givePlayerHealth(client, amount) {
if(getPlayerHealth(client)+amount > 100) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s health to 100`);
setPlayerHealth(client, 100);
} else {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s health to ${getPlayerHealth(client)+amount}`);
setPlayerHealth(client, getPlayerHealth(client)+amount);
}
if(getPlayerHealth(client)+amount > 100) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s health to 100`);
setPlayerHealth(client, 100);
} else {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s health to ${getPlayerHealth(client)+amount}`);
setPlayerHealth(client, getPlayerHealth(client)+amount);
}
}
// ===========================================================================
function givePlayerArmour(client, amount) {
if(getPlayerArmour(client)+amount > 100) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s armour to 100`);
setPlayerArmour(client, 100);
} else {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s armour to ${getPlayerArmour(client)+amount}`);
setPlayerArmour(client, getPlayerArmour(client)+amount);
}
if(getPlayerArmour(client)+amount > 100) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s armour to 100`);
setPlayerArmour(client, 100);
} else {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s armour to ${getPlayerArmour(client)+amount}`);
setPlayerArmour(client, getPlayerArmour(client)+amount);
}
}
// ===========================================================================
function getServerGame() {
return getGame();
return getGame();
}
// ===========================================================================
function consolePrint(text) {
console.log(text);
console.log(text);
}
// ===========================================================================
function getPlayerName(client) {
return client.name;
return client.name;
}
// ===========================================================================
function getServerName() {
return server.name;
return server.name;
}
// ===========================================================================
function createGamePickup(modelIndex, position, type) {
if(!isGameFeatureSupported("pickups")) {
return false;
}
return game.createPickup(modelIndex, position, type);
if(!isGameFeatureSupported("pickups")) {
return false;
}
return game.createPickup(modelIndex, position, type);
}
// ===========================================================================
function createGameBlip(position, type = 0, colour = toColour(255, 255, 255, 255)) {
if(!isGameFeatureSupported("blips")) {
return false;
}
return game.createBlip(type, position, 1, colour);
if(!isGameFeatureSupported("blips")) {
return false;
}
return game.createBlip(type, position, 1, colour);
}
// ===========================================================================
function createGameObject(modelIndex, position) {
if(!isGameFeatureSupported("objects")) {
return false;
}
return game.createObject(getGameConfig().objects[getGame()][modelIndex][0], position);
if(!isGameFeatureSupported("objects")) {
return false;
}
return game.createObject(getGameConfig().objects[getGame()][modelIndex][0], position);
}
// ===========================================================================
function setElementOnAllDimensions(element, state) {
if(!isNull(element) && element != false) {
element.onAllDimensions = state;
}
if(!isNull(element) && element != false) {
if(typeof element.netFlags != "undefined") {
if(typeof element.netFlags.onAllDimensions != "undefined") {
element.netFlags.onAllDimensions = state;
}
} else {
if(typeof element.onAllDimensions != "undefined") {
element.onAllDimensions = state;
}
}
}
}
// ===========================================================================
function destroyGameElement(element) {
if(!isNull(element) && element != false) {
destroyElement(element);
}
if(!isNull(element) && element != false) {
destroyElement(element);
}
}
// ===========================================================================
function isMeleeWeapon(weaponId, gameId = getServerGame()) {
return (getGameConfig().meleeWeapons[gameId].indexOf(weaponId) != -1);
return (getGameConfig().meleeWeapons[gameId].indexOf(weaponId) != -1);
}
// ===========================================================================
function getPlayerLastVehicle(client) {
return getPlayerData(client).lastVehicle;
return getPlayerData(client).lastVehicle;
}
// ===========================================================================
function isVehicleObject(vehicle) {
return (vehicle.type == ELEMENT_VEHICLE);
return (vehicle.type == ELEMENT_VEHICLE);
}
// ===========================================================================
@@ -470,7 +527,7 @@ function setVehicleLights(vehicle, lights) {
function setVehicleEngine(vehicle, engine) {
vehicle.engine = engine;
setEntityData(vehicle, "vrr.engine", engine, true);
setEntityData(vehicle, "vrr.engine", engine, true);
}
// ===========================================================================
@@ -500,7 +557,7 @@ function getVehicleEngine(vehicle) {
// ===========================================================================
function getVehicleLocked(vehicle) {
return vehicle.locked;
return vehicle.lockedStatus;
}
// ===========================================================================
@@ -515,13 +572,13 @@ function setVehicleColours(vehicle, colour1, colour2, colour3 = -1, colour4 = -1
vehicle.colour1 = colour1;
vehicle.colour2 = colour2;
if(colour3 != -1) {
vehicle.colour3 = colour3;
}
if(colour3 != -1) {
vehicle.colour3 = colour3;
}
if(colour4 != -1) {
vehicle.colour4 = colour4;
}
if(colour4 != -1) {
vehicle.colour4 = colour4;
}
}
// ===========================================================================
@@ -534,8 +591,24 @@ function createGameVehicle(modelIndex, position, heading, toClient = null) {
// ===========================================================================
function createGameCivilian(modelIndex, position, heading, toClient = null) {
if(areServerElementsSupported()) {
let civilian = game.createCivilian(getGameConfig().skins[getGame()][modelIndex][0], 0);
if(!isNull(civilian)) {
civilian.position = position;
civilian.heading = heading;
addToWorld(civilian);
return civilian;
}
}
return false;
}
// ===========================================================================
function getIsland(position) {
if(getServerGame() == VRR_GAME_GTA_III) {
if(getServerGame() == VRR_GAME_GTA_III) {
if(position.x > 616) {
return VRR_ISLAND_PORTLAND;
} else if(position.x < -283) {
@@ -552,11 +625,11 @@ function getIsland(position) {
// ===========================================================================
function isValidVehicleModel(model) {
if(getVehicleModelIndexFromModel(model) != false) {
return true;
}
if(getVehicleModelIndexFromModel(model) != false) {
return true;
}
return false;
return false;
}
// ===========================================================================
@@ -580,8 +653,8 @@ function setPlayerFightStyle(client, fightStyleId) {
return false;
}
setEntityData(getPlayerElement(client), "vrr.fightStyle", [getGameConfig().fightStyles[getServerGame()][fightStyleId][1][0], getGameConfig().fightStyles[getServerGame()][fightStyleId][1][1]]);
forcePlayerToSyncElementProperties(null, getPlayerElement(client));
setEntityData(getPlayerElement(client), "vrr.fightStyle", [getGameConfig().fightStyles[getServerGame()][fightStyleId][1][0], getGameConfig().fightStyles[getServerGame()][fightStyleId][1][1]]);
forcePlayerToSyncElementProperties(null, getPlayerElement(client));
}
// ===========================================================================
@@ -640,32 +713,36 @@ function isTaxiVehicle(vehicle) {
// ===========================================================================
function getVehicleName(vehicle) {
let model = getElementModel(vehicle);
let model = getElementModel(vehicle);
return getVehicleNameFromModel(model) || "Unknown";
}
// ===========================================================================
function getElementModel(element) {
if(typeof element.modelIndex != "undefined") {
return element.modelIndex;
}
if(typeof element.modelIndex != "undefined") {
return element.modelIndex;
}
if(typeof element.model != "undefined") {
return element.model;
}
if(typeof element.model != "undefined") {
return element.model;
}
}
// ===========================================================================
function givePlayerWeaponAmmo(client, ammo) {
givePlayerWeapon(client, getPlayerWeapon(client), getPlayerWeaponAmmo(client) + ammo);
givePlayerWeapon(client, getPlayerWeapon(client), getPlayerWeaponAmmo(client) + ammo);
}
// ===========================================================================
function getPlayerWeapon(client) {
return client.player.weapon;
if(areServerElementsSupported(client)) {
return getPlayerPed(client).weapon;;
} else {
return getPlayerData(client).syncWeapon;
}
}
// ===========================================================================
@@ -905,7 +982,7 @@ function sendNetworkEventToPlayer(eventName, client, ...args) {
// ===========================================================================
function addNetworkEventHandler(eventName, handlerFunction) {
addNetworkHandler(eventName, handlerFunction);
addNetworkHandler(eventName, handlerFunction);
}
// ===========================================================================
@@ -1018,8 +1095,75 @@ function setVehicleHealth(vehicle, health) {
// ===========================================================================
function givePlayerWeapon(client, weaponId, ammo, active = true) {
logToConsole(LOG_DEBUG, `[VRR.Client] Sending signal to ${getPlayerDisplayForConsole(client)} to give weapon (Weapon: ${weaponId}, Ammo: ${ammo})`);
sendNetworkEventToPlayer("vrr.giveWeapon", client, weaponId, ammo, active);
logToConsole(LOG_DEBUG, `[VRR.Client] Sending signal to ${getPlayerDisplayForConsole(client)} to give weapon (Weapon: ${weaponId}, Ammo: ${ammo})`);
sendNetworkEventToPlayer("vrr.giveWeapon", client, weaponId, ammo, active);
}
// ===========================================================================
function setPlayerWantedLevel(client, wantedLevel) {
sendNetworkEventToPlayer("vrr.wantedLevel", client, wantedLevel);
return true;
}
// ===========================================================================
function setElementStreamInDistance(element, distance) {
if(!isNull(element) && element != false) {
if(typeof element == "Entity") {
if(typeof element.streamInDistance != "undefined") {
element.streamInDistance = distance;
}
}
}
}
// ===========================================================================
function setElementStreamOutDistance(element, distance) {
if(!isNull(element) && element != false) {
if(typeof element == "Entity") {
if(typeof element.streamOutDistance != "undefined") {
element.streamOutDistance = distance;
}
}
}
}
// ===========================================================================
function getPlayerPed(client) {
if(getGame() == VRR_GAME_GTA_IV) {
return getPlayerData(client).ped;
} else {
return client.player;
}
}
// ===========================================================================
function setEntityData(entity, dataName, dataValue, syncToClients = true) {
if(entity != null) {
return entity.setData(dataName, dataValue, syncToClients);
}
}
// ===========================================================================
function removeEntityData(entity, dataName) {
if(entity != null) {
return entity.removeData(dataName);
}
return null;
}
// ===========================================================================
function doesEntityDataExist(entity, dataName) {
if(entity != null) {
return (entity.getData(dataName) != null);
}
return null;
}
// ===========================================================================

View File

@@ -8,23 +8,25 @@
// ===========================================================================
function initNPCScript() {
getServerData().npcs = loadNPCsFromDatabase();
setAllNPCDataIndexes();
if(!getServerConfig().devServer) {
getServerData().npcs = loadNPCsFromDatabase();
}
spawnAllNPCs();
setNPCDataIndexes();
spawnNPCs();
}
// ===========================================================================
/**
* @param {Ped} ped - The data index of the NPC
* @param {Number} npcId - The data index of the NPC
* @return {NPCData} The NPC's data (class instancee)
*/
function getNPCData(ped) {
if(ped.getData("vrr.dataIndex")) {
return ped.getData("vrr.dataIndex");
function getNPCData(npcId) {
if(typeof getServerData().npcs[npcId] != "undefined") {
return getServerData().npcs[npcId];
}
return false;
return false;
}
// ===========================================================================
@@ -38,20 +40,14 @@ function createNPCCommand(client, command, params) {
let skinId = getSkinModelIndexFromParams(params);
if(!skinId) {
messagePlayerError(client, `Invalid skin`);
messagePlayerError(client, getLocaleString(client, "InvalidSkin"));
return false;
}
let position = getPosInFrontOfPos(getPlayerPosition(client), getPlayerHeading(client), 3);
let tempNPCData = new NPCData(false);
tempNPCData.position = position;
tempNPCData.heading = getPlayerHeading(client);
tempNPCData.skin = skinId;
let npcIndex = getServerData().npcs.push(tempNPCData);
spawnNPC(npcIndex-1);
let npcId = createNPC(skinId, position, getPlayerHeading(client));
messageAdmins(`${client.name}{MAINCOLOUR} created a ${getSkinNameFromIndex(getNPCData(npcId).skin)} NPC!`);
}
// ===========================================================================
@@ -155,7 +151,11 @@ function loadNPCTriggerResponsesFromDatabase(npcTriggerDatabaseId) {
// ===========================================================================
function saveAllNPCsToDatabase() {
function saveNPCsToDatabase() {
if(getServerConfig().devServer) {
return false;
}
for(let i in getServerData().npcs) {
saveNPCToDatabase(i);
}
@@ -163,108 +163,93 @@ function saveAllNPCsToDatabase() {
// ===========================================================================
function saveNPCToDatabase(npc) {
if(getNPCData(vehicleDataId) == null) {
// Invalid vehicle data
function saveNPCToDatabase(npcDataId) {
if(getNPCData(npcDataId) == null) {
// Invalid NPC data
return false;
}
let tempVehicleData = getServerData().vehicles[vehicleDataId];
let tempNPCData = getNPCData(npcDataId);
if(tempVehicleData.databaseId == -1) {
// Temp vehicle, no need to save
if(tempNPCData.databaseId == -1) {
// Temp NPC, no need to save
return false;
}
if(!tempVehicleData.needsSaved) {
// Vehicle hasn't changed. No need to save.
if(!tempNPCData.needsSaved) {
// NPC hasn't changed. No need to save.
return false;
}
logToConsole(LOG_VERBOSE, `[VRR.Vehicle]: Saving vehicle ${tempVehicleData.databaseId} to database ...`);
logToConsole(LOG_VERBOSE, `[VRR.NPC]: Saving NPC ${tempNPCData.databaseId} to database ...`);
let dbConnection = connectToDatabase();
if(dbConnection) {
if(tempVehicleData.vehicle != false) {
if(!tempVehicleData.spawnLocked) {
if(tempNPCData.ped != false) {
if(!tempNPCData.spawnLocked) {
if(areServerElementsSupported()) {
tempVehicleData.spawnPosition = tempVehicleData.vehicle.position;
tempVehicleData.spawnRotation = tempVehicleData.vehicle.heading;
tempNPCData.spawnPosition = tempNPCData.vehicle.position;
tempNPCData.spawnRotation = tempNPCData.vehicle.heading;
} else {
tempVehicleData.spawnPosition = tempVehicleData.syncPosition;
tempVehicleData.spawnRotation = tempVehicleData.syncHeading;
tempNPCData.spawnPosition = tempNPCData.syncPosition;
tempNPCData.spawnRotation = tempNPCData.syncHeading;
}
}
}
let safeAnimationName = escapeDatabaseString(tempNPCData.animationName);
let safeFirstName = escapeDatabaseString(tempNPCData.firstName);
let safeLastName = escapeDatabaseString(tempNPCData.lastName);
let safeMiddleName = escapeDatabaseString(tempNPCData.middleName);
let data = [
["veh_server", getServerId()],
["veh_model", toInteger(tempVehicleData.model)],
["veh_owner_type", toInteger(tempVehicleData.ownerType)],
["veh_owner_id", toInteger(tempVehicleData.ownerId)],
["veh_locked", boolToInt(tempVehicleData.locked)],
["veh_spawn_lock", boolToInt(tempVehicleData.spawnLocked)],
["veh_buy_price", toInteger(tempVehicleData.buyPrice)],
["veh_rent_price", toInteger(tempVehicleData.rentPrice)],
["veh_pos_x", toFloat(tempVehicleData.spawnPosition.x)],
["veh_pos_y", toFloat(tempVehicleData.spawnPosition.y)],
["veh_pos_z", toFloat(tempVehicleData.spawnPosition.z)],
["veh_rot_z", toFloat(tempVehicleData.spawnRotation)],
["veh_col1", toInteger(tempVehicleData.colour1)],
["veh_col2", toInteger(tempVehicleData.colour2)],
["veh_col3", toInteger(tempVehicleData.colour3)],
["veh_col4", toInteger(tempVehicleData.colour4)],
["veh_col1_isrgb", boolToInt(tempVehicleData.colour1IsRGBA)],
["veh_col2_isrgb", boolToInt(tempVehicleData.colour2IsRGBA)],
["veh_col3_isrgb", boolToInt(tempVehicleData.colour3IsRGBA)],
["veh_col4_isrgb", boolToInt(tempVehicleData.colour4IsRGBA)],
["veh_extra1", tempVehicleData.extras[0]],
["veh_extra2", tempVehicleData.extras[1]],
["veh_extra3", tempVehicleData.extras[2]],
["veh_extra4", tempVehicleData.extras[3]],
["veh_extra5", tempVehicleData.extras[4]],
["veh_extra6", tempVehicleData.extras[5]],
["veh_extra7", tempVehicleData.extras[6]],
["veh_extra8", tempVehicleData.extras[7]],
["veh_extra9", tempVehicleData.extras[8]],
["veh_extra10", tempVehicleData.extras[9]],
["veh_extra11", tempVehicleData.extras[10]],
["veh_extra12", tempVehicleData.extras[11]],
["veh_extra13", tempVehicleData.extras[12]],
["veh_engine", intToBool(tempVehicleData.engine)],
["veh_lights", intToBool(tempVehicleData.lights)],
["veh_health", toInteger(tempVehicleData.health)],
["veh_damage_engine", toInteger(tempVehicleData.engineDamage)],
["veh_damage_visual", toInteger(tempVehicleData.visualDamage)],
["veh_dirt_level", toInteger(tempVehicleData.dirtLevel)],
["veh_int", toInteger(tempVehicleData.interior)],
["veh_vw", toInteger(tempVehicleData.dimension)],
["veh_livery", toInteger(tempVehicleData.livery)],
["npc_server", getServerId()],
["npc_skin", toInteger(tempNPCData.model)],
["npc_name_first", safeFirstName],
["npc_name_middle", safeMiddleName],
["npc_name_last", safeLastName],
["npc_owner_type", toInteger(tempNPCData.ownerType)],
["npc_owner_id", toInteger(tempNPCData.ownerId)],
["npc_pos_x", toFloat(tempNPCData.position.x)],
["npc_pos_y", toFloat(tempNPCData.position.y)],
["npc_pos_z", toFloat(tempNPCData.position.z)],
["npc_rot_z", toFloat(tempNPCData.heading)],
["npc_scale_x", toFloat(tempNPCData.scale.x)],
["npc_scale_y", toFloat(tempNPCData.scale.y)],
["npc_scale_z", toFloat(tempNPCData.scale.z)],
["npc_animation", safeAnimationName],
["npc_health", toInteger(tempNPCData.health)],
["npc_armour", toInteger(tempNPCData.armour)],
["npc_invincible", boolToInt(tempNPCData.invincible)],
["npc_heedthreats", boolToInt(tempNPCData.heedThreats)],
["npc_threats", toInteger(tempNPCData.threats)],
["npc_stay", boolToInt(tempNPCData.stay)],
["npc_type_flags", toInteger(tempNPCData.typeFlags)],
];
let dbQuery = null;
if(tempVehicleData.databaseId == 0) {
let queryString = createDatabaseInsertQuery("veh_main", data);
if(tempNPCData.databaseId == 0) {
let queryString = createDatabaseInsertQuery("npc_main", data);
dbQuery = queryDatabase(dbConnection, queryString);
getServerData().vehicles[vehicleDataId].databaseId = getDatabaseInsertId(dbConnection);
getServerData().vehicles[vehicleDataId].needsSaved = false;
tempNPCData.databaseId = getDatabaseInsertId(dbConnection);
tempNPCData.needsSaved = false;
} else {
let queryString = createDatabaseUpdateQuery("veh_main", data, `veh_id=${tempVehicleData.databaseId}`);
let queryString = createDatabaseUpdateQuery("npc_main", data, `npc_id=${tempNPCData.databaseId}`);
dbQuery = queryDatabase(dbConnection, queryString);
getServerData().vehicles[vehicleDataId].needsSaved = false;
tempNPCData.needsSaved = false;
}
freeDatabaseQuery(dbQuery);
disconnectFromDatabase(dbConnection);
return true;
}
logToConsole(LOG_VERBOSE, `[VRR.Vehicle]: Saved vehicle ${vehicleDataId} to database!`);
logToConsole(LOG_VERBOSE, `[VRR.NPC]: Saved NPC ${npcDataId} to database!`);
return false;
}
// ===========================================================================
function setAllNPCDataIndexes() {
function setNPCDataIndexes() {
for(let i in getServerData().npcs) {
getServerData().npcs[i].index = i;
@@ -291,16 +276,120 @@ function spawnNPC(npcIndex) {
let civilian = createGameCivilian(getNPCData(npcIndex).model, getNPCData(npcIndex).spawnPosition, getNPCData(npcIndex).spawnRotation);
if(civilian) {
civilian.setData("vrr.dataIndex", npcIndex);
if(getNPCData(npcIndex).animationName != "") {
civilian.setData("vrr.animation", getNPCData(npcIndex).animationName);
}
getNPCData(npcIndex).ped = civilian;
}
}
// ===========================================================================
function spawnAllNPCs() {
function spawnNPCs() {
for(let i in getServerData().npcs) {
spawnNPC(npcIndex);
}
}
// ===========================================================================
function deleteNPCCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, command);
return false;
}
let closestNPC = getClosestNPC(getPlayerPosition(client));
if(!getNPCData(closestNPC)) {
messagePlayerError(client, getLocaleString(client, "InvalidNPC"));
return false;
}
let npcName = getNPCData(closestNPC).name;
deleteNPC(closestNPC);
messageAdmins(`${client.name}{MAINCOLOUR} deleted NPC {npcPink}${npcName}`);
}
// ===========================================================================
function deleteNPC(npcId) {
quickDatabaseQuery(`DELETE FROM npc_main WHERE npc_id=${getNPCData(npcId).databaseId}`);
if(getNPCData(npcId)) {
if(getNPCData(npcId).ped != false) {
deleteEntity(getNPCData(npcId).ped);
}
getServerData().npcs.splice(npcId, 1);
}
setNPCDataIndexes();
}
// ===========================================================================
function setNPCAnimationCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, command);
return false;
}
let closestNPC = getClosestNPC(getPlayerPosition(client));
let animationId = getAnimationFromParams(getParam(params, " ", 1));
let animationPositionOffset = 1;
if(!getNPCData(closestNPC)) {
messagePlayerError(client, getLocaleString(client, "InvalidNPC"));
return false;
}
if(!getAnimationData(animationId)) {
messagePlayerError(client, getLocaleString(client, "InvalidAnimation"));
return false;
}
if(areThereEnoughParams(params, 2, " ")) {
if(toInteger(animationPositionOffset) < 0 || toInteger(animationPositionOffset) > 3) {
messagePlayerError(client, getLocaleString(client, "InvalidAnimationDistance"));
return false;
}
animationPositionOffset = getParam(params, " ", 2);
}
getNPCData(closestNPC).animationName = animation;
makePedPlayAnimation(getNPCData(closestNPC).ped, animationId, animationPositionOffset);
}
// ===========================================================================
function getClosestNPC(position) {
let npcs = getServerData().npcs;
let closest = 0;
for(let i in npcs) {
if(getDistance(npcs[i].ped.position, position) < getDistance(npcs[i].ped.position, position)) {
closest = i;
}
}
return closest;
}
// ===========================================================================
function createNPC(skinIndex, position, heading) {
let tempNPCData = new NPCData(false);
tempNPCData.position = position;
tempNPCData.heading = heading;
tempNPCData.skin = skinIndex;
tempNPCData.animationName = "";
let npcIndex = getServerData().npcs.push(tempNPCData);
spawnNPC(npcIndex-1);
setNPCDataIndexes();
return npcIndex-1;
}
// ===========================================================================

View File

@@ -8,21 +8,21 @@
// ===========================================================================
function attemptToSignalToNearbyTaxi(client) {
if(!isPlayerLoggedIn(client)) {
return false;
}
if(!isPlayerLoggedIn(client)) {
return false;
}
if(!isPlayerSpawned(client)) {
return false;
}
if(!isPlayerSpawned(client)) {
return false;
}
let nearbyTaxis = getElementsByType(ELEMENT_VEHICLE).filter((v) > getPlayerPosition(client).distance(v.position) <= 15 && isTaxiVehicle(v));
let nearbyTaxis = getElementsByType(ELEMENT_VEHICLE).filter((v) > getPlayerPosition(client).distance(v.position) <= 15 && isTaxiVehicle(v));
let closestTaxi = nearbyTaxis.reduce((i, j) => (i.position.distance(pos) < j.position.distance(pos)) ? i : j);
if(!closestTaxi.getOccupant(0).isType(ELEMENT_PLAYER)) {
setVehicleCruiseSpeed(closestTaxi, 0.0);
setVehicleLockedState(closestTaxi, false);
}
let closestTaxi = nearbyTaxis.reduce((i, j) => (i.position.distance(pos) < j.position.distance(pos)) ? i : j);
if(!closestTaxi.getOccupant(0).isType(ELEMENT_PLAYER)) {
setVehicleCruiseSpeed(closestTaxi, 0.0);
setVehicleLocked(closestTaxi, false);
}
}
// ===========================================================================

31
scripts/server/race.js Normal file
View File

@@ -0,0 +1,31 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: race.js
// DESC: Provides racing usage and functions
// TYPE: Server (JavaScript)
// ===========================================================================
function initRaceScript() {
if(!getServerConfig().devServer) {
getServerData().races = loadRacesFromDatabase();
}
setRaceDataIndexes();
}
// ===========================================================================
/**
* @param {Number} raceId - The data index of the race
* @return {RaceData} The race's data (class instance)
*/
function getRaceData(raceId) {
if(typeof getServerData().races[raceId] != "undefined") {
return getServerData().races[raceId];
}
return false;
}
// ===========================================================================

View File

@@ -9,7 +9,10 @@
function initRadioScript() {
logToConsole(LOG_INFO, "[VRR.Radio]: Initializing radio script ...");
getServerData().radioStations = loadRadioStationsFromDatabase();
if(!getServerConfig().devServer) {
getServerData().radioStations = loadRadioStationsFromDatabase();
}
setRadioStationIndexes();
logToConsole(LOG_INFO, "[VRR.Radio]: Radio script initialized successfully!");
return true;
@@ -41,6 +44,15 @@ function loadRadioStationsFromDatabase() {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function playStreamingRadioCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -145,6 +157,15 @@ function playStreamingRadioCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function setStreamingRadioVolumeCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -185,6 +206,15 @@ function getPlayerStreamingRadioVolume(client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function showRadioStationListCommand(command, params, client) {
let stationList = getServerData().radioStations.map(function(x) { return `{ALTCOLOUR}${toInteger(x.index)+1}: {MAINCOLOUR}${x.name}`; });
@@ -213,13 +243,22 @@ function getRadioStationData(radioStationId) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function reloadAllRadioStationsCommand(command, params, client) {
stopRadioStreamForPlayer(null);
clearArray(getServerData().radioStations);
getServerData().radioStations = loadRadioStationsFromDatabase();
setRadioStationIndexes();
messageAdminAction(`All radio stations have been reloaded by an admin!`);
announceAdminAction(`AllRadioStationsReloaded`);
}
// ===========================================================================

File diff suppressed because it is too large Load Diff

View File

@@ -185,7 +185,7 @@ function saveSubAccountToDatabase(subAccountData) {
freeDatabaseQuery(dbQuery);
disconnectFromDatabase(dbConnection);
}
}
}
// ===========================================================================
@@ -275,7 +275,7 @@ function checkNewCharacter(client, firstName, lastName) {
lastName = lastName.trim();
if(doesNameContainInvalidCharacters(firstName) || doesNameContainInvalidCharacters(lastName)) {
logToConsole(LOG_WARN, `[VRR.Account] Subaccount ${firstName} ${lastName} could not be created (invalid characters in name)`);
logToConsole(LOG_INFO|LOG_WARN, `[VRR.Account] Subaccount ${firstName} ${lastName} could not be created (invalid characters in name)`);
showPlayerNewCharacterFailedGUI(client, "Invalid characters in name!");
return false;
}
@@ -371,16 +371,20 @@ function selectCharacter(client, characterId = -1) {
//setPlayerCameraLookAt(client, getPosBehindPos(spawnPosition, spawnHeading, 5), spawnPosition);
getPlayerData(client).pedState = VRR_PEDSTATE_SPAWNING;
if(getGame() < VRR_GAME_GTA_IV) {
if(getGame() <= VRR_GAME_GTA_SA) {
spawnPlayer(client, spawnPosition, spawnHeading, getGameConfig().skins[getGame()][skin][0], spawnInterior, spawnDimension);
} else if(getGame() == VRR_GAME_GTA_IV) {
spawnPlayer(client, spawnPosition, spawnHeading, getGameConfig().skins[getGame()][skin][0], spawnInterior, spawnDimension);
//clearPlayerWeapons(client);
//setPlayerSkin(client, skin);
//setPlayerPosition(client, spawnPosition);
//setPlayerHeading(client, spawnHeading);
//setPlayerInterior(client, spawnInterior);
//setPlayerDimension(client, spawnDimension);
} else if(getGame() >= VRR_GAME_MAFIA_ONE) {
//restorePlayerCamera(client);
} else if(getGame() == VRR_GAME_MAFIA_ONE) {
//spawnPlayer(client, spawnPosition, spawnHeading, getGameConfig().skins[getGame()][skin][0]);
logToConsole(LOG_DEBUG, `[VRR.SubAccount] Spawning ${getPlayerDisplayForConsole(client)} as ${getGameConfig().skins[getGame()][skin][1]} (${getGameConfig().skins[getGame()][skin][0]})`);
spawnPlayer(client, getGameConfig().skins[getGame()][skin][0], spawnPosition, spawnHeading);
}
@@ -546,45 +550,6 @@ function setFightStyleCommand(command, params, client) {
// ===========================================================================
function forceFightStyleCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
let targetClient = getPlayerFromParams(getParam(params, " ", 1));
let fightStyleId = getFightStyleFromParams(getParam(params, " ", 2));
//if(!targetClient) {
// messagePlayerError(client, `Player not found!`);
// return false;
//}
//if(!getPlayerData(targetClient)) {
// messagePlayerError(client, `Player not found!`);
// return false;
//}
//if(!isPlayerSpawned(targetClient)) {
// messagePlayerError(client, `That player isn't spawned`);
// return false;
//}
if(!fightStyleId) {
messagePlayerError(client, `That fight style doesn't exist!`);
messagePlayerError(client, `Fight styles: ${getGameConfig().fightStyles[getServerGame()].map(fs => fs[0]).join(", ")}`);
return false;
}
getPlayerCurrentSubAccount(client).fightStyle = fightStyleId;
setPlayerFightStyle(client, fightStyleId);
messagePlayerSuccess(client, `You set ${getCharacterFullName(targetClient)}'s fight style to ${getGameConfig().fightStyles[getServerGame()][fightStyleId][0]}`)
return true;
}
// ===========================================================================
function createDefaultSubAccountServerData(databaseId, thisServerSkin) {
for(let i = 1 ; i <= 5 ; i++) {
if(i == getServerId()) {

View File

@@ -11,7 +11,7 @@ let serverTimers = {};
// ===========================================================================
function saveAllServerDataToDatabase() {
function saveServerDataToDatabase() {
if(getServerConfig().pauseSavingToDatabase) {
return false;
}
@@ -19,55 +19,49 @@ function saveAllServerDataToDatabase() {
logToConsole(LOG_DEBUG, "[VRR.Utilities]: Saving all server data to database ...");
try {
saveAllClientsToDatabase();
saveClientsToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save clients to database: ${error}`);
}
try {
saveAllClansToDatabase();
saveClansToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save clans to database: ${error}`);
}
try {
saveAllHousesToDatabase();
saveHousesToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save houses to database: ${error}`);
}
try {
saveAllBusinessesToDatabase();
saveBusinessesToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save businesses to database: ${error}`);
}
try {
saveServerConfigToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save server config to database: ${error}`);
}
try {
saveAllVehiclesToDatabase();
saveVehiclesToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save vehicles to database: ${error}`);
}
try {
saveAllItemTypesToDatabase();
saveItemTypesToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save item types to database: ${error}`);
}
try {
saveAllItemsToDatabase();
saveItemsToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save items to database: ${error}`);
}
try {
saveAllJobsToDatabase();
saveJobsToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save jobs to database: ${error}`);
}
@@ -112,7 +106,7 @@ function oneMinuteTimerFunction() {
function tenMinuteTimerFunction() {
showRandomTipToAllPlayers();
saveAllServerDataToDatabase();
saveServerDataToDatabase();
checkInactiveVehicleRespawns();
}
@@ -251,18 +245,18 @@ function showRandomTipToAllPlayers() {
function checkInactiveVehicleRespawns() {
let vehicles = getElementsByType(ELEMENT_VEHICLE);
for(let i in vehicles) {
if(getVehicleData(vehicles[i] != false)) {
if(isVehicleUnoccupied(vehicles[i])) {
if(getVehicleData(vehicles[i]).lastActiveTime != false) {
if(getCurrentUnixTimestamp() - getVehicleData(vehicles[i]).lastActiveTime >= getGlobalConfig().vehicleInactiveRespawnDelay) {
respawnVehicle(vehicles[i]);
getVehicleData(vehicles[i]).lastActiveTime = false;
}
}
} else {
getVehicleData(vehicles[i]).lastActiveTime = getCurrentUnixTimestamp();
}
}
if(getVehicleData(vehicles[i] != false)) {
if(isVehicleUnoccupied(vehicles[i])) {
if(getVehicleData(vehicles[i]).lastActiveTime != false) {
if(getCurrentUnixTimestamp() - getVehicleData(vehicles[i]).lastActiveTime >= getGlobalConfig().vehicleInactiveRespawnDelay) {
respawnVehicle(vehicles[i]);
getVehicleData(vehicles[i]).lastActiveTime = false;
}
}
} else {
getVehicleData(vehicles[i]).lastActiveTime = getCurrentUnixTimestamp();
}
}
}
}

View File

@@ -8,44 +8,44 @@
// ===========================================================================
const triggerTypes = [
"onBusinessOwnerChange",
"onBusinessNameChange",
"onBusinessLockChange",
"onBusinessPlayerEnter",
"onBusinessPlayerExit",
"onBusinessBotEnter",
"onBusinessBotExit",
"onBusinessDamage",
"onBusinessRobbed",
"onBusinessPlayerPurchase",
"onBusinessBotPurchase",
"onHouseOwnerChange",
"onHouseNameChange",
"onHouseLockChange",
"onHousePlayerEnter",
"onHousePlayerExit",
"onHouseBotEnter",
"onHouseBotExit",
"onHouseDamage",
"onHouseRobbed",
"onVehicleOwnerChange",
"onVehiclePlayerEnter",
"onVehiclePlayerExit",
"onVehicleBotEnter",
"onVehicleBotExit",
"onVehicleCollision",
"onVehicleDamaged",
"onVehicleShot",
"onVehicleTrunkChange",
"onVehicleItemTaken",
"onVehicleItemStored",
"onVehicleEngineChange",
"onVehicleLightsChange",
"onVehicleSirenChange",
"onVehicleLockChange",
"onVehicleRepaired",
"onVehicleColourChange",
"onVehicleExtraChange",
"onBusinessOwnerChange",
"onBusinessNameChange",
"onBusinessLockChange",
"onBusinessPlayerEnter",
"onBusinessPlayerExit",
"onBusinessBotEnter",
"onBusinessBotExit",
"onBusinessDamage",
"onBusinessRobbed",
"onBusinessPlayerPurchase",
"onBusinessBotPurchase",
"onHouseOwnerChange",
"onHouseNameChange",
"onHouseLockChange",
"onHousePlayerEnter",
"onHousePlayerExit",
"onHouseBotEnter",
"onHouseBotExit",
"onHouseDamage",
"onHouseRobbed",
"onVehicleOwnerChange",
"onVehiclePlayerEnter",
"onVehiclePlayerExit",
"onVehicleBotEnter",
"onVehicleBotExit",
"onVehicleCollision",
"onVehicleDamaged",
"onVehicleShot",
"onVehicleTrunkChange",
"onVehicleItemTaken",
"onVehicleItemStored",
"onVehicleEngineChange",
"onVehicleLightsChange",
"onVehicleSirenChange",
"onVehicleLockChange",
"onVehicleRepaired",
"onVehicleColourChange",
"onVehicleExtraChange",
];
// ===========================================================================

View File

@@ -10,8 +10,8 @@
// ===========================================================================
function startTutorial(client) {
getPlayerData(client).tutorialItem = createGroundItem(tutorialItem[0], tutorialItem[1], tutorialItem[3]);
getPlayerData(client).tutorialVehicle = createGroundItem(tutorialItem[0], tutorialItem[1], tutorialItem[3]);
getPlayerData(client).tutorialItem = createGroundItem(tutorialItem[0], tutorialItem[1], tutorialItem[3]);
getPlayerData(client).tutorialVehicle = createGroundItem(tutorialItem[0], tutorialItem[1], tutorialItem[3]);
}
// ===========================================================================

View File

@@ -82,7 +82,7 @@ function initAllClients() {
function updateServerRules() {
logToConsole(LOG_DEBUG, `[VRR.Utilities]: Updating all server rules ...`);
logToConsole(LOG_DEBUG, `[VRR.Utilities]: Time support: ${isTimeSupported()}`);
if(isTimeSupported()) {
if(getServerConfig() != false) {
@@ -363,7 +363,7 @@ function updateConnectionLogOnClientInfoReceive(client, clientVersion, screenWid
let safeClientVersion = escapeDatabaseString(dbConnection, clientVersion);
let safeScreenWidth = escapeDatabaseString(dbConnection, toString(screenWidth));
let safeScreenHeight = escapeDatabaseString(dbConnection, toString(screenHeight));
quickDatabaseQuery(`UPDATE conn_main SET conn_client_version='${safeClientVersion}', conn_screen_width='${safeScreenWidth}', conn_screen_height='${safeScreenHeight}' WHERE conn_id = ${getPlayerData(client).sessionId}`);
quickDatabaseQuery(`UPDATE conn_main SET conn_client_version='${safeClientVersion}', conn_screen_width='${safeScreenWidth}', conn_screen_height='${safeScreenHeight}' WHERE conn_id = ${getPlayerData(client).sessionId}`);
}
}
@@ -395,19 +395,22 @@ function getClientFromSyncerId(syncerId) {
// ===========================================================================
async function triggerWebHook(webHookURL, payloadData) {
return new Promise(resolve => {
//console.warn(webHookURL);
httpGet(
webHookURL,
`data=${payloadData}`,
function(data) {
//console.warn(JSON.parse(data));
},
function(data) {
}
);
});
function triggerWebHook(messageString, serverId = getServerId(), type = VRR_DISCORD_WEBHOOK_LOG) {
let tempURL = getGlobalConfig().discord.webhook.webhookBaseURL;
tempURL = tempURL.replace("{0}", encodeURI(messageString));
tempURL = tempURL.replace("{1}", serverId);
tempURL = tempURL.replace("{2}", type);
tempURL = tempURL.replace("{3}", getGlobalConfig().discord.webhook.pass);
httpGet(
tempURL,
"",
function(data) {
},
function(data) {
}
);
}
// ===========================================================================
@@ -445,9 +448,9 @@ function clearTemporaryPeds() {
// ===========================================================================
function kickAllClients() {
getClients().forEach((client) => {
client.disconnect();
})
getClients().forEach((client) => {
client.disconnect();
})
}
// ===========================================================================
@@ -464,4 +467,30 @@ function isClientInitialized(client) {
return (typeof getServerData().clients[client.index] != "undefined");
}
// ===========================================================================
// ===========================================================================
function getPedForNetworkEvent(ped) {
if(getGame() == VRR_GAME_GTA_IV) {
return ped;
} else {
return ped.id;
}
}
// ===========================================================================
// Get how many times a player connected in the last month by name
function getPlayerConnectionsInLastMonthByName(name) {
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeName = escapeDatabaseString(dbConnection, name);
let result = quickDatabaseQuery(`SELECT COUNT(*) AS count FROM conn_main WHERE conn_when_connect >= NOW() - INTERVAL 1 MONTH AND conn_name = '${safeName}'`);
if(result) {
return result[0].count;
}
}
return 0;
}
// ===========================================================================

View File

@@ -9,7 +9,10 @@
function initVehicleScript() {
logToConsole(LOG_INFO, "[VRR.Vehicle]: Initializing vehicle script ...");
getServerData().vehicles = loadVehiclesFromDatabase();
if(!getServerConfig().devServer) {
getServerData().vehicles = loadVehiclesFromDatabase();
}
spawnAllVehicles();
setAllVehicleIndexes();
logToConsole(LOG_INFO, "[VRR.Vehicle]: Vehicle script initialized successfully!");
@@ -42,7 +45,11 @@ function loadVehiclesFromDatabase() {
// ===========================================================================
function saveAllVehiclesToDatabase() {
function saveVehiclesToDatabase() {
if(getServerConfig().devServer) {
return false;
}
logToConsole(LOG_INFO, "[VRR.Vehicle]: Saving all server vehicles to database ...");
let vehicles = getServerData().vehicles;
for(let i in vehicles) {
@@ -560,7 +567,7 @@ function buyVehicleCommand(command, params, client) {
getPlayerData(client).buyingVehicle = vehicle;
getVehicleData(vehicle).engine = true;
vehicle.engine = true;
setEntityData(vehicle, "vrr.engine", getVehicleData(vehicle).engine, true);
setEntityData(vehicle, "vrr.engine", getVehicleData(vehicle).engine, true);
getVehicleData(vehicle).needsSaved = true;
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_TESTDRIVE, vehicle.id, getVehiclePosition(vehicle));
@@ -790,17 +797,25 @@ function setVehicleClanCommand(command, params, client) {
}
let vehicle = getPlayerVehicle(client);
let clanId = getClanFromParams(params);
let clanId = getPlayerClan(client);
if(!getClanData(clanId)) {
messagePlayerError(client, "That clan is invalid or doesn't exist!");
return false;
}
getVehicleData(vehicle).ownerType = VRR_VEHOWNER_CLAN;
getVehicleData(vehicle).ownerId = getClanData(clanId).databaseId;
if(getVehicleData(vehicle).ownerType != VRR_VEHOWNER_PLAYER) {
messagePlayerError(client, getLocaleString(client, "MustOwnVehicle"));
return false;
}
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)} {MAINCOLOUR}owner to the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan`);
if(getVehicleData(vehicle).ownerId != getPlayerCurrentSubAccount(client).databaseId) {
messagePlayerError(client, getLocaleString(client, "MustOwnVehicle"));
return false;
}
showPlayerPromptGUI(client, getLocaleString(client, "SetVehicleClanConfirmMessage"), getLocaleString(client, "SetVehicleClanConfirm"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
getPlayerData(client).promptType = VRR_PROMPT_GIVEVEHTOCLAN;
getVehicleData(vehicle).needsSaved = true;
}
@@ -1073,7 +1088,7 @@ function reloadAllVehiclesCommand(command, params, client) {
getServerData().vehicles = loadVehiclesFromDatabase();
spawnAllVehicles();
messageAdminAction(`All server vehicles have been reloaded by an admin!`);
announceAdminAction(`AllVehiclesReloaded`);
getVehicleData(vehicle).needsSaved = true;
}
@@ -1081,14 +1096,14 @@ function reloadAllVehiclesCommand(command, params, client) {
// ===========================================================================
function respawnVehicleCommand(command, params, client) {
if(isPlayerInAnyVehicle(client)) {
removeAllOccupantsFromVehicle(getPlayerVehicle(client));
respawnVehicle(getPlayerVehicle(client));
}
if(isPlayerInAnyVehicle(client)) {
removeAllOccupantsFromVehicle(getPlayerVehicle(client));
respawnVehicle(getPlayerVehicle(client));
}
setAllVehicleIndexes();
messagePlayerSuccess(client, `Your vehicle has been respawned`);
messagePlayerSuccess(client, getLocaleString(client, `YourVehicleRespawned`));
}
@@ -1106,7 +1121,7 @@ function respawnAllVehiclesCommand(command, params, client) {
setAllVehicleIndexes();
messageAdminAction(`All vehicles have been respawned by an admin!`);
announceAdminAction(`AllVehiclesRespawned`);
}
// ===========================================================================
@@ -1125,7 +1140,7 @@ function respawnEmptyVehiclesCommand(command, params, client) {
}
}
messageAdminAction(`All empty vehicles have been respawned by an admin!`);
announceAdminAction(`EmptyVehiclesRespawned`);
}
// ===========================================================================
@@ -1135,9 +1150,9 @@ function respawnJobVehiclesCommand(command, params, client) {
if(getServerData().vehicles[i].ownerType == VRR_VEHOWNER_JOB) {
respawnVehicle(getServerData().vehicles[i].vehicle);
}
}
}
messageAdminAction(`All job vehicles have been respawned by an admin!`);
announceAdminAction(`JobVehiclesRespawned`);
}
// ===========================================================================
@@ -1147,9 +1162,9 @@ function respawnClanVehiclesCommand(command, params, client) {
if(getServerData().vehicles[i].ownerType == VRR_VEHOWNER_CLAN) {
respawnVehicle(getServerData().vehicles[i].vehicle);
}
}
}
messageAdminAction(`All clan vehicles have been respawned by an admin!`);
announceAdminAction(`ClanVehiclesRespawned`);
}
// ===========================================================================
@@ -1159,9 +1174,9 @@ function respawnPlayerVehiclesCommand(command, params, client) {
if(getServerData().vehicles[i].ownerType == VRR_VEHOWNER_PLAYER) {
respawnVehicle(getServerData().vehicles[i].vehicle);
}
}
}
messageAdminAction(`All player-owned vehicles have been respawned by an admin!`);
announceAdminAction(`PlayerVehiclesRespawned`);
}
// ===========================================================================
@@ -1171,9 +1186,9 @@ function respawnPublicVehiclesCommand(command, params, client) {
if(getServerData().vehicles[i].ownerType == VRR_VEHOWNER_PUBLIC) {
respawnVehicle(getServerData().vehicles[i].vehicle);
}
}
}
messageAdminAction(`All public vehicles have been respawned by an admin!`);
announceAdminAction(`PublicVehiclesRespawned`);
}
// ===========================================================================
@@ -1183,9 +1198,9 @@ function respawnBusinessVehiclesCommand(command, params, client) {
if(getServerData().vehicles[i].ownerType == VRR_VEHOWNER_BIZ) {
respawnVehicle(getServerData().vehicles[i].vehicle);
}
}
}
messageAdminAction(`All business-owned vehicles have been respawned by an admin!`);
announceAdminAction(`BusinessVehiclesRespawned`);
}
// ===========================================================================
@@ -1417,76 +1432,83 @@ function createPermanentVehicle(modelIndex, position, heading, interior = 0, dim
// ===========================================================================
function processVehiclePurchasing() {
if(!getGlobalConfig().useServerSideVehiclePurchaseCheck) {
return false;
}
if(!getGlobalConfig().useServerSideVehiclePurchaseCheck) {
return false;
}
getClients().forEach((client) => {
if(!isPlayerLoggedIn(client)) {
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
return false;
}
if(!isPlayerSpawned(client)) {
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
return false;
}
if(!getPlayerData(client)) {
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
return false;
}
if(!getPlayerData(client).buyingVehicle) {
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
return false;
}
if(!isPlayerInAnyVehicle(client)) {
if(getPlayerData(client).buyingVehicle != false) {
messagePlayerError(client, getLocaleString(client, "DealershipPurchaseExitedVehicle"));
respawnVehicle(getPlayerData(client).buyingVehicle);
getPlayerData(client).buyingVehicle = false;
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
}
return false;
}
if(getDistance(getVehiclePosition(getPlayerData(client).buyingVehicle), getVehicleData(getPlayerData(client).buyingVehicle).spawnPosition) > getGlobalConfig().buyVehicleDriveAwayDistance) {
if(getPlayerCurrentSubAccount(client).cash < getVehicleData(getPlayerData(client).buyingVehicle).buyPrice) {
messagePlayerError(client, getLocaleString(client, "VehiclePurchaseNotEnoughMoney"));
respawnVehicle(getPlayerData(client).buyingVehicle);
getPlayerData(client).buyingVehicle = false;
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
return false;
}
createNewDealershipVehicle(getVehicleData(getPlayerData(client).buyingVehicle).model, getVehicleData(getPlayerData(client).buyingVehicle).spawnPosition, getVehicleData(getPlayerData(client).buyingVehicle).spawnRotation, getVehicleData(getPlayerData(client).buyingVehicle).buyPrice, getVehicleData(getPlayerData(client).buyingVehicle).ownerId);
takePlayerCash(client, getVehicleData(getPlayerData(client).buyingVehicle).buyPrice);
updatePlayerCash(client);
getVehicleData(getPlayerData(client).buyingVehicle).ownerId = getPlayerCurrentSubAccount(client).databaseId;
getVehicleData(getPlayerData(client).buyingVehicle).ownerType = VRR_VEHOWNER_PLAYER;
getVehicleData(getPlayerData(client).buyingVehicle).buyPrice = 0;
getVehicleData(getPlayerData(client).buyingVehicle).rentPrice = 0;
getVehicleData(getPlayerData(client).buyingVehicle).spawnLocked = false;
getPlayerData(client).buyingVehicle = false;
messagePlayerSuccess(client, getLocaleString(client, "VehiclePurchaseComplete"));
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
return true;
}
});
let clients = getClients();
for(let i in clients) {
checkVehicleBuying(clients[i]);
}
return false;
}
// ===========================================================================
function checkVehicleBuying(client) {
if(!isPlayerLoggedIn(client)) {
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
return false;
}
if(!isPlayerSpawned(client)) {
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
return false;
}
if(!getPlayerData(client)) {
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
return false;
}
if(!getPlayerData(client).buyingVehicle) {
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
return false;
}
if(!isPlayerInAnyVehicle(client)) {
if(getPlayerData(client).buyingVehicle != false) {
messagePlayerError(client, getLocaleString(client, "DealershipPurchaseExitedVehicle"));
respawnVehicle(getPlayerData(client).buyingVehicle);
getPlayerData(client).buyingVehicle = false;
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
}
return false;
}
if(getDistance(getVehiclePosition(getPlayerData(client).buyingVehicle), getVehicleData(getPlayerData(client).buyingVehicle).spawnPosition) > getGlobalConfig().buyVehicleDriveAwayDistance) {
if(getPlayerCurrentSubAccount(client).cash < getVehicleData(getPlayerData(client).buyingVehicle).buyPrice) {
messagePlayerError(client, getLocaleString(client, "VehiclePurchaseNotEnoughMoney"));
respawnVehicle(getPlayerData(client).buyingVehicle);
getPlayerData(client).buyingVehicle = false;
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
return false;
}
createNewDealershipVehicle(getVehicleData(getPlayerData(client).buyingVehicle).model, getVehicleData(getPlayerData(client).buyingVehicle).spawnPosition, getVehicleData(getPlayerData(client).buyingVehicle).spawnRotation, getVehicleData(getPlayerData(client).buyingVehicle).buyPrice, getVehicleData(getPlayerData(client).buyingVehicle).ownerId);
takePlayerCash(client, getVehicleData(getPlayerData(client).buyingVehicle).buyPrice);
updatePlayerCash(client);
getVehicleData(getPlayerData(client).buyingVehicle).ownerId = getPlayerCurrentSubAccount(client).databaseId;
getVehicleData(getPlayerData(client).buyingVehicle).ownerType = VRR_VEHOWNER_PLAYER;
getVehicleData(getPlayerData(client).buyingVehicle).buyPrice = 0;
getVehicleData(getPlayerData(client).buyingVehicle).rentPrice = 0;
getVehicleData(getPlayerData(client).buyingVehicle).spawnLocked = false;
getPlayerData(client).buyingVehicle = false;
messagePlayerSuccess(client, getLocaleString(client, "VehiclePurchaseComplete"));
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
return true;
}
}
// ===========================================================================
function processVehicleBurning() {
let vehicles = getElementsByType(ELEMENT_VEHICLE);
for(let i in vehicles) {
if(vehicles[i].health <= 250) {
return false;
}
if(vehicles[i].health <= 250) {
return false;
}
}
}
@@ -1524,19 +1546,19 @@ function setAllVehicleIndexes() {
// ===========================================================================
function doesVehicleHaveMegaphone(vehicle) {
if(getVehicleData(vehicle).ownerType == VRR_VEHOWNER_JOB) {
if(getJobType(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)) == VRR_JOB_POLICE) {
return true;
}
if(getVehicleData(vehicle).ownerType == VRR_VEHOWNER_JOB) {
if(getJobType(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)) == VRR_JOB_POLICE) {
return true;
}
if(getJobType(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)) == VRR_JOB_FIRE) {
return true;
}
if(getJobType(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)) == VRR_JOB_FIRE) {
return true;
}
if(getJobType(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)) == VRR_JOB_MEDICAL) {
return true;
}
}
if(getJobType(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)) == VRR_JOB_MEDICAL) {
return true;
}
}
return false;
}
@@ -1581,11 +1603,11 @@ function getVehicleTrunkPosition(vehicle) {
// ===========================================================================
function removeAllOccupantsFromVehicle(vehicle) {
for(let i = 0 ; i <= 16 ; i++) {
if(vehicle.getOccupant(i) != null) {
removePlayerFromVehicle(vehicle.getOccupant(i));
}
}
for(let i = 0 ; i <= 16 ; i++) {
if(vehicle.getOccupant(i) != null) {
removePlayerFromVehicle(vehicle.getOccupant(i));
}
}
}
// ===========================================================================

View File

@@ -3,7 +3,7 @@
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: const.js
// DESC: Provides constants
// DESC: Provides shared constants
// TYPE: Shared (JavaScript)
// ===========================================================================
@@ -80,6 +80,8 @@ const VRR_ANIMMOVE_RIGHT = 4;
const VRR_MPMOD_NONE = 0;
const VRR_MPMOD_GTAC = 1;
const VRR_MPMOD_MAFIAC = 2;
const VRR_MPMOD_OAKWOOD = 3;
const VRR_MPMOD_RAGEMP = 4;
// Business/House Game Script States
//const VRR_GAMESCRIPT_NONE = 0;
@@ -92,4 +94,19 @@ const VRR_VEHBUYSTATE_NONE = 0;
const VRR_VEHBUYSTATE_TESTDRIVE = 1;
const VRR_VEHBUYSTATE_EXITVEH = 2;
const VRR_VEHBUYSTATE_FARENOUGH = 3;
const VRR_VEHBUYSTATE_WRONGVEH = 4;
const VRR_VEHBUYSTATE_WRONGVEH = 4;
// Body Parts for Skin Select
const VRR_SKINSELECT_NONE = 0;
const VRR_SKINSELECT_SKIN = 1;
const VRR_SKINSELECT_HAT = 2;
const VRR_SKINSELECT_HAIR = 3;
const VRR_SKINSELECT_EYES = 5;
const VRR_SKINSELECT_UPPER = 6;
const VRR_SKINSELECT_LOWER = 7;
const VRR_SKINSELECT_SHOES = 8;
const VRR_SKINSELECT_LEFTWRIST = 9;
const VRR_SKINSELECT_RIGHTWRIST = 10;
const VRR_SKINSELECT_LEFTHAND = 11;
const VRR_SKINSELECT_RIGHTHAND = 12;
const VRR_SKINSELECT_HEAD = 13;

File diff suppressed because it is too large Load Diff

View File

@@ -2,174 +2,131 @@
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: v.js
// FILE: utilities.js
// DESC: Provides shared utilities
// TYPE: Shared (JavaScript)
// ===========================================================================
let bindableKeys = {
8: "backspace",
9: "tab",
13: "return",
27: "escape",
32: "space",
33: "exclamation",
34: "doublequote",
35: "hashtag",
36: "dollar",
37: "percent",
38: "ampersand",
39: "quote",
40: "leftparenthesis",
41: "rightparenthesis",
42: "asterisk",
43: "plus",
44: "comma",
45: "minus",
46: "period",
47: "slash",
48: "0",
49: "1",
50: "2",
51: "3",
52: "4",
53: "5",
54: "6",
55: "7",
56: "8",
57: "9",
58: "colon",
59: "semicolon",
60: "less",
61: "equals",
62: "greater",
63: "questionmark",
64: "at",
91: "leftbracket",
92: "backslash",
93: "rightbracket",
95: "underscore",
97: "a",
98: "b",
99: "c",
100: "d",
101: "e",
102: "f",
103: "g",
104: "h",
105: "i",
106: "j",
107: "k",
108: "l",
109: "m",
110: "n",
111: "o",
112: "p",
113: "q",
114: "r",
115: "s",
116: "t",
117: "u",
118: "v",
119: "w",
120: "x",
121: "y",
122: "z",
127: "delete",
1073741881: "capslock",
1073741882: "f12",
1073741883: "f2",
1073741884: "f3",
1073741885: "f4",
1073741886: "f5",
1073741887: "f6",
1073741888: "f7",
1073741889: "f8",
1073741890: "f9",
1073741891: "f10",
1073741892: "f11",
1073741893: "f12",
1073741894: "printscreen",
1073741895: "scrolllock",
1073741896: "pause",
1073741897: "insert",
1073741898: "home",
1073741899: "pageup",
1073741901: "end",
1073741902: "pagedown",
1073741903: "right",
1073741904: "left",
1073741905: "down",
1073741906: "up",
1073741908: "numdivide",
1073741909: "nummultiply",
1073741910: "numminus",
1073741911: "numplus",
1073741912: "numenter",
1073741913: "num1",
1073741914: "num2",
1073741915: "num3",
1073741916: "num4",
1073741917: "num5",
1073741918: "num6",
1073741919: "num7",
1073741920: "num8",
1073741921: "num9",
1073741922: "num0",
1073741923: "numperiod",
1073742048: "leftctrl",
1073742049: "leftshift",
1073742050: "leftalt",
1073742052: "rightctrl",
1073742053: "rightshift",
1073742054: "rightalt",
8: "backspace",
9: "tab",
13: "return",
27: "escape",
32: "space",
33: "exclamation",
34: "doublequote",
35: "hashtag",
36: "dollar",
37: "percent",
38: "ampersand",
39: "quote",
40: "leftparenthesis",
41: "rightparenthesis",
42: "asterisk",
43: "plus",
44: "comma",
45: "minus",
46: "period",
47: "slash",
48: "0",
49: "1",
50: "2",
51: "3",
52: "4",
53: "5",
54: "6",
55: "7",
56: "8",
57: "9",
58: "colon",
59: "semicolon",
60: "less",
61: "equals",
62: "greater",
63: "questionmark",
64: "at",
91: "leftbracket",
92: "backslash",
93: "rightbracket",
95: "underscore",
97: "a",
98: "b",
99: "c",
100: "d",
101: "e",
102: "f",
103: "g",
104: "h",
105: "i",
106: "j",
107: "k",
108: "l",
109: "m",
110: "n",
111: "o",
112: "p",
113: "q",
114: "r",
115: "s",
116: "t",
117: "u",
118: "v",
119: "w",
120: "x",
121: "y",
122: "z",
127: "delete",
1073741881: "capslock",
1073741882: "f12",
1073741883: "f2",
1073741884: "f3",
1073741885: "f4",
1073741886: "f5",
1073741887: "f6",
1073741888: "f7",
1073741889: "f8",
1073741890: "f9",
1073741891: "f10",
1073741892: "f11",
1073741893: "f12",
1073741894: "printscreen",
1073741895: "scrolllock",
1073741896: "pause",
1073741897: "insert",
1073741898: "home",
1073741899: "pageup",
1073741901: "end",
1073741902: "pagedown",
1073741903: "right",
1073741904: "left",
1073741905: "down",
1073741906: "up",
1073741908: "numdivide",
1073741909: "nummultiply",
1073741910: "numminus",
1073741911: "numplus",
1073741912: "numenter",
1073741913: "num1",
1073741914: "num2",
1073741915: "num3",
1073741916: "num4",
1073741917: "num5",
1073741918: "num6",
1073741919: "num7",
1073741920: "num8",
1073741921: "num9",
1073741922: "num0",
1073741923: "numperiod",
1073742048: "leftctrl",
1073742049: "leftshift",
1073742050: "leftalt",
1073742052: "rightctrl",
1073742053: "rightshift",
1073742054: "rightalt",
};
// ===========================================================================
let weekDays = [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
];
// ===========================================================================
let months = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
];
// ===========================================================================
let cardinalDirections = [
"North",
"Northeast",
"East",
"Southeast",
"South",
"Southwest",
"West",
"Northwest",
"Unknown"
];
// ===========================================================================
let serverColours = {
hex: {
byType: {
@@ -189,6 +146,7 @@ let serverColours = {
clanOrange: "FF9900",
vehiclePurple: "960096",
jobYellow: "FFFF00",
npcPink: "DB7093",
},
byName: {
white: "FFFFFF",
@@ -264,9 +222,12 @@ let serverColours = {
businessBlue: toColour(0, 153, 255, 255),
houseGreen: toColour(17, 204, 17, 255),
clanOrange: toColour(255, 153, 0, 255),
npcPink: toColour(219, 112, 147, 255),
},
};
// ===========================================================================
let serverEmoji = [
[":hash:", "#"],
[":zero:", "0"],
@@ -1125,6 +1086,21 @@ let serverEmoji = [
// ===========================================================================
let placesOfOrigin = [
"Liberty City",
"Vice City",
"Los Santos",
"San Fierro",
"Las Venturas",
"San Andreas",
"Blaine County",
"Red County",
"Bone County",
"Other",
];
// ===========================================================================
function getGameConfig() {
return gameData;
}
@@ -1138,24 +1114,24 @@ function makeLargeNumberReadable(num) {
// ===========================================================================
function getKeyIdFromParams(params) {
let tempParams = toLowerCase(toString(params));
let tempParams = toLowerCase(toString(params));
//let sdlName = sdl.getKeyFromName(tempParams);
//if(sdlName != null) {
// return sdlName;
//}
//let sdlName = sdl.getKeyFromName(tempParams);
//if(sdlName != null) {
// return sdlName;
//}
for(let i in bindableKeys) {
if(toLowerCase(bindableKeys[i]) == toLowerCase(tempParams)) {
return i;
}
}
for(let i in bindableKeys) {
if(toLowerCase(bindableKeys[i]) == toLowerCase(tempParams)) {
return i;
}
}
}
// ===========================================================================
function getKeyNameFromId(params) {
return bindableKeys[toInteger(params)];
return bindableKeys[toInteger(params)];
}
// ===========================================================================
@@ -1350,36 +1326,6 @@ function getEntityData(entity, dataName) {
return entity.getData(dataName);
}
}
return null;
}
// ===========================================================================
function setEntityData(entity, dataName, dataValue, syncToClients = true) {
if(entity != null) {
if(typeof server != "undefined") {
return entity.setData(dataName, dataValue, syncToClients);
} else {
return entity.setData(dataName, dataValue);
}
}
}
// ===========================================================================
function removeEntityData(entity, dataName) {
if(entity != null) {
return entity.removeData(dataName);
}
return null;
}
// ===========================================================================
function doesEntityDataExist(entity, dataName) {
if(entity != null) {
return (entity.getData(dataName) != null);
}
return null;
}
@@ -1389,21 +1335,21 @@ function getDistance(vec1, vec2) {
if(isNull(vec1) || isNull(vec2)) {
return false;
}
return vec1.distance(vec2);
return vec1.distance(vec2);
}
// ===========================================================================
function logToConsole(tempLogLevel, text) {
if(typeof server != "undefined") {
text = removeColoursInMessage(text);
}
if(typeof server != "undefined") {
text = removeColoursInMessage(text);
}
if((logLevel & tempLogLevel) || logLevel == LOG_ALL) {
if(tempLogLevel == LOG_ERROR) {
if((logLevel & tempLogLevel)) {
if(tempLogLevel & LOG_ERROR) {
console.error(text);
return true;
} else if(tempLogLevel == LOG_WARN) {
} else if(tempLogLevel & LOG_WARN) {
console.warn(text);
return true;
} else {
@@ -1417,10 +1363,10 @@ function logToConsole(tempLogLevel, text) {
// ===========================================================================
function Enum(constantsList) {
let tempTable = {};
let tempTable = {};
for(let i in constantsList) {
tempTable[constantsList[i]] = i;
}
tempTable[constantsList[i]] = i;
}
return tempTable;
}
@@ -1499,13 +1445,13 @@ function arePickupsSupported() {
// ===========================================================================
function areBlipsSupported() {
return supportedFeatures.blips[getGame()];
return supportedFeatures.blips[getGame()];
}
// ===========================================================================
function areMarkersSupported() {
return supportedFeatures.markers[getGame()];
return supportedFeatures.markers[getGame()];
}
// ===========================================================================
@@ -1714,6 +1660,16 @@ function getSkinNameFromModel(model, gameId = getGame()) {
// ===========================================================================
function getSkinNameFromIndex(index, gameId = getGame()) {
if(typeof getGameConfig().skins[gameId][index] != "undefined") {
return getGameConfig().skins[gameId][index][1];
}
return "Unknown";
}
// ===========================================================================
function getSkinModelFromName(name, gameId = getGame()) {
let skins = getGameConfig().skins[gameId];
for(let i in skins) {
@@ -1800,7 +1756,7 @@ function getPosInFrontOfPos(pos, angle, distance) {
y = (pos.y+((Math.sin(angle+(Math.PI/2)))*distance));
} else {
while(angle < 0.0)
angle += 360.0;
angle += 360.0;
while(angle > 360.0)
angle -= 360.0;
@@ -2056,23 +2012,23 @@ function removeHexColoursFromString(str) {
// ===========================================================================
async function waitUntil(condition) {
return new Promise((resolve) => {
let interval = setInterval(() => {
if (!condition()) {
return
}
return new Promise((resolve) => {
let interval = setInterval(() => {
if (!condition()) {
return;
}
clearInterval(interval);
resolve();
}, 1);
});
clearInterval(interval);
resolve();
}, 1);
});
}
// ===========================================================================
function getGameLocationFromParams(params) {
if(isNaN(params)) {
let locations = getGameConfig().locations[getGame()];
let locations = getGameConfig().locations[getGame()];
for(let i in locations) {
if(toLowerCase(locations[i][0]).indexOf(toLowerCase(params)) != -1) {
return i;
@@ -2204,16 +2160,16 @@ function getCardinalDirection(pos1, pos2) {
function getTimeDifferenceDisplay(timeStamp2, timeStamp1) {
timeStamp1 = timeStamp1 * 1000;
timeStamp2 = timeStamp2 * 1000;
if(isNaN(timeStamp1) || isNaN(timeStamp2)) {
return "Unknown";
}
if(isNaN(timeStamp1) || isNaN(timeStamp2)) {
return "Unknown";
}
let millisecondDiff = timeStamp2 - timeStamp1;
let days = Math.floor(millisecondDiff / 1000 / 60 / (60 * 24));
let diffDate = new Date(millisecondDiff);
let days = Math.floor(millisecondDiff / 1000 / 60 / (60 * 24));
let diffDate = new Date(millisecondDiff);
return `${days} days, ${diffDate.getHours()} hours, ${diffDate.getMinutes()} minutes`;
return `${days} days, ${diffDate.getHours()} hours, ${diffDate.getMinutes()} minutes`;
}
// ===========================================================================
@@ -2318,35 +2274,52 @@ function ArrayBufferToString(buffer) {
// ===========================================================================
function getElementTypeName(typeId) {
switch(typeId) {
case ELEMENT_VEHICLE:
return "Vehicle";
if(getGame() == VRR_GAME_MAFIA_ONE) {
switch(typeId) {
case ELEMENT_VEHICLE:
return "Vehicle";
case ELEMENT_OBJECT:
return "Object";
case ELEMENT_PED:
return "Ped";
case ELEMENT_PED:
return "Ped";
case ELEMENT_PLAYER:
return "Player Ped";
case ELEMENT_PLAYER:
return "Player Ped";
default:
return "Unknown"
}
} else {
switch(typeId) {
case ELEMENT_VEHICLE:
return "Vehicle";
case ELEMENT_PICKUP:
return "Pickup";
case ELEMENT_OBJECT:
return "Object";
case ELEMENT_BLIP:
return "Blip";
case ELEMENT_PED:
return "Ped";
case ELEMENT_MARKER:
return "Marker";
case ELEMENT_PLAYER:
return "Player Ped";
case ELEMENT_BUILDING:
return "Building";
case ELEMENT_PICKUP:
return "Pickup";
default:
return "Unknown"
case ELEMENT_BLIP:
return "Blip";
case ELEMENT_MARKER:
return "Marker";
case ELEMENT_BUILDING:
return "Building";
default:
return "Unknown"
}
}
return "Unknown";
}
@@ -2399,12 +2372,24 @@ function isConsole(client) {
// ===========================================================================
/**
* Gets the console client (only valid on server)
*
* @return {Boolean} Whether or not the two clients are the same
*
*/
function isSamePlayer(client1, client2) {
return (client1 == client2);
}
// ===========================================================================
/**
* Gets the console client (only valid on server)
*
* @return {Client} Console client
*
*/
function getConsoleClient() {
let clients = getClients();
for(let i in clients) {
@@ -2416,24 +2401,51 @@ function getConsoleClient() {
// ===========================================================================
/**
* Gets the entire colours table
*
* @return {Object} Colours table
*
*/
function getServerColours() {
return serverColours;
}
// ===========================================================================
/**
* Gets an RGB value for a colour type name
*
* @param {String} typeName - Colour type name (red, blue, etc)
* @return {Number} Colour value (same as from toColour)
*
*/
function getColourByType(typeName) {
return getServerColours().byType[typeName];
}
// ===========================================================================
/**
* Gets an RGB value for a colour name
*
* @param {String} colourName - Colour name (error, businessBlue, etc)
* @return {Number} Colour value (same as from toColour)
*
*/
function getColourByName(colourName) {
return getServerColours().byName[colourName];
}
// ===========================================================================
/**
* Gets a hex value for a colour type
*
* @param {String} colourName - Colour name (red, blue, etc)
* @return {String} Hex value as string without brackets (has only the hashtag)
*
*/
function getHexColourByName(colourName) {
//let rgbaColour = getServerColours().byName[colourName];
//let rgbaArray = rgbaArrayFromToColour(rgbaColour);
@@ -2444,7 +2456,14 @@ function getHexColourByName(colourName) {
// ===========================================================================
function getHexColourByType(colourName) {
/**
* Gets a hex value for a colour type
*
* @param {String} typeName - Colour type name (error, businessBlue, etc)
* @return {String} Hex value as string without brackets (has only the hashtag)
*
*/
function getHexColourByType(typeName) {
//let rgbaColour = getServerColours().byType[colourName];
//let rgbaArray = rgbaArrayFromToColour(rgbaColour);
//return rgbToHex(rgbaArray[0], rgbaArray[1], rgbaArray[2]);
@@ -2585,29 +2604,43 @@ function getInlineChatColourByType(colourName) {
*
*/
function rgbaArrayFromToColour(colour) {
//return [
// (colour >> 24) & 0xFF, // red
// (colour >> 16) & 0xFF,
// (colour >> 8) & 0xFF,
// colour & 0xFF // alpha
//];
return [
(colour >> 16) & 0xFF, // red
(colour >> 8) & 0xFF,
colour & 0xFF,
(colour >> 24) & 0xFF// alpha
];
//return [
// (colour >> 24) & 0xFF, // red
// (colour >> 16) & 0xFF,
// (colour >> 8) & 0xFF,
// colour & 0xFF // alpha
//];
return [
(colour >> 16) & 0xFF, // red
(colour >> 8) & 0xFF,
colour & 0xFF,
(colour >> 24) & 0xFF// alpha
];
}
// ===========================================================================
/**
* Gets a hex formatting colour by type for use inline in chatbox messages (example: [#FFFFFF]).
*
* @param {Number} colourValue - Colour value (from toColour)
* @return {String} HEX-formatted colour string without brackets (just the hashtag)
*
*/
function hexFromToColour(colour) {
let rgba = rgbaArrayFromToColour(colour);
return rgbToHex(rgba[0], rgba[1], rgba[2]);
return rgbToHex(rgba[0], rgba[1], rgba[2]);
}
// ===========================================================================
/**
* Replaces colour types with HEX values in a message string
*
* @param {String} colouredString - String with colours
* @return {String} String with replaced colours for inline chatbox usage
*
*/
function replaceColoursInMessage(messageText) {
if(messageText == null) {
return "";
@@ -2642,6 +2675,13 @@ function replaceColoursInMessage(messageText) {
// ===========================================================================
/**
* Removes colour types from a message
*
* @param {String} colouredString - String with colours
* @return {String} String without colours
*
*/
function removeColoursInMessage(messageText) {
if(messageText == null) {
return "";
@@ -2676,6 +2716,13 @@ function removeColoursInMessage(messageText) {
// ===========================================================================
/**
* Replaces emoji texts with actual emoji
*
* @param {String} colouredString - String with emoji names
* @return {String} String with actual emoji images
*
*/
function replaceEmojiInString(messageString) {
for(let i in emojiReplaceString) {
while(messageString.indexOf(emojiReplaceString[i][0]) != -1) {
@@ -2685,4 +2732,59 @@ function replaceEmojiInString(messageString) {
return messageString;
}
// ===========================================================================
function isWeekend() {
let d = new Date();
return d.getDay() == 6 || d.getDay() == 0;
}
// ===========================================================================
/*
function getPlayerLocationName(client) {
if(getPlayerBusiness(client)) {
return `at ${getBusinessData(getPlayerBusiness(client)).name}`;
}
if(getPlayerHouse(client)) {
return `at ${getHouseData(getPlayerHouse(client)).description}`;
}
let closestBusiness = getClosestBusinessEntrance(client.position, getPlayerDimension(client));
if(getBusinessData(closestBusiness)) {
return `near ${getBusinessData(closestBusiness).name} in ${getGameAreaFromPos(getPlayerPosition(client))}`;
}
let closestHouse = getClosestHouseEntrance(client.position, getPlayerDimension(client));
if(getHouseData(closestHouse)) {
let areaId = getGameAreaFromPos(getPlayerPosition(client));
if(getDistance(getHouseData(closestHouse).entrancePosition) > 7) {
return `near ${getHouseData(closestHouse).description} in ${getGameConfig().areas[getGame()][areaId][1]}`;
}
}
}
*/
// ===========================================================================
function getGameAreaFromPos(position) {
let areas = getGameConfig().areas[getGame()];
for(let i in areas) {
if(isPointInPoly(areas[i].borders, position)) {
return i;
}
}
}
// ===========================================================================
function isPosInPoly(poly, position) {
for(var c = false, i = -1, l = poly.length, j = l - 1; ++i < l; j = i)
((poly[i].y <= position.y && position.y < poly[j].y) || (poly[j].y <= position.y && position.y < poly[i].y))
&& (position.x < (poly[j].x - poly[i].x) * (position[1] - poly[i].y) / (poly[j].y - poly[i].y) + poly[i].x)
&& (c = !c);
return c;
}
// ===========================================================================