Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Sublime AMXX Editor v2.2 */
- #include <amxmodx>
- #include <amxmisc>
- #include <cstrike>
- #include <hamsandwich>
- #include <fvault>
- #define PLUGIN "Admin Models Menu"
- #define VERSION "1.0"
- #define AUTHOR "FanTa. & Cosmin" // Tibers edit
- #define ADMIN_FLAG ADMIN_LEVEL_H // Flag "t" in users.ini
- new isFreeForAll
- // Definition of keys for the menu
- const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0;
- const MENU_KEY_EXIT = 9 // will be 0
- // Vault name for storing player models data
- new const save_models[] = "save-models"
- new SaveType
- // Arrays to store player model choices
- new bool:PlayerTero1[33], PlayerTero2[33], PlayerTero3[33];
- new bool:PlayerCounter1[33], PlayerCounter2[33], PlayerCounter3[33];
- // Arrays to store available models for each team
- new const ModelsTero[][] =
- {
- "Asasin",
- "Anonymous",
- "Agent"
- };
- new const ModelsCounter[][] =
- {
- "Ghost",
- "Vendetta",
- "Neo"
- };
- // Plugin initialization function
- public plugin_init()
- {
- register_plugin(PLUGIN, VERSION, AUTHOR);
- register_menu("Test Menu", KEYSMENU, "test_menu"); // Register the main menu
- register_clcmd("say /admodels", "admin"); // Register the command to open the menu
- RegisterHam(Ham_Spawn, "player", "Player_Spawn", 1); // Register Ham to detect player spawns
- // Register cvars
- SaveType = register_cvar("SaveType", "2"); // 1 - IP || 2 - Nick || 3 - SteamID
- isFreeForAll = register_cvar("FreeForAll", "0"); // Enable FreeForAll mode by default (1 enable, 0 disable)
- // Add your code here...
- }
- // Function to open the menu for admins
- public admin(id)
- {
- // Check if the player is an admin or FreeForAll is enabled
- if ((get_user_flags(id) & ADMIN_FLAG) || get_pcvar_num(isFreeForAll))
- {
- TestMenu(id);
- }
- else
- {
- client_print(id, print_chat, "The models are only for Admins Members!");
- }
- }
- // Player spawn function
- public Player_Spawn(id)
- {
- if (get_user_team(id) == 1)
- {
- if (!get_pcvar_num(isFreeForAll))
- {
- // Reset models for Terrorists if isFreeForAll is 0 and the player is not an admin
- if (!(get_user_flags(id) & ADMIN_FLAG))
- {
- PlayerTero1[id] = false;
- PlayerTero2[id] = false;
- PlayerTero3[id] = false;
- cs_reset_user_model(id);
- }
- else
- {
- // If admin and isFreeForAll is 0, set the default Terrorist model
- cs_reset_user_model(id);
- if (PlayerTero1[id]) cs_set_user_model(id, ModelsTero[0]);
- if (PlayerTero2[id]) cs_set_user_model(id, ModelsTero[1]);
- if (PlayerTero3[id]) cs_set_user_model(id, ModelsTero[2]);
- }
- }
- else
- {
- // Reset models for Terrorists if isFreeForAll is 1 or the player is an admin
- cs_reset_user_model(id);
- if (PlayerTero1[id]) cs_set_user_model(id, ModelsTero[0]);
- if (PlayerTero2[id]) cs_set_user_model(id, ModelsTero[1]);
- if (PlayerTero3[id]) cs_set_user_model(id, ModelsTero[2]);
- }
- }
- else if (get_user_team(id) == 2)
- {
- if (!get_pcvar_num(isFreeForAll))
- {
- // If admin and isFreeForAll is 0, set the default Counter-Terrorist model
- if (!(get_user_flags(id) & ADMIN_FLAG))
- {
- PlayerCounter1[id] = false;
- PlayerCounter2[id] = false;
- PlayerCounter3[id] = false;
- cs_reset_user_model(id);
- }
- else
- {
- // If admin and isFreeForAll is 0, set the default Counter-Terrorist model
- cs_reset_user_model(id);
- if (PlayerCounter1[id]) cs_set_user_model(id, ModelsCounter[0]);
- if (PlayerCounter2[id]) cs_set_user_model(id, ModelsCounter[1]);
- if (PlayerCounter3[id]) cs_set_user_model(id, ModelsCounter[2]);
- }
- }
- else
- {
- // Reset models for Counter-Terrorists if isFreeForAll is 1 or the player is an admin
- cs_reset_user_model(id);
- if (PlayerCounter1[id]) cs_set_user_model(id, ModelsCounter[0]);
- if (PlayerCounter2[id]) cs_set_user_model(id, ModelsCounter[1]);
- if (PlayerCounter3[id]) cs_set_user_model(id, ModelsCounter[2]);
- }
- }
- }
- // Precache models function
- public plugin_precache()
- {
- for (new i = 0; i < sizeof(ModelsTero); i++)
- {
- new Text[64];
- formatex(Text, sizeof(Text) - 1, "models/player/%s/%s.mdl", ModelsTero[i], ModelsTero[i]);
- precache_model(Text);
- }
- for (new i = 0; i < sizeof(ModelsCounter); i++)
- {
- new Text[64];
- formatex(Text, sizeof(Text) - 1, "models/player/%s/%s.mdl", ModelsCounter[i], ModelsCounter[i]);
- precache_model(Text);
- }
- }
- // Display menu function
- public TestMenu(id)
- {
- new szMenu[512], iLen;
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\wAdmin Models Menu:^n^n");
- if (cs_get_user_team(id) == CS_TEAM_T)
- {
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[\y1\d]\w Assassin's Creed %s", PlayerTero1[id] ? "\y[ON]^n" : "\r[OFF]^n");
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[\y2\d]\w 1337 Anonymous L33T %s", PlayerTero2[id] ? "\y[ON]^n" : "\r[OFF]^n");
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[\y3\d]\w Agent Smith Matrix %s^n^n", PlayerTero3[id] ? "\y[ON]^n" : "\r[OFF]^n");
- }
- else if (cs_get_user_team(id) == CS_TEAM_CT)
- {
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[\y1\d]\w Ghostface Death %s", PlayerCounter1[id] ? "\y[ON]^n" : "\r[OFF]^n");
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[\y2\d]\w V for Vendetta %s", PlayerCounter2[id] ? "\y[ON]^n" : "\r[OFF]^n");
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[\y3\d]\w Neo from The Matrix %s^n^n", PlayerCounter3[id] ? "\y[ON]^n" : "\r[OFF]^n");
- }
- iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[\y0\d]\w Exit^n");
- show_menu(id, KEYSMENU, szMenu, -1, "Test Menu");
- }
- // Function to handle menu selection
- public test_menu(id, key)
- {
- if (cs_get_user_team(id) == CS_TEAM_T)
- {
- switch (key)
- {
- case 0:
- {
- if (!PlayerTero1[id])
- {
- PlayerTero1[id] = true;
- PlayerTero2[id] = false;
- PlayerTero3[id] = false;
- cs_set_user_model(id, ModelsTero[0]);
- client_print(id, print_chat, "You have enabled your Assassin's Creed model.");
- }
- else
- {
- PlayerTero1[id] = false;
- cs_reset_user_model(id);
- client_print(id, print_chat, "You have disabled your Assassin's Creed model.");
- }
- }
- case 1:
- {
- if (!PlayerTero2[id])
- {
- PlayerTero1[id] = false;
- PlayerTero2[id] = true;
- PlayerTero3[id] = false;
- cs_set_user_model(id, ModelsTero[1]);
- client_print(id, print_chat, "You have enabled your 1337 Anonymous L33T model.");
- }
- else
- {
- PlayerTero2[id] = false;
- cs_reset_user_model(id);
- client_print(id, print_chat, "You have disabled your 1337 Anonymous L33T model.");
- }
- }
- case 2:
- {
- if (!PlayerTero3[id])
- {
- PlayerTero1[id] = false;
- PlayerTero2[id] = false;
- PlayerTero3[id] = true;
- cs_set_user_model(id, ModelsTero[2]);
- client_print(id, print_chat, "You have enabled your Agent Smith Matrix model.");
- }
- else
- {
- PlayerTero3[id] = false;
- cs_reset_user_model(id);
- client_print(id, print_chat, "You have disabled your Agent Smith Matrix model.");
- }
- }
- case MENU_KEY_EXIT: // exit
- {
- return PLUGIN_HANDLED;
- }
- }
- }
- else if (cs_get_user_team(id) == CS_TEAM_CT)
- {
- switch (key)
- {
- case 0:
- {
- if (!PlayerCounter1[id])
- {
- PlayerCounter1[id] = true;
- PlayerCounter2[id] = false;
- PlayerCounter3[id] = false;
- cs_set_user_model(id, ModelsCounter[0]);
- client_print(id, print_chat, "You have enabled your Ghostface Death model.");
- }
- else
- {
- PlayerCounter1[id] = false;
- cs_reset_user_model(id);
- client_print(id, print_chat, "You have disabled your Ghostface Death model.");
- }
- }
- case 1:
- {
- if (!PlayerCounter2[id])
- {
- PlayerCounter1[id] = false;
- PlayerCounter2[id] = true;
- PlayerCounter3[id] = false;
- cs_set_user_model(id, ModelsCounter[1]);
- client_print(id, print_chat, "You have enabled your V for Vendetta model.");
- }
- else
- {
- PlayerCounter2[id] = false;
- cs_reset_user_model(id);
- client_print(id, print_chat, "You have disabled your V for Vendetta model.");
- }
- }
- case 2:
- {
- if (!PlayerCounter3[id])
- {
- PlayerCounter1[id] = false;
- PlayerCounter2[id] = false;
- PlayerCounter3[id] = true;
- cs_set_user_model(id, ModelsCounter[2]);
- client_print(id, print_chat, "You have enabled your Neo from The Matrix model.");
- }
- else
- {
- PlayerCounter3[id] = false;
- cs_reset_user_model(id);
- client_print(id, print_chat, "You have disabled your Neo from The Matrix model.");
- }
- }
- case MENU_KEY_EXIT: // exit
- {
- return PLUGIN_HANDLED;
- }
- }
- }
- // Save player data and redisplay the menu
- SaveData(id);
- TestMenu(id);
- return PLUGIN_HANDLED;
- }
- // Function called when a client disconnects
- public client_disconnected(id)
- {
- // Save player data when disconnected
- SaveData(id);
- }
- // Function called when a client is authorized
- public client_authorized(id)
- {
- // Load player data when authorized
- LoadData(id);
- }
- // Function to save player data
- public SaveData(id)
- {
- new TypeSave[64], Data[256]
- // Determine the type of save based on a cvar
- switch(get_pcvar_num(SaveType))
- {
- case 1: get_user_ip(id, TypeSave, charsmax(TypeSave), 1)
- case 2: get_user_name(id, TypeSave, charsmax(TypeSave))
- case 3: get_user_authid(id, TypeSave, charsmax(TypeSave))
- }
- // Format player data for saving
- formatex(Data, charsmax(Data), "%d %d %d %d %d %d", PlayerTero1[id], PlayerTero2[id], PlayerTero3[id], PlayerCounter1[id], PlayerCounter2[id], PlayerCounter3[id])
- // Save the data using a vault
- fvault_set_data(save_models, TypeSave, Data)
- }
- // Function to load player data
- public LoadData(id)
- {
- new TypeSave[64], Data[256], PlayerData[6][2];
- // Determine the type of load based on a cvar
- switch(get_pcvar_num(SaveType))
- {
- case 1: get_user_ip(id, TypeSave, charsmax(TypeSave), 1)
- case 2: get_user_name(id, TypeSave, charsmax(TypeSave))
- case 3: get_user_authid(id, TypeSave, charsmax(TypeSave))
- }
- if (fvault_get_data(save_models, TypeSave, Data, charsmax(Data)))
- {
- // Data found, so parse and load values
- parse(Data, PlayerData[0], 1, PlayerData[1], 1, PlayerData[2], 1, PlayerData[3], 1, PlayerData[4], 1, PlayerData[5], 1);
- PlayerTero1[id] = str_to_num(PlayerData[0]) == 1;
- PlayerTero2[id] = str_to_num(PlayerData[1]) == 1;
- PlayerTero3[id] = str_to_num(PlayerData[2]) == 1;
- PlayerCounter1[id] = str_to_num(PlayerData[3]) == 1;
- PlayerCounter2[id] = str_to_num(PlayerData[4]) == 1;
- PlayerCounter3[id] = str_to_num(PlayerData[5]) == 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement