New util for if player can edit biz
This commit is contained in:
@@ -243,12 +243,10 @@ function setBusinessNameCommand(command, params, client) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("manageBusinesses"))) {
|
if(!canPlayerManageBusiness(client, businessId)) {
|
||||||
if(getBusinessData(businessId).ownerType == VRR_BIZOWNER_PLAYER && getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
|
messagePlayerError(client, "You can't change the name of this business!");
|
||||||
messagePlayerError(client, "You don't own this business!");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let oldBusinessName = getBusinessData(businessId).name;
|
let oldBusinessName = getBusinessData(businessId).name;
|
||||||
getBusinessData(businessId).name = newBusinessName;
|
getBusinessData(businessId).name = newBusinessName;
|
||||||
@@ -260,6 +258,11 @@ function setBusinessNameCommand(command, params, client) {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function setBusinessOwnerCommand(command, params, client) {
|
function setBusinessOwnerCommand(command, params, client) {
|
||||||
|
if(areParamsEmpty(params)) {
|
||||||
|
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
let newBusinessOwner = getPlayerFromParams(params);
|
let newBusinessOwner = getPlayerFromParams(params);
|
||||||
let businessId = getPlayerBusiness(client);
|
let businessId = getPlayerBusiness(client);
|
||||||
|
|
||||||
@@ -273,10 +276,8 @@ function setBusinessOwnerCommand(command, params, client) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getBusinessData(businessId).ownerType != VRR_BIZOWNER_PLAYER || getBusinessData(businessId).ownerId != getPlayerCurrentSubAccount(client).databaseId) {
|
if(!canPlayerManageBusiness(client, businessId)) {
|
||||||
if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("manageBusinesses"))) {
|
messagePlayerError(client, "You can't change the owner of this business!");
|
||||||
messagePlayerError(client, "You don't own this business!");
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,12 +305,10 @@ function setBusinessClanCommand(command, params, client) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("manageBusinesses"))) {
|
if(!canPlayerManageBusiness(client, businessId)) {
|
||||||
if(getBusinessData(businessId).ownerType != VRR_BIZOWNER_PLAYER && getBusinessData(businessId).ownerId != getPlayerCurrentSubAccount(client).databaseId) {
|
messagePlayerError(client, "You can't change this business clan!");
|
||||||
messagePlayerError(client, "You don't own this business!");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
getBusinessData(businessId).ownerType = VRR_BIZOWNER_CLAN;
|
getBusinessData(businessId).ownerType = VRR_BIZOWNER_CLAN;
|
||||||
getBusinessData(businessId).ownerId = getClanData(clanId).databaseId;
|
getBusinessData(businessId).ownerId = getClanData(clanId).databaseId;
|
||||||
@@ -330,6 +329,11 @@ function setBusinessClanCommand(command, params, client) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function setBusinessRankCommand(command, params, client) {
|
function setBusinessRankCommand(command, params, client) {
|
||||||
|
if(areParamsEmpty(params)) {
|
||||||
|
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
let businessId = getPlayerBusiness(client);
|
let businessId = getPlayerBusiness(client);
|
||||||
|
|
||||||
if(!getBusinessData(businessId)) {
|
if(!getBusinessData(businessId)) {
|
||||||
@@ -351,8 +355,8 @@ function setBusinessClanCommand(command, params, client) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(doesPlayerHaveClanPermission(client, getClanFlagValue("manageBusinesses"))) {
|
if(!canPlayerManageBusiness(client, businessId)) {
|
||||||
messagePlayerError(client, "You can't set clan business ranks!");
|
messagePlayerError(client, "You can't change this business rank!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -435,12 +439,10 @@ function lockUnlockBusinessCommand(command, params, client) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("manageBusinesses"))) {
|
if(!canPlayerManageBusiness(client, businessId)) {
|
||||||
if(canPlayerLockUnlockBusiness(client, businessId)) {
|
messagePlayerError(client, "You can't change this business rank!");
|
||||||
messagePlayerError(client, "You don't have keys to this business!");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
getBusinessData(businessId).locked = !getBusinessData(businessId).locked;
|
getBusinessData(businessId).locked = !getBusinessData(businessId).locked;
|
||||||
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.locked", getBusinessData(businessId).locked, true);
|
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.locked", getBusinessData(businessId).locked, true);
|
||||||
@@ -468,12 +470,10 @@ function lockUnlockBusinessCommand(command, params, client) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("manageBusinesses"))) {
|
if(!canPlayerManageBusiness(client, businessId)) {
|
||||||
if(canPlayerSetBusinessInteriorLights(client, businessId)) {
|
messagePlayerError(client, "You can't change the interior lights for this business!");
|
||||||
messagePlayerError(client, "You don't have keys to this business!");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
getBusinessData(businessId).interiorLights = !getBusinessData(businessId).interiorLights;
|
getBusinessData(businessId).interiorLights = !getBusinessData(businessId).interiorLights;
|
||||||
updateBusinessInteriorLightsForOccupants(businessId);
|
updateBusinessInteriorLightsForOccupants(businessId);
|
||||||
@@ -494,12 +494,10 @@ function setBusinessEntranceFeeCommand(command, params, client) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("manageBusinesses"))) {
|
if(!canPlayerManageBusiness(client, businessId)) {
|
||||||
if(canPlayerSetBusinessEntranceFee(client, businessId)) {
|
messagePlayerError(client, "You can't change the entrance fee for this business!");
|
||||||
messagePlayerError(client, "You don't have keys to this business!");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
getBusinessData(businessId).entranceFee = entranceFee;
|
getBusinessData(businessId).entranceFee = entranceFee;
|
||||||
getBusinessData(businessId).needsSaved = true;
|
getBusinessData(businessId).needsSaved = true;
|
||||||
@@ -768,12 +766,10 @@ function withdrawFromBusinessCommand(command, params, client) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("manageBusinesses"))) {
|
if(!canPlayerManageBusiness(client, businessId)) {
|
||||||
if(canPlayerWithdrawFromBusinessTill(client, businessId)) {
|
messagePlayerError(client, "You can't withdraw cash from this business!");
|
||||||
messagePlayerError(client, "You don't have keys to this business!");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(getBusinessData(businessId).till < amount) {
|
if(getBusinessData(businessId).till < amount) {
|
||||||
messagePlayerError(client, `Business ${getInlineChatColourByType("businessBlue")}${tempBusinessData.name} doesn't have that much money! Use /bizbalance.`);
|
messagePlayerError(client, `Business ${getInlineChatColourByType("businessBlue")}${tempBusinessData.name} doesn't have that much money! Use /bizbalance.`);
|
||||||
@@ -806,6 +802,11 @@ function setBusinessBuyPriceCommand(command, params, client) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!canPlayerManageBusiness(client, businessId)) {
|
||||||
|
messagePlayerError(client, "You can't change the purchase price for this business!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if(amount < 0) {
|
if(amount < 0) {
|
||||||
messagePlayerError(client, `The amount can't be less than 0!`);
|
messagePlayerError(client, `The amount can't be less than 0!`);
|
||||||
return false;
|
return false;
|
||||||
@@ -836,6 +837,12 @@ function depositIntoBusinessCommand(command, params, client) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Let anybody deposit money
|
||||||
|
//if(!canPlayerManageBusiness(client, businessId)) {
|
||||||
|
// messagePlayerError(client, "You can't deposit cash into this business!");
|
||||||
|
// return false;
|
||||||
|
//}
|
||||||
|
|
||||||
if(getPlayerCurrentSubAccount(client).cash < amount) {
|
if(getPlayerCurrentSubAccount(client).cash < amount) {
|
||||||
messagePlayerError(client, `You don't have that much money! You only have $${getPlayerCurrentSubAccount(client).cash}`);
|
messagePlayerError(client, `You don't have that much money! You only have $${getPlayerCurrentSubAccount(client).cash}`);
|
||||||
return false;
|
return false;
|
||||||
@@ -879,7 +886,12 @@ function orderItemForBusinessCommand(command, params, client) {
|
|||||||
logToConsole(LOG_DEBUG, `[VRR.Business] ${getPlayerDisplayForConsole(client)} is ordering ${amount} ${splitParams.slice(0,-2).join(" ")} (${value})`);
|
logToConsole(LOG_DEBUG, `[VRR.Business] ${getPlayerDisplayForConsole(client)} is ordering ${amount} ${splitParams.slice(0,-2).join(" ")} (${value})`);
|
||||||
|
|
||||||
if(!getBusinessData(businessId)) {
|
if(!getBusinessData(businessId)) {
|
||||||
messagePlayerError(client, "You must be inside or near a business door!");
|
messagePlayerError(client, "Business not found!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!canPlayerManageBusiness(client, businessId)) {
|
||||||
|
messagePlayerError(client, "You can't order items for this business!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -924,6 +936,11 @@ function viewBusinessTillAmountCommand(command, params, client) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!canPlayerManageBusiness(client, businessId)) {
|
||||||
|
messagePlayerError(client, "You can't see the till amount for this business!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
messagePlayerSuccess(client, `Business ${getInlineChatColourByType("businessBlue")}${getBusinessData(businessId).name} ${getInlineChatColourByName("white")}till has ${getInlineChatColourByName("lightGrey")}$${getBusinessData(businessId).till}`);
|
messagePlayerSuccess(client, `Business ${getInlineChatColourByType("businessBlue")}${getBusinessData(businessId).name} ${getInlineChatColourByName("white")}till has ${getInlineChatColourByName("lightGrey")}$${getBusinessData(businessId).till}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1897,3 +1914,31 @@ function canPlayerLockUnlockBusiness(client, businessId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
|
function canPlayerManageBusiness(client, businessId) {
|
||||||
|
if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("manageBusinesses"))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(getBusinessData(businessId).ownerType == VRR_BIZOWNER_PLAYER) {
|
||||||
|
if(getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(getBusinessData(businessId).ownerType == VRR_BIZOWNER_CLAN) {
|
||||||
|
if(getBusinessData(businessId).ownerId == getPlayerClan(client)) {
|
||||||
|
if(doesPlayerHaveClanPermission(client, getClanFlagValue("manageBusinesses"))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//if(getBusinessData(businessId).clanRank <= getClanRankData(getPlayerClan(client), getPlayerClanRank(client)).level) {
|
||||||
|
// return true;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
Reference in New Issue
Block a user