From 8c9ef8f151d496226dbf5174a310ff3fc3ad945a Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 16 Dec 2020 08:01:02 -0600 Subject: [PATCH] Add new police cmd checks --- scripts/server/job/police.js | 104 +++++++++++++++++++++++++++++++++-- 1 file changed, 98 insertions(+), 6 deletions(-) diff --git a/scripts/server/job/police.js b/scripts/server/job/police.js index b0d7d79f..15efba97 100644 --- a/scripts/server/job/police.js +++ b/scripts/server/job/police.js @@ -9,10 +9,27 @@ // =========================================================================== function policeTazerCommand(command, params, client) { - if(!canClientUseJobs(client) || !!canClientUsePoliceJob(client)){ + if(!canPlayerUseJobs(client)) { + messageClientError(client, "You are not allowed to use jobs."); return false; } + if(!canPlayerUsePoliceJob(client)) { + messageClientError(client, "You are not allowed to use the police job."); + return false; + } + + if(!isPlayerWorking(client)) { + messageClientError(client, "You are working! Use /startwork first."); + return false; + } + + if(!doesPlayerHaveJobType(client, AG_JOB_POLICE)) { + messageClientError(client, "You don't have a police job."); + return false; + } + + return true; } @@ -20,10 +37,25 @@ function policeTazerCommand(command, params, client) { // --------------------------------------------------------------------------- function policeCuffCommand(command, params, client) { - if(!canClientUseJobs(client) || !!canClientUsePoliceJob(client)) { + if(!canPlayerUseJobs(client)) { + messageClientError(client, "You are not allowed to use jobs."); return false; } + if(!canPlayerUsePoliceJob(client)) { + messageClientError(client, "You are not allowed to use the police job."); + return false; + } + + if(!isPlayerWorking(client)) { + messageClientError(client, "You are working! Use /startwork first."); + return false; + } + + if(!doesPlayerHaveJobType(client, AG_JOB_POLICE)) { + messageClientError(client, "You don't have a police job."); + return false; + } return true; } @@ -31,10 +63,25 @@ function policeCuffCommand(command, params, client) { // --------------------------------------------------------------------------- function policeArrestCommand(command, params, client) { - if(!canClientUseJobs(client) || !!canClientUsePoliceJob(client)) { + if(!canPlayerUseJobs(client)) { + messageClientError(client, "You are not allowed to use jobs."); return false; } + if(!canPlayerUsePoliceJob(client)) { + messageClientError(client, "You are not allowed to use the police job."); + return false; + } + + if(!isPlayerWorking(client)) { + messageClientError(client, "You are working! Use /startwork first."); + return false; + } + + if(!doesPlayerHaveJobType(client, AG_JOB_POLICE)) { + messageClientError(client, "You don't have a police job."); + return false; + } return true; } @@ -42,10 +89,25 @@ function policeArrestCommand(command, params, client) { // --------------------------------------------------------------------------- function policeSearchCommand(command, params, client) { - if(!canClientUseJobs(client) || !!canClientUsePoliceJob(client)) { + if(!canPlayerUseJobs(client)) { + messageClientError(client, "You are not allowed to use jobs."); return false; } + if(!canPlayerUsePoliceJob(client)) { + messageClientError(client, "You are not allowed to use the police job."); + return false; + } + + if(!isPlayerWorking(client)) { + messageClientError(client, "You are working! Use /startwork first."); + return false; + } + + if(!doesPlayerHaveJobType(client, AG_JOB_POLICE)) { + messageClientError(client, "You don't have a police job."); + return false; + } return true; } @@ -53,10 +115,25 @@ function policeSearchCommand(command, params, client) { // --------------------------------------------------------------------------- function policeDragCommand(command, params, client) { - if(!canClientUseJobs(client) || !!canClientUsePoliceJob(client)) { + if(!canPlayerUseJobs(client)) { + messageClientError(client, "You are not allowed to use jobs."); return false; } + if(!canPlayerUsePoliceJob(client)) { + messageClientError(client, "You are not allowed to use the police job."); + return false; + } + + if(!isPlayerWorking(client)) { + messageClientError(client, "You are working! Use /startwork first."); + return false; + } + + if(!doesPlayerHaveJobType(client, AG_JOB_POLICE)) { + messageClientError(client, "You don't have a police job."); + return false; + } return true; } @@ -64,10 +141,25 @@ function policeDragCommand(command, params, client) { // --------------------------------------------------------------------------- function policeDetainCommand(command, params, client) { - if(!canClientUseJobs(client) || !!canClientUsePoliceJob(client)) { + if(!canPlayerUseJobs(client)) { + messageClientError(client, "You are not allowed to use jobs."); return false; } + if(!canPlayerUsePoliceJob(client)) { + messageClientError(client, "You are not allowed to use the police job."); + return false; + } + + if(!isPlayerWorking(client)) { + messageClientError(client, "You are working! Use /startwork first."); + return false; + } + + if(!doesPlayerHaveJobType(client, AG_JOB_POLICE)) { + messageClientError(client, "You don't have a police job."); + return false; + } return true; }