Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <amxmisc>
- #include <cstrike>
- #include <fun>
- #define PLUGIN "JB CT Menu"
- #define VERSION "1.0"
- #define AUTHOR "MiX"
- #define COLOR_OFF -1
- #define COLOR_RED 0
- #define COLOR_BLUE 1
- #define COLOR_GREEN 2
- #define COLOR_LAST 2
- new const MSG_PREFIX[] = "|Fn|"; // Defines the Message Prefix
- new g_iSelectedColor[33], g_sayText;
- public plugin_init()
- {
- register_plugin(PLUGIN, VERSION, AUTHOR);
- register_clcmd("say /ctmenu", "clcmd_say_ctmenu", _, "- Opens a menu for CTs");
- register_logevent("logevent_roundstart", 2, "1=Round_Start");
- g_sayText = get_user_msgid("SayText");
- }
- // Unglow all Terrorists on round start
- public logevent_roundstart()
- {
- static i;
- for (i = 0; i < 33; ++i)
- if (is_user_alive(i))
- set_user_rendering(i, kRenderFxGlowShell, 0, 0, 0);
- }
- srv_message(id, const message[], any:...)
- {
- static szMessage[192];
- static const MSG_PREFIX_LENGTH = (sizeof(MSG_PREFIX) + 3);
- formatex(szMessage, MSG_PREFIX_LENGTH, "^x04%s^x01 ", MSG_PREFIX);
- vformat(szMessage[MSG_PREFIX_LENGTH], 191 - MSG_PREFIX_LENGTH, message, 3);
- if (!id) {
- message_begin(MSG_BROADCAST, g_sayText, _, -1);
- write_byte(-1);
- } else {
- message_begin(MSG_ONE_UNRELIABLE, g_sayText, _, id);
- write_byte(id);
- }
- write_string(szMessage);
- message_end();
- }
- // A player said /ctmenu in chat
- public clcmd_say_ctmenu(id)
- {
- // Check if user is an alive CT, else print an error message
- if (cs_get_user_team(id) != CS_TEAM_CT || !is_user_alive(id)) {
- srv_message(id, "You cannot open this menu as it's for alive CTs only.");
- return PLUGIN_HANDLED;
- }
- new menu = menu_create("CT Menu", "menu_handle_ct");
- menu_additem(menu, "Glow Players");
- menu_additem(menu, "Glow into 50/50");
- menu_additem(menu, "\dOpen Cells");
- menu_additem(menu, "\dStart a Funday");
- menu_display(id, menu);
- return PLUGIN_HANDLED;
- }
- // Handles the option chosen in the CT Menu
- public menu_handle_ct(id, menu, item)
- {
- switch (item) {
- case 0: {
- menu_destroy(menu);
- g_iSelectedColor[id] = 0; // Set the first color option to the default color
- menu_display(id, menu_create_glow(id));
- }
- case 1: {
- menu_destroy(menu);
- glow_terrors_random(id);
- }
- case 2: {
- menu_destroy(menu);
- srv_message(id, "Functionality not yet implemented");
- }
- case 3: {
- menu_destroy(menu);
- srv_message(id, "Functionality not yet implemented");
- }
- default: // On exit
- menu_destroy(menu);
- }
- return PLUGIN_HANDLED;
- }
- // Creates and returns the menu for glowing Terrorists
- public menu_create_glow(id)
- {
- static i, iTerrors[32], iTerrorsNum, iItemCount, szColorItem[17], szTempName[34], szMenuInfo[1];
- static iTempId;
- // The currently selected color
- switch (g_iSelectedColor[id]) {
- case COLOR_RED:
- copy(szColorItem, 16, "\yColor: \wRed");
- case COLOR_BLUE:
- copy(szColorItem, 16, "\yColor: \wBlue");
- case COLOR_GREEN:
- copy(szColorItem, 16, "\yColor: \wGreen");
- default:
- copy(szColorItem, 16, "\yColor: \wOff");
- }
- new menu = menu_create("CT Menu - Glow", "menu_handle_glow");
- menu_additem(menu, "\yUnglow all", {-1});
- get_players(iTerrors, iTerrorsNum, "e", "TERRORIST");
- iItemCount = 1; // The amount of items on the current page
- for (i = 0; i < iTerrorsNum; i++) {
- iItemCount++;
- if (iItemCount > 6) {
- // The 7th item is the color chooser; 8 and 9 are previous and next page
- menu_additem(menu, szColorItem, {0});
- iItemCount = 0;
- }
- iTempId = iTerrors[i];
- szMenuInfo[0] = iTempId; // Store the ID in the info
- if (is_user_alive(iTempId)) {
- get_user_name(iTempId, szTempName, 33);
- } else {
- copy(szTempName, 2, "\d");
- get_user_name(iTempId, szTempName[2], 31);
- }
- menu_additem(menu, szTempName, szMenuInfo);
- }
- menu_additem(menu, szColorItem, {0}); // The last item is always the color chooser
- return menu;
- }
- // Handles the option chosen in the Glow menu
- public menu_handle_glow(id, menu, item)
- {
- if (item == MENU_EXIT) {
- menu_destroy(menu);
- return PLUGIN_HANDLED;
- }
- // Get the selected item from the info
- static szMenuInfo[1], iTarget, iAccess, iCallback, iPage;
- menu_item_getinfo(menu, item, iAccess, szMenuInfo, 1, _, _, iCallback);
- iTarget = szMenuInfo[0];
- // Check which item was selected
- switch (iTarget) {
- case -1: { // Unglow all
- static i, iTerrors[32], iTerrorsNum, szName[32];
- get_players(iTerrors, iTerrorsNum, "ae", "TERRORIST");
- for (i = 0; i < iTerrorsNum; i++)
- set_user_rendering(iTerrors[i], kRenderFxGlowShell, 0, 0, 0);
- // Announce in chat
- get_user_name(id, szName, 31);
- srv_message(0, "%s has split the prisoners into two teams.", szName);
- }
- case 0: { // Change color
- if (g_iSelectedColor[id] >= COLOR_LAST)
- g_iSelectedColor[id] = COLOR_OFF;
- else
- g_iSelectedColor[id]++;
- }
- default: { // Glow a player
- if (is_user_alive(iTarget)) { // Disregard dead players
- static iColor[3], szColor[6], szName[32], szTarg[32];
- // The selected color
- switch (g_iSelectedColor[id]) {
- case COLOR_RED:{
- iColor = {255, 0, 0};
- copy(szColor, 5, "red");
- }
- case COLOR_BLUE: {
- iColor = {0, 0, 255};
- copy(szColor, 5, "blue");
- }
- case COLOR_GREEN: {
- iColor = {0, 255, 0};
- copy(szColor, 5, "green");
- }
- default: iColor = {0, 0, 0};
- }
- set_user_rendering(iTarget, kRenderFxGlowShell, iColor[0], iColor[1], iColor[2]);
- }
- }
- }
- menu_destroy(menu);
- iPage = (item / 7); // 7 items per page (previous/next page and exit do not count as items)
- menu_display(id, menu_create_glow(id), iPage);
- return PLUGIN_HANDLED;
- }
- // Divide all alive Terrorists into two Teams and glows them accordingly
- public glow_terrors_random(id)
- {
- static i, iTerrors[32], iTerrorsNum, iTeamMax, iTeamANum, iTeamBNum, iTeamA[16], iTeamB[16];
- get_players(iTerrors, iTerrorsNum, "ae", "TERRORIST");
- iTeamMax = (iTerrorsNum / 2);
- iTeamANum = 0;
- iTeamBNum = 0;
- for (i = 0; i < iTerrorsNum; i++) {
- if (iTeamANum < iTeamMax) { // Check if Team A isn't full yet
- // Check if Team B isn't full yet, then randomly decide
- if ((iTeamBNum < iTeamMax) && random(2)) {
- iTeamB[iTeamBNum] = iTerrors[i];
- iTeamBNum++;
- } else { // Fill Team A with (remaining) Players
- iTeamA[iTeamANum] = iTerrors[i];
- iTeamANum++;
- }
- } else { // Fill Team B with remaining Players
- iTeamB[iTeamBNum] = iTerrors[i];
- iTeamBNum++;
- }
- }
- for (i = 0; i < iTeamANum; i++)
- set_user_rendering(iTeamA[i], kRenderFxGlowShell, 255, 0, 0);
- for (i = 0; i < iTeamBNum; i++)
- set_user_rendering(iTeamB[i], kRenderFxGlowShell, 0, 0, 255);
- // Announce in chat
- static szName[32];
- get_user_name(id, szName, 31);
- srv_message(0, "%s has randomly divided the Terrorists into two Teams.", szName);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement