Junior Member
Join Date: Jul 2018
Location: Romania
|

04-06-2023
, 14:34
Re: [CSS/CSGO/ANY?] SLAYER Custom MVP Anthem (Kento_MVP)
|
#15
|
Quote:
Originally Posted by rogeraabbccdd
Add this in OnPluginStart should fix the problem.
PHP Code:
SetCommandFlags("playgamesound", GetCommandFlags("playgamesound") ^ FCVAR_CHEAT);
|
PHP Code:
#include <sourcemod> #include <clientprefs> #include <sdktools> #include <sdkhooks> #include <adminmenu> #include <multicolors>
#pragma semicolon 1
#define MAX_FILE_LEN 1024 // Maximum Lenght of file path #define MAX_MVP_COUNT 1000 // Maximum Numbers of Mvps
// ConVars ConVar sEnable; ConVar sVolume; ConVar sMessage; ConVar sPreview; ConVar sPreviewTime; ConVar sBotMvp; ConVar sAllowBot; ConVar sShowPremium; ConVar sShowFound; ConVar sAlreadyUsedMVPs;
// Ints int MVPCount, Selected[MAXPLAYERS+1], MenuSelect[MAXPLAYERS+1]; int AlreadyUsed = 1;
// Bools bool IsPremiumMVP[MAX_MVP_COUNT + 1];
// Chars char ConfigfilePath[1024], MVPName[MAX_MVP_COUNT + 1][1024], MVPFile[MAX_MVP_COUNT + 1][1024], MVPAlreadyUsed[101][1024], MVPFlag[MAX_MVP_COUNT + 1][AdminFlags_TOTAL], MVPLink[MAX_MVP_COUNT + 1][1024], NameMVP[MAXPLAYERS + 1][1024];
// Arrays ArrayList MVPSteamID[MAX_MVP_COUNT+1];
// Floats float VolMVP[MAXPLAYERS + 1]; float mvp_defaultVol;
// Handles Handle mvp_cookie, mvp_cookie2; Handle MvpPreviewTimer[MAXPLAYERS+1];
public Plugin myinfo = { name = "[CSGO] Custom MVP Anthem", author = "SLAYER", version = "1.3", description = "Allow player to set Custom MVP Anthem", url = "https://forums.alliedmods.net/member.php?u=293943" };
public void OnPluginStart() { // Cookies mvp_cookie = RegClientCookie("mvp_name", "Player's MVP Anthem", CookieAccess_Private); mvp_cookie2 = RegClientCookie("mvp_vol", "Player MVP volume", CookieAccess_Private); // Convars sEnable = CreateConVar("mvp_enabled", "1", "Enable/Disable SLAYER MVP plugin. (0 = Disabled, 1 = Enabled)", FCVAR_NOTIFY, true, 0.0, true, 1.0); sVolume = CreateConVar("mvp_defaultvol", "1.0", "Default MVP anthem volume.", FCVAR_NOTIFY, true, 0.0, true, 1.0); sMessage = CreateConVar("mvp_announce_type", "3", "Announcement of playing MVP Anthem in (1 = Chat, 2 = Hint, 3 = Both)", FCVAR_NOTIFY); sPreview = CreateConVar("mvp_preview", "1", "Allow player to Preview MVP? (0 = No, 1 = Yes)", FCVAR_NOTIFY, true, 0.0, true, 1.0); sPreviewTime = CreateConVar("mvp_preview_time", "10.0", "MVP Anthem Preview Time in Seconds", FCVAR_NOTIFY, true, 1.0); sBotMvp = CreateConVar("mvp_bot", "1", "Play Random MVP Anthem if bot becomes MVP? (0 = No, 1 = Yes)", FCVAR_NOTIFY, true, 0.0, true, 1.0); sAllowBot = CreateConVar("mvp_bot_allow", "1", "Allow Bots to use Premium MVPs? (0 = No, 1 = Yes)", FCVAR_NOTIFY, true, 0.0, true, 1.0); sShowPremium = CreateConVar("mvp_show_premium", "1", "Show Premium MVPs (as Disabled) to which Client don't have Access? (0 = No, 1 = Yes)", FCVAR_NOTIFY, true, 0.0, true, 1.0); sShowFound = CreateConVar("mvp_show_found", "1", "Show MVPs name in server console which are founded in given directory by using 'sm_mvp_load' cmd? (0 = No, 1 = Yes)", FCVAR_NOTIFY, true, 0.0, true, 1.0); sAlreadyUsedMVPs = CreateConVar("mvp_already_played", "5", "How many recent Random MVPs can't play which are already played? (0 = Play any Random Mvp)", FCVAR_NOTIFY, true, 0.0, true, 100.0); sVolume.AddChangeHook(OnConVarChanged); // Events HookEvent("round_mvp", Event_RoundMVP); // Cmds RegConsoleCmd("sm_mvp", Command_MVP, "Select Your MVP Anthem"); RegConsoleCmd("sm_mvpvol", Command_MVPVol, "MVP Volume"); RegAdminCmd("sm_mvp_refresh", CommandRefresh, ADMFLAG_RCON); RegAdminCmd("sm_mvp_load", CommandLoad, ADMFLAG_RCON); // Translation LoadTranslations("SLAYER_Mvp.phrases"); // Config AutoExecConfig(true, "SLAYER_Mvp"); for(int i = 1; i <= MaxClients; i++) { if(IsValidClient(i) && !IsFakeClient(i) && !AreClientCookiesCached(i)) OnClientCookiesCached(i); } } public void OnConfigsExecuted() { mvp_defaultVol = sVolume.FloatValue;
LoadConfig(); }
public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue) { if (convar == sVolume) mvp_defaultVol = sVolume.FloatValue; if(convar == sEnable) {if(convar.BoolValue){sEnable.BoolValue = true;CPrintToChatAll("SLAYER MVP Plugin is now Enabled!");}else{sEnable.BoolValue = false;CPrintToChatAll("Kento MVP Plugin is now Disabled!");}} }
public void OnClientPutInServer(int client) { if (IsValidClient(client)) { if(!IsFakeClient(client))OnClientCookiesCached(client); } }
public void OnClientCookiesCached(int client) { if(!IsValidClient(client) && IsFakeClient(client)) return; char random_mvp[1024]; Format(random_mvp, sizeof(random_mvp), "%t", "Random MVP"); char scookie[1024]; GetClientCookie(client, mvp_cookie, scookie, sizeof(scookie)); if(!StrEqual(scookie, "")) { if(StrEqual(scookie, random_mvp))strcopy(NameMVP[client], sizeof(NameMVP[]), random_mvp); else { int id = FindMVPIDByName(scookie); if(id > 0) { Selected[client] = id; strcopy(NameMVP[client], sizeof(NameMVP[]), scookie); } else { Format(NameMVP[client], sizeof(NameMVP[]), ""); SetClientCookie(client, mvp_cookie, ""); } } } else if(StrEqual(scookie,"")) { Selected[client] = -1; strcopy(NameMVP[client], sizeof(NameMVP[]), random_mvp); } GetClientCookie(client, mvp_cookie2, scookie, sizeof(scookie)); if(!StrEqual(scookie, "")) { VolMVP[client] = StringToFloat(scookie); } else if(StrEqual(scookie,""))VolMVP[client] = mvp_defaultVol; } public Action Event_RoundMVP(Handle event, const char[] name, bool dontBroadcast) { if(sEnable.BoolValue) { int client = GetClientOfUserId(GetEventInt(event, "userid")); if(IsValidClient(client)) { char random_mvp[1024]; Format(random_mvp, sizeof(random_mvp), "%t", "Random MVP"); if(IsFakeClient(client) && sBotMvp.BoolValue)strcopy(NameMVP[client], sizeof(NameMVP[]), random_mvp); int mvp; if(StrEqual(NameMVP[client], random_mvp) || Selected[client] == -1) // If Random MVP is selected { if(sAlreadyUsedMVPs.IntValue > 0 && sAlreadyUsedMVPs.IntValue >= MVPCount) { LogError("Error: 'mvp_already_played %d' Convar can't be equal/greater than your Total MVPs (%d). Please decrease the value of 'mvp_already_played' from config file.", sAlreadyUsedMVPs.IntValue, MVPCount); PrintToServer("[SLAYER-MVP] Error: 'mvp_already_played %d' Convar can't be equal/greater than your Total MVPs (%d). Please decrease the value of 'mvp_already_played' from config file.", sAlreadyUsedMVPs.IntValue, MVPCount); return; } do { do { mvp = GetRandomInt(1,MVPCount); // Select a Random MVP } while(!CheckIsMvpAlreadyUsed(mvp)); // if mvp is already used then select another random mvp again } while(!CanUseMVP(client, mvp)); // If client don't have access to that random MVP then Select another random mvp again if(sAlreadyUsedMVPs.IntValue > 0 && AlreadyUsed > sAlreadyUsedMVPs.IntValue)AlreadyUsed = 1; // Reset the Counter if(sAlreadyUsedMVPs.IntValue > 0) { MVPAlreadyUsed[AlreadyUsed] = MVPName[mvp]; // Save the name of the MVP in String Array AlreadyUsed++; // Increase the Counter } } else {mvp = Selected[client];} // If Random MVP is not Selceted if(StrEqual(NameMVP[client], "") || mvp == 0)return; // If MVP is not selected then return char sound[1024]; Format(sound, sizeof(sound), "%s", MVPFile[mvp]); for(int i = 1; i <= MaxClients; i++) { if (IsValidClient(i) && !IsFakeClient(i)) // Play Sound to Every Vaild Player except BOT { // Announce MVP if(sMessage.IntValue == 2 || sMessage.IntValue == 3)PrintHintText(i, "%t", "MVP_Hint", client, MVPName[mvp]); if(sMessage.IntValue == 1 || sMessage.IntValue == 3)CPrintToChat(i, "%t %t", "Tag","MVP_Chat", client, MVPName[mvp]); // Mute game sound ClientCommand(i, "playgamesound Music.StopAllMusic"); //StopPlayingMVPs(i); // Play MVP Anthem EmitSoundToClient(i, sound, SOUND_FROM_PLAYER, SNDCHAN_STATIC, SNDLEVEL_NONE, _, VolMVP[i]); } } } } }
int FindMVPIDByName(char [] name) { int id = 0; for(int i = 1; i <= MVPCount; i++) { if(StrEqual(MVPName[i], name)) id = i; } return id; }
public Action CommandRefresh(int client, int args) { LoadConfig(); ReplyToCommand(client, "[SLAYER MVP] MVP Sounds and Settings are Refreshed!"); return Plugin_Handled; } public Action CommandLoad(int client, int args) { // If less than 2 arguments given then give error and return if(args < 1) { ReplyToCommand(client, "[SLAYER MVP] Usage: sm_mvp_load "mvps_folder_path" "number_of_mvps" "mvp_name_prefix" "preimum_mvp_flag""); return Plugin_Handled; } // Get and Save Client Given Arguments char FolderPath[PLATFORM_MAX_PATH]; char MvpsToLoad[4]; char MvpsPrefix[50]; char MvpsFlag[50]; GetCmdArg(1, FolderPath, sizeof(FolderPath)); GetCmdArg(2, MvpsToLoad, sizeof(MvpsToLoad)); GetCmdArg(3, MvpsPrefix, sizeof(MvpsPrefix)); GetCmdArg(4, MvpsFlag, sizeof(MvpsFlag)); // Checking if the given Path is Vaild or Not if (!DirExists(FolderPath)) { // If path is INVALID then print error to client ReplyToCommand(client, "[SLAYER MVP] Given Path is INVAILD "%s"! Please Enter the VAILD Path", FolderPath); return Plugin_Handled; } AddSoundsInConfig(FolderPath, StringToInt(MvpsToLoad), MvpsPrefix, MvpsFlag); return Plugin_Handled; } void LoadConfig() { // Config File Path BuildPath(Path_SM, ConfigfilePath, MAX_FILE_LEN, "configs/SLAYER_Mvp.cfg"); // Check is Config File Exist or not if(!FileExists(ConfigfilePath)) SetFailState("Can not find config file "%s"!", ConfigfilePath); char SoundFilePath[PLATFORM_MAX_PATH]; KeyValues kv = CreateKeyValues("MVP"); kv.ImportFromFile(ConfigfilePath); MVPCount = 1; // Reseting Variables for(int i = 0; i < MAX_MVP_COUNT; i++) { IsPremiumMVP[i] = false; delete MVPSteamID[i]; MVPSteamID[i] = new ArrayList(ByteCountToCells(1024)); } // Reading Config File if(kv.GotoFirstSubKey()) { do { // Getting and Saving the Information of MVP Sound kv.GetSectionName(MVPName[MVPCount], sizeof(MVPName[])); kv.GetString("file", MVPFile[MVPCount], sizeof(MVPFile[])); kv.GetString("flag", MVPFlag[MVPCount], sizeof(MVPFlag[]), ""); kv.GetString("link", MVPLink[MVPCount], sizeof(MVPLink[]), ""); // If MVP sound have any admin flag then it will be a Premium MVP if(!StrEqual(MVPFlag[MVPCount], "") && !StrEqual(MVPFlag[MVPCount], " "))IsPremiumMVP[MVPCount] = true; // Checking that the given sound file path shouldn't be empty. if(StrEqual(MVPFile[MVPCount], "") && StrEqual(MVPFile[MVPCount], " ")) { LogError("Error: Given File Path of the Sound '%s' is Empty!", MVPName[MVPCount]); PrintToServer("[SLAYER MVP] Error: Given File Path of the Sound '%s' is Empty!", MVPName[MVPCount]); } // Checking that is the Given Sound File Path is Vaild or not. If not vaild then give error otherwise continue Format(SoundFilePath, sizeof(SoundFilePath), "%s%s", "sound/", MVPFile[MVPCount]); if(!FileExists(SoundFilePath)) { LogError("Failed to load %s from '%s'. Please Enter a Vaild Sound Path", MVPName[MVPCount], SoundFilePath); PrintToServer("[SLAYER MVP] Failed to load %s from '%s'. Please Enter a Vaild Sound Path", MVPName[MVPCount], SoundFilePath); } if(kv.JumpToKey("steamid")) { char steamid[32][32]; int i = 0; do { FormatEx(steamid[0], sizeof(steamid[]), "%i", ++i); kv.GetString(steamid[0], steamid[1], sizeof(steamid[]), ""); MVPSteamID[MVPCount].PushString(steamid[1]); } while(steamid[1][0]); MVPSteamID[MVPCount].Erase(MVPSteamID[MVPCount].Length-1); // Remove the last entry since it should be empty due to the check above. if(MVPSteamID[MVPCount].Length)IsPremiumMVP[MVPCount] = true; kv.GoBack(); // We need to go back since we used KeyValue.JumpToKey() } // The Precaches all the sounds and adds them to the downloads table so that clients can automatically download them char downloadFile[MAX_FILE_LEN]; if(!StrEqual(MVPFile[MVPCount], "")) { PrecacheSound(MVPFile[MVPCount], true); Format(downloadFile, MAX_FILE_LEN, "sound/%s", MVPFile[MVPCount]); AddFileToDownloadsTable(downloadFile); } MVPCount++; } while (kv.GotoNextKey()); kv.Rewind(); delete kv; } if(sAlreadyUsedMVPs.IntValue > 0 && sAlreadyUsedMVPs.IntValue >= MVPCount) { LogError("Error: 'mvp_already_played %d' Convar can't be equal/greater than your Total MVPs (%d). Please decrease the value of 'mvp_already_played' from config file.", sAlreadyUsedMVPs.IntValue, MVPCount); PrintToServer("[SLAYER-MVP] Error: 'mvp_already_played %d' Convar can't be equal/greater than your Total MVPs (%d). Please decrease the value of 'mvp_already_played' from config file.", sAlreadyUsedMVPs.IntValue, MVPCount); } MVPCount--; PrintToServer("[SLAYER MVP] Total '%i' MVP Sounds are now loaded!", MVPCount); } void AddSoundsInConfig(char[] SoundFolderPath, int TotalSoundsToLoad=0, char[] SoundsNamePrefix="", char[] PremiumSoundsFlag="") { int fileCounter = 1; char fileBuffer[512][PLATFORM_MAX_PATH]; char fileExtension[10]; // ------------------------------------------------------------------------------------------------------ // Getting and Saving the names of the sound files in an array which are founded in the given directory // ------------------------------------------------------------------------------------------------------ PrintToServer("------------------------------------------------------------"); DirectoryListing dL = OpenDirectory(SoundFolderPath); while (dL.GetNext(fileBuffer[fileCounter], sizeof(fileBuffer))) { // Geting File Extension GetFileExtension(fileBuffer[fileCounter], fileExtension, sizeof(fileExtension)); // File should have vaild name if(StrEqual(fileBuffer[fileCounter], ".", true) == true || StrEqual(fileBuffer[fileCounter], "..", true) == true)continue; // Sound File should have 'mp3' or 'wav' extension otherwise will not be added if(!StrEqual(fileExtension, "mp3", false) && !StrEqual(fileExtension, "wav", false))continue; // Break the While loop if Sounds of a given amount are loaded if(TotalSoundsToLoad > 0 && fileCounter >= TotalSoundsToLoad){fileCounter++;break;} else fileCounter++; } fileCounter--; // --------------------------------------------------- // Now Adding Founded Sound Files in MVP Config File // --------------------------------------------------- // Creating the Path of the Config file BuildPath(Path_SM, ConfigfilePath, MAX_FILE_LEN, "configs/SLAYER_Mvp.cfg"); // If Config file not exists then give error if(!FileExists(ConfigfilePath)) SetFailState("Can not find config file "%s"!", ConfigfilePath); int AddedSounds = 1; int SoundCounter = 1; char SoundPath[PLATFORM_MAX_PATH]; char SoundName[PLATFORM_MAX_PATH]; KeyValues kv = CreateKeyValues("MVP"); kv.ImportFromFile(ConfigfilePath); kv.Rewind(); // Creating a While Loop while(SoundCounter <= fileCounter) { // if(StrEqual(fileBuffer[SoundCounter], "", false) || StrEqual(fileBuffer[SoundCounter], " ", false))continue; // Copying the Name of the Current Sound File strcopy(SoundName, sizeof(SoundName), fileBuffer[SoundCounter]); // Saving the Extension of the Current Sound File GetFileExtension(SoundName, fileExtension, sizeof(fileExtension)); // Check if the Extension is "mp3" then replace the ".mp3" with "" to get Exact file name if(StrEqual(fileExtension, "mp3", false))ReplaceString(SoundName, sizeof(SoundName), ".mp3", "", false); // Check if the Extension is "wav" then replace the ".wav" with "" to get Exact file name if(StrEqual(fileExtension, "wav", false))ReplaceString(SoundName, sizeof(SoundName), ".wav", "", false); // If any Prefix is given then add it at the start of the Sound Name if(!StrEqual(SoundsNamePrefix, "", false) && !StrEqual(SoundsNamePrefix, " ", false)) Format(SoundName, sizeof(SoundName), "%s %s", SoundsNamePrefix, SoundName); // Check if the given folder path ends with '/' or not. if not then add '/' on the end of the given path and then also add song name. if(CheckPathEndsWithSlash(SoundFolderPath))Format(SoundPath, sizeof(SoundPath), "%s%s", SoundFolderPath, fileBuffer[SoundCounter]); if(!CheckPathEndsWithSlash(SoundFolderPath))Format(SoundPath, sizeof(SoundPath), "%s/%s", SoundFolderPath, fileBuffer[SoundCounter]); // Now remove the 'sound/' from the start of the path ReplaceString(SoundPath, sizeof(SoundPath), "sound/", "", false); // Now Check, is this Sound already exists in the Config file or not. if(!IsSoundExistInCfgFile(ConfigfilePath, SoundPath)) { kv.Rewind(); // If the Sound Name doen't exists then add the new key value if(kv.JumpToKey(SoundName, true)) { // Set the path of the Sound file to newly created key value kv.SetString("file", SoundPath); // if any admin flag is given then also add flag it in key value if(!StrEqual(PremiumSoundsFlag, "", false) && !StrEqual(PremiumSoundsFlag, " ", false)) kv.SetString("flag", PremiumSoundsFlag); } if(sShowFound.BoolValue)PrintToServer("[SLAYER MVP] %d. MVP Added: %s", SoundCounter, fileBuffer[SoundCounter]); AddedSounds++; } else { if(sShowFound.BoolValue)PrintToServer("[SLAYER MVP] %d. MVP already Exists: %s", SoundCounter, fileBuffer[SoundCounter]); } kv.Rewind(); SoundCounter++; } kv.Rewind(); kv.ExportToFile(ConfigfilePath); delete kv; AddedSounds--;SoundCounter--; PrintToServer("------------------------------------------------------------"); PrintToServer("[SLAYER MVP] '%d' MVPs Found in the given Directory", fileCounter); PrintToServer("[SLAYER MVP] '%d' MVPs are now added in the Config file", AddedSounds); PrintToServer("[SLAYER MVP] '%d' MVPs already exist in the Config file", fileCounter-AddedSounds); LoadConfig(); PrintToServer("------------------------------------------------------------"); } public Action Command_MVP(int client,int args) { if(sEnable.BoolValue) { if (IsValidClient(client) && !IsFakeClient(client)) { ShowMainMenu(client); } } else { CPrintToChat(client, "%t %t","Tag", "Disabled"); } return Plugin_Handled; }
void ShowMainMenu(int client) { Menu settings_menu = new Menu(SettingsMenuHandler); char name[200]; if(StrEqual(NameMVP[client], "")) Format(name, sizeof(name), "%T", "No MVP", client); else Format(name, sizeof(name), NameMVP[client]); char menutitle[200]; Format(menutitle, sizeof(menutitle), "%T", "Setting Menu Title", client, name, VolMVP[client]); settings_menu.SetTitle(menutitle); char mvpmenu[200], volmenu[200]; Format(mvpmenu, sizeof(mvpmenu), "%T", "MVP Menu Title", client); Format(volmenu, sizeof(volmenu), "%T", "Vol Menu Title", client); settings_menu.AddItem("mvp", mvpmenu); settings_menu.AddItem("vol", volmenu); settings_menu.Display(client, 0); }
public int SettingsMenuHandler(Menu menu, MenuAction action, int client, int param) { if(action == MenuAction_Select) { char select[1024]; GetMenuItem(menu, param, select, sizeof(select)); if(StrEqual(select, "mvp")) { DisplayMVPMenu(client, 0); } else if(StrEqual(select, "vol")) { DisplayVolMenu(client); } } }
void DisplayMVPMenu(int client, int start) { if (IsValidClient(client) && !IsFakeClient(client)) { Menu mvp_menu = new Menu(MVPMenuHandler); char name[1024]; if(StrEqual(NameMVP[client], "")) Format(name, sizeof(name), "%T", "No MVP", client); else Format(name, sizeof(name), NameMVP[client]); char mvpmenutitle[1024]; Format(mvpmenutitle, sizeof(mvpmenutitle), "%T", "MVP Menu Title 2", client, name); mvp_menu.SetTitle(mvpmenutitle); char nomvp[200]; Format(nomvp, sizeof(nomvp), "%T", "No MVP", client); char random_mvp[200]; Format(random_mvp, sizeof(random_mvp), "%t", "Random MVP"); char premium_mvp[200]; Format(premium_mvp, sizeof(premium_mvp), ">> %t", "Premium MVP"); char player_mvp[200]; Format(player_mvp, sizeof(player_mvp), ">> %t", "Player MVP"); mvp_menu.AddItem("", nomvp); mvp_menu.AddItem(premium_mvp, premium_mvp); mvp_menu.AddItem(player_mvp, player_mvp); mvp_menu.AddItem(random_mvp, random_mvp); for(int i = 1; i <= MVPCount; i++) { if(StrEqual(MVPFlag[i], "") || StrEqual(MVPFlag[i], " ")) // Add Only Those MVPs which don't have any admin flag and steamid { if(!MVPSteamID[i].Length)mvp_menu.AddItem(MVPName[i], MVPName[i]); } } mvp_menu.ExitBackButton = true; mvp_menu.DisplayAt(client, start, 0); } }
public int MVPMenuHandler(Menu menu, MenuAction action, int client,int param) { if(action == MenuAction_Select) { char mvp_name[1024]; GetMenuItem(menu, param, mvp_name, sizeof(mvp_name)); char random_mvp[200]; Format(random_mvp, sizeof(random_mvp), "%t", "Random MVP"); char premium_mvp[200]; Format(premium_mvp, sizeof(premium_mvp), ">> %t", "Premium MVP"); char player_mvp[200]; Format(player_mvp, sizeof(player_mvp), ">> %t", "Player MVP"); if(StrEqual(mvp_name, "")) { CPrintToChat(client, "%t %t", "Tag","No Selected"); Selected[client] = 0; NameMVP[client] = ""; SetClientCookie(client, mvp_cookie, ""); DisplayMVPMenu(client, menu.Selection); } else if(StrEqual(mvp_name, random_mvp)) // if Client Select Random Mvp Option { Selected[client] = -1; CPrintToChat(client, "%t %t", "Tag","Selected", random_mvp); strcopy(NameMVP[client], sizeof(NameMVP[]), random_mvp); SetClientCookie(client, mvp_cookie, random_mvp); DisplayMVPMenu(client, menu.Selection); } else if(StrEqual(mvp_name, premium_mvp)) // If Client Select Premium Mvp Option { DisplayPremiumMvpMenu(client, 0); } else if(StrEqual(mvp_name, player_mvp)) // If Client Select other player MVP Option { DisplayClientMenu(client); } else { if(sPreview.BoolValue) { MenuSelect[client] = FindMVPIDByName(mvp_name); PreviewMVP(client); } else { int id = FindMVPIDByName(mvp_name); if(CanUseMVP(client, id)) { CPrintToChat(client, "%t %t", "Tag", "Selected", mvp_name); Selected[client] = id; strcopy(NameMVP[client], sizeof(NameMVP[]), mvp_name); SetClientCookie(client, mvp_cookie, mvp_name); } else CPrintToChat(client, "%t %t", "Tag", "No Flag", mvp_name); } } } else if (action == MenuAction_Cancel && param == MenuCancel_ExitBack) { ShowMainMenu(client); } } void DisplayClientMenu(int client) { if (IsValidClient(client) && !IsFakeClient(client)) { Menu player_menu = new Menu(PlayerMenuHandler); char mvpmenutitle[200]; Format(mvpmenutitle, sizeof(mvpmenutitle), "%t", "Player MVP"); player_menu.SetTitle(mvpmenutitle); AddTargetsToMenu2(player_menu, 0,COMMAND_FILTER_NO_BOTS); player_menu.ExitBackButton = true; player_menu.DisplayAt(client, 0, 0); } }
public int PlayerMenuHandler(Menu menu, MenuAction action, int client,int param) { if(action == MenuAction_Select) { char steamid[50]; int target; GetMenuItem(menu, param, steamid, sizeof(steamid)); int userid = StringToInt(steamid); if ((target = GetClientOfUserId(userid)) == 0) { CPrintToChat(client, "%t {white}Player no longer {darkred]Available","Tag"); } else { int id = Selected[target]; if(CanUseMVP(client, id)) { CPrintToChat(client, "%t %t", "Tag", "Selected", MVPName[id]); Selected[client] = id; strcopy(NameMVP[client], sizeof(NameMVP[]), MVPName[id]); SetClientCookie(client, mvp_cookie, MVPName[id]); } else { CPrintToChat(client, "%t %t", "Tag", "No Flag", MVPName[id]); } } DisplayMVPMenu(client, 0); } else if (action == MenuAction_Cancel && param == MenuCancel_ExitBack)DisplayMVPMenu(client, 0); } void DisplayPremiumMvpMenu(int client, int start) { if (IsValidClient(client) && !IsFakeClient(client)) { Menu premium_mvp_menu = new Menu(PremiumMVPMenuHandler); char name[200]; if(StrEqual(NameMVP[client], "")) Format(name, sizeof(name), "%t", "No MVP"); else Format(name, sizeof(name), NameMVP[client]); char mvpmenutitle[200]; Format(mvpmenutitle, sizeof(mvpmenutitle), "%t", "MVP Menu Title 2", name); int count_mvp = 0; for(int i = 1; i <= MVPCount; i++) { if(CanUsePremiumMVP(client, i)) // Show Only those Premium MVPs to which Client have Access by admin flags/steamid { premium_mvp_menu.AddItem(MVPName[i], MVPName[i]); count_mvp++; } else { if(sShowPremium.BoolValue && IsPremiumMVP[i]) { premium_mvp_menu.AddItem(MVPName[i], MVPName[i], ITEMDRAW_DISABLED); count_mvp++; } } } if(count_mvp == 0) // If Client don't have access to any premium MVPs { char no_mvp[100]; Format(no_mvp, sizeof(no_mvp), "%t", "No Premium MVP"); premium_mvp_menu.AddItem(no_mvp, no_mvp, ITEMDRAW_DISABLED); } else premium_mvp_menu.SetTitle(mvpmenutitle); premium_mvp_menu.ExitBackButton = true; premium_mvp_menu.DisplayAt(client, start, 0); } } public int PremiumMVPMenuHandler(Menu menu, MenuAction action, int client,int param) { if(action == MenuAction_Select) { char mvp_name[1024]; GetMenuItem(menu, param, mvp_name, sizeof(mvp_name)); if(sPreview.BoolValue) { MenuSelect[client] = FindMVPIDByName(mvp_name); PreviewMVP(client); } else { int id = FindMVPIDByName(mvp_name); if(CanUseMVP(client, id)) { CPrintToChat(client, "%t %t", "Tag", "Selected", mvp_name); Selected[client] = id; strcopy(NameMVP[client], sizeof(NameMVP[]), mvp_name); SetClientCookie(client, mvp_cookie, mvp_name); } else { CPrintToChat(client, "%t %t", "Tag", "No Flag", mvp_name); } } } else if (action == MenuAction_Cancel && param == MenuCancel_ExitBack)DisplayMVPMenu(client, 0); } void PreviewMVP(int client) { if (IsValidClient(client) && !IsFakeClient(client)) { Menu preview_mvp_menu = new Menu(PreviewMVPMenuHandler); char preview[50]; Format(preview, sizeof(preview), "%t", "Preview Menu"); char select[50]; Format(select, sizeof(select), "%t", "Select Menu"); char link[50]; Format(link, sizeof(link), "%t", "Link Menu"); int id = MenuSelect[client]; preview_mvp_menu.AddItem(select, select); preview_mvp_menu.AddItem(preview, preview); if(!StrEqual(MVPLink[id], "") && !StrEqual(MVPLink[id], " "))preview_mvp_menu.AddItem(link, link); preview_mvp_menu.ExitBackButton = true; preview_mvp_menu.DisplayAt(client, 0, 0); } } public int PreviewMVPMenuHandler(Menu menu, MenuAction action, int client,int param) { if(action == MenuAction_Select) { char option[50]; GetMenuItem(menu, param, option, sizeof(option)); char preview[50]; Format(preview, sizeof(preview), "%t", "Preview Menu"); char select[50]; Format(select, sizeof(select), "%t", "Select Menu"); char link[50]; Format(link, sizeof(link), "%t", "Link Menu"); int id = MenuSelect[client]; if(StrEqual(option, select)) { if(CanUseMVP(client, id)) // If client Selecte 'Selecte Mvp' Option { CPrintToChat(client, "%t %t", "Tag", "Selected", MVPName[id]); Selected[client] = id; strcopy(NameMVP[client], sizeof(NameMVP[]), MVPName[id]); SetClientCookie(client, mvp_cookie, MVPName[id]); } else { CPrintToChat(client, "%t %t", "Tag", "No Flag", MVPName[id]); } DisplayMVPMenu(client, 0); } else if(StrEqual(option, preview)) // if Client Select Preview Mvp Option { char sound[1024]; Format(sound, sizeof(sound), "%s", MVPFile[id]); // Stop MVPs from Playing if they are playing StopPlayingMVPs(client); // Play MVP Anthem EmitSoundToClient(client, sound, SOUND_FROM_PLAYER, SNDCHAN_STATIC, SNDLEVEL_NONE, _, VolMVP[client]); if(MvpPreviewTimer[client] != null)delete MvpPreviewTimer[client]; // Check is there already Auto stop MVP timer is running if then delete it MvpPreviewTimer[client] = CreateTimer(sPreviewTime.FloatValue, MvpPreviewTimerHandle, client, TIMER_FLAG_NO_MAPCHANGE);// Create Auto Stop MVP Anthem Timer PreviewMVP(client); } else if(StrEqual(option, link)) // if Client Select Mvp Link Option { CPrintToChat(client, "%t {default}Link: %s", "Tag", MVPLink[id]); PreviewMVP(client); } } else if (action == MenuAction_Cancel && param == MenuCancel_ExitBack)DisplayMVPMenu(client, 0); } public Action MvpPreviewTimerHandle(Handle timer, any client) { if(IsValidClient(client) && !IsFakeClient(client)) { char sound[1024]; Format(sound, sizeof(sound), "%s", MVPFile[MenuSelect[client]]); StopSound(client, SNDCHAN_STATIC, sound); // Mute sound } MvpPreviewTimer[client] = null; } // Stop All MVPs file which are playing void StopPlayingMVPs(int client) { if(IsValidClient(client) && !IsFakeClient(client)) { char sound[1024]; for(int i = 1; i <= MVPCount; i++) { Format(sound, sizeof(sound), "%s", MVPFile[i]); StopSound(client, SNDCHAN_STATIC, sound); // Mute sound } } } void DisplayVolMenu(int client) { if (IsValidClient(client) && !IsFakeClient(client)) { Menu vol_menu = new Menu(VolMenuHandler); char vol[1024]; if(VolMVP[client] > 0.00) Format(vol, sizeof(vol), "%.2f", VolMVP[client]); else Format(vol, sizeof(vol), "%T", "Mute", client); char menutitle[1024]; Format(menutitle, sizeof(menutitle), "%T", "Vol Menu Title 2", client, vol); vol_menu.SetTitle(menutitle); char mute[1024]; Format(mute, sizeof(mute), "%T", "Mute", client); vol_menu.AddItem("0", mute); vol_menu.AddItem("0.1", "10%"); vol_menu.AddItem("0.2", "20%"); vol_menu.AddItem("0.4", "40%"); vol_menu.AddItem("0.6", "60%"); vol_menu.AddItem("0.8", "80%"); vol_menu.AddItem("1.0", "100%"); vol_menu.ExitBackButton = true; vol_menu.Display(client, 0); } }
public int VolMenuHandler(Menu menu, MenuAction action, int client,int param) { if(action == MenuAction_Select) { char vol[1024]; GetMenuItem(menu, param, vol, sizeof(vol)); VolMVP[client] = StringToFloat(vol); CPrintToChat(client, "%t %t", "Tag", "Volume 2", VolMVP[client]); SetClientCookie(client, mvp_cookie2, vol);
DisplayVolMenu(client); } else if (action == MenuAction_Cancel && param == MenuCancel_ExitBack) { ShowMainMenu(client); } }
public Action Command_MVPVol(int client,int args) { if(sEnable.BoolValue) { if (IsValidClient(client)) { char arg[20]; float volume; if (args < 1) { CPrintToChat(client, "%t %t", "Tag", "Volume 1", client); return Plugin_Handled; } GetCmdArg(1, arg, sizeof(arg)); volume = StringToFloat(arg); if (volume < 0.0 || volume > 1.0) { CPrintToChat(client, "%t %t", "Tag", "Volume 1", client); return Plugin_Handled; } VolMVP[client] = StringToFloat(arg); CPrintToChat(client, "%t %t", "Tag", "Volume 2", VolMVP[client]); SetClientCookie(client, mvp_cookie2, arg); } } else { CPrintToChat(client, "%t %t","Tag", "Disabled"); } return Plugin_Handled; }
stock bool IsValidClient(int client) { if (client <= 0) return false; if (client > MaxClients) return false; if (!IsClientConnected(client)) return false; return IsClientInGame(client); }
// Return True if MVP is not already Used stock bool CheckIsMvpAlreadyUsed(int id) { if(sAlreadyUsedMVPs.IntValue > 0) { for(int i = 1; i <= sAlreadyUsedMVPs.IntValue; i++) { if(StrEqual(MVPAlreadyUsed[i], MVPName[id]))return false; } return true; } else return true; }
bool CanUseMVP(int client, int id) { if(!IsPremiumMVP[id])return true; else { if(IsFakeClient(client) && !sAllowBot.BoolValue)return false; else if(IsFakeClient(client) && sAllowBot.BoolValue)return true; if(CanUsePremiumMVP(client, id))return true; else return false; // If he has nothing he was a totally normal player then he can't use this mvp } } stock bool CanUsePremiumMVP(int client, int id) { if(!IsPremiumMVP[id])return false; if(ClientHaveSteamIDAccess(client, id))return true; // Check is Client have MVP access by Steam ID else if(!StrEqual(MVPFlag[id], "") && !StrEqual(MVPFlag[id], " ")) // If there not any admin flag restriction then check client have those flags or not { if(CheckCommandAccess(client, "mvp", ReadFlagString(MVPFlag[id]), true))return true; else return false; } else return false; }
stock bool ClientHaveSteamIDAccess(int client, int id) { if(MVPSteamID[id].Length) // If the MVP has any steam id restrictions { char steamid[64]; GetClientAuthId(client, AuthId_Engine, steamid, sizeof(steamid)); if(!IsFakeClient(client) && MVPSteamID[id].FindString(steamid) != -1)return true; else return false; } else return false; // If the MVP has not any steam id restrictions then return }
stock GetFileExtension(char[] file_name, char[] extension, int len) { int i, j, k;
for (i = strlen(file_name) - 1; i >= 0; i--) { if (file_name[i] == '.') { if (j == 0) j = i + 1; else break; } }
k = 0; for (i = j; i < strlen(file_name) && k < len - 1; i++) { extension[k++] = file_name[i]; }
extension[k] = '\0'; } stock bool CheckPathEndsWithSlash(char[] str) { char[] slash = "/"; int len = strlen(str); if (len == 0) { return false; // Empty string } else if (StrEqual(str[len - 1], slash)) { return true; // String ends with a slash } else { return false; // String does not end with a slash } }
stock bool IsSoundExistInCfgFile(char[] CfgFilePath, char[] SoundPath) { if(!FileExists(CfgFilePath)) { SetFailState("Can not find config file "%s"!", CfgFilePath); return false; } char CfgSoundPath[100]; KeyValues kv = CreateKeyValues("MVP"); kv.ImportFromFile(CfgFilePath); // Now Reading Config File if(kv.GotoFirstSubKey()) { do { kv.GetString("file", CfgSoundPath, sizeof(CfgSoundPath)); // Check is Sound Exist by Path in CFG File if(StrEqual(CfgSoundPath, SoundPath, false)) { return true; } } while (kv.GotoNextKey()); kv.Rewind(); delete kv; } return false; }
can you please compile for me, i have a problem with my compiler, dont work, i try online and local, if you have a compiler.exe can u put it please with this one compiler, i give a vodka
__________________
Last edited by DarkDeviL; 04-30-2023 at 11:56.
Reason: Adjusted QUOTE to CODE/PHP tags
|
|