Bunch of changes (see description)

* New script files to organize GUI
* Added clientside pickup detection to reduce server load for enter/exit
* Added notips command for players to toggle random tips
* Select account last IP as part of wildcard (was separate due to old INT)
* Save account registration with datetime instead of unix timestamp
* Don't force mouse camera on moving anims in SA+
* Add IP ban to server runtime memory in subnet ban command
* Add non-roleplay character name account moderation flag
* Fix bizowner and bizclan commands
* Fix bug that allowed buying items without having the needed cash
* Fix set biz blip command
* Add dealership help label type command
* Added command to show all clan flag types
* Added discord config and load from database
* Fix angle for directional teleport and anim move directions
* Use new colour structure in preparation for locale translations
* Add on-foot only item usetype array to prevent using when in veh
* Fix wrong const value for exit pickup type
* Start using datetime in MySQL tables instead of unix timestamps
* Start adding webhooks for discord (unfinished)
* Added new discord URL to discord help category
* Added house reset pickups/blips utils
* Prevent using items when in skin selector
* Fix get player command
* Fix give player money command
* Add coffee shop and vehicle repair shop default biz item templates
* Remove old game fixes util (resource now in server config)
* Fix bug where characters in clans wouldn't be shown in char select
* Slimmed down the amount of timers
* Made some potentially large numbers more readable (commas)
* Remove colours in message for console output
This commit is contained in:
Vortrex
2021-09-28 11:41:33 -05:00
parent b19b35368d
commit 9d8d5d1418
48 changed files with 1804 additions and 1154 deletions

View File

