Add log level cmds
This commit is contained in:
@@ -12,10 +12,11 @@ function initDeveloperScript() {
|
|||||||
logToConsole(LOG_DEBUG, "[Asshat.Developer]: Initializing developer script ...");
|
logToConsole(LOG_DEBUG, "[Asshat.Developer]: Initializing developer script ...");
|
||||||
|
|
||||||
// Use GTAC command handlers for these since they need to be available on console
|
// Use GTAC command handlers for these since they need to be available on console
|
||||||
addCommandHandler("sc", executeServerCodeCommand);
|
//addCommandHandler("sc", executeServerCodeCommand);
|
||||||
addCommandHandler("cc", executeServerCodeCommand);
|
//addCommandHandler("cc", executeServerCodeCommand);
|
||||||
addCommandHandler("docmd", simulateCommandForPlayer);
|
//addCommandHandler("docmd", simulateCommandForPlayerCommand);
|
||||||
addCommandHandler("allcmd", simulateCommandForAllPlayers);
|
//addCommandHandler("allcmd", simulateCommandForAllPlayersCommand);
|
||||||
|
//addCommandHandler("addloglvl", setServerLogLevelCommand);
|
||||||
|
|
||||||
logToConsole(LOG_DEBUG, "[Asshat.Developer]: Developer script initialized successfully!");
|
logToConsole(LOG_DEBUG, "[Asshat.Developer]: Developer script initialized successfully!");
|
||||||
return true;
|
return true;
|
||||||
@@ -23,7 +24,83 @@ function initDeveloperScript() {
|
|||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function simulateCommandForPlayer(command, params, client) {
|
function addServerLogLevelCommand(command, params, client) {
|
||||||
|
if(areParamsEmpty(params)) {
|
||||||
|
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(toLowerCase(params)) {
|
||||||
|
case "debug":
|
||||||
|
logLevel = logLevel | LOG_DEBUG;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "warn":
|
||||||
|
logLevel = logLevel | LOG_WARN;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "error":
|
||||||
|
logLevel = logLevel | LOG_ERROR;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "info":
|
||||||
|
logLevel = logLevel | LOG_INFO;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "verbose":
|
||||||
|
logLevel = logLevel | LOG_VERBOSE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
messageAdminAction(`[#AAAAAA]${client.name} [#FFFFFF]enabled log level [#AAAAAA]${toLowerCase(params)}`);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function removeServerLogLevelCommand(command, params, client) {
|
||||||
|
if(areParamsEmpty(params)) {
|
||||||
|
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(toLowerCase(params)) {
|
||||||
|
case "debug":
|
||||||
|
logLevel = logLevel & ~LOG_DEBUG;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "warn":
|
||||||
|
logLevel = logLevel & ~LOG_WARN;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "error":
|
||||||
|
logLevel = logLevel & ~LOG_ERROR;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "info":
|
||||||
|
logLevel = logLevel & ~LOG_INFO;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "verbose":
|
||||||
|
logLevel = logLevel & ~LOG_VERBOSE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
messageAdminAction(`[#AAAAAA]${client.name} [#FFFFFF]disabled log level [#AAAAAA]${toLowerCase(params)}`);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function simulateCommandForPlayerCommand(command, params, client) {
|
||||||
if(getCommand(command).requireLogin) {
|
if(getCommand(command).requireLogin) {
|
||||||
if(!isPlayerLoggedIn(client)) {
|
if(!isPlayerLoggedIn(client)) {
|
||||||
messagePlayerError(client, "You must be logged in to use this command!");
|
messagePlayerError(client, "You must be logged in to use this command!");
|
||||||
@@ -64,7 +141,7 @@ function simulateCommandForPlayer(command, params, client) {
|
|||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function simulateCommandForAllPlayers(command, params, client) {
|
function simulateCommandForAllPlayersCommand(command, params, client) {
|
||||||
if(getCommand(command).requireLogin) {
|
if(getCommand(command).requireLogin) {
|
||||||
if(!isPlayerLoggedIn(client)) {
|
if(!isPlayerLoggedIn(client)) {
|
||||||
messagePlayerError(client, "You must be logged in to use this command!");
|
messagePlayerError(client, "You must be logged in to use this command!");
|
||||||
@@ -105,52 +182,28 @@ function simulateCommandForAllPlayers(command, params, client) {
|
|||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function executeServerCodeCommand(command, params, client) {
|
function executeServerCodeCommand(command, params, client) {
|
||||||
if(getCommand(command).requireLogin) {
|
|
||||||
if(!isPlayerLoggedIn(client)) {
|
|
||||||
messagePlayerError(client, "You must be logged in to use this command!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
|
|
||||||
messagePlayerError(client, "You do not have permission to use this command!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(areParamsEmpty(params)) {
|
if(areParamsEmpty(params)) {
|
||||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let returnVal = "Nothing";
|
let returnValue = "Nothing";
|
||||||
try {
|
try {
|
||||||
returnVal = eval("(" + params + ")");
|
returnValue = eval("(" + params + ")");
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
messagePlayerError(client, "The code could not be executed!");
|
messagePlayerError(client, "The code could not be executed!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
messagePlayerSuccess(client, "Server code executed!");
|
messagePlayerSuccess(client, "Server code executed!");
|
||||||
messagePlayerNormal(client, `Code: ${params}`);
|
messagePlayerNormal(client, `Code: ${params}`, COLOUR_YELLOW);
|
||||||
messagePlayerNormal(client, `Returns: ${returnVal}`);
|
messagePlayerNormal(client, `Returns: ${returnValue}`, COLOUR_YELLOW);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function executeClientCodeCommand(command, params, client) {
|
function executeClientCodeCommand(command, params, client) {
|
||||||
if(getCommand(command).requireLogin) {
|
|
||||||
if(!isPlayerLoggedIn(client)) {
|
|
||||||
messagePlayerError(client, "You must be logged in to use this command!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
|
|
||||||
messagePlayerError(client, "You do not have permission to use this command!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(areParamsEmpty(params)) {
|
if(areParamsEmpty(params)) {
|
||||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user