Add radiostation and keybinds list
This commit is contained in:
@@ -1240,6 +1240,7 @@ function initClassTable() {
|
||||
this.url = "";
|
||||
this.genre = "";
|
||||
this.codec = "";
|
||||
this.index = -1;
|
||||
|
||||
if(dbAssoc) {
|
||||
this.databaseId = dbAssoc["radio_id"];
|
||||
|
||||
@@ -280,23 +280,24 @@ function loadCommands() {
|
||||
commandData("jobreloadall", reloadAllJobsCommand, "", getStaffFlagValue("manageJobs"), true, false),
|
||||
],
|
||||
keybind: [
|
||||
commandData("bindkey", addKeyBindCommand, "<key id/name> <command> [params]", getStaffFlagValue("none"), true, false),
|
||||
commandData("unbindkey", removeKeyBindCommand, "<key id/name>", getStaffFlagValue("none"), true, false),
|
||||
//commandData("keybinds", showKeyBindCommands, "", getStaffFlagValue("none"), true, false),
|
||||
commandData("bindkey", addKeyBindCommand, "<key id/name> <command> [params]", getStaffFlagValue("none"), true, false, "Binds a key to a command and optional parameters"),
|
||||
commandData("unbindkey", removeKeyBindCommand, "<key id/name>", getStaffFlagValue("none"), true, false, "Removes an existing keybind from your account"),
|
||||
commandData("keybinds", showKeyBindListCommand, "", getStaffFlagValue("none"), true, false, "Shows a list of all your current keybinds"),
|
||||
],
|
||||
locale: [],
|
||||
messaging: [],
|
||||
misc: [
|
||||
commandData("pos", getPositionCommand, "", getStaffFlagValue("basicModeration"), true, false),
|
||||
commandData("idea", submitIdeaCommand, "<message>", getStaffFlagValue("none"), true, true),
|
||||
commandData("bug", submitBugReportCommand, "<message>", getStaffFlagValue("none"), true, true),
|
||||
commandData("enter", enterExitPropertyCommand, "", getStaffFlagValue("none"), true, true),
|
||||
commandData("cursor", toggleMouseCursorCommand, "", getStaffFlagValue("none"), true, false),
|
||||
commandData("mousecam", toggleMouseCameraCommand, "", getStaffFlagValue("none"), true, false),
|
||||
commandData("yes", playerPromptAnswerYesCommand, "", getStaffFlagValue("none"), true, false),
|
||||
commandData("no", playerPromptAnswerNoCommand, "", getStaffFlagValue("none"), true, false),
|
||||
commandData("radiostation", playStreamingRadioCommand, "<radio station id>", getStaffFlagValue("none"), true, false),
|
||||
commandData("radiovolume", setStreamingRadioVolumeCommand, "<volume level>", getStaffFlagValue("none"), true, false),
|
||||
commandData("pos", getPositionCommand, "", getStaffFlagValue("basicModeration"), true, false, "Shows your current coordinates"),
|
||||
commandData("idea", submitIdeaCommand, "<message>", getStaffFlagValue("none"), true, true, "Sends an suggestion/idea to the developers"),
|
||||
commandData("bug", submitBugReportCommand, "<message>", getStaffFlagValue("none"), true, true, "Submits a bug report"),
|
||||
commandData("enter", enterExitPropertyCommand, "", getStaffFlagValue("none"), true, true, "Enters or exists a house/business"),
|
||||
commandData("cursor", toggleMouseCursorCommand, "", getStaffFlagValue("none"), true, false, "Toggles cursor visibility"),
|
||||
commandData("mousecam", toggleMouseCameraCommand, "", getStaffFlagValue("none"), true, false, "Toggles vehicle mouse camera for games that don't have it"),
|
||||
commandData("yes", playerPromptAnswerYesCommand, "", getStaffFlagValue("none"), true, false, "Answers a prompt with YES"),
|
||||
commandData("no", playerPromptAnswerNoCommand, "", getStaffFlagValue("none"), true, false, "Answers a prompt with NO"),
|
||||
commandData("radiostation", playStreamingRadioCommand, "<radio station id>", getStaffFlagValue("none"), true, false, "Plays a radio station in your vehicle, house, or business (depending on which one you're in)"),
|
||||
commandData("radiostations", showRadioStationListCommand, "", getStaffFlagValue("none"), true, false, "Shows a list of all available radio stations"),
|
||||
commandData("radiovolume", setStreamingRadioVolumeCommand, "<volume level>", getStaffFlagValue("none"), true, false, "Sets the radio streaming volume (for your game only)."),
|
||||
],
|
||||
moderation: [
|
||||
commandData("kick", kickClientCommand, "<player name/id> [reason]", getStaffFlagValue("basicModeration"), true, true, "Kicks a player from the server"),
|
||||
|
||||
@@ -196,4 +196,18 @@ function loadKeyBindConfiguration() {
|
||||
return JSON.parse(keyBindConfigFile);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function showKeyBindListCommand(command, params, client) {
|
||||
let keybindList = getPlayerData(client).accountData.keyBinds.map(function(x) { return `${getInlineChatColourByName("lightGrey")}${toUpperCase(getKeyNameFromId(x.key))}: ${getInlineChatColourByName("white")}${x.commandString}`; });
|
||||
|
||||
let chunkedList = splitArrayIntoChunks(keybindList, 6);
|
||||
|
||||
messagePlayerInfo(client, `${getInlineChatColourByType("clanOrange")}== ${getInlineChatColourByType("jobYellow")}Your Key Binds ${getInlineChatColourByType("clanOrange")}===========================`);
|
||||
|
||||
for(let i in chunkedList) {
|
||||
messagePlayerInfo(client, chunkedList[i].join(", "));
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -7,13 +7,10 @@
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
let radioStations = [];
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initRadioScript() {
|
||||
logToConsole(LOG_INFO, "[VRR.Radio]: Initializing radio script ...");
|
||||
radioStations = loadRadioStationsFromDatabase();
|
||||
getServerData().radioStations = loadRadioStationsFromDatabase();
|
||||
setRadioStationIndexes();
|
||||
logToConsole(LOG_INFO, "[VRR.Radio]: Radio script initialized successfully!");
|
||||
return true;
|
||||
}
|
||||
@@ -47,12 +44,13 @@ function loadRadioStationsFromDatabase() {
|
||||
function playStreamingRadioCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
messagePlayerInfo(client, "Use /radiostations for a list of available radio stations.");
|
||||
return false;
|
||||
}
|
||||
|
||||
let radioStationId = params;
|
||||
|
||||
if(radioStationId != 0 && typeof radioStations[radioStationId-1] == "undefined") {
|
||||
if(radioStationId != 0 && typeof getServerData().radioStations[radioStationId-1] == "undefined") {
|
||||
messagePlayerError(client, "That radio station ID does not exist!");
|
||||
return false;
|
||||
}
|
||||
@@ -79,12 +77,12 @@ function playStreamingRadioCommand(command, params, client) {
|
||||
|
||||
getVehicleData(getPlayerVehicle(client)).streamingRadioStation = radioStationId-1;
|
||||
getPlayerData(client).streamingRadioStation = radioStationId-1;
|
||||
meActionToNearbyPlayers(client, `changes their vehicle's radio station to ${radioStations[radioStationId-1].name} (${radioStations[radioStationId-1].genre})`);
|
||||
meActionToNearbyPlayers(client, `changes their vehicle's radio station to ${getRadioStationData(radioStationId-1).name} (${getRadioStationData(radioStationId-1).genre})`);
|
||||
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(getPlayerVehicle(client) == getPlayerVehicle(clients[i])) {
|
||||
playRadioStreamForPlayer(clients[i], radioStations[radioStationId-1].url, true, getPlayerStreamingRadioVolume(client));
|
||||
playRadioStreamForPlayer(clients[i], getRadioStationData(radioStationId-1).url, true, getPlayerStreamingRadioVolume(client));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -104,12 +102,12 @@ function playStreamingRadioCommand(command, params, client) {
|
||||
} else {
|
||||
getHouseData(houseId).streamingRadioStation = radioStationId-1;
|
||||
getPlayerData(client).streamingRadioStation = radioStationId-1;
|
||||
meActionToNearbyPlayers(client, `changes their house radio station to ${radioStations[radioStationId-1].name} (${radioStations[radioStationId-1].genre})`);
|
||||
meActionToNearbyPlayers(client, `changes their house radio station to ${getRadioStationData(radioStationId-1).name} (${getRadioStationData(radioStationId-1).genre})`);
|
||||
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(getEntityData(clients[i], "vrr.inHouse") == houseId) {
|
||||
playRadioStreamForPlayer(clients[i], radioStations[radioStationId-1].url, true, getPlayerStreamingRadioVolume(clients[i]));
|
||||
playRadioStreamForPlayer(clients[i], getRadioStationData(radioStationId-1).url, true, getPlayerStreamingRadioVolume(clients[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,12 +127,12 @@ function playStreamingRadioCommand(command, params, client) {
|
||||
} else {
|
||||
getBusinessData(businessId).streamingRadioStation = radioStationId-1;
|
||||
getPlayerData(client).streamingRadioStation = radioStationId-1;
|
||||
meActionToNearbyPlayers(client, `changes the business radio station to ${radioStations[radioStationId-1].name} (${radioStations[radioStationId-1].genre})`);
|
||||
meActionToNearbyPlayers(client, `changes the business radio station to ${getRadioStationData(radioStationId-1).name} (${getRadioStationData(radioStationId-1).genre})`);
|
||||
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(getEntityData(clients[i], "vrr.inBusiness") == businessId) {
|
||||
playRadioStreamForPlayer(clients[i], radioStations[radioStationId-1].url, true, getPlayerStreamingRadioVolume(clients[i]));
|
||||
playRadioStreamForPlayer(clients[i], getRadioStationData(radioStationId-1).url, true, getPlayerStreamingRadioVolume(clients[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -185,4 +183,32 @@ function getPlayerStreamingRadioVolume(client) {
|
||||
return getPlayerData(client).accountData.streamingRadioVolume;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function showRadioStationListCommand(command, params, client) {
|
||||
let stationList = getServerData().radioStations.map(function(x) { return `${getInlineChatColourByName("lightGrey")}${x.index}: ${getInlineChatColourByName("white")}${x.name}`; });
|
||||
|
||||
let chunkedList = splitArrayIntoChunks(stationList, 4);
|
||||
|
||||
messagePlayerInfo(client, `${getInlineChatColourByType("clanOrange")}== ${getInlineChatColourByType("jobYellow")}Radio Stations ${getInlineChatColourByType("clanOrange")}===========================`);
|
||||
|
||||
for(let i in chunkedList) {
|
||||
messagePlayerInfo(client, chunkedList[i].join(", "));
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function setRadioStationIndexes() {
|
||||
for(let i in getServerData().radioStations) {
|
||||
getServerData().radioStations[i].index = i;
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getRadioStationData(radioStationId) {
|
||||
return getServerData().radioStations[radioStationId];
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
Reference in New Issue
Block a user