@@ -46,6 +46,36 @@ function autoLoginByIPCommand(command, params, client) {
// ===========================================================================
function toggleNoRandomTipsCommand(command, params, client) {
let flagValue = getAccountSettingsFlagValue("noTimedRandomTips");
if(isAccountAutoIPLoginEnabled(getPlayerData(client).accountData)) {
getPlayerData(client).accountData.settings = getPlayerData(client).accountData.settings & ~flagValue;
messagePlayerSuccess(client, `You will not receive random tips anymore.`);
} else {
getPlayerData(client).accountData.settings = getPlayerData(client).accountData.settings | flagValue;
messagePlayerSuccess(client, `You will now receive random tips every 15 minutes.`);
}
return true;
}
// ===========================================================================
function toggleNoActionTipsCommand(command, params, client) {
let flagValue = getAccountSettingsFlagValue("noActionTips");
if(isAccountAutoIPLoginEnabled(getPlayerData(client).accountData)) {
getPlayerData(client).accountData.settings = getPlayerData(client).accountData.settings & ~flagValue;
messagePlayerSuccess(client, `You will not receive action-based tips anymore.`);
} else {
getPlayerData(client).accountData.settings = getPlayerData(client).accountData.settings | flagValue;
messagePlayerSuccess(client, `You will now receive tips for some actions and commands.`);
}
return true;
}
// ===========================================================================
function autoSelectLastCharacterCommand(command, params, client) {
let flagValue = getAccountSettingsFlagValue("autoSelectLastCharacter");
@@ -296,6 +326,37 @@ function verifyAccountEmailCommand(command, params, client) {
// ===========================================================================
/*
function resetAccountPasswordCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
let splitParams = params.split(" ");
let verificationCode = splitParams[0] || "";
if(!isAccountEmailVerified(getPlayerData(client).accountData)) {
messagePlayerError(client, `Your email is not verified. Your password will not be reset!`);
return false;
}
if(!areParamsEmpty(verificationCode)) {
if(module.hashing.sha512(verificationCode) != getPlayerData(client).accountData.resetPasswordVerificationCode) {
messagePlayerError(client, `Invalid reset password verification code! A new one has been created and sent to your email.`);
let resetPasswordVerificationCode = generateResetPasswordVerificationCode();
setAccountEmailVerificationCode(getPlayerData(client).accountData, emailVerificationCode);
sendEmailVerificationEmail(client, emailVerificationCode);
return false;
}
}
saveAccountToDatabase(getPlayerData(client).accountData);
}
*/
// ===========================================================================
function setAccountDiscordCommand(command, params, client) {
messagePlayerError(client, `This command is not yet finished and will be available soon!`);
return false;
@@ -371,7 +432,7 @@ function loadAccountFromName(accountName, fullLoad = false) {
let dbConnection = connectToDatabase();
if(dbConnection) {
accountName = escapeDatabaseString(dbConnection, accountName);
let dbQueryString = `SELECT acct_main.*, acct_svr.*, acct_main.acct_ip AS ipstring FROM acct_main INNER JOIN acct_svr ON acct_svr.acct_svr_acct = acct_main.acct_id AND acct_svr.acct_svr_svr = ${getServerId()} WHERE acct_name = '${accountName}' LIMIT 1;`;
let dbQueryString = `SELECT acct_main.*, acct_svr.* FROM acct_main INNER JOIN acct_svr ON acct_svr.acct_svr_acct = acct_main.acct_id AND acct_svr.acct_svr_svr = ${getServerId()} WHERE acct_name = '${accountName}' LIMIT 1;`;
let dbQuery = queryDatabase(dbConnection, dbQueryString);
if(dbQuery) {
if(dbQuery.numRows > 0) {
@@ -664,7 +725,7 @@ function createAccount(name, password, email = "") {
let safeName = escapeDatabaseString(dbConnection, name);
let safeEmail = escapeDatabaseString(dbConnection, email);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO acct_main (acct_name, acct_pass, acct_email, acct_when_registered) VALUES ('${safeName}', '${hashedPassword}', '${safeEmail}', UNIX_TIMESTAMP())`);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO acct_main (acct_name, acct_pass, acct_email, acct_when_registered) VALUES ('${safeName}', '${hashedPassword}', '${safeEmail}', CURRENT_TIMESTAMP())`);
if(getDatabaseInsertId(dbConnection) > 0) {
let tempAccountData = loadAccountFromId(getDatabaseInsertId(dbConnection), false);
createDefaultAccountServerData(tempAccountData.databaseId);

View File

@@ -40,8 +40,8 @@ function playPlayerAnimationCommand(command, params, client) {
getPlayerData(client).currentAnimationPositionReturnTo = getPlayerPosition(client);
getPlayerData(client).animationStart = getCurrentUnixTimestamp();
//setEntityData(getPlayerData(client).ped, "vrr.animation", animationSlot, true);
messagePlayerTip(client, `${getInlineChatColourByName("white")}Use ${getInlineChatColourByName("lightGrey")}/stopanim ${getInlineChatColourByName("white")}to stop your animation`);
makePedPlayAnimation(getPlayerData(client).ped, animationSlot, animationPositionOffset);
setPlayerMouseCameraState(client, true);
}
// ===========================================================================

View File

@@ -109,6 +109,8 @@ function subNetBanCommand(command, params, client, fromDiscord) {
messageAdminAction(`${targetgetPlayerName(client)} has been banned from the server (subnet ban).`);
banSubNet(targetClient.ip, getSubNet(targetClient.ip, octetAmount), getPlayerData(client).accountData.databaseId, reason);
server.banIP(targetClient.ip);
}
// ===========================================================================

View File

@@ -59,6 +59,7 @@ let serverBitFlagKeys = {
"characterNameNeedsStaffApproval",
"emailVerified",
"twoFactorAuthVerified",
"nonRoleplayCharacterName",
],
factionFlagKeys: [
"none",

View File

@@ -273,17 +273,17 @@ function setBusinessOwnerCommand(command, params, client) {
return false;
}
if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("manageBusinesses"))) {
if(getBusinessData(businessId).ownerType == VRR_BIZOWNER_PLAYER && getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
if(getBusinessData(businessId).ownerType != VRR_BIZOWNER_PLAYER || getBusinessData(businessId).ownerId != getPlayerCurrentSubAccount(client).databaseId) {
if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("manageBusinesses"))) {
messagePlayerError(client, "You don't own this business!");
return false;
}
return false;
}
getBusinessData(businessId).ownerType = VRR_BIZOWNER_PLAYER;
getBusinessData(businessId).ownerId = getServerData().clients[newBusinessOwner.index].accountData.databaseId;
getBusinessData(businessId).ownerId = getPlayerCurrentSubAccount(newBusinessOwner).databaseId;
getBusinessData(businessId).needsSaved = true;
messagePlayerSuccess(`${getInlineChatColourByName("white")}You gave business ${getInlineChatColourByType("businessBlue")}${getBusinessData(businessId).name} ${getInlineChatColourByName("white")}to ${getInlineChatColourByName("lightGrey")}${newBusinessOwner.name}`);
}
@@ -297,7 +297,7 @@ function setBusinessClanCommand(command, params, client) {
return false;
}
let clanId = getPlayerClan(params);
let clanId = getPlayerClan(client);
if(!getClanData(clanId)) {
messagePlayerError(client, "Clan not found!");
@@ -305,7 +305,7 @@ function setBusinessClanCommand(command, params, client) {
}
if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("manageBusinesses"))) {
if(getBusinessData(businessId).ownerType == VRR_BIZOWNER_PLAYER && getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
if(getBusinessData(businessId).ownerType != VRR_BIZOWNER_PLAYER && getBusinessData(businessId).ownerId != getPlayerCurrentSubAccount(client).databaseId) {
messagePlayerError(client, "You don't own this business!");
return false;
}
@@ -313,8 +313,8 @@ function setBusinessClanCommand(command, params, client) {
getBusinessData(businessId).ownerType = VRR_BIZOWNER_CLAN;
getBusinessData(businessId).ownerId = getClanData(clanId).databaseId;
getBusinessData(businessId).needsSaved = true;
messagePlayerSuccess(`${getInlineChatColourByName("white")}You gave business ${getInlineChatColourByType("businessBlue")}${getBusinessData(businessId).name} ${getInlineChatColourByName("white")}to the ${getInlineChatColourByType("clanOrange")}${getClanData(clanId).name} ${getInlineChatColourByName("white")}clan!`);
}
@@ -337,7 +337,7 @@ function setBusinessClanCommand(command, params, client) {
return false;
}
let clanId = getPlayerClan(params);
let clanId = getPlayerClan(client);
if(!getClanData(clanId)) {
messagePlayerError(client, "Clan not found!");
@@ -552,8 +552,9 @@ function getBusinessInfoCommand(command, params, client) {
function setBusinessPickupCommand(command, params, client) {
let splitParams = params.split(" ");
let typeParam = splitParams[0] || "business";
let businessId = getPlayerBusiness(client);
if(!getBusinessnData(businessId)) {
if(!getBusinessData(businessId)) {
messagePlayerError(client, "Business not found!");
return false;
}
@@ -570,10 +571,7 @@ function setBusinessPickupCommand(command, params, client) {
getBusinessData(businessId).entrancePickupModel = toInteger(typeParam);
}
deleteBusinessEntrancePickup(businessId);
deleteBusinessExitPickup(businessId);
createBusinessEntrancePickup(businessId);
createBusinessExitPickup(businessId);
resetBusinessPickups(businessId);
getBusinessData(businessId).needsSaved = true;
@@ -650,7 +648,7 @@ function setBusinessBlipCommand(command, params, client) {
getBusinessData(businessId).entranceBlipModel = toInteger(typeParam);
}
resetBusinessBlips();
resetBusinessBlips(businessId);
getBusinessData(businessId).needsSaved = true;
messageAdmins(`${getInlineChatColourByName("lightGrey")}${getPlayerName(client)} ${getInlineChatColourByName("white")}set business ${getInlineChatColourByType("businessBlue")}${getBusinessData(businessId).name} ${getInlineChatColourByName("white")}blip display to ${getInlineChatColourByName("lightGrey")}${toLowerCase(typeParam)}`);
@@ -694,6 +692,22 @@ function giveDefaultItemsToBusinessCommand(command, params, client) {
// ===========================================================================
function setBusinessEntranceLabelToDealershipCommand(command, params, client) {
let splitParams = params.split(" ");
let businessId = getPlayerBusiness(client);
if(!getBusinessData(businessId)) {
messagePlayerError(client, "Business not found!");
return false;
}
updateBusinessPickupLabelData(businessId);
messageAdmins(`${getInlineChatColourByName("lightGrey")}${getPlayerName(client)} ${getInlineChatColourByName("white")}gave business ${getInlineChatColourByType("businessBlue")}${getBusinessData(businessId).name} ${getInlineChatColourByName("white")}the default items for ${toLowerCase(typeParam)}`);
}
// ===========================================================================
function deleteBusinessFloorItemsCommand(command, params, client) {
let splitParams = params.split(" ");
@@ -1142,6 +1156,7 @@ function createAllBusinessPickups() {
for(let i in getServerData().businesses) {
createBusinessEntrancePickup(i);
createBusinessExitPickup(i);
updateBusinessPickupLabelData(i);
}
}
@@ -1196,8 +1211,8 @@ function createBusinessEntranceBlip(businessId) {
//getBusinessData(businessId).entranceBlip.streamInDistance = 300;
//getBusinessData(businessId).entranceBlip.streamOutDistance = 350;
//getBusinessData(businessId).entranceBlip.interior = getBusinessData(businessId).entranceInterior;
setEntityData(getBusinessData(businessId).entranceBlip, "vrr.owner.type", VRR_BLIP_BUSINESS_ENTRANCE, false);
setEntityData(getBusinessData(businessId).entranceBlip, "vrr.owner.id", businessId, false);
//setEntityData(getBusinessData(businessId).entranceBlip, "vrr.owner.type", VRR_BLIP_BUSINESS_ENTRANCE, false);
//setEntityData(getBusinessData(businessId).entranceBlip, "vrr.owner.id", businessId, false);
addToWorld(getBusinessData(businessId).entranceBlip);
}
}
@@ -1220,7 +1235,10 @@ function createBusinessExitPickup(businessId) {
getBusinessData(businessId).exitPickup = createGamePickup(pickupModelId, getBusinessData(businessId).exitPosition, getGameConfig().pickupTypes[getServerGame()].business);
setElementDimension(getBusinessData(businessId).exitPickup, getBusinessData(businessId).exitDimension);
setElementOnAllDimensions(getBusinessData(businessId).exitPickup, false);
//setEntityData(getBusinessData(businessId).entranceBlip, "vrr.owner.type", VRR_PICKUP_BUSINESS_EXIT, false);
//setEntityData(getBusinessData(businessId).entranceBlip, "vrr.owner.id", businessId, false);
//getBusinessData(businessId).exitPickup.interior = getBusinessData(businessId).exitInterior;
updateBusinessPickupLabelData(businessId);
addToWorld(getBusinessData(businessId).exitPickup);
}
}
@@ -1245,8 +1263,8 @@ function createBusinessExitBlip(businessId) {
setElementDimension(getBusinessData(businessId).exitBlip, getBusinessData(businessId).entranceDimension);
setElementOnAllDimensions(getBusinessData(businessId).exitBlip, false);
//getBusinessData(businessId).exitBlip.interior = getBusinessData(businessId).exitInterior;
setEntityData(getBusinessData(businessId).exitBlip, "vrr.owner.type", VRR_BLIP_BUSINESS_EXIT, false);
setEntityData(getBusinessData(businessId).exitBlip, "vrr.owner.id", businessId, false);
//setEntityData(getBusinessData(businessId).exitBlip, "vrr.owner.type", VRR_BLIP_BUSINESS_EXIT, false);
//setEntityData(getBusinessData(businessId).exitBlip, "vrr.owner.id", businessId, false);
addToWorld(getBusinessData(businessId).exitBlip);
}
}
@@ -1304,13 +1322,12 @@ function removePlayerFromBusinesses(client) {
// ===========================================================================
function exitBusiness(client) {
let businessId = getEntityData(client, "vrr.inBusiness");
let businessId = getPlayerBusiness(client);
if(isPlayerSpawned(client)) {
setPlayerInterior(client, getServerData().businesses[businessId].entranceInterior);
setPlayerDimension(client, client, getServerData().businesses[businessId].entranceDimension);
setPlayerPosition(client, client, getServerData().businesses[businessId].entrancePosition);
}
removeEntityData(client, "vrr.inBusiness");
}
// ===========================================================================
@@ -1507,11 +1524,6 @@ function buyFromBusinessCommand(command, params, client) {
}
}
if(getPlayerCurrentSubAccount(client).cash < getBusinessData(businessId).floorItemCache[itemSlot-1].buyPrice*amount) {
messagePlayerError(client, `You don't have enough money! You need ${getInlineChatColourByName("lightGrey")}${getBusinessData(businessId).floorItemCache[itemSlot-1].buyPrice*amount-getPlayerCurrentSubAccount(client).cash} ${getInlineChatColourByName("white")}more!`);
return false;
}
if(getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).amount < amount) {
messagePlayerError(client, `There are only ${getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).amount} ${getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).itemTypeIndex).name} in slot ${itemSlot-1}`);
return false;
@@ -1528,6 +1540,11 @@ function buyFromBusinessCommand(command, params, client) {
let itemName = getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).itemTypeIndex).name;
let priceEach = (amount > 1) ? `($${individualCost} each)` : ``;
if(getPlayerCurrentSubAccount(client).cash < totalCost) {
messagePlayerError(client, `You don't have enough money! You need ${getInlineChatColourByName("lightGrey")}${getBusinessData(businessId).floorItemCache[itemSlot-1].buyPrice*amount-getPlayerCurrentSubAccount(client).cash} ${getInlineChatColourByName("white")}more!`);
return false;
}
takePlayerCash(client, totalCost);
createItem(getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).itemTypeIndex, getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).value, VRR_ITEM_OWNER_PLAYER, getPlayerCurrentSubAccount(client).databaseId, amount);
cachePlayerHotBarItems(client);
@@ -1722,27 +1739,39 @@ function getBusinessIdFromDatabaseId(databaseId) {
// ===========================================================================
function updateBusinessPickupLabelData(businessId) {
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.owner.type", VRR_PICKUP_BUSINESS_ENTRANCE, false);
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.owner.id", businessId, false);
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.type", VRR_LABEL_BUSINESS, true);
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.name", getBusinessData(businessId).name, true);
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.locked", getBusinessData(businessId).locked, true);
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_BIZLABEL_INFO_NONE, true);
if(getBusinessData(businessId).hasInterior) {
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_BIZLABEL_INFO_ENTER, true);
} else {
if(doesBusinessHaveAnyItemsToBuy(businessId)) {
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_BIZLABEL_INFO_BUY, true);
if(getBusinessData(businessId).exitPickup != null) {
setEntityData(getBusinessData(businessId).exitPickup, "vrr.owner.type", VRR_PICKUP_BUSINESS_EXIT, false);
setEntityData(getBusinessData(businessId).exitPickup, "vrr.owner.id", businessId, false);
setEntityData(getBusinessData(businessId).exitPickup, "vrr.label.type", VRR_LABEL_EXIT, true);
}
if(getBusinessData(businessId).entrancePickup != null) {
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.owner.type", VRR_PICKUP_BUSINESS_ENTRANCE, false);
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.owner.id", businessId, false);
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.type", VRR_LABEL_BUSINESS, true);
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.name", getBusinessData(businessId).name, true);
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.locked", getBusinessData(businessId).locked, true);
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_BIZLABEL_INFO_NONE, true);
if(getBusinessData(businessId).labelHelpType == VRR_BIZLABEL_ENTERVEHICLE) {
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_BIZLABEL_INFO_ENTERVEHICLE, true);
} else if(getBusinessData(businessId).labelHelpType == VRR_BIZLABEL_INFO_REFUEL) {
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_BIZLABEL_INFO_REFUEL, true);
} else if(getBusinessData(businessId).labelHelpType == VRR_BIZLABEL_INFO_REPAIR) {
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_BIZLABEL_INFO_REPAIR, true);
} else {
if(getBusinessData(businessId).hasInterior) {
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_BIZLABEL_INFO_ENTER, true);
} else {
if(doesBusinessHaveAnyItemsToBuy(businessId)) {
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_BIZLABEL_INFO_BUY, true);
}
}
}
if(getBusinessData(businessId).buyPrice > 0) {
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.price", getBusinessData(businessId).buyPrice, true);
}
}
if(getBusinessData(businessId).buyPrice > 0) {
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.price", getBusinessData(businessId).buyPrice, true);
}
setEntityData(getBusinessData(businessId).exitPickup, "vrr.owner.type", VRR_PICKUP_BUSINESS_EXIT, false);
setEntityData(getBusinessData(businessId).exitPickup, "vrr.owner.id", businessId, false);
setEntityData(getBusinessData(businessId).exitPickup, "vrr.label.type", VRR_LABEL_EXIT, true);
}
// ===========================================================================

View File

@@ -1059,4 +1059,61 @@ function getPlayerClanRankName(client) {
}
}
// ===========================================================================
// ===========================================================================
function showClanFlagListCommand(command, params, client) {
let flagList = getServerBitFlagKeys().clanFlagKeys;
let chunkedList = splitArrayIntoChunks(flagList, 10);
messagePlayerInfo(client, `${getInlineChatColourByType("clanOrange")}== ${getInlineChatColourByType("jobYellow")}Clan Permissions List ${getInlineChatColourByType("clanOrange")}=====================`);
for(let i in chunkedList) {
messagePlayerInfo(client, chunkedList[i].join(", "));
}
}
// ===========================================================================
/*
function showClanFlagListCommand(command, params, client) {
if(!doesPlayerHaveClanPermission(client, getClanFlagValue("rankFlags"))) {
messagePlayerError(client, "You can not change a clan rank's permissions!");
return false;
}
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
let clanId = getPlayerClan(client);
if(!getClanData(clanId)) {
messagePlayerError(client, "Clan not found!");
return false;
}
let splitParams = params.split(" ");
let rankId = getClanRankFromParams(clanId, splitParams[0]);
if(!getClanRankData(clanId, rankId)) {
messagePlayerError(client, "Clan rank not found!");
return false;
}
let tempClanRankData = getClanRankData(clanId, rankId).flags;
for(let i in tempClanRankData) {
if(getServerBitFlags().clanFlags.indexOf(tempClanRankData)))
}
let flagList = getServerBitFlag().clanFlags;
let chunkedList = splitArrayIntoChunks(flagList, 10);
messagePlayerInfo(client, `${getInlineChatColourByType("clanOrange")}== ${getInlineChatColourByType("jobYellow")}Clan Permissions List ${getInlineChatColourByType("clanOrange")}=====================`);
for(let i in chunkedList) {
messagePlayerInfo(client, chunkedList[i].join(", "));
}
}
*/

View File

@@ -20,7 +20,7 @@ function initClassScript() {
* @class Representing data for server configuration
*/
class ServerConfigData {
constructor(dbAssoc) {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.name = "";
this.password = "";
@@ -83,6 +83,15 @@ class ServerConfigData {
this.useRealTime = false;
this.realTimeZone = 0;
this.discordConfig = {
eventChannelWebHookURL: "",
chatChannelWebHookURL: "",
adminChannelWebHookURL: "",
sendEvents: true,
sendChat: true,
sendAdminEvents: true,
};
if(dbAssoc) {
this.databaseId = dbAssoc["svr_id"];
console.log("1");
@@ -137,6 +146,15 @@ class ServerConfigData {
this.introMusicURL = dbAssoc["svr_intro_music"];
this.useRealTime = intToBool(dbAssoc["svr_time_realtime_enabled"]);
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"],
sendEvents: true,
sendChat: true,
sendAdminEvents: true,
};
}
}
};
@@ -191,7 +209,6 @@ class ClientData {
this.alcoholLevel = 0;
this.pedState = VRR_PEDSTATE_NONE;
this.promptType = VRR_PROMPT_NONE;
this.businessOrderAmount = 0;
@@ -224,6 +241,10 @@ class ClientData {
this.returnToBusiness = null;
this.changingCharacterName = false;
this.currentPickup = false;
this.usingSkinSelect = false;
}
};
@@ -231,7 +252,7 @@ class ClientData {
* @class Representing an account, loaded/saved in the database
*/
class AccountData {
constructor(dbAssoc) {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.name = "";
this.password = "";
@@ -295,7 +316,7 @@ class AccountData {
* @class Representing an account's contact list, loaded/saved in the database
*/
class AccountContactData {
constructor(dbAssoc) {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.accountId = 0;
this.contactAccountId = 0;
@@ -317,7 +338,7 @@ class AccountContactData {
* @class Representing an account's messages, loaded/saved in the database
*/
class AccountMessageData {
constructor(dbAssoc) {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.account = 0;
this.whoSent = 0;
@@ -347,7 +368,7 @@ class AccountMessageData {
* @class Representing an account's staff notes. Visible only to staff and loaded/saved in the database
*/
class AccountStaffNoteData {
constructor(dbAssoc) {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.account = 0;
this.whoAdded = 0;
@@ -375,7 +396,7 @@ class AccountStaffNoteData {
* @class Representing a character's (subaccount) data. Loaded and saved in the database
*/
class SubAccountData {
constructor(dbAssoc) {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.server = 0;
this.firstName = "John";
@@ -481,7 +502,7 @@ class SubAccountData {
* @class Representing a businesses' data. Loaded and saved in the database
*/
class BusinessData {
constructor(dbAssoc) {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.name = "";
this.ownerType = VRR_BIZOWNER_NONE;
@@ -521,6 +542,8 @@ class BusinessData {
this.streamingRadioStation = -1;
this.labelHelpType = VRR_BIZLABEL_INFO_NONE;
if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["biz_id"]);
this.name = toString(dbAssoc["biz_name"]);
@@ -547,15 +570,17 @@ class BusinessData {
this.entranceFee = toInteger(dbAssoc["biz_entrance_fee"]);
this.till = toInteger(dbAssoc["biz_till"]);
this.labelHelpType = toInteger(dbAssoc["biz_label_help_type"]);
}
}
};
};
/**
* @class Representing a business's location data. Multiple can be used for a single business. Used for things like doors, fuel pumps, drive thru positions, etc. Loaded and saved in the database
*/
class BusinessLocationData {
constructor(dbAssoc) {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.name = "";
this.type = 0;
@@ -587,7 +612,7 @@ class BusinessLocationData {
* @class Representing a business's game scripts. Multiple can be used for a single business. Used for things like bar and club NPCs and other actions
*/
class BusinessGameScriptData {
constructor(dbAssoc) {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.name = "";
this.business = 0;
@@ -609,7 +634,7 @@ class BusinessGameScriptData {
* @class Representing a house's data. Loaded and saved in the database
*/
class HouseData {
constructor(dbAssoc) {
constructor(dbAssoc = false) {
this.databaseId = 0
this.description = "";
this.ownerType = VRR_HOUSEOWNER_NONE;
@@ -680,7 +705,7 @@ class HouseData {
* @class Representing a houses's location data. Multiple can be used for a single house. Used for things like doors, garage entry/exit/vehspawn, gates, etc. Loaded and saved in the database
*/
class HouseLocationData {
constructor(dbAssoc) {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.name = "";
this.type = 0;
@@ -717,7 +742,7 @@ class HouseLocationData {
* @class Representing a house's game scripts. Multiple can be used for a single house
*/
class HouseGameScriptData {
constructor(dbAssoc) {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.name = "";
this.business = 0;
@@ -739,7 +764,7 @@ class HouseGameScriptData {
* @class Representing a clan's data. Loaded and saved in the database
*/
class ClanData {
constructor(dbAssoc) {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.name = "";
this.ownerId = 0;
@@ -771,7 +796,7 @@ class ClanData {
* @class Representing a clan rank's data. Loaded and saved in the database
*/
class ClanRankData {
constructor(dbAssoc) {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.clan = 0;
this.name = "";
@@ -800,7 +825,7 @@ class ClanRankData {
* @class Representing a clan member's data. Loaded and saved in the database
*/
class ClanMemberData {
constructor(dbAssoc) {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.clan = 0;
this.subAccount = 0;
@@ -1334,7 +1359,7 @@ class InteriorTemplateData {
};
class RadioStationData {
constructor(dbAssoc) {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.name = "";
this.url = "";
@@ -1452,7 +1477,7 @@ class ItemTypeData {
}
};
class NPCData {
constructor(dbAssoc) {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.server = 0;
this.firstName = "John";
@@ -1546,7 +1571,7 @@ class NPCData {
};
class NPCTriggerData {
constructor(dbAssoc) {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.npcId = 0;
this.index = 0;
@@ -1564,7 +1589,7 @@ class NPCTriggerData {
};
class NPCTriggerConditionData {
constructor(dbAssoc) {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.triggerId = 0;
this.index = 0;
@@ -1583,7 +1608,7 @@ class NPCTriggerConditionData {
};
class NPCTriggerResponseData {
constructor(dbAssoc) {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.triggerId = 0;
this.index = 0;
@@ -1597,4 +1622,23 @@ class NPCTriggerResponseData {
this.responseValue = toInteger(dbAssoc["npc_trig_resp_val"]);
}
}
};
};
class BanData {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.type = VRR_BANTYPE_NONE;
this.detail = "";
this.ipAddress = "";
this.name = "";
this.reason = "";
if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["ban_id"]);
this.type = dbAssoc["ban_type"];
this.detail = toInteger(dbAssoc["ban_detail"]);
this.ipAddress = toInteger(dbAssoc["ban_ip"]);
this.reason = toInteger(dbAssoc["ban_reason"]);
}
}
}

View File

@@ -29,6 +29,7 @@ function addAllNetworkHandlers() {
addNetworkHandler("vrr.afk", playerChangeAFKState);
// Event
addNetworkHandler("vrr.pickup", onPlayerNearPickup);
addNetworkHandler("vrr.enteredSphere", onPlayerEnteredSphere);
addNetworkHandler("vrr.exitedSphere", onPlayerExitedSphere);
addNetworkHandler("vrr.playerDeath", onPlayerDeath);
@@ -941,21 +942,25 @@ function makePedPlayAnimation(ped, animationSlot, positionOffset) {
setElementCollisionsEnabled(ped, false);
switch(animationData[9]) {
case VRR_ANIMMOVE_FORWARD:
setElementPosition(ped, getPosInFrontOfPos(getElementPosition(ped), getElementHeading(ped), positionOffset));
setElementPosition(ped, getPosInFrontOfPos(getElementPosition(ped), fixAngle(getElementHeading(ped)), positionOffset));
break;
case VRR_ANIMMOVE_BACK:
setElementPosition(ped, getPosBehindPos(getElementPosition(ped), getElementHeading(ped), positionOffset));
setElementPosition(ped, getPosBehindPos(getElementPosition(ped), fixAngle(getElementHeading(ped)), positionOffset));
break;
case VRR_ANIMMOVE_LEFT:
setElementPosition(ped, getPosToLeftOfPos(getElementPosition(ped), getElementHeading(ped), positionOffset));
setElementPosition(ped, getPosToLeftOfPos(getElementPosition(ped), fixAngle(getElementHeading(ped)), positionOffset));
break;
case VRR_ANIMMOVE_RIGHT:
setElementPosition(ped, getPosToRightOfPos(getElementPosition(ped), getElementHeading(ped), positionOffset));
setElementPosition(ped, getPosToRightOfPos(getElementPosition(ped), fixAngle(getElementHeading(ped)), positionOffset));
break;
}
if(getGame() < GAME_GTA_SA) {
setPlayerMouseCameraState(client, true);
}
}
triggerNetworkEvent("vrr.pedAnim", null, ped.id, animationData[1], animationData[2], animationData[3], animationData[4], animationData[5], positionOffset);
}
@@ -1018,4 +1023,17 @@ function sendPlayerPedPartsAndProps(client) {
triggerNetworkEvent("vrr.ped")
}
// ===========================================================================
function setPlayerVanillaRadioStation(client, radioStationId) {
triggerNetworkEvent("vrr.vanillaRadio", client, radioStationId);
return true;
}
// ===========================================================================
function onPlayerNearPickup(client, pickupId) {
getPlayerData(client).currentPickup = getElementFromId(pickupId);
}
// ===========================================================================

View File

@@ -249,7 +249,7 @@ function getRandomRGB() {
*
*/
function getInlineChatColourByName(colourName) {
return `[${getHexColourByName(colourName)}]`;
return `{${colourName}}`;
}
// ===========================================================================
@@ -262,7 +262,7 @@ function getInlineChatColourByName(colourName) {
*
*/
function getInlineChatColourByType(colourName) {
return `[${getHexColourByType(colourName)}]`;
return `{${colourName}}`;
}
// ===========================================================================
@@ -296,4 +296,42 @@ function hexFromToColour(colour) {
return rgbToHex(rgba[0], rgba[1], rgba[2]);
}
// ===========================================================================
function replaceColoursInMessage(messageText) {
for(let i in getServerColours().hex.byName) {
let find = `{${i}}`;
let re = new RegExp(find, 'g');
messageText = messageText.replace(re, `[#${getServerColours().hex.byName[i]}]`);
}
for(let i in getServerColours().hex.byType) {
let find = `{${i}}`;
let re = new RegExp(find, 'g');
messageText = messageText.replace(re, `[#${getServerColours().hex.byType[i]}]`);
}
return messageText;
}
// ===========================================================================
function removeColoursInMessage(messageText) {
for(let i in getServerColours().hex.byName) {
let find = `{${i}}`;
let re = new RegExp(find, 'g');
messageText = messageText.replace(re, ``);
}
for(let i in getServerColours().hex.byType) {
let find = `{${i}}`;
let re = new RegExp(find, 'g');
messageText = messageText.replace(re, ``);
}
return messageText;
}
// ===========================================================================

View File

@@ -40,14 +40,15 @@ function loadCommands() {
account: [
commandData("login", loginCommand, "<password>", getStaffFlagValue("none"), false, false, "Login to an account"),
commandData("register", registerCommand, "<password>", getStaffFlagValue("none"), false, false, "Creates an account"),
commandData("changepass", changePasswordCommand, "<password>", getStaffFlagValue("none"), true, false, "Change an account password"),
commandData("changepass", changePasswordCommand, "<old password> <new password>", getStaffFlagValue("none"), true, false, "Change an account password"),
commandData("iplogin", autoLoginByIPCommand, "", getStaffFlagValue("none"), true, false, "Toggle whether to automatically login if you join with the same IP as your last join"),
commandData("autolastchar", autoSelectLastCharacterCommand, "", getStaffFlagValue("none"), true, false, "Toggle whether to automatically spawn with the last character you played as"),
commandData("gui", toggleAccountGUICommand, "", getStaffFlagValue("none"), false, false, "Toggle whether to use GUI. If GUI is disabled on the server, it won't show even if you have GUI enabled."),
commandData("2fa", toggleAccountTwoFactorAuthCommand, "", getStaffFlagValue("none"), true, false, "Set up and use two-factor authentication."),
commandData("setemail", setAccountEmailCommand, "<email address>", getStaffFlagValue("none"), true, false, "Sets your email. To reset your password, you must have a valid email set and verified."),
commandData("verifyemail", verifyAccountEmailCommand, "<verification code>", getStaffFlagValue("none"), true, false, "Confirms/verifies your email."),
commandData("setdiscord", setAccountDiscordCommand, "<Name#0000 - discord name and id>", getStaffFlagValue("none"), true, false, "Set up the integration for discord. Allows you to see info and use in-game commands on discord."),
//commandData("setdiscord", setAccountDiscordCommand, "<discord id>", getStaffFlagValue("none"), true, false, "Set up the integration for discord. Allows you to see info and use in-game commands on discord."),
commandData("notips", toggleNoRandomTipsCommand, "", getStaffFlagValue("none"), true, false, "Turn on and off random tips"),
],
ammunation: [],
animation: [
@@ -109,6 +110,7 @@ function loadCommands() {
commandData("bizdefaultitems", giveDefaultItemsToBusinessCommand, "<item template>", getStaffFlagValue("manageItems"), true, true, "Gives the business the default items based on template name"),
commandData("bizdelflooritems", deleteBusinessFloorItemsCommand, "", getStaffFlagValue("manageItems"), true, true, "Destroys all items on the business floor (for-sale items)"),
commandData("bizdelstorageitems", deleteBusinessStorageItemsCommand, "", getStaffFlagValue("manageItems"), true, true, "Destroys all items in the business's storage"),
commandData("bizdealership", setBusinessEntranceLabelToDealershipCommand, "", getStaffFlagValue("manageBusinesses"), true, true, "Sets the business's door label to vehicle dealership"),
],
chat: [
commandData("me", meActionCommand, "<message>", getStaffFlagValue("none"), true, false, "Shows a custom action message in chat"),
@@ -130,6 +132,7 @@ function loadCommands() {
clan: [
commandData("clans", listClansCommand, "[search text]", getStaffFlagValue("none"), true, true, "List clans (search by partial name, if provided)"),
commandData("clanranks", listClanRanksCommand, "[clan name]", getStaffFlagValue("none"), true, true, "Shows a list of a clan's ranks"),
commandData("clanflags", showClanFlagListCommand, "", getStaffFlagValue("none"), true, true, "Shows a list of clan permission flags"),
commandData("addclan", createClanCommand, "<name>", getStaffFlagValue("manageClans"), true, true, "Creates an new empty, unowned clan."),
commandData("delclan", deleteClanCommand, "<clan id>", getStaffFlagValue("manageClans"), true, true, "Deletes a clan by ID or name"),
@@ -147,6 +150,7 @@ function loadCommands() {
commandData("clanmembertitle", setClanMemberTitleCommand, "<player name/id> <title>", getStaffFlagValue("none"), true, true, "Sets a clan members's custom title"),
commandData("clanaddrankflag", addClanRankFlagCommand, "<rank name/id> <flag name>", getStaffFlagValue("none"), true, true, "Gives a clan rank a clan permission."),
commandData("clandelrankflag", removeClanRankFlagCommand, "<rank name/id> <flag name>", getStaffFlagValue("none"), true, true, "Takes a clan permission from a clan rank"),
//commandData("clanrankflags", listClanRankFlagsCommand, "<rank name/id>", getStaffFlagValue("none"), true, true, "Shows a list of a clan rank's current permission flags"),
commandData("clanaddmemberflag", addClanMemberFlagCommand, "<player name/id> <flag name>", getStaffFlagValue("none"), true, true, "Gives a clan member a clan permission"),
commandData("clandelmemberflag", removeClanMemberFlagCommand, "<player name/id> <flag name>", getStaffFlagValue("none"), true, true, "Takes a clan permission from a clan member"),
],
@@ -192,6 +196,8 @@ function loadCommands() {
commandData("delloglvl", removeServerLogLevelCommand, "<log level name>", getStaffFlagValue("developer"), true, true),
commandData("nosave", togglePauseSavingToDatabase, "", getStaffFlagValue("developer"), true, true),
//commandData("forceresetpass", forceAccountPasswordResetCommand, "<account name>", getStaffFlagValue("developer"), true, true),
//commandData("loglvl", getServerLogLevelCommand, "<log level name>", getStaffFlagValue("developer"), true, true),
],
discord: [],

View File

@@ -45,6 +45,7 @@ function loadGlobalConfig() {
phoneSpeakerDistance: 15,
phoneTalkDistance: 15,
tazerEffectDuration: 15000,
vehicleRepairDistance: 5,
weaponEquippableTypes: [
VRR_ITEM_USETYPE_WEAPON,
VRR_ITEM_USETYPE_TAZER,
@@ -52,12 +53,20 @@ function loadGlobalConfig() {
VRR_ITEM_USETYPE_SPRAYPAINT,
VRR_ITEM_USETYPE_PEPPERSPRAY,
],
onFootOnlyItems: [
VRR_ITEM_USETYPE_VEHREPAIR,
VRR_ITEM_USETYPE_VEHCOLOUR,
VRR_ITEM_USETYPE_VEHUPGRADE_PART,
VRR_ITEM_USETYPE_VEHLIVERY,
VRR_ITEM_USETYPE_VEHTIRE,
],
itemActionStateReset: 5000,
subAccountNameAllowedCharacters: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
emailValidationRegex: /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/,
itemActionDelayExtraTimeout: 1000,
geoIPCountryDatabaseFilePath: "geoip-country.mmdb",
geoIPCityDatabaseFilePath: "geoip-city.mmdb",
randomTipInterval: 600000,
};
}

View File

@@ -31,7 +31,7 @@ const VRR_PICKUP_BUSINESS_ENTRANCE = 2;
const VRR_PICKUP_BUSINESS_EXIT = 3;
const VRR_PICKUP_HOUSE_ENTRANCE = 4;
const VRR_PICKUP_HOUSE_EXIT = 5;
const VRR_PICKUP_EXIT = 5;
const VRR_PICKUP_EXIT = 6;
// Vehicle Owner Types
const VRR_VEHOWNER_NONE = 0; // Not owned

View File

@@ -293,6 +293,7 @@ function executeServerCodeCommand(command, params, client) {
messagePlayerSuccess(client, "Server code executed!");
messagePlayerNormal(client, `Code: ${params}`, COLOUR_YELLOW);
messagePlayerNormal(client, `Returns: ${returnValue}`, COLOUR_YELLOW);
console.log(returnValue);
return true;
}
@@ -392,7 +393,7 @@ function submitIdea(client, ideaText) {
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeIdeaMessage = escapeDatabaseString(dbConnection, ideaText);
queryDatabase(dbConnection, `INSERT INTO idea_main (idea_server, idea_script_ver, idea_who_added, idea_when_added, idea_message, idea_pos_x, idea_pos_y, idea_pos_z, idea_rot_z, idea_svr_start, idea_session) VALUES (${getServerId()}, '${scriptVersion}', ${databaseId}, UNIX_TIMESTAMP(), '${safeIdeaMessage}',${position.x}, ${position.y}, ${position.z}, ${heading}, ${serverStartTime}, ${session})`);
queryDatabase(dbConnection, `INSERT INTO idea_main (idea_server, idea_script_ver, idea_who_added, idea_when_added, idea_message, idea_pos_x, idea_pos_y, idea_pos_z, idea_rot_z, idea_svr_start, idea_session) VALUES (${getServerId()}, '${scriptVersion}', ${databaseId}, NOW(), '${safeIdeaMessage}',${position.x}, ${position.y}, ${position.z}, ${heading}, ${serverStartTime}, ${session})`);
}
}
@@ -413,7 +414,7 @@ function submitBugReport(client, bugText) {
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeBugMessage = escapeDatabaseString(dbConnection, bugText);
queryDatabase(dbConnection, `INSERT INTO bug_main (bug_server, bug_script_ver, bug_who_added, bug_when_added, bug_message, bug_pos_x, bug_pos_y, bug_pos_z, bug_rot_z, bug_svr_start, bug_session) VALUES (${getServerId()}, '${scriptVersion}', ${databaseId}, UNIX_TIMESTAMP(), '${safeBugMessage}', ${position.x}, ${position.y}, ${position.z}, ${heading}, ${serverStartTime}, ${session})`);
queryDatabase(dbConnection, `INSERT INTO bug_main (bug_server, bug_script_ver, bug_who_added, bug_when_added, bug_message, bug_pos_x, bug_pos_y, bug_pos_z, bug_rot_z, bug_svr_start, bug_session) VALUES (${getServerId()}, '${scriptVersion}', ${databaseId}, NOW(), '${safeBugMessage}', ${position.x}, ${position.y}, ${position.z}, ${heading}, ${serverStartTime}, ${session})`);
}
}

View File

@@ -89,19 +89,52 @@ function getDiscordUserData(discordUserId) {
// ===========================================================================
function messageDiscordChatChannel(message) {
let gameEmoji = getGameEmojiForDiscord(getServerGame());
if(!getServerConfig().discordConfig.sendChat) {
return false;
}
message = removeColoursInMessage(message);
console.warn(message);
let payloadData = {
"username": "Chat",
"content": message,
};
triggerWebHook(getServerConfig().discordConfig.chatChannelWebHookURL, JSON.stringify(payloadData));
}
// ===========================================================================
function messageDiscordAdminChannel(message) {
let gameEmoji = getGameEmojiForDiscord(getServerGame());
if(!getServerConfig().discordConfig.sendAdminEvents) {
return false;
}
message = removeColoursInMessage(message);
console.warn(message);
let payloadData = {
"username": "Admin Event",
"content": message,
};
triggerWebHook(getServerConfig().discordConfig.adminChannelWebHookURL, JSON.stringify(payloadData));
}
// ===========================================================================
function messageDiscordEventChannel(message) {
let gameEmoji = getGameEmojiForDiscord(getServerGame());
if(!getServerConfig().discordConfig.sendEvents) {
return false;
}
message = removeColoursInMessage(message);
console.warn(message);
let payloadData = {
"username": "Event",
"content": message,
};
triggerWebHook(getServerConfig().discordConfig.eventChannelWebHookURL, JSON.stringify(payloadData));
}
// ===========================================================================

View File

@@ -49,6 +49,8 @@ function onPlayerJoin(event, client) {
if(isFadeCameraSupported()) {
fadeCamera(client, true, 1.0);
}
messageDiscordEventChannel(`:waving: ${getPlayerDisplayForConsole(client)} has joined the server.`);
}
// ===========================================================================
@@ -76,6 +78,8 @@ function onPlayerQuit(event, client, quitReasonId) {
resetClientStuff(client);
getServerData().clients[client.index] = null;
}
messageDiscordEventChannel(`${getPlayerDisplayForConsole(client)} has left the server.`);
}
// ===========================================================================
@@ -104,8 +108,8 @@ function onPlayerChat(event, client, messageText) {
}
messageText = messageText.substring(0, 128);
messagePlayerNormal(null, `${getInlineChatColourByName("white")}💬 [${hexFromToColour(getPlayerColour(client))}]${getCharacterFullName(client)}: ${getInlineChatColourByName("white")}${messageText}`, getPlayerColour(client));
messagePlayerNormal(null, replaceColoursInMessage(`${getInlineChatColourByName("white")}💬 [${hexFromToColour(getPlayerColour(client))}]${getCharacterFullName(client)}: ${getInlineChatColourByName("white")}${messageText}`), getPlayerColour(client));
messageDiscordChatChannel(`💬 ${getCharacterFullName(client)}: ${messageText}`);
}
// ===========================================================================
@@ -260,7 +264,7 @@ async function onPlayerEnteredVehicle(client, clientVehicle, seat) {
ownerType = toLowerCase(getVehicleOwnerTypeText(getVehicleData(vehicle).ownerType));
switch(getVehicleData(vehicle).ownerType) {
case VRR_VEHOWNER_CLAN:
ownerName = getClanData(getVehicleData(vehicle).ownerId).name;
ownerName = getClanData(getClanIdFromDatabaseId(getVehicleData(vehicle).ownerId)).name;
ownerType = "clan";
break;
@@ -365,7 +369,7 @@ function onPlayerDeath(client, position) {
setTimeout(function() {
if(getPlayerCurrentSubAccount(client).inJail) {
let closestJail = getClosestJail(getPlayerPosition(client));
//client.despawnPlayer();
client.despawnPlayer();
getPlayerCurrentSubAccount(client).interior = closestJail.interior;
getPlayerCurrentSubAccount(client).dimension = closestJail.dimension;
if(getServerGame() == GAME_GTA_IV) {
@@ -380,7 +384,7 @@ function onPlayerDeath(client, position) {
updatePlayerSpawnedState(client, true);
} else {
let closestHospital = getClosestHospital(getPlayerPosition(client));
//client.despawnPlayer();
client.despawnPlayer();
getPlayerCurrentSubAccount(client).interior = closestHospital.interior;
getPlayerCurrentSubAccount(client).dimension = closestHospital.dimension;
if(getServerGame() == GAME_GTA_IV) {
@@ -566,16 +570,6 @@ function onPlayerSpawn(client) {
updatePlayerCash(client);
getPlayerData(client).payDayTickStart = sdl.ticks;
if(getPlayerCurrentSubAccount(client).inBusiness > 0) {
setEntityData(client.player, "vrr.inBusiness", getBusinessIdFromDatabaseId(getPlayerCurrentSubAccount(client).inBusiness), true);
}
if(getPlayerCurrentSubAccount(client).inHouse > 0) {
setEntityData(client.player, "vrr.inHouse", getHouseIdFromDatabaseId(getPlayerCurrentSubAccount(client).inHouse), true);
}
//}
}

View File

@@ -254,7 +254,7 @@ function showWebsiteHelpMessage(client) {
function showDiscordHelpMessage(client) {
messagePlayerInfo(client, `${getInlineChatColourByType("clanOrange")}== ${getInlineChatColourByType("jobYellow")}Discord ${getInlineChatColourByType("clanOrange")}=============================`);
messagePlayerNormal(client, `${getInlineChatColourByType("clanOrange")}${getInlineChatColourByName("white")}Discord coming soon!`);
messagePlayerNormal(client, `${getInlineChatColourByType("clanOrange")}${getInlineChatColourByName("white")}https://discord.gg/hA8GSdYyw6`);
}
// ===========================================================================

View File

@@ -455,8 +455,7 @@ function setHouseBlipCommand(command, params, client) {
deleteGameElement(getHouseData(houseId).entranceBlip);
}
createHouseEntranceBlip(houseId);
resetHouseBlips(houseId);
getHouseData(houseId).needsSaved = true;
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]set house [#11CC11]${getHouseData(houseId).description} [#FFFFFF]blip display to [#AAAAAA]${toLowerCase(typeParam)}`);
@@ -490,10 +489,8 @@ function moveHouseEntranceCommand(command, params, client) {
//createAllHouseBlips(houseId);
//createAllHousePickups(houseId);
deleteHouseEntrancePickup(houseId);
deleteHouseEntranceBlip(houseId);
createHouseEntrancePickup(houseId);
createHouseEntranceBlip(houseId);
resetHouseBlips();
resetHousePickups();
getHouseData(houseId).needsSaved = true;
@@ -1307,4 +1304,22 @@ function canPlayerLockUnlockHouse(client, houseId) {
return false;
}
// ===========================================================================
function resetHousePickups(houseId) {
deleteHouseEntrancePickup(houseId);
deleteHouseExitPickup(houseId);
createHouseEntrancePickup(houseId);
createHouseExitPickup(houseId);
}
// ===========================================================================
function resetHouseBlips(houseId) {
deleteHouseEntranceBlip(houseId);
deleteHouseExitBlip(houseId);
createHouseEntranceBlip(houseId);
createHouseExitBlip(houseId);
}
// ===========================================================================

View File

@@ -107,9 +107,8 @@ function createGroundItemObject(itemId) {
setElementRotation(getItemData(itemId).object, getItemTypeData(getItemData(itemId).itemTypeIndex).dropRotation);
setElementOnAllDimensions(getItemData(itemId).object, false);
setElementDimension(getItemData(itemId).object, getItemData(itemId).dimension);
//setEntityData(getItemData(itemId).object, "vrr.scale", getItemTypeData(getItemData(itemId).itemTypeIndex).dropScale, true);
setEntityData(getItemData(itemId).object, "vrr.scale", getItemTypeData(getItemData(itemId).itemTypeIndex).dropScale, true);
addToWorld(getItemData(itemId).object);
//setEntityData(getItemData(itemId).object, "vrr.scale", getItemTypeData(getItemData(itemId).itemTypeIndex).dropScale, true);
getServerData().groundItemCache.push(itemId);
}
@@ -208,6 +207,11 @@ function useItemCommand(command, params, client) {
return false;
}
if(getPlayerData(client).usingSkinSelect) {
messagePlayerError(client, `Your can't use an item while customizing your appearance`);
return false;
}
getPlayerData(client).itemActionState = VRR_ITEM_ACTION_USE;
getPlayerData(client).itemActionItem = hotBarSlot;
showPlayerItemUseDelay(client, hotBarSlot);
@@ -272,6 +276,11 @@ function pickupItemCommand(command, params, client) {
return false;
}
if(getPlayerData(client).usingSkinSelect) {
messagePlayerError(client, `Your can't pick up an item while customizing your appearance`);
return false;
}
getPlayerData(client).itemActionState = VRR_ITEM_ACTION_PICKUP;
getPlayerData(client).itemActionItem = itemId;
showPlayerItemPickupDelay(client, itemId);
@@ -317,6 +326,11 @@ function dropItemCommand(command, params, client) {
return false;
}
if(getPlayerData(client).usingSkinSelect) {
messagePlayerError(client, `Your can't drop an item while customizing your appearance`);
return false;
}
getPlayerData(client).itemActionState = VRR_ITEM_ACTION_DROP;
getPlayerData(client).itemActionItem = hotBarSlot;
showPlayerItemDropDelay(client, hotBarSlot);
@@ -350,6 +364,11 @@ function putItemCommand(command, params, client) {
return false;
}
if(getPlayerData(client).usingSkinSelect) {
messagePlayerError(client, `Your can't store an item while customizing your appearance`);
return false;
}
getPlayerData(client).itemActionItem = hotBarSlot;
getPlayerData(client).itemActionState = VRR_ITEM_ACTION_PUT;
showPlayerItemPutDelay(client, hotBarSlot);
@@ -383,6 +402,11 @@ function takeItemCommand(command, params, client) {
return false;
}
if(getPlayerData(client).usingSkinSelect) {
messagePlayerError(client, `Your can't take an item while customizing your appearance`);
return false;
}
getPlayerData(client).itemActionItem = itemId;
getPlayerData(client).itemActionState = VRR_ITEM_ACTION_TAKE;
showPlayerItemTakeDelay(client, itemId);
@@ -627,6 +651,11 @@ function playerUseItem(client, hotBarSlot) {
if(getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleRepairDistance) {
meActionToNearbyPlayers(client, `takes their repair kit and fixes the vehicle`);
repairVehicle(vehicle);
getItemData(itemIndex).value = getItemData(itemIndex).value - getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue;
if(getItemData(itemIndex).value == 0) {
destroyItem(itemIndex);
}
}
break;
@@ -916,7 +945,7 @@ function playerSwitchHotBarSlotCommand(command, params, client) {
}
if(getPlayerData(client).activeHotBarSlot == hotBarSlot) {
return false;
hotBarSlot = -1;
}
if(getPlayerData(client).itemActionState != VRR_ITEM_ACTION_NONE) {
@@ -924,6 +953,11 @@ function playerSwitchHotBarSlotCommand(command, params, client) {
return false;
}
if(getPlayerData(client).usingSkinSelect) {
messagePlayerError(client, `Your can't switch items while customizing your appearance`);
return false;
}
switchPlayerActiveHotBarSlot(client, hotBarSlot);
}

View File

@@ -19,39 +19,38 @@ function messageAdminAction(messageText) {
if(getServerConfig().discordEnabled) {
messageDiscord(`:warning: ${messageText}`);
}
//logToConsole(LOG_INFO, `[VRR.Messaging] ADMIN: ${messageText}`);
}
// ===========================================================================
function messagePlayerNormal(client, messageText, colour = COLOUR_WHITE) {
if(isConsole(client)) {
console.log(messageText);
logToConsole(LOG_INFO, `[VRR.Messaging] ${messageText}`);
return true;
}
sendChatBoxMessageToPlayer(client, `${messageText}`, colour);
//if(!isClientFromDiscord(client)) {
//
//} else {
// messageDiscordUser(client, `${messageText}`);
//}
sendChatBoxMessageToPlayer(client, `${replaceColoursInMessage(messageText)}`, colour);
}
// ===========================================================================
function messageAdmins(messageText, colour = COLOUR_WHITE) {
let plainMessage = removeColoursInMessage(messageText);
let clients = getClients();
for(let i in clients) {
if(isConsole(clients[i])) {
logToConsole(LOG_INFO, `[VRR.Messaging] ADMINS: ${messageText}`);
logToConsole(LOG_INFO, `[VRR.Messaging] ADMINS: ${plainMessage}`);
} else {
if(doesPlayerHaveStaffPermission(clients[i], getStaffFlagValue("basicModeration"))) {
sendChatBoxMessageToPlayer(clients[i], `🛡️ ${messageText}`, getColourByName("softRed"));
messagePlayerNormal(clients[i], `🛡️ ${messageText}`, getColourByName("softRed"));
}
}
}
if(getServerConfig().discordConfig.sendAdminEvents) {
messageDiscordAdminChannel(plainMessage);
}
}

View File

@@ -122,41 +122,69 @@ function submitBugReportCommand(command, params, client) {
// ===========================================================================
function enterExitPropertyCommand(command, params, client) {
let closestBusinessEntrance = getClosestBusinessEntrance(getPlayerPosition(client), getPlayerDimension(client));
let closestBusinessExit = getClosestBusinessExit(getPlayerPosition(client), getPlayerDimension(client));
let closestHouseEntrance = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client));
let closestHouseExit = getClosestHouseExit(getPlayerPosition(client), getPlayerDimension(client));
//let closestBusinessEntrance = getClosestBusinessEntrance(getPlayerPosition(client), getPlayerDimension(client));
//let closestBusinessExit = getClosestBusinessExit(getPlayerPosition(client), getPlayerDimension(client));
//let closestHouseEntrance = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client));
//let closestHouseExit = getClosestHouseExit(getPlayerPosition(client), getPlayerDimension(client));
let closestEntrance = null;
let closestExit = null;
let closestProperty = null;
let isEntrance = false;
let isBusiness = false;
if(getDistance(getPlayerPosition(client), getBusinessData(closestBusinessEntrance).entrancePosition) <= getDistance(getPlayerPosition(client), getHouseData(closestHouseEntrance).entrancePosition)) {
closestEntrance = getBusinessData(closestBusinessEntrance);
} else {
closestEntrance = getHouseData(closestHouseEntrance);
}
//if(getDistance(getPlayerPosition(client), getBusinessData(closestBusinessEntrance).entrancePosition) <= getDistance(getPlayerPosition(client), getHouseData(closestHouseEntrance).entrancePosition)) {
// closestEntrance = getBusinessData(closestBusinessEntrance);
//} else {
// closestEntrance = getHouseData(closestHouseEntrance);
//}
if(getDistance(getPlayerPosition(client), getBusinessData(closestBusinessExit).exitPosition) <= getDistance(getPlayerPosition(client), getHouseData(closestHouseExit).exitPosition)) {
closestExit = getBusinessData(closestBusinessExit);
} else {
closestExit = getHouseData(closestHouseExit);
}
//if(getDistance(getPlayerPosition(client), getBusinessData(closestBusinessExit).exitPosition) <= getDistance(getPlayerPosition(client), getHouseData(closestHouseExit).exitPosition)) {
// closestExit = getBusinessData(closestBusinessExit);
//} else {
// closestExit = getHouseData(closestHouseExit);
//}
if(getDistance(getPlayerPosition(client), closestEntrance.entrancePosition) <= getDistance(getPlayerPosition(client), closestExit.exitPosition)) {
closestProperty = closestEntrance;
isEntrance = true;
} else {
closestProperty = closestExit;
isEntrance = false;
}
//if(getDistance(getPlayerPosition(client), closestEntrance.entrancePosition) <= getDistance(getPlayerPosition(client), closestExit.exitPosition)) {
// closestProperty = closestEntrance;
// isEntrance = true;
//} else {
// closestProperty = closestExit;
// isEntrance = false;
//}
if(closestProperty instanceof HouseData) {
isBusiness = false;
} else {
isBusiness = true;
if(getPlayerData(client).currentPickup != false) {
let ownerType = getEntityData(getPlayerData(client).currentPickup, "vrr.owner.type");
let ownerId = getEntityData(getPlayerData(client).currentPickup, "vrr.owner.id");
//logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} is near pickup for owner ID ${ownerId}`);
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;
}
}
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s closest door is ${(isBusiness) ? closestProperty.name : closestProperty.description} ${(isEntrance) ? "entrance" : "exit"}`);
@@ -167,6 +195,12 @@ function enterExitPropertyCommand(command, params, client) {
meActionToNearbyPlayers(client, `tries to open the ${(isBusiness) ? "business" : "house"} door but fails because it's locked`);
return false;
}
if(!closestProperty.hasInterior) {
messagePlayerAlert(client, `This ${(isBusiness) ? "business" : "house"} does not have an interior, but you can still use commands at the door icon.`);
return false;
}
clearPlayerStateToEnterExitProperty(client);
getPlayerData(client).pedState = VRR_PEDSTATE_ENTERINGPROPERTY;
meActionToNearbyPlayers(client, `opens the door and enters the ${(isBusiness) ? "business" : "house"}`);
@@ -234,22 +268,6 @@ function enterExitPropertyCommand(command, params, client) {
// ===========================================================================
function loadGameFixesResource() {
//switch(getServerGame()) {
// case GAME_GTA_III:
// if(findResourceByName("asshat-gta3") != null) {
// findResourceByName("asshat-gta3").start();
// }
// break;
//
// default:
// break;
//}
return true;
}
// ===========================================================================
function getPlayerInfoCommand(command, params, client) {
if(areParamsEmpty(params)) {
return false;

View File

@@ -379,7 +379,8 @@ function gotoPositionCommand(command, params, client) {
return false;
}
let splitParams = params.replace(",", "").split(" ");
params = params.replace(",", "");
splitParams = params.split(" ");
let x = splitParams[0] || getPlayerPosition(client).x;
let y = splitParams[1] || getPlayerPosition(client).y;
let z = splitParams[2] || getPlayerPosition(client).z;
@@ -407,9 +408,10 @@ function teleportForwardCommand(command, params, client) {
return false;
}
setPlayerPosition(client, getPosInFrontOfPos(getPlayerPosition(client), getPlayerHeading(client), params));
let distance = toFloat(params) || 1;
setPlayerPosition(client, getPosInFrontOfPos(getPlayerPosition(client), getPlayerHeading(client), distance));
messagePlayerSuccess(client, `You teleported forward ${params} meters`);
messagePlayerSuccess(client, `You teleported forward ${distance} meters`);
}
// ===========================================================================
@@ -420,9 +422,10 @@ function teleportBackwardCommand(command, params, client) {
return false;
}
setPlayerPosition(client, getPosBehindPos(getPlayerPosition(client), getPlayerHeading(client), params));
let distance = toFloat(params) || 1;
setPlayerPosition(client, getPosBehindPos(getPlayerPosition(client), getPlayerHeading(client), distance));
messagePlayerSuccess(client, `You teleported backward ${getInlineChatColourByName("lightGrey")}${params} ${getInlineChatColourByName("white")}meters`);
messagePlayerSuccess(client, `You teleported backward ${getInlineChatColourByName("lightGrey")}${distance} ${getInlineChatColourByName("white")}meters`);
}
// ===========================================================================
@@ -433,9 +436,10 @@ function teleportLeftCommand(command, params, client) {
return false;
}
setPlayerPosition(client, getPosToLeftOfPos(getPlayerPosition(client), getPlayerHeading(client), params));
let distance = toFloat(params) || 1;
setPlayerPosition(client, getPosToLeftOfPos(getPlayerPosition(client), fixAngle(getPlayerHeading(client)), distance));
messagePlayerSuccess(client, `You teleported left ${getInlineChatColourByName("lightGrey")}${params} ${getInlineChatColourByName("white")}meters`);
messagePlayerSuccess(client, `You teleported left ${getInlineChatColourByName("lightGrey")}${distance} ${getInlineChatColourByName("white")}meters`);
}
// ===========================================================================
@@ -446,9 +450,10 @@ function teleportUpCommand(command, params, client) {
return false;
}
setPlayerPosition(client, getPosAbovePos(getPlayerPosition(client), params));
let distance = toFloat(params) || 1;
setPlayerPosition(client, getPosAbovePos(getPlayerPosition(client), distance));
messagePlayerSuccess(client, `You teleported up ${getInlineChatColourByName("lightGrey")}${params} ${getInlineChatColourByName("white")}meters`);
messagePlayerSuccess(client, `You teleported up ${getInlineChatColourByName("lightGrey")}${distance} ${getInlineChatColourByName("white")}meters`);
}
// ===========================================================================
@@ -459,9 +464,10 @@ function teleportDownCommand(command, params, client) {
return false;
}
setPlayerPosition(client, getPosBelowPos(getPlayerPosition(client), params));
let distance = toFloat(params) || 1;
setPlayerPosition(client, getPosBelowPos(getPlayerPosition(client), distance));
messagePlayerSuccess(client, `You teleported down ${getInlineChatColourByName("lightGrey")}${params} ${getInlineChatColourByName("white")}meters`);
messagePlayerSuccess(client, `You teleported down ${getInlineChatColourByName("lightGrey")}${distance} ${getInlineChatColourByName("white")}meters`);
}
// ===========================================================================
@@ -472,9 +478,10 @@ function teleportRightCommand(command, params, client) {
return false;
}
setPlayerPosition(client, getPosToRightOfPos(getPlayerPosition(client), getPlayerHeading(client), params));
let distance = toFloat(params) || 1;
setPlayerPosition(client, getPosToRightOfPos(getPlayerPosition(client), fixAngle(getPlayerHeading(client)), distance));
messagePlayerSuccess(client, `You teleported right ${getInlineChatColourByName("lightGrey")}${params} ${getInlineChatColourByName("white")}meters`);
messagePlayerSuccess(client, `You teleported right ${getInlineChatColourByName("lightGrey")}${distance} ${getInlineChatColourByName("white")}meters`);
}
// ===========================================================================
@@ -549,11 +556,11 @@ function getPlayerCommand(command, params, client) {
//getPlayerData(targetClient).returnToInterior = getPlayerInterior(targetClient);
if(isPlayerInAnyHouse(targetClient)) {
getPlayerData(targetClient).returnToHouse = getEntityData(client, "vrr.inHouse");
getPlayerData(targetClient).returnToHouse = getPlayerHouse(targetClient);
}
if(isPlayerInAnyBusiness(targetClient)) {
getPlayerData(targetClient).returnToBusiness = getEntityData(client, "vrr.inBusiness");
getPlayerData(targetClient).returnToBusiness = getPlayerBusiness(targetClient);
}
setPlayerPosition(targetClient, getPosBehindPos(getPlayerPosition(client), getPlayerHeading(client), 2));
@@ -561,14 +568,6 @@ function getPlayerCommand(command, params, client) {
setPlayerInterior(targetClient, getPlayerInterior(client));
setPlayerDimension(targetClient, getPlayerDimension(client));
if(isPlayerInAnyBusiness(client)) {
setEntityData(client, "vrr.inBusiness", getPlayerBusiness(client), true);
}
if(isPlayerInAnyBusiness(client)) {
setEntityData(client, "vrr.inHouse", getPlayerBusiness(client), true);
}
messagePlayerSuccess(client, `You teleported ${getInlineChatColourByName("lightGrey")}${getPlayerName(targetClient)} ${getInlineChatColourByName("white")}to you.`);
messagePlayerAlert(targetClient, `An admin has teleported you to their location`);
}
@@ -599,14 +598,6 @@ function returnPlayerCommand(command, params, client) {
setPlayerInterior(targetClient, getPlayerData(targetClient).returnToInterior);
setPlayerDimension(targetClient, getPlayerData(targetClient).returnToDimension);
if(getPlayerData(targetClient).returnToHouse != null) {
setEntityData(client, "vrr.inHouse", getPlayerData(targetClient).returnToHouse, true);
}
if(getPlayerData(targetClient).returnToBusiness != null) {
setEntityData(client, "vrr.inBusiness", getPlayerData(targetClient).returnToBusiness, true);
}
getPlayerData(targetClient).returnToPosition = null;
getPlayerData(targetClient).returnToHeading = null;
getPlayerData(targetClient).returnToDimension = null;
@@ -798,7 +789,7 @@ function givePlayerMoneyCommand(command, params, client) {
return false;
}
givePlayerMoney(client, toInteger(amount));
givePlayerCash(client, toInteger(amount));
updatePlayerCash(targetClient);
messagePlayerSuccess(client, `You gave ${getInlineChatColourByName("lightGrey")}$${amount} ${getInlineChatColourByName("white")}to ${getInlineChatColourByName("lightGrey")}${getCharacterFullName(targetClient)}`);
messagePlayerAlert(client, `An admin gave you ${getInlineChatColourByName("lightGrey")}$${amount}`);

View File

@@ -3133,12 +3133,12 @@ let gameData = {
ammunation: 20,
payAndSpray: 18,
vehicleDealership: 6,
restaurant: -1,
fastFood: -1,
restaurant: 0,
fastFood: 0,
bank: 0,
fuelStation: -1,
business: -1,
house: -1,
fuelStation: 0,
business: 0,
house: 0,
},
{ // GTA VC
policeStation: 0,
@@ -3147,12 +3147,12 @@ let gameData = {
ammunation: 16,
payAndSpray: 27,
vehicleDealership: 7,
restaurant: -1,
fastFood: -1,
restaurant: 0,
fastFood: 0,
bank: 0,
fuelStation: -1,
business: -1,
house: -1,
fuelStation: 0,
business: 0,
house: 0,
},
{ // GTA SA
policeStation: 30,
@@ -3164,14 +3164,14 @@ let gameData = {
airplaneDealership: 5,
boatDealership: 9,
restaurant: 50,
fastFood: -1,
fastFood: 0,
clothes: 45,
pizza: 29,
chicken: 14,
burger: 10,
bank: 52,
gasStation: 17,
business: -1,
business: 0,
house: 31,
bar: 49,
club: 48,
@@ -3182,32 +3182,21 @@ let gameData = {
job: 56,
},
{ // GTA UG
policeStation: 8,
fireStation: 9,
hospital: 12,
ammunation: 20,
payAndSpray: 18,
vehicleDealership: 6,
restaurant: -1,
fastFood: -1,
bank: 52,
fuelStation: 0,
business: -1,
house: -1,
},
{ // GTA IV
policeStation: 8,
fireStation: 9,
hospital: 12,
ammunation: 20,
policeStation: 60,
fireStation: 61,
hospital: 62,
ammunation: 59,
payAndSpray: 18,
vehicleDealership: 6,
restaurant: -1,
fastFood: -1,
restaurant: 57,
fastFood: 21,
bank: 52,
fuelStation: 0,
business: -1,
house: -1,
business: 0,
house: 29,
},
],
pickupModels: [
@@ -3502,6 +3491,27 @@ let gameData = {
["Hot Wings", 500, 2],
["Bottle of Soda", 500, 2],
],
coffeeDonutShop: [
["Glazed Donut", 500, 2],
["Frosted Donut", 500, 2],
["Jelly Donut", 500, 2],
["Cream-filled Donut", 500, 2],
["Apple Fritter", 500, 2],
["Pumpkin Spice Latte", 500, 2],
["Mocha Latte", 500, 2],
["Iced Coffee", 500, 2],
["Large Coffee", 500, 2],
["Small Coffee", 500, 2],
],
vehicleRepairShop: [
["Vehicle Repair Kit", 500, 2],
["Vehicle Decal Kit", 500, 2],
["Vehicle Primary Colour Kit", 500, 2],
["Vehicle Secondary Colour Kit", 500, 2],
//["Vehicle NOS Kit", 500, 2],
//["Vehicle Hydraulics Kit", 500, 2],
//["Vehicle Body Part Kit", 500, 2],
],
},
{
clothingStore: [
@@ -3615,6 +3625,27 @@ let gameData = {
["Hot Wings", 500, 2],
["Bottle of Soda", 500, 2],
],
coffeeDonutShop: [
["Glazed Donut", 500, 2],
["Frosted Donut", 500, 2],
["Jelly Donut", 500, 2],
["Cream-filled Donut", 500, 2],
["Apple Fritter", 500, 2],
["Pumpkin Spice Latte", 500, 2],
["Mocha Latte", 500, 2],
["Iced Coffee", 500, 2],
["Large Coffee", 500, 2],
["Small Coffee", 500, 2],
],
vehicleRepairShop: [
["Vehicle Repair Kit", 500, 2],
["Vehicle Decal Kit", 500, 2],
["Vehicle Primary Colour Kit", 500, 2],
["Vehicle Secondary Colour Kit", 500, 2],
//["Vehicle NOS Kit", 500, 2],
//["Vehicle Hydraulics Kit", 500, 2],
//["Vehicle Body Part Kit", 500, 2],
],
},
{
clothingStore: [
@@ -3735,6 +3766,28 @@ let gameData = {
["Hot Wings", 500, 2],
["Bottle of Soda", 500, 2],
],
coffeeDonutShop: [
["Glazed Donut", 500, 2],
["Frosted Donut", 500, 2],
["Jelly Donut", 500, 2],
["Cream-filled Donut", 500, 2],
["Apple Fritter", 500, 2],
["Pumpkin Spice Latte", 500, 2],
["Mocha Latte", 500, 2],
["Iced Coffee", 500, 2],
["Apple Fritter", 500, 2],
["Large Coffee", 500, 2],
["Small Coffee", 500, 2],
],
vehicleRepairShop: [
["Vehicle Repair Kit", 500, 2],
["Vehicle Decal Kit", 500, 2],
["Vehicle Primary Colour Kit", 500, 2],
["Vehicle Secondary Colour Kit", 500, 2],
//["Vehicle NOS Kit", 500, 2],
//["Vehicle Hydraulics Kit", 500, 2],
//["Vehicle Body Part Kit", 500, 2],
],
}
],
interiorTemplates: [
@@ -4328,7 +4381,9 @@ function setPlayerDimension(client, dimension) {
function setPlayerInterior(client, interior) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s interior to ${interior}`);
sendPlayerSetInterior(client, interior);
getPlayerCurrentSubAccount(client).interior = interior;
if(isPlayerLoggedIn(client) && isPlayerSpawned(client)) {
getPlayerCurrentSubAccount(client).interior = interior;
}
}
// ===========================================================================
@@ -4402,6 +4457,7 @@ function getVehicleForNetworkEvent(vehicle) {
function deleteGameElement(element) {
logToConsole(LOG_DEBUG, `Destroying game element ${element.id} (Type: ${element.type})`);
if(element != null) {
//removeFromWorld(element);
destroyElement(element);
return true;
}
@@ -4464,7 +4520,11 @@ function getPlayerArmour(client) {
// ===========================================================================
function setPlayerCash(client, amount) {
if(typeof amount != "number") {
if(client == null) {
return false;
}
if(isNan(amount)) {
return false;
}
@@ -4475,7 +4535,11 @@ function setPlayerCash(client, amount) {
// ===========================================================================
function givePlayerCash(client, amount) {
if(typeof amount != "number") {
if(client == null) {
return false;
}
if(isNan(amount)) {
return false;
}
@@ -4486,7 +4550,11 @@ function givePlayerCash(client, amount) {
// ===========================================================================
function takePlayerCash(client, amount) {
if(typeof amount != "number") {
if(client == null) {
return false;
}
if(isNan(amount)) {
return false;
}

View File

@@ -82,6 +82,7 @@ function playStreamingRadioCommand(command, params, client) {
let clients = getClients();
for(let i in clients) {
if(getPlayerVehicle(client) == getPlayerVehicle(clients[i])) {
setPlayerVanillaRadioStation(clients[i], 0);
playRadioStreamForPlayer(clients[i], getRadioStationData(radioStationId-1).url, true, getPlayerStreamingRadioVolume(client));
}
}
@@ -107,12 +108,13 @@ function playStreamingRadioCommand(command, params, client) {
let clients = getClients();
for(let i in clients) {
if(getEntityData(clients[i], "vrr.inHouse") == houseId) {
setPlayerVanillaRadioStation(clients[i], 0);
playRadioStreamForPlayer(clients[i], getRadioStationData(radioStationId-1).url, true, getPlayerStreamingRadioVolume(clients[i]));
}
}
}
} else if(doesEntityDataExist(client, "vrr.inBusiness")) {
let businessId = getEntityData(client, "vrr.inBusiness");
} else if(isPlayerInAnyBusiness(client)) {
let businessId = getPlayerBusiness(client);
if(radioStationId == 0) {
getBusinessData(businessId).streamingRadioStation = -1;
getPlayerData(client).streamingRadioStation = -1;
@@ -120,8 +122,8 @@ function playStreamingRadioCommand(command, params, client) {
let clients = getClients();
for(let i in clients) {
if(getEntityData(clients[i], "vrr.inBusiness") == businessId) {
playRadioStreamForPlayer(clients[i], "");
if(getPlayerBusiness(clients[i]) == businessId) {
stopRadioStreamForPlayer(clients[i]);
}
}
} else {
@@ -131,7 +133,8 @@ function playStreamingRadioCommand(command, params, client) {
let clients = getClients();
for(let i in clients) {
if(getEntityData(clients[i], "vrr.inBusiness") == businessId) {
if(getPlayerBusiness(clients[i]) == businessId) {
setPlayerVanillaRadioStation(clients[i], 0);
playRadioStreamForPlayer(clients[i], getRadioStationData(radioStationId-1).url, true, getPlayerStreamingRadioVolume(clients[i]));
}
}

View File

@@ -40,8 +40,6 @@ function initServerScripts() {
initTimers();
loadGameFixesResource();
serverStartTime = getCurrentUnixTimestamp();
initCommandScript();

View File

@@ -201,7 +201,7 @@ function createSubAccount(accountId, firstName, lastName) {
let safeFirstName = escapeDatabaseString(dbConnection, firstName);
let safeLastName = escapeDatabaseString(dbConnection, lastName);
dbQuery = queryDatabase(dbConnection, `INSERT INTO sacct_main (sacct_acct, sacct_name_first, sacct_name_last, sacct_pos_x, sacct_pos_y, sacct_pos_z, sacct_rot_z, sacct_cash, sacct_server, sacct_health, sacct_when_made, sacct_when_lastlogin) VALUES (${accountId}, '${safeFirstName}', '${safeLastName}', ${getServerConfig().newCharacter.spawnPosition.x}, ${getServerConfig().newCharacter.spawnPosition.y}, ${getServerConfig().newCharacter.spawnPosition.z}, ${getServerConfig().newCharacter.spawnHeading}, ${getServerConfig().newCharacter.money}, ${getServerId()}, 100, UNIX_TIMESTAMP(), 0)`);
dbQuery = queryDatabase(dbConnection, `INSERT INTO sacct_main (sacct_acct, sacct_name_first, sacct_name_last, sacct_pos_x, sacct_pos_y, sacct_pos_z, sacct_rot_z, sacct_cash, sacct_server, sacct_health, sacct_when_made, sacct_when_lastlogin) VALUES (${accountId}, '${safeFirstName}', '${safeLastName}', ${getServerConfig().newCharacter.spawnPosition.x}, ${getServerConfig().newCharacter.spawnPosition.y}, ${getServerConfig().newCharacter.spawnPosition.z}, ${getServerConfig().newCharacter.spawnHeading}, ${getServerConfig().newCharacter.money}, ${getServerId()}, 100, CURRENT_TIMESTAMP(), 0)`);
//if(dbQuery) {
if(getDatabaseInsertId(dbConnection) > 0) {
let dbInsertId = getDatabaseInsertId(dbConnection);
@@ -250,7 +250,7 @@ function showCharacterSelectToClient(client) {
messagePlayerNormal(client, `You have the following characters. Use /usechar <id> to select one:`, getColourByName("teal"));
getPlayerData(client).subAccounts.forEach(function(subAccount, index) {
let tempSubAccount = getPlayerData(client).subAccounts[0];
let clanName = (tempSubAccount.clan != 0) ? getClanData(tempSubAccount.clan).name : "None";
let clanName = (tempSubAccount.clan != 0) ? getClanData(getClanIdFromDatabaseId(tempSubAccount.clan)).name : "None";
let lastPlayedText = (tempSubAccount.lastLogin != 0) ? `${msToTime(getCurrentUnixTimestamp()-tempSubAccount.lastLogin)} ago` : "Never";
messagePlayerNormal(client, `${index+1} • [#BBBBBB]${subAccount.firstName} ${subAccount.lastName} ($${tempSubAccount.cash}, ${lastPlayedText})`);
});
@@ -320,7 +320,7 @@ function checkPreviousCharacter(client) {
let subAccountId = getPlayerData(client).currentSubAccount;
let tempSubAccount = getPlayerData(client).subAccounts[subAccountId];
let clanName = (tempSubAccount.clan != 0) ? getClanData(tempSubAccount.clan).name : "None";
let clanName = (tempSubAccount.clan != 0) ? getClanData(getClanIdFromDatabaseId(tempSubAccount.clan)).name : "None";
let lastPlayedText = (tempSubAccount.lastLogin != 0) ? `${getTimeDifferenceDisplay(tempSubAccount.lastLogin, getCurrentUnixTimestamp())} ago` : "Never";
showPlayerCharacterSelectGUI(client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.cash, clanName, lastPlayedText, tempSubAccount.skin);
@@ -341,7 +341,7 @@ function checkNextCharacter(client) {
let subAccountId = getPlayerData(client).currentSubAccount;
let tempSubAccount = getPlayerData(client).subAccounts[subAccountId];
let clanName = (tempSubAccount.clan != 0) ? getClanData(tempSubAccount.clan).name : "None";
let clanName = (tempSubAccount.clan != 0) ? getClanData(getClanIdFromDatabaseId(tempSubAccount.clan)).name : "None";
let lastPlayedText = (tempSubAccount.lastLogin != 0) ? `${getTimeDifferenceDisplay(tempSubAccount.lastLogin, getCurrentUnixTimestamp())} ago` : "Never";
showPlayerCharacterSelectGUI(client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.cash, clanName, lastPlayedText, tempSubAccount.skin);

View File

@@ -81,19 +81,36 @@ function saveAllServerDataToDatabase() {
function initTimers() {
//if(!isDevelopmentServer()) {
serverTimers.saveDataIntervalTimer = setInterval(saveAllServerDataToDatabase, 600000);
//serverTimers.updateTimeRuleTimer = setInterval(updateTimeRule, 60000);
serverTimers.updatePingsTimer = setInterval(updatePings, 5000);
serverTimers.vehicleRentTimer = setInterval(vehicleRentCheck, 60000);
serverTimers.garbageCollectorTimer = setInterval(collectAllGarbage, 60000);
serverTimers.payDayTimer = setInterval(checkPayDays, 1800000);
serverTimers.randomTipTimer = setInterval(showRandomTipToAllPlayers, 600000);
serverTimers.gameTime = setInterval(checkServerGameTime, 60000);
serverTimers.oneMinuteTimer = setInterval(oneMinuteTimerFunction, 60000);
serverTimers.fifteenMinuteTimer = setInterval(tenMinuteTimerFunction, 600000);
serverTimers.thirtyMinuteTimer = setInterval(thirtyMinuteTimerFunction, 1800000);
//}
}
// ===========================================================================
function oneMinuteTimerFunction() {
checkServerGameTime();
vehicleRentCheck();
collectAllGarbage();
}
// ===========================================================================
function tenMinuteTimerFunction() {
showRandomTipToAllPlayers();
saveAllServerDataToDatabase();
}
// ===========================================================================
function thirtyMinuteTimerFunction() {
checkPayDays();
}
// ===========================================================================
function vehicleRentCheck() {
for(let i in getServerData().vehicles) {
if(getServerData().vehicles[i] != null) {

View File

@@ -1109,7 +1109,7 @@ function getPluralForm(name) {
// ===========================================================================
function removeColoursFromString(str) {
function removeHexColoursFromString(str) {
let matchRegex = /#([a-f0-9]{3}|[a-f0-9]{4}(?:[a-f0-9]{2}){0,2})\b/gi;
let matchedHexes = str.match(matchRegex);
for(let i in matchHex) {
@@ -1144,6 +1144,8 @@ function showConnectCameraToPlayer(client) {
}
if(isCustomCameraSupported()) {
//setPlayerInterior(client, 0);
//setPlayerDimension(client, 0);
setPlayerCameraLookAt(client, getServerConfig().connectCameraPosition, getServerConfig().connectCameraLookAt);
}
}
@@ -1587,4 +1589,31 @@ function getClientFromSyncerId(syncerId) {
return getClients().filter(c => c.index == syncerId)[0];
}
// ===========================================================================
// ===========================================================================
function fixAngle(angle) {
angle = radToDeg(angle);
if(angle < 0)
{
angle = Math.abs(angle);
angle = ((180-angle+1)+180);
}
return degToRad(angle);
}
// ===========================================================================
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) {
}
);
});
}

View File

@@ -452,7 +452,7 @@ function vehicleColourCommand(command, params, client) {
}
if(getPlayerCurrentSubAccount(client).cash < getGlobalConfig().resprayVehicleCost) {
messagePlayerError(client, `You don't have enough money to respray the vehicle (need $${getGlobalConfig().resprayVehicleCost-getPlayerCurrentSubAccount(client).cash} more!)`);
messagePlayerError(client, `You don't have enough money to respray the vehicle (need $${makeLargeNumberReadable(getGlobalConfig().resprayVehicleCost-getPlayerCurrentSubAccount(client).cash)} more!)`);
return false;
}
@@ -495,7 +495,7 @@ function vehicleRepairCommand(command, params, client) {
}
if(getPlayerCurrentSubAccount(client).cash < getGlobalConfig().repairVehicleCost) {
messagePlayerError(client, `You don't have enough money to repair the vehicle (need $${getGlobalConfig().resprayVehicleCost-getPlayerCurrentSubAccount(client).cash} more!)`);
messagePlayerError(client, `You don't have enough money to repair the vehicle (need $${makeLargeNumberReadable(getGlobalConfig().resprayVehicleCost-getPlayerCurrentSubAccount(client).cash)} more!)`);
return false;
}
@@ -530,7 +530,7 @@ function vehicleLiveryCommand(command, params, client) {
}
if(getPlayerCurrentSubAccount(client).cash < getGlobalConfig().repairVehicleCost) {
messagePlayerError(client, `You don't have enough money to change the vehicle's livery (need $${getGlobalConfig().resprayVehicleCost-getPlayerCurrentSubAccount(client).cash} more!)`);
messagePlayerError(client, `You don't have enough money to change the vehicle's livery (need $${makeLargeNumberReadable(getGlobalConfig().resprayVehicleCost-getPlayerCurrentSubAccount(client).cash)} more!)`);
return false;
}
@@ -571,7 +571,7 @@ function buyVehicleCommand(command, params, client) {
}
if(getPlayerCurrentSubAccount(client).cash < getVehicleData(vehicle).buyPrice) {
messagePlayerError(client, `You don't have enough money to buy this vehicle (need $${getVehicleData(vehicle).buyPrice-getPlayerCurrentSubAccount(client).cash} more!)`);
messagePlayerError(client, `You don't have enough money to buy this vehicle (need $${makeLargeNumberReadable(getVehicleData(vehicle).buyPrice-getPlayerCurrentSubAccount(client).cash)} more!)`);
return false;
}
@@ -632,7 +632,7 @@ function rentVehicleCommand(command, params, client) {
getVehicleData(vehicle).needsSaved = true;
meActionToNearbyPlayers(client, `rents the ${getVehicleName(vehicle)} and receives a set of vehicle keys!`);
messagePlayerAlert(client, `You will be charged $${getVehicleData(vehicle).rentPrice} per minute to use this vehicle. To stop renting this vehicle, use /vehrent again.`);
messagePlayerAlert(client, `You will be charged $${makeLargeNumberReadable(getVehicleData(vehicle).rentPrice)} per minute to use this vehicle. To stop renting this vehicle, use /vehrent again.`);
if(!getVehicleData(vehicle).engine) {
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "engine")) {
@@ -913,7 +913,7 @@ function setVehicleRentPriceCommand(command, params, client) {
getVehicleData(vehicle).rentPrice = amount;
messageAdmins(`${getInlineChatColourByName("lightGrey")}${getPlayerName(client)} ${getInlineChatColourByName("white")}set their ${getInlineChatColourByType("vehiclePurple")}${getVehicleName(vehicle)} ${getInlineChatColourByName("white")}rent price to ${getInlineChatColourByName("lightGrey")}$${amount}`);
messageAdmins(`${getInlineChatColourByName("lightGrey")}${getPlayerName(client)} ${getInlineChatColourByName("white")}set their ${getInlineChatColourByType("vehiclePurple")}${getVehicleName(vehicle)} ${getInlineChatColourByName("white")}rent price to ${getInlineChatColourByName("lightGrey")}$${makeLargeNumberReadable(amount)}`);
getVehicleData(vehicle).needsSaved = true;
}
@@ -938,7 +938,7 @@ function setVehicleBuyPriceCommand(command, params, client) {
getVehicleData(vehicle).buyPrice = amount;
messageAdmins(`${getInlineChatColourByName("lightGrey")}${getPlayerName(client)} ${getInlineChatColourByName("white")}set their ${getInlineChatColourByType("vehiclePurple")}${getVehicleName(vehicle)}'s ${getInlineChatColourByName("white")}buy price to ${getInlineChatColourByName("lightGrey")}$${amount}`);
messageAdmins(`${getInlineChatColourByName("lightGrey")}${getPlayerName(client)} ${getInlineChatColourByName("white")}set their ${getInlineChatColourByType("vehiclePurple")}${getVehicleName(vehicle)}'s ${getInlineChatColourByName("white")}buy price to ${getInlineChatColourByName("lightGrey")}$${makeLargeNumberReadable(amount)}`);
getVehicleData(vehicle).needsSaved = true;
}