Make save queries easier to modify
This commit is contained in:
@@ -504,10 +504,23 @@ function saveAccountToDatabase(accountData) {
|
|||||||
let safeIRCAccount = escapeDatabaseString(dbConnection, accountData.ircAccount);
|
let safeIRCAccount = escapeDatabaseString(dbConnection, accountData.ircAccount);
|
||||||
//logToConsole(LOG_VERBOSE, `${getPlayerDisplayForConsole(client)}'s irc account escaped successfully`);
|
//logToConsole(LOG_VERBOSE, `${getPlayerDisplayForConsole(client)}'s irc account escaped successfully`);
|
||||||
|
|
||||||
let dbQueryString = `UPDATE acct_main SET acct_email='${safeEmailAddress}', acct_pass='${safePassword}', acct_settings=${accountData.settings}, acct_staff_flags=${accountData.flags.admin}, acct_mod_flags=${accountData.flags.moderation}, acct_discord=${accountData.discordAccount}, acct_ip=INET_ATON('${accountData.ipAddress}'), acct_code_verifyemail='${accountData.emailVerificationCode}' WHERE acct_id=${accountData.databaseId}`;
|
let dbQueryString =
|
||||||
logToConsole(LOG_VERBOSE, dbQueryString);
|
`UPDATE acct_main SET
|
||||||
|
acct_email='${safeEmailAddress}',
|
||||||
|
acct_pass='${safePassword}',
|
||||||
|
acct_settings=${accountData.settings},
|
||||||
|
acct_staff_flags=${accountData.flags.admin},
|
||||||
|
acct_mod_flags=${accountData.flags.moderation},
|
||||||
|
acct_discord=${accountData.discordAccount},
|
||||||
|
acct_ip=INET_ATON('${accountData.ipAddress}'),
|
||||||
|
acct_code_verifyemail='${accountData.emailVerificationCode}'
|
||||||
|
WHERE acct_id=${accountData.databaseId}`;
|
||||||
|
|
||||||
|
//dbQueryString = dbQueryString.trim();
|
||||||
|
dbQueryString = dbQueryString.replace(/(?:\r\n|\r|\n|\t)/g, "");
|
||||||
|
logToConsole(LOG_DEBUG, dbQueryString);
|
||||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||||
//freeDatabaseQuery(dbQuery);
|
freeDatabaseQuery(dbQuery);
|
||||||
disconnectFromDatabase(dbConnection);
|
disconnectFromDatabase(dbConnection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -818,7 +818,7 @@ function saveBusinessToDatabase(businessId) {
|
|||||||
|
|
||||||
let dbQueryString =
|
let dbQueryString =
|
||||||
`UPDATE biz_main SET
|
`UPDATE biz_main SET
|
||||||
biz_name='${safeBusinessName}',
|
biz_name='${safeBusinessName}',
|
||||||
biz_owner_type=${tempBusinessData.ownerType},
|
biz_owner_type=${tempBusinessData.ownerType},
|
||||||
biz_owner_id=${tempBusinessData.ownerId},
|
biz_owner_id=${tempBusinessData.ownerId},
|
||||||
biz_locked=${boolToInt(tempBusinessData.locked)},
|
biz_locked=${boolToInt(tempBusinessData.locked)},
|
||||||
@@ -838,9 +838,13 @@ function saveBusinessToDatabase(businessId) {
|
|||||||
biz_exit_vw=${tempBusinessData.exitDimension},
|
biz_exit_vw=${tempBusinessData.exitDimension},
|
||||||
biz_has_interior=${boolToInt(tempBusinessData.hasInterior)}
|
biz_has_interior=${boolToInt(tempBusinessData.hasInterior)}
|
||||||
biz_buy_price=${tempBusinessData.buyPrice}
|
biz_buy_price=${tempBusinessData.buyPrice}
|
||||||
WHERE biz_id=${tempBusinessData.databaseId}`;
|
WHERE biz_id=${tempBusinessData.databaseId}`;
|
||||||
|
|
||||||
queryDatabase(dbConnection, dbQueryString);
|
dbQueryString = dbQueryString.replace(/(?:\r\n|\r|\n|\t)/g, "");
|
||||||
|
logToConsole(LOG_DEBUG, dbQueryString);
|
||||||
|
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||||
|
freeDatabaseQuery(dbQuery);
|
||||||
|
disconnectFromDatabase(dbConnection);
|
||||||
}
|
}
|
||||||
disconnectFromDatabase(dbConnection);
|
disconnectFromDatabase(dbConnection);
|
||||||
return true;
|
return true;
|
||||||
@@ -1168,11 +1172,13 @@ function buyFromBusinessCommand(command, params, client) {
|
|||||||
|
|
||||||
if(typeof getBusinessData(businessId).floorItemCache[itemSlot] == "undefined") {
|
if(typeof getBusinessData(businessId).floorItemCache[itemSlot] == "undefined") {
|
||||||
messagePlayerError(client, `Item slot ${itemSlot} doesn't exist!`);
|
messagePlayerError(client, `Item slot ${itemSlot} doesn't exist!`);
|
||||||
|
messagePlayerTip(client, `Use /bizitems to see what the business has for sale.`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getBusinessData(businessId).floorItemCache[itemSlot] == -1) {
|
if(getBusinessData(businessId).floorItemCache[itemSlot] == -1) {
|
||||||
messagePlayerError(client, `Item slot ${itemSlot} slot is empty!`);
|
messagePlayerError(client, `Item slot ${itemSlot} slot is empty!`);
|
||||||
|
messagePlayerTip(client, `Use /bizitems to see what the business has for sale.`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -436,7 +436,7 @@ function saveHouseToDatabase(houseId) {
|
|||||||
|
|
||||||
let dbQueryString =
|
let dbQueryString =
|
||||||
`UPDATE house_main SET
|
`UPDATE house_main SET
|
||||||
house_description='${safeHouseDescription}',
|
house_description='${safeHouseDescription}',
|
||||||
house_owner_type=${tempHouseData.ownerType},
|
house_owner_type=${tempHouseData.ownerType},
|
||||||
house_owner_id=${tempHouseData.ownerId},
|
house_owner_id=${tempHouseData.ownerId},
|
||||||
house_locked=${boolToInt(tempHouseData.locked)},
|
house_locked=${boolToInt(tempHouseData.locked)},
|
||||||
@@ -455,14 +455,19 @@ function saveHouseToDatabase(houseId) {
|
|||||||
house_buy_price=${tempHouseData.buyPrice},
|
house_buy_price=${tempHouseData.buyPrice},
|
||||||
house_rent_price=${tempHouseData.rentPrice},
|
house_rent_price=${tempHouseData.rentPrice},
|
||||||
house_has_interior=${boolToInt(tempHouseData.hasInterior)}
|
house_has_interior=${boolToInt(tempHouseData.hasInterior)}
|
||||||
WHERE house_id=${tempHouseData.databaseId}`;
|
WHERE house_id=${tempHouseData.databaseId}`;
|
||||||
|
|
||||||
queryDatabase(dbConnection, dbQueryString);
|
//dbQueryString = dbQueryString.trim();
|
||||||
|
dbQueryString = dbQueryString.replace(/(?:\r\n|\r|\n|\t)/g, "");
|
||||||
|
logToConsole(LOG_DEBUG, dbQueryString);
|
||||||
|
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||||
|
freeDatabaseQuery(dbQuery);
|
||||||
|
disconnectFromDatabase(dbConnection);
|
||||||
}
|
}
|
||||||
disconnectFromDatabase(dbConnection);
|
disconnectFromDatabase(dbConnection);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
logToConsole(LOG_DEBUG, `[Asshat.house]: Saved house '${tempHouseData.description}' to database!`);
|
logToConsole(LOG_DEBUG, `[Asshat.House]: Saved house '${tempHouseData.description}' to database!`);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ function saveSubAccountToDatabase(subAccountData) {
|
|||||||
|
|
||||||
let dbQueryString = `
|
let dbQueryString = `
|
||||||
UPDATE sacct_main SET
|
UPDATE sacct_main SET
|
||||||
sacct_name_first='${safeFirstName}',
|
sacct_name_first='${safeFirstName}',
|
||||||
sacct_name_last='${safeLastName}',
|
sacct_name_last='${safeLastName}',
|
||||||
sacct_name_middle='${safeMiddleName}',
|
sacct_name_middle='${safeMiddleName}',
|
||||||
sacct_pos_x=${subAccountData.spawnPosition.x},
|
sacct_pos_x=${subAccountData.spawnPosition.x},
|
||||||
@@ -112,38 +112,40 @@ function saveSubAccountToDatabase(subAccountData) {
|
|||||||
sacct_fightstyle=${subAccountData.fightStyle},
|
sacct_fightstyle=${subAccountData.fightStyle},
|
||||||
sacct_walkstyle=${subAccountData.walkStyle},
|
sacct_walkstyle=${subAccountData.walkStyle},
|
||||||
sacct_when_lastlogin=${subAccountData.lastLogin},
|
sacct_when_lastlogin=${subAccountData.lastLogin},
|
||||||
sacct_origin=${subAccountData.placeOfOrigin},
|
sacct_origin='${subAccountData.placeOfOrigin}',
|
||||||
sacct_when_born=${subAccountData.dateOfBirth},
|
sacct_when_born='${subAccountData.dateOfBirth}',
|
||||||
sacct_iv_part_hair_model=${subAccountData.bodyParts.hair[0]},
|
sacct_hd_part_hair_model=${subAccountData.bodyParts.hair[0]},
|
||||||
sacct_iv_part_hair_texture=${subAccountData.bodyParts.hair[1]},
|
sacct_hd_part_hair_texture=${subAccountData.bodyParts.hair[1]},
|
||||||
sacct_iv_part_head_model=${subAccountData.bodyParts.head[0]},
|
sacct_hd_part_head_model=${subAccountData.bodyParts.head[0]},
|
||||||
sacct_iv_part_head_texture=${subAccountData.bodyParts.head[1]},
|
sacct_hd_part_head_texture=${subAccountData.bodyParts.head[1]},
|
||||||
sacct_iv_part_upper_model=${subAccountData.bodyParts.upper[0]},
|
sacct_hd_part_upper_model=${subAccountData.bodyParts.upper[0]},
|
||||||
sacct_iv_part_upper_texture=${subAccountData.bodyParts.upper[1]},
|
sacct_hd_part_upper_texture=${subAccountData.bodyParts.upper[1]},
|
||||||
sacct_iv_part_lower_model=${subAccountData.bodyParts.lower[0]},
|
sacct_hd_part_lower_model=${subAccountData.bodyParts.lower[0]},
|
||||||
sacct_iv_part_lower_texture=${subAccountData.bodyParts.lower[1]},
|
sacct_hd_part_lower_texture=${subAccountData.bodyParts.lower[1]},
|
||||||
sacct_iv_prop_hair_model=${subAccountData.bodyProps.hair[0]},
|
sacct_hd_prop_hair_model=${subAccountData.bodyProps.hair[0]},
|
||||||
sacct_iv_prop_hair_texture=${subAccountData.bodyProps.hair[1]},
|
sacct_hd_prop_hair_texture=${subAccountData.bodyProps.hair[1]},
|
||||||
sacct_iv_prop_eyes_model=${subAccountData.bodyProps.eyes[0]},
|
sacct_hd_prop_eyes_model=${subAccountData.bodyProps.eyes[0]},
|
||||||
sacct_iv_prop_eyes_texture=${subAccountData.bodyProps.eyes[1]},
|
sacct_hd_prop_eyes_texture=${subAccountData.bodyProps.eyes[1]},
|
||||||
sacct_iv_prop_head_model=${subAccountData.bodyProps.head[0]},
|
sacct_hd_prop_head_model=${subAccountData.bodyProps.head[0]},
|
||||||
sacct_iv_prop_head_texture=${subAccountData.bodyProps.head[1]},
|
sacct_hd_prop_head_texture=${subAccountData.bodyProps.head[1]},
|
||||||
sacct_iv_prop_lefthand_model=${subAccountData.bodyProps.leftHand[0]},
|
sacct_hd_prop_lefthand_model=${subAccountData.bodyProps.leftHand[0]},
|
||||||
sacct_iv_prop_lefthand_texture=${subAccountData.bodyProps.leftHand[1]},
|
sacct_hd_prop_lefthand_texture=${subAccountData.bodyProps.leftHand[1]},
|
||||||
sacct_iv_prop_righthand_model=${subAccountData.bodyProps.rightHand[0]},
|
sacct_hd_prop_righthand_model=${subAccountData.bodyProps.rightHand[0]},
|
||||||
sacct_iv_prop_righthand_texture=${subAccountData.bodyProps.rightHand[1]},
|
sacct_hd_prop_righthand_texture=${subAccountData.bodyProps.rightHand[1]},
|
||||||
sacct_iv_prop_leftwrist_model=${subAccountData.bodyProps.leftWrist[0]},
|
sacct_hd_prop_leftwrist_model=${subAccountData.bodyProps.leftWrist[0]},
|
||||||
sacct_iv_prop_leftwrist_texture=${subAccountData.bodyProps.leftWrist[1]},
|
sacct_hd_prop_leftwrist_texture=${subAccountData.bodyProps.leftWrist[1]},
|
||||||
sacct_iv_prop_rightwrist_model=${subAccountData.bodyProps.rightWrist[0]},
|
sacct_hd_prop_rightwrist_model=${subAccountData.bodyProps.rightWrist[0]},
|
||||||
sacct_iv_prop_rightwrist_texture=${subAccountData.bodyProps.rightWrist[1]},
|
sacct_hd_prop_rightwrist_texture=${subAccountData.bodyProps.rightWrist[1]},
|
||||||
sacct_iv_prop_hip_model=${subAccountData.bodyProps.hip[0]},
|
sacct_hd_prop_hip_model=${subAccountData.bodyProps.hip[0]},
|
||||||
sacct_iv_prop_hip_texture=${subAccountData.bodyProps.hip[1]},
|
sacct_hd_prop_hip_texture=${subAccountData.bodyProps.hip[1]},
|
||||||
sacct_iv_prop_leftfoot_model=${subAccountData.bodyProps.leftFoot[0]},
|
sacct_hd_prop_leftfoot_model=${subAccountData.bodyProps.leftFoot[0]},
|
||||||
sacct_iv_prop_leftfoot_texture=${subAccountData.bodyProps.leftFoot[1]},
|
sacct_hd_prop_leftfoot_texture=${subAccountData.bodyProps.leftFoot[1]},
|
||||||
sacct_iv_prop_rightfoot_model=${subAccountData.bodyProps.rightFoot[0]},
|
sacct_hd_prop_rightfoot_model=${subAccountData.bodyProps.rightFoot[0]},
|
||||||
sacct_iv_prop_rightfoot_texture=${subAccountData.bodyProps.rightFoot[1]}
|
sacct_hd_prop_rightfoot_texture=${subAccountData.bodyProps.rightFoot[1]}
|
||||||
WHERE sacct_id=${subAccountData.databaseId}`;
|
WHERE sacct_id=${subAccountData.databaseId}`;
|
||||||
|
|
||||||
|
//dbQueryString = dbQueryString.trim();
|
||||||
|
dbQueryString = dbQueryString.replace(/(?:\r\n|\r|\n|\t)/g, "");
|
||||||
logToConsole(LOG_DEBUG, dbQueryString);
|
logToConsole(LOG_DEBUG, dbQueryString);
|
||||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||||
freeDatabaseQuery(dbQuery);
|
freeDatabaseQuery(dbQuery);
|
||||||
|
|||||||
Reference in New Issue
Block a user