diff --git a/README.md b/README.md index 7204667..248ea61 100644 --- a/README.md +++ b/README.md @@ -10,17 +10,15 @@ Huge thanks to everyone who helped me learn GSC: Birchy, DoktorSAS, FutureRave a ## How do I download a script? -If you are unsure whether you should download a compiled or a source script, first read [What are compiled and source scripts?](#what-are-compiled-and-source-scripts) - - [Download this repository](https://github.com/Resxt/Plutonium-T6-Scripts/archive/refs/heads/master.zip) - Open the downloaded ZIP file - Drag and drop the script(s) you want in the folder they need to be placed in. -If no instructions are provided for the script you want then simply follow the instructions given in [How do I use a compiled script?](#how-do-i-use-a-compiled-script) +If no instructions are provided for the script you want then simply follow the instructions given in [How do I use a script?](#how-do-i-use-a-script) Just keep in mind that this downloads a copy of this repository at the moment you download it. If a script is updated after you downloaded this repository and you want the new version then you will need to download this repository again. -## How do I use a compiled script? +## How do I use a script? [Follow the instructions in the documentation](https://plutonium.pw/docs/modding/loading-mods/#loading-existing-scripts-on-t6) @@ -30,32 +28,3 @@ If the script should only be loaded for the multiplayer mode then put it in `scr If the script should only be loaded for the zombies mode then put it in `scripts\zm`. Note that you can use `map_restart` in the [console](https://plutonium.pw/docs/opening-console/) to quickly restart your current game and reload scripts. - -## How do I compile a script? - - - -- Download [GSC Tool](https://github.com/xensik/gsc-tool/releases/latest) -- Read the [instructions to compile a file](https://github.com/xensik/gsc-tool#usage) - -It should look similar to this -`gsc-tool.exe comp t6 "C:\Users\Resxt\AppData\Local\Plutonium\storage\t6\scripts\mapvote.gsc"` - -If after opening the file you see that it has a lot of non readable characters this means that it was successfully compiled. - -## What are compiled and source scripts? - -Before downloading a script it's important to understand what compiled and source scripts mean. -A source script is the script in a human readable form (a text file), this is how the script is written. -A compiled script is simply a source script that has been compiled by a compiler to make it readable by the game. -At the time of writing, T6 cannot read source scripts so you have to compile them to allow the game to read them. - -So if you only want to use a script and you don't want to edit it or review its code then -you can simply read [How do I use a compiled script?](#how-do-i-use-a-compiled-script). - -All of my scripts always come as two files: - -- script.gsc (compiled script, ready to be used) -- script-source.gsc (source script, made to read the code and eventually edit it, cannot be read by the game, needs to be compiled) diff --git a/mapvote/mapvote.gsc b/mapvote/mapvote.gsc index 11a6ed8..91c997b 100644 Binary files a/mapvote/mapvote.gsc and b/mapvote/mapvote.gsc differ diff --git a/mapvote/mapvote_mp_extend.gsc b/mapvote/mapvote_mp_extend.gsc index 174043e..0578e19 100644 Binary files a/mapvote/mapvote_mp_extend.gsc and b/mapvote/mapvote_mp_extend.gsc differ diff --git a/mapvote/mapvote_zm_extend.gsc b/mapvote/mapvote_zm_extend.gsc index c6ca773..b564734 100644 Binary files a/mapvote/mapvote_zm_extend.gsc and b/mapvote/mapvote_zm_extend.gsc differ diff --git a/mapvote/source/mapvote-source.gsc b/mapvote/source/mapvote-source.gsc deleted file mode 100644 index 91c997b..0000000 --- a/mapvote/source/mapvote-source.gsc +++ /dev/null @@ -1,1146 +0,0 @@ -/* -====================================================================== -| Game: Plutonium T6 | -| Description : Let players vote | -| for a map and mode at the end of each game | -| Author: Resxt | -====================================================================== -| https://github.com/Resxt/Plutonium-T6-Scripts/tree/main/mapvote | -====================================================================== -*/ - -#include maps\mp\gametypes\_hud_util; -#include maps\mp\gametypes_zm\_hud_util; -#include common_scripts\utility; -#include maps\mp\_utility; - -/* Entry point */ - -Init() -{ - if (GetDvarInt("mapvote_enable")) - { - level.mapvote_rotate_function = ::StartRotation; - - InitMapvote(); - } -} - - - -/* Init section */ - -InitMapvote() -{ - InitDvars(); - InitVariables(); - - if (GetDvarInt("mapvote_debug")) - { - Print("[MAPVOTE] Debug mode is ON"); - wait 3; - level thread StartVote(); - level thread ListenForEndVote(); - } - else - { - // Starting the mapvote normally is handled in mp\mapvote_mp_extend.gsc and zm\mapvote_zm_extend.gsc - } -} - -InitDvars() -{ - SetDvarIfNotInitialized("mapvote_debug", false); - - if (IsMultiplayerMode()) - { - SetDvarIfNotInitialized("mapvote_maps", "Aftermath:Cargo:Carrier:Drone:Express:Hijacked:Meltdown:Overflow:Plaza:Raid:Slums:Standoff:Turbine:Yemen:Nuketown:Downhill:Mirage:Hydro:Grind:Encore:Magma:Vertigo:Studio:Uplink:Detour:Cove:Rush:Dig:Frost:Pod:Takeoff"); - SetDvarIfNotInitialized("mapvote_modes", "Team Deathmatch,tdm:Domination,dom:Hardpoint,koth"); - SetDvarIfNotInitialized("mapvote_limits_maps", 0); - SetDvarIfNotInitialized("mapvote_limits_modes", 0); - SetDvarIfNotInitialized("mapvote_sounds_menu_enabled", 1); - SetDvarIfNotInitialized("mapvote_sounds_timer_enabled", 1); - SetDvarIfNotInitialized("mapvote_default_rotation_maps", "Hijacked:Raid:Nuketown"); - SetDvarIfNotInitialized("mapvote_default_rotation_modes", "tdm"); - } - else - { - SetDvarIfNotInitialized("mapvote_maps", "Bus Depot,Bus Depot,zm_standard_transit:Town,Town,zm_standard_town:Farm,Farm,zm_standard_farm:Mob of The Dead,Mob of The Dead,zm_classic_prison:Nuketown,Nuketown,zm_standard_nuked:Origins,Origins,zm_classic_tomb:Buried,Buried,zm_classic_processing:Die Rise,Die Rise,zm_classic_rooftop"); - SetDvarIfNotInitialized("mapvote_default_rotation_maps", "Town,zm_standard_town:Farm,zm_standard_farm"); - } - - SetDvarIfNotInitialized("mapvote_limits_max", 12); - SetDvarIfNotInitialized("mapvote_colors_selected", "blue"); - SetDvarIfNotInitialized("mapvote_colors_unselected", "white"); - SetDvarIfNotInitialized("mapvote_colors_timer", "blue"); - SetDvarIfNotInitialized("mapvote_colors_timer_low", "red"); - SetDvarIfNotInitialized("mapvote_colors_help_text", "white"); - SetDvarIfNotInitialized("mapvote_colors_help_accent", "blue"); - SetDvarIfNotInitialized("mapvote_colors_help_accent_mode", "standard"); - SetDvarIfNotInitialized("mapvote_vote_time", 30); - SetDvarIfNotInitialized("mapvote_blur_level", 2.5); - SetDvarIfNotInitialized("mapvote_blur_fade_in_time", 2); - SetDvarIfNotInitialized("mapvote_horizontal_spacing", 75); - SetDvarIfNotInitialized("mapvote_display_wait_time", 1); - SetDvarIfNotInitialized("mapvote_default_rotation_min_players", 0); - SetDvarIfNotInitialized("mapvote_default_rotation_max_players", 0); -} - -InitVariables() -{ - mapsArray = StrTok(GetDvar("mapvote_maps"), ":"); - voteLimits = []; - - if (IsMultiplayerMode()) - { - modesArray = StrTok(GetDvar("mapvote_modes"), ":"); - - if (GetDvarInt("mapvote_limits_maps") == 0 && GetDvarInt("mapvote_limits_modes") == 0) - { - voteLimits = GetVoteLimits(mapsArray.size, modesArray.size); - } - else if (GetDvarInt("mapvote_limits_maps") > 0 && GetDvarInt("mapvote_limits_modes") == 0) - { - voteLimits = GetVoteLimits(GetDvarInt("mapvote_limits_maps"), modesArray.size); - } - else if (GetDvarInt("mapvote_limits_maps") == 0 && GetDvarInt("mapvote_limits_modes") > 0) - { - voteLimits = GetVoteLimits(mapsArray.size, GetDvarInt("mapvote_limits_modes")); - } - else - { - voteLimits = GetVoteLimits(GetDvarInt("mapvote_limits_maps"), GetDvarInt("mapvote_limits_modes")); - } - - level.mapvote["limit"]["maps"] = voteLimits["maps"]; - level.mapvote["limit"]["modes"] = voteLimits["modes"]; - } - else - { - if (GetDvarInt("mapvote_limits_maps") == 0) - { - level.mapvote["limit"]["maps"] = GetVoteLimits(mapsArray.size); - } - else - { - level.mapvote["limit"]["maps"] = GetVoteLimits(GetDvarInt("mapvote_limits_maps")); - } - } - - SetMapvoteData("map"); - - if (IsMultiplayerMode()) - { - SetMapvoteData("mode"); - } - - level.mapvote["vote"]["maps"] = []; - level.mapvote["vote"]["modes"] = []; - level.mapvote["hud"]["maps"] = []; - level.mapvote["hud"]["modes"] = []; -} - - - -/* Player section */ - -/* -This is used instead of notifyonplayercommand("mapvote_up", "speed_throw") -to fix an issue where players using toggle ads would have to press right click twice for it to register one right click. -With this instead it keeps scrolling every 0.25s until they right click again which is a better user experience -*/ -ListenForRightClick() -{ - self endon("disconnect"); - - while (true) - { - if (self AdsButtonPressed()) - { - self notify("mapvote_up"); - wait 0.25; - } - - wait 0.05; - } -} - -ListenForVoteInputs() -{ - self endon("disconnect"); - - self thread ListenForRightClick(); - - self notifyonplayercommand("mapvote_down", "+attack"); - self notifyonplayercommand("mapvote_select", "+gostand"); - self notifyonplayercommand("mapvote_unselect", "+usereload"); - self notifyonplayercommand("mapvote_unselect", "+activate"); - - if (GetDvarInt("mapvote_debug")) - { - self notifyonplayercommand("mapvote_debug", "+melee"); - } - - while(true) - { - input = self waittill_any_return("mapvote_down", "mapvote_up", "mapvote_select", "mapvote_unselect", "mapvote_debug"); - - section = self.mapvote["vote_section"]; - - if (section == "end" && input != "mapvote_unselect" && input != "mapvote_debug") - { - continue; // stop/skip execution - } - else if (section == "mode" && level.mapvote["modes"]["by_index"].size <= 1 && input != "mapvote_unselect" && input != "mapvote_debug") - { - continue; // stop/skip execution - } - - if (input == "mapvote_down") - { - if (self.mapvote[section]["hovered_index"] < (level.mapvote[section + "s"]["by_index"].size - 1)) - { - if (GetDvarInt("mapvote_sounds_menu_enabled")) - { - self playlocalsound("uin_start_count_down"); - } - - self UpdateSelection(section, (self.mapvote[section]["hovered_index"] + 1)); - } - } - else if (input == "mapvote_up") - { - if (self.mapvote[section]["hovered_index"] > 0) - { - if (GetDvarInt("mapvote_sounds_menu_enabled")) - { - self playlocalsound("uin_start_count_down"); - } - - self UpdateSelection(section, (self.mapvote[section]["hovered_index"] - 1)); - } - } - else if (input == "mapvote_select") - { - if (GetDvarInt("mapvote_sounds_menu_enabled")) - { - self playlocalsound("mpl_killconfirm_tags_pickup"); - } - - self ConfirmSelection(section); - } - else if (input == "mapvote_unselect") - { - if (section != "map") - { - if (GetDvarInt("mapvote_sounds_menu_enabled")) - { - self playlocalsound("fly_betty_jump"); - } - - self CancelSelection(section); - } - } - else if (input == "mapvote_debug" && GetDvarInt("mapvote_debug")) - { - Print("--------------------------------"); - - foreach (player in GetHumanPlayers()) - { - if (player.mapvote["map"]["selected_index"] == -1) - { - Print(player.name + " did not vote for any map"); - } - else - { - mapName = ""; - - if (IsMultiplayerMode()) - { - mapName = level.mapvote["maps"]["by_index"][player.mapvote["map"]["selected_index"]]; - } - else - { - mapName = level.mapvote["maps"]["by_index"][player.mapvote["map"]["selected_index"]][0]; - } - - Print(player.name + " voted for map [" + player.mapvote["map"]["selected_index"] +"] " + mapName); - } - - if (IsMultiplayerMode()) - { - if (player.mapvote["mode"]["selected_index"] == -1) - { - Print(player.name + " did not vote for any mode"); - } - else - { - Print(player.name + " voted for mode [" + player.mapvote["mode"]["selected_index"] + "] " + level.mapvote["modes"]["by_index"][player.mapvote["mode"]["selected_index"]]); - } - } - } - } - - wait 0.05; - } -} - -OnPlayerDisconnect() -{ - self waittill("disconnect"); - - if (self.mapvote["map"]["selected_index"] != -1) - { - level.mapvote["vote"]["maps"][self.mapvote["map"]["selected_index"]] = (level.mapvote["vote"]["maps"][self.mapvote["map"]["selected_index"]] - 1); - level.mapvote["hud"]["maps"][self.mapvote["map"]["selected_index"]] SetValue(level.mapvote["vote"]["maps"][self.mapvote["map"]["selected_index"]]); - } - - if (self.mapvote["mode"]["selected_index"] != -1) - { - level.mapvote["vote"]["modes"][self.mapvote["mode"]["selected_index"]] = (level.mapvote["vote"]["modes"][self.mapvote["mode"]["selected_index"]] - 1); - level.mapvote["hud"]["modes"][self.mapvote["mode"]["selected_index"]] SetValue(level.mapvote["vote"]["modes"][self.mapvote["mode"]["selected_index"]]); - } -} - - -/* Vote section */ - -CreateVoteMenu() -{ - spacing = 20; - hudLastPosY = 0; - - if (IsMultiplayerMode()) - { - sectionsSeparation = 0; - - if (level.mapvote["modes"]["by_index"].size > 1) - { - sectionsSeparation = 1; - } - - hudLastPosY = -((((level.mapvote["maps"]["by_index"].size + level.mapvote["modes"]["by_index"].size + sectionsSeparation) * spacing) / 2) - (spacing / 2)); - } - else - { - hudLastPosY = -(((level.mapvote["maps"]["by_index"].size * spacing) / 2) - (spacing / 2)); - } - - for (mapIndex = 0; mapIndex < level.mapvote["maps"]["by_index"].size; mapIndex++) - { - mapVotesHud = CreateHudText("", "objective", 1.5, "LEFT", "CENTER", GetDvarInt("mapvote_horizontal_spacing"), hudLastPosY, true, 0); - mapVotesHud.color = GetGscColor(GetDvar("mapvote_colors_selected")); - - level.mapvote["hud"]["maps"][mapIndex] = mapVotesHud; - - foreach (player in GetHumanPlayers()) - { - mapName = ""; - - if (IsMultiplayerMode()) - { - mapName = level.mapvote["maps"]["by_index"][mapIndex]; - } - else - { - mapName = level.mapvote["maps"]["by_index"][mapIndex][0]; - } - - player.mapvote["map"][mapIndex]["hud"] = player CreateHudText(mapName, "objective", 1.5, "LEFT", "CENTER", -(GetDvarInt("mapvote_horizontal_spacing")), hudLastPosY); - - if (mapIndex == 0) - { - player UpdateSelection("map", 0); - } - else - { - SetElementUnselected(player.mapvote["map"][mapIndex]["hud"]); - } - } - - hudLastPosY += spacing; - } - - if (IsMultiplayerMode() && level.mapvote["modes"]["by_index"].size > 1) - { - hudLastPosY += spacing; // Space between maps and modes sections - - for (modeIndex = 0; modeIndex < level.mapvote["modes"]["by_index"].size; modeIndex++) - { - modeVotesHud = CreateHudText("", "objective", 1.5, "LEFT", "CENTER", GetDvarInt("mapvote_horizontal_spacing"), hudLastPosY, true, 0); - modeVotesHud.color = GetGscColor(GetDvar("mapvote_colors_selected")); - - level.mapvote["hud"]["modes"][modeIndex] = modeVotesHud; - - foreach (player in GetHumanPlayers()) - { - player.mapvote["mode"][modeIndex]["hud"] = player CreateHudText(level.mapvote["modes"]["by_index"][modeIndex], "objective", 1.5, "LEFT", "CENTER", -(GetDvarInt("mapvote_horizontal_spacing")), hudLastPosY); - - SetElementUnselected(player.mapvote["mode"][modeIndex]["hud"]); - } - - hudLastPosY += spacing; - } - } - - foreach(player in GetHumanPlayers()) - { - player.mapvote["map"]["selected_index"] = -1; - player.mapvote["mode"]["selected_index"] = -1; - - buttonsHelpMessage = ""; - - if (GetDvar("mapvote_colors_help_accent_mode") == "standard") - { - buttonsHelpMessage = GetChatColor(GetDvar("mapvote_colors_help_text")) + "Press " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "[{+attack}] " + GetChatColor(GetDvar("mapvote_colors_help_text")) + "to go down - Press " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "[{+speed_throw}] " + GetChatColor(GetDvar("mapvote_colors_help_text")) + "to go up - Press " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "[{+gostand}] " + GetChatColor(GetDvar("mapvote_colors_help_text")) + "to select - Press " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "[{+activate}] " + GetChatColor(GetDvar("mapvote_colors_help_text")) + "to undo"; - } - else if(GetDvar("mapvote_colors_help_accent_mode") == "max") - { - buttonsHelpMessage = GetChatColor(GetDvar("mapvote_colors_help_text")) + "Press " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "[{+attack}] " + GetChatColor(GetDvar("mapvote_colors_help_text")) + "to go " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "down " + GetChatColor(GetDvar("mapvote_colors_help_text")) + "- Press " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "[{+speed_throw}] " + GetChatColor(GetDvar("mapvote_colors_help_text")) + "to go " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "up " + GetChatColor(GetDvar("mapvote_colors_help_text")) + "- Press " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "[{+gostand}] " + GetChatColor(GetDvar("mapvote_colors_help_text")) + "to " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "select " + GetChatColor(GetDvar("mapvote_colors_help_text")) + "- Press " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "[{+activate}] " + GetChatColor(GetDvar("mapvote_colors_help_text")) + "to " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "undo"; - } - - if (GetDvarInt("mapvote_debug")) - { - if (GetDvar("mapvote_colors_help_accent_mode") == "standard") - { - buttonsHelpMessage = buttonsHelpMessage + " - Press " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "[{+melee}] " + GetChatColor(GetDvar("mapvote_colors_help_text")) + "to debug"; - } - else if(GetDvar("mapvote_colors_help_accent_mode") == "max") - { - buttonsHelpMessage = buttonsHelpMessage + GetChatColor(GetDvar("mapvote_colors_help_text")) + " - Press " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "[{+melee}] " + GetChatColor(GetDvar("mapvote_colors_help_text")) + "to " + GetChatColor(GetDvar("mapvote_colors_help_accent")) + "debug"; - } - } - - player CreateHudText(buttonsHelpMessage, "objective", 1.5, "CENTER", "CENTER", 0, 210); - } -} - -CreateVoteTimer() -{ - soundFX = spawn("script_origin", (0,0,0)); - soundFX hide(); - - timerhud = CreateTimer(GetDvarInt("mapvote_vote_time"), &"Vote ends in: ", "objective", 1.5, "CENTER", "CENTER", 0, -210); - timerhud.color = GetGscColor(GetDvar("mapvote_colors_timer")); - for (i = GetDvarInt("mapvote_vote_time"); i > 0; i--) - { - if(i <= 5) - { - timerhud.color = GetGscColor(GetDvar("mapvote_colors_timer_low")); - - if (GetDvarInt("mapvote_sounds_timer_enabled")) - { - soundFX playSound( "mpl_ui_timer_countdown" ); - } - } - wait(1); - } - level notify("mapvote_vote_end"); -} - -StartVote() -{ - level endon("end_game"); - - for (i = 0; i < level.mapvote["maps"]["by_index"].size; i++) - { - level.mapvote["vote"]["maps"][i] = 0; - } - - if (IsMultiplayerMode()) - { - for (i = 0; i < level.mapvote["modes"]["by_index"].size; i++) - { - level.mapvote["vote"]["modes"][i] = 0; - } - } - - level thread CreateVoteMenu(); - level thread CreateVoteTimer(); - - foreach (player in GetHumanPlayers()) - { - player FreezeControlsAllowLook(1); - player SetBlur(GetDvarInt("mapvote_blur_level"), GetDvarInt("mapvote_blur_fade_in_time")); - - player thread ListenForVoteInputs(); - player thread OnPlayerDisconnect(); - } -} - -ListenForEndVote() -{ - level endon("end_game"); - level waittill("mapvote_vote_end"); - - mostVotedMapIndex = 0; - mostVotedMapVotes = 0; - mostVotedModeIndex = 0; - mostVotedModeVotes = 0; - - foreach (mapIndex in GetArrayKeys(level.mapvote["vote"]["maps"])) - { - if (level.mapvote["vote"]["maps"][mapIndex] > mostVotedMapVotes) - { - mostVotedMapIndex = mapIndex; - mostVotedMapVotes = level.mapvote["vote"]["maps"][mapIndex]; - } - } - - foreach (modeIndex in GetArrayKeys(level.mapvote["vote"]["modes"])) - { - if (level.mapvote["vote"]["modes"][modeIndex] > mostVotedModeVotes) - { - mostVotedModeIndex = modeIndex; - mostVotedModeVotes = level.mapvote["vote"]["modes"][modeIndex]; - } - } - - if (mostVotedMapVotes == 0) - { - mostVotedMapIndex = GetRandomElementInArray(GetArrayKeys(level.mapvote["vote"]["maps"])); - - if (GetDvarInt("mapvote_debug")) - { - Print("[MAPVOTE] No vote for map. Chosen random map index: " + mostVotedMapIndex); - } - } - else - { - if (GetDvarInt("mapvote_debug")) - { - Print("[MAPVOTE] Most voted map has " + mostVotedMapVotes + " votes. Most voted map index: " + mostVotedMapIndex); - } - } - - if (mostVotedModeVotes == 0) - { - mostVotedModeIndex = GetRandomElementInArray(GetArrayKeys(level.mapvote["vote"]["modes"])); - - if (GetDvarInt("mapvote_debug")) - { - Print("[MAPVOTE] No vote for mode. Chosen random mode index: " + mostVotedModeIndex); - } - } - else - { - if (GetDvarInt("mapvote_debug")) - { - Print("[MAPVOTE] Most voted mode has " + mostVotedModeVotes + " votes. Most voted mode index: " + mostVotedModeIndex); - } - } - - modeName = ""; - modeCfg = ""; - mapName = ""; - - if (IsMultiplayerMode()) - { - modeName = level.mapvote["modes"]["by_index"][mostVotedModeIndex]; - modeCfg = level.mapvote["modes"]["by_name"][level.mapvote["modes"]["by_index"][mostVotedModeIndex]]; - mapName = GetMapCodeName(level.mapvote["maps"]["by_index"][mostVotedMapIndex]); - } - else - { - modeCfg = level.mapvote["maps"]["by_index"][mostVotedMapIndex][2]; - mapName = GetMapCodeName(level.mapvote["maps"]["by_index"][mostVotedMapIndex][1]); - } - - if (GetDvarInt("mapvote_debug")) - { - Print("[MAPVOTE] mapName: " + mapName); - Print("[MAPVOTE] modeName: " + modeName); - Print("[MAPVOTE] modeCfg: " + modeCfg); - Print("[MAPVOTE] Rotating to " + mapName + " | " + modeName + " (" + modeCfg + ".cfg)"); - } - - DoRotation(modeCfg, mapName); -} - -SetMapvoteData(type) -{ - limit = level.mapvote["limit"][type + "s"]; - - availableElements = StrTok(GetDvar("mapvote_" + type + "s"), ":"); - - if (availableElements.size < limit) - { - limit = availableElements.size; - } - - if (type == "map") - { - if (IsMultiplayerMode()) - { - level.mapvote["maps"]["by_index"] = GetRandomUniqueElementsInArray(availableElements, limit); - } - else - { - zombiesArrays = GetRandomUniqueElementsInArray(availableElements, limit); - - level.mapvote["maps"]["by_index"] = []; - - foreach (element in zombiesArrays) - { - splittedElement = StrTok(element, ","); - level.mapvote["maps"]["by_index"] = AddElementToArray(level.mapvote["maps"]["by_index"], array(splittedElement[0], splittedElement[1], splittedElement[2])); - } - } - } - else if (type == "mode") - { - finalElements = []; - - foreach (mode in GetRandomUniqueElementsInArray(availableElements, limit)) - { - splittedMode = StrTok(mode, ","); - finalElements = AddElementToArray(finalElements, splittedMode[0]); - - level.mapvote["modes"]["by_name"][splittedMode[0]] = splittedMode[1]; - } - - level.mapvote["modes"]["by_index"] = finalElements; - } -} - -/* -Gets the amount of maps and modes to display on screen -This is used to get default values if the limits dvars are not set -It will dynamically adjust the amount of maps and modes to show -*/ -GetVoteLimits(mapsAmount, modesAmount) -{ - maxLimit = GetDvarInt("mapvote_limits_max"); - limits = []; - - if (!IsDefined(modesAmount)) - { - if (mapsAmount <= maxLimit) - { - return mapsAmount; - } - else - { - return maxLimit; - } - } - - if ((mapsAmount + modesAmount) <= maxLimit) - { - limits["maps"] = mapsAmount; - limits["modes"] = modesAmount; - } - else - { - if (mapsAmount >= (maxLimit / 2) && modesAmount >= (maxLimit)) - { - limits["maps"] = (maxLimit / 2); - limits["modes"] = (maxLimit / 2); - } - else - { - if (mapsAmount > (maxLimit / 2)) - { - finalMapsAmount = 0; - - if (modesAmount <= 1) - { - limits["maps"] = maxLimit; - } - else - { - limits["maps"] = (maxLimit - modesAmount); - } - - limits["modes"] = modesAmount; - } - else if (modesAmount > (maxLimit / 2)) - { - limits["maps"] = mapsAmount; - limits["modes"] = (maxLimit - mapsAmount); - } - } - } - - return limits; -} - -ShouldRotateDefault() -{ - humanPlayersCount = GetHumanPlayers().size; - - if (GetDvarInt("mapvote_default_rotation_max_players") > 0 && humanPlayersCount >= GetDvarInt("mapvote_default_rotation_min_players") && humanPlayersCount <= GetDvarInt("mapvote_default_rotation_max_players")) - { - return true; - } - - return false; -} - -RotateDefault() -{ - mapName = ""; - modeCfg = ""; - - if (IsMultiplayerMode()) - { - modeCfg = GetRandomElementInArray(StrTok(GetDvar("mapvote_default_rotation_modes"), ":")); - mapName = GetMapCodeName(GetRandomElementInArray(StrTok(GetDvar("mapvote_default_rotation_maps"), ":"))); - } - else - { - data = GetRandomElementInArray(StrTok(GetDvar("mapvote_default_rotation_maps"), ":")); - dataSplitted = StrTok(data, ","); - - modeCfg = dataSplitted[1]; - mapName = GetMapCodeName(dataSplitted[0]); - } - - DoRotation(modeCfg, mapName); -} - -DoRotation(modeCfg, mapName) -{ - SetDvar("sv_maprotationcurrent", "exec " + modeCfg + ".cfg map " + mapName); - SetDvar("sv_maprotation", "exec " + modeCfg + ".cfg map " + mapName); -} - -StartRotation() -{ - if (ShouldRotateDefault()) - { - RotateDefault(); - } - else - { - StartVote(); - ListenForEndVote(); - } -} - - - -/* HUD section */ - -UpdateSelection(type, index) -{ - if (type == "map" || type == "mode") - { - if (!IsDefined(self.mapvote[type]["hovered_index"])) - { - self.mapvote[type]["hovered_index"] = 0; - } - - self.mapvote["vote_section"] = type; - - SetElementUnselected(self.mapvote[type][self.mapvote[type]["hovered_index"]]["hud"]); // Unselect previous element - SetElementSelected(self.mapvote[type][index]["hud"]); // Select new element - - self.mapvote[type]["hovered_index"] = index; // Update the index - } - else if (type == "end") - { - self.mapvote["vote_section"] = "end"; - } -} - -ConfirmSelection(type) -{ - self.mapvote[type]["selected_index"] = self.mapvote[type]["hovered_index"]; - level.mapvote["vote"][type + "s"][self.mapvote[type]["selected_index"]] = (level.mapvote["vote"][type + "s"][self.mapvote[type]["selected_index"]] + 1); - level.mapvote["hud"][type + "s"][self.mapvote[type]["selected_index"]] SetValue(level.mapvote["vote"][type + "s"][self.mapvote[type]["selected_index"]]); - - if (type == "map") - { - modeIndex = 0; - - if (IsDefined(self.mapvote["mode"]["hovered_index"])) - { - modeIndex = self.mapvote["mode"]["hovered_index"]; - } - - self UpdateSelection("mode", modeIndex); - } - else if (type == "mode") - { - self UpdateSelection("end"); - } -} - -CancelSelection(type) -{ - typeToCancel = ""; - - if (type == "mode") - { - typeToCancel = "map"; - } - else if (type == "end") - { - typeToCancel = "mode"; - } - - level.mapvote["vote"][typeToCancel + "s"][self.mapvote[typeToCancel]["selected_index"]] = (level.mapvote["vote"][typeToCancel + "s"][self.mapvote[typeToCancel]["selected_index"]] - 1); - level.mapvote["hud"][typeToCancel + "s"][self.mapvote[typeToCancel]["selected_index"]] SetValue(level.mapvote["vote"][typeToCancel + "s"][self.mapvote[typeToCancel]["selected_index"]]); - - self.mapvote[typeToCancel]["selected_index"] = -1; - - if (type == "mode") - { - SetElementUnselected(self.mapvote["mode"][self.mapvote["mode"]["hovered_index"]]["hud"]); - self.mapvote["vote_section"] = "map"; - } - else if (type == "end") - { - self.mapvote["vote_section"] = "mode"; - } -} - -SetElementSelected(element) -{ - element.color = GetGscColor(GetDvar("mapvote_colors_selected")); -} - -SetElementUnselected(element) -{ - element.color = GetGscColor(GetDvar("mapvote_colors_unselected")); -} - -CreateHudText(text, font, fontScale, relativeToX, relativeToY, relativeX, relativeY, isServer, value) -{ - hudText = ""; - - if (IsDefined(isServer) && isServer) - { - hudText = CreateServerFontString( font, fontScale ); - } - else - { - hudText = CreateFontString( font, fontScale ); - } - - if (IsDefined(value)) - { - hudText.label = text; - hudText SetValue(value); - } - else - { - hudText SetText(text); - } - - hudText SetPoint(relativeToX, relativeToY, relativeX, relativeY); - - hudText.hideWhenInMenu = 1; - hudText.glowAlpha = 0; - - return hudText; -} - -CreateTimer(time, label, font, fontScale, relativeToX, relativeToY, relativeX, relativeY) -{ - timer = createServerTimer(font, fontScale); - timer setpoint(relativeToX, relativeToY, relativeX, relativeY); - timer.label = label; - timer.hideWhenInMenu = 1; - timer.glowAlpha = 0; - timer setTimer(time); - - return timer; -} - - - -/* Utils section */ - -SetDvarIfNotInitialized(dvar, value) -{ - if (!IsInitialized(dvar)) - { - SetDvar(dvar, value); - } -} - -IsInitialized(dvar) -{ - result = GetDvar(dvar); - return result != ""; -} - -IsBot() -{ - return IsDefined(self.pers["isBot"]) && self.pers["isBot"]; -} - -IsMultiplayerMode() -{ - return !IsDefined(level.zombiemode) || !level.zombiemode; -} - -GetHumanPlayers() -{ - humanPlayers = []; - - foreach (player in level.players) - { - if (!player IsBot()) - { - humanPlayers = AddElementToArray(humanPlayers, player); - } - } - - return humanPlayers; -} - -GetRandomElementInArray(array) -{ - return array[GetArrayKeys(array)[randomint(array.size)]]; -} - -GetRandomUniqueElementsInArray(array, limit) -{ - finalElements = []; - - for (i = 0; i < limit; i++) - { - findElement = true; - - while (findElement) - { - randomElement = GetRandomElementInArray(array); - - if (!ArrayContainsValue(finalElements, randomElement)) - { - finalElements = AddElementToArray(finalElements, randomElement); - - findElement = false; - } - } - } - - return finalElements; -} - -ArrayContainsValue(array, valueToFind) -{ - if (array.size == 0) - { - return false; - } - - foreach (value in array) - { - if (value == valueToFind) - { - return true; - } - } - - return false; -} - -AddElementToArray(array, element) -{ - array[array.size] = element; - return array; -} - -GetMapCodeName(mapName) -{ - formattedMapName = ToUpper(mapName); - - if (IsMultiplayerMode()) - { - switch(formattedMapName) - { - case "NUKETOWN": - return "mp_nuketown_2020"; - - case "HIJACKED": - return "mp_hijacked"; - - case "MELTDOWN": - return "mp_meltdown"; - - case "EXPRESS": - return "mp_express"; - - case "CARRIER": - return "mp_carrier"; - - case "OVERFLOW": - return "mp_overflow"; - - case "SLUMS": - return "mp_slums"; - - case "AFTERMATH": - return "mp_la"; - - case "CARGO": - return "mp_dockside"; - - case "TURBINE": - return "mp_turbine"; - - case "DRONE": - return "mp_drone"; - - case "RAID": - return "mp_raid"; - - case "STANDOFF": - return "mp_village"; - - case "PLAZA": - return "mp_nightclub"; - - case "YEMEN": - return "mp_socotra"; - - case "UPLINK": - return "mp_uplink"; - - case "DETOUR": - return "mp_bridge"; - - case "COVE": - return "mp_castaway"; - - case "RUSH": - return "mp_paintball"; - - case "STUDIO": - return "mp_studio"; - - case "MAGMA": - return "mp_magma"; - - case "VERTIGO": - return "mp_vertigo"; - - case "ENCORE": - return "mp_concert"; - - case "DOWNHILL": - return "mp_downhill"; - - case "GRIND": - return "mp_skate"; - - case "HYDRO": - return "mp_hydro"; - - case "MIRAGE": - return "mp_mirage"; - - case "FROST": - return "mp_frostbite"; - - case "TAKEOFF": - return "mp_takeoff"; - - case "POD": - return "mp_pod"; - - case "DIG": - return "mp_dig"; - } - } - else - { - switch(formattedMapName) - { - case "BURIED": - return "zm_buried"; - - case "DIE RISE": - return "zm_highrise"; - - case "MOB OF THE DEAD": - return "zm_prison"; - - case "NUKETOWN": - return "zm_nuked"; - - case "ORIGINS": - return "zm_tomb"; - - case "TRANZIT": - case "FARM": - case "TOWN": - case "BUS DEPOT": - return "zm_transit"; - - case "DINER": - return "zm_transit_dr"; - } - } -} - -GetGscColor(colorName) -{ - switch (colorName) - { - case "red": - return (1, 0, 0.059); - - case "green": - return (0.549, 0.882, 0.043); - - case "yellow": - return (1, 0.725, 0); - - case "blue": - return (0, 0.553, 0.973); - - case "cyan": - return (0, 0.847, 0.922); - - case "purple": - return (0.427, 0.263, 0.651); - - case "white": - return (1, 1, 1); - - case "grey": - case "gray": - return (0.137, 0.137, 0.137); - - case "black": - return (0, 0, 0); - } -} - -GetChatColor(colorName) -{ - switch(colorName) - { - case "red": - return "^1"; - - case "green": - return "^2"; - - case "yellow": - return "^3"; - - case "blue": - return "^4"; - - case "cyan": - return "^5"; - - case "purple": - return "^6"; - - case "white": - return "^7"; - - case "grey": - return "^0"; - - case "black": - return "^0"; - } -} \ No newline at end of file diff --git a/mapvote/source/mapvote_mp_extend-source.gsc b/mapvote/source/mapvote_mp_extend-source.gsc deleted file mode 100644 index 0578e19..0000000 --- a/mapvote/source/mapvote_mp_extend-source.gsc +++ /dev/null @@ -1,32 +0,0 @@ -#include maps\mp\_utility; - -Init() -{ - if (GetDvarInt("mapvote_enable")) - { - replaceFunc(maps\mp\gametypes\_killcam::finalkillcamwaiter, ::OnKillcamEnd); - } -} - -OnKillcamEnd() -{ - if (!IsDefined(level.finalkillcam_winner)) - { - if (isRoundBased() && !wasLastRound()) - return false; - - wait GetDvarInt("mapvote_display_wait_time"); - [[level.mapvote_rotate_function]](); - - return false; - } - - level waittill("final_killcam_done"); - if (isRoundBased() && !wasLastRound()) - return true; - - wait GetDvarInt("mapvote_display_wait_time"); - [[level.mapvote_rotate_function]](); - - return true; -} \ No newline at end of file diff --git a/mapvote/source/mapvote_zm_extend-source.gsc b/mapvote/source/mapvote_zm_extend-source.gsc deleted file mode 100644 index b564734..0000000 --- a/mapvote/source/mapvote_zm_extend-source.gsc +++ /dev/null @@ -1,154 +0,0 @@ -/* -All the credits for this script go to DoktorSAS for both the source code and for helping me figuring this out -https://github.com/DoktorSAS/PlutoniumT6Mapvote/blob/master/Zombies/mapvote.gsc - -menuSounds = array("zmb_meteor_activate", "zmb_spawn_powerup", "zmb_powerup_grabbed", "zmb_switch_flip", "zmb_elec_start", "zmb_perks_packa_ready"); -*/ - -#include common_scripts\utility; -#include maps\mp\_utility; - -Init() -{ - if (GetDvarInt("mapvote_enable")) - { - replaceFunc(maps\mp\zombies\_zm::intermission, ::OnIntermissionStart); - } -} - -OnIntermissionStart() -{ - level.intermission = 1; - level notify("intermission"); - - for (i = 0; i < level.players.size; i++) - { - level.players[i] thread player_intermission(); - level.players[i] hide(); - level.players[i] setclientuivisibilityflag("hud_visible", 0); - - level.players[i] setclientthirdperson(0); - level.players[i].health = 100; - level.players[i] stopsounds(); - level.players[i] stopsounds(); - } - - wait GetDvarInt("mapvote_display_wait_time"); - - [[level.mapvote_rotate_function]](); - - for (i = 0; i < level.players.size; i++) - { - level.players[i] notify("_zombie_game_over"); - level.players[i].sessionstate = "intermission"; - } - - players = get_players(); - i = 0; - while (i < players.size) - { - setclientsysstate("levelNotify", "zi", players[i]); - i++; - } - wait 0.25; - players = get_players(); - i = 0; - while (i < players.size) - { - setclientsysstate("lsm", "0", players[i]); - i++; - } - level thread maps\mp\zombies\_zm::zombie_game_over_death(); -} - -player_intermission() -{ - self closemenu(); - self closeingamemenu(); - - level endon("stop_intermission"); - self endon("disconnect"); - self endon("death"); - - self.score = self.score_total; - - self.spectatorclient = -1; - self.killcamentity = -1; - self.archivetime = 0; - self.psoffsettime = 0; - self.friendlydamage = undefined; - points = getstructarray("intermission", "targetname"); - if (!isDefined(points) || points.size == 0) - { - points = getentarray("info_intermission", "classname"); - - location = getDvar("ui_zm_mapstartlocation"); - for(i = 0;i < points.size;i++) - { - if(points[i].script_string == location) - { - points = points[i]; - } - } - - if (points.size < 1) - { - return; - } - } - if (isdefined(self.game_over_bg)) - self.game_over_bg destroy(); - org = undefined; - while (1) - { - points = array_randomize(points); - i = 0; - while (i < points.size) - { - point = points[i]; - if (!isDefined(org)) - { - self spawn(point.origin, point.angles); - } - if (isDefined(points[i].target)) - { - if (!isDefined(org)) - { - org = spawn("script_model", self.origin + vectorScale((0, 0, -1), 60)); - org setmodel("tag_origin"); - } - org.origin = points[i].origin; - org.angles = points[i].angles; - j = 0; - while (j < get_players().size) - { - player = get_players()[j]; - player camerasetposition(org); - player camerasetlookat(); - player cameraactivate(1); - j++; - } - speed = 20; - if (isDefined(points[i].speed)) - { - speed = points[i].speed; - } - target_point = getstruct(points[i].target, "targetname"); - dist = distance(points[i].origin, target_point.origin); - time = dist / speed; - q_time = time * 0.25; - if (q_time > 1) - { - q_time = 1; - } - org moveto(target_point.origin, time, q_time, q_time); - org rotateto(target_point.angles, time, q_time, q_time); - wait(time - q_time); - wait q_time; - i++; - continue; - } - i++; - } - } -} \ No newline at end of file diff --git a/small_scripts/get_player_guid-source.gsc b/small_scripts/get_player_guid-source.gsc deleted file mode 100644 index de073d8..0000000 --- a/small_scripts/get_player_guid-source.gsc +++ /dev/null @@ -1,24 +0,0 @@ -Init() -{ - level thread OnPlayerConnect(); -} - -OnPlayerConnect() -{ - for(;;) - { - level waittill("connected", player); - Print(player.name + " GUID: " + player.guid); - player thread OnPlayerSpawned(); - } -} - -OnPlayerSpawned() -{ - self endon("disconnect"); - for(;;) - { - self waittill("spawned_player"); - Print(self.name + " GUID: " + self.guid); - } -} \ No newline at end of file diff --git a/small_scripts/get_player_guid.gsc b/small_scripts/get_player_guid.gsc index 3530a88..fca360a 100644 Binary files a/small_scripts/get_player_guid.gsc and b/small_scripts/get_player_guid.gsc differ