Jump to content

NOWY SZABLON NA FORUM

Wprowadziliśmy nowy szablon na forum!

Prosimy o zgłaszanie znalezionych błędów.

Przejdź do tematu

NABÓR DO ADMINISTRACJI

Z dniem 20.04.2020 został otwarty nabór do Administracji forum.

Jeżeli chcesz nam pomóc w rozwoju nie zwlekaj, złóz podanie już teraz!

Przejdź do tematu

VIP ZA FREE!

Grasz na naszych serwerach i chcesz dostać darmowego VIP'a?

Odwiedź dział "Odbierz darmowego VIP'a" na wybranym przez Ciebie serwerze !

Przejdź do tematu
# Nickname Score Time Played
Sahito🧠 33 kills 46 minutes and 10 seconds
n3LLy // Rzeznia.pro 27 kills 46 minutes and 56 seconds
Adelay 15 kills 25 minutes and 12 seconds
xSmQ 14 kills 35 minutes and 41 seconds
ziabol 12 kills 12 minutes and 11 seconds
NeoN Rzeznia.Pro 11 kills 49 minutes and 35 seconds
♥Amelka♥ Rzeznia.Pro 10 kills 13 minutes and 26 seconds
Jakubeaw Key-drop.com.pl 9 kills 49 minutes and 35 seconds
BartoszPL 7 kills 9 minutes and 55 seconds
Shu 7 kills 33 minutes and 23 seconds
ścibas Rzeznia.Pro 7 kills 49 minutes and 36 seconds
rurzowo włosy 6 kills 48 minutes and 53 seconds
Lisu 5 kills 19 minutes and 50 seconds
Adrian ♥999♥ 4 kills 23 minutes and 20 seconds
F Rzeznia.Pro Rzeznia.Pro 4 kills 49 minutes and 35 seconds
pyrax_omen 3 kills 7 minutes and 55 seconds
Jabłkowy Cymes 1 kill 14 minutes and 3 seconds
D1YaN 0 kills 33 minutes and 21 seconds
Death__3 Rzeznia.Pro 0 kills 36 minutes and 21 seconds
KusiaK 0 kills 48 minutes and 10 seconds
Rzeznia.Pro - GOTV 0 kills 15 hours, 2 minutes and 29 seconds
Xsereczek Rzeznia.Pro 0 kills 2 minutes and 33 seconds
kaktusRzeznia.ProRzeznia.Pro 0 kills 29 minutes and 9 seconds
de_mirage
# Nickname Score Time Played
Czasoumilacz 0 kills
TS3Gamer.pl \p @BOT #1 0 kills
â ª Witaj na TS3Gamer.pl â ª 0 kills
TS3Gamer.pl \p @BOT #2 0 kills
TS3Gamer.pl \p Impreza 0 kills
TS3Gamer.pl \p Disco Polo 0 kills
TS3Gamer.pl \p Rap&Hip-Hop 0 kills
MÅ ody Boss 0 kills
TomyShell 0 kills
Takuto 0 kills
dzej317 0 kills
Adam MaÅ ysz 0 kills
Tooful 0 kills
Wladimir Kliczko 0 kills
JPoly 0 kills
Matiks 0 kills
niemiec 0 kills
n/a
Sign in to follow this  
FareN

[CS:GO] MVP Music - Własna muzyka MVP

Recommended Posts

Właściciel

O Pluginie:

  • Plugin umożliwia ustawienie własnej piosenki MVP.

 

Komendy:

  • !mvp - Główne menu.
  • !testmvp - Puszczenie losowej muzyki z folderu z piosenkami.

 

Instalacja:

  • Plik .smx wrzucamy do: addons/sourcemod/plugins/
  • Plik .cfg wrzucamy do: addons/sourcemod/scripting/
  • Folder mvp_yamakashi wrzucamy do : csgo/sound/

 

Kod:


/* [ Includes ] */
#include <sourcemod>
#include <sdktools>
#include <multicolors>
#include <clientprefs>

/* [ Compiler Options ] */
#pragma newdecls required
#pragma semicolon 1

/* [ Defines ] */
#define PluginTag 	"{darkred}[ {lightred}★{darkred} MVP Music {lightred}★ {darkred}]{default}"

/* [ Handles ] */
Handle g_hCookie, g_hCookie2, g_hCookie3, g_hCookie4;

/* [ Arrays ] */
ArrayList g_arSounds;
ArrayList g_arFlag;
ArrayList g_arMusicName;
ArrayList g_arPlayerMusic;

/* [ Chars ] */
char g_sLogFile[256];

/* [ Integers ] */
int g_iClientMusic[MAXPLAYERS + 1];
int g_iClientVolume[MAXPLAYERS + 1];
int g_iFirstConnect[MAXPLAYERS + 1];
int g_iMusics;

/* [ Floats ] */
float g_fClientVolume[MAXPLAYERS + 1];

/* [ Plugin Author and Information ] */
public Plugin myinfo = 
{
	name = "[CS:GO] MVP Music", 
	author = "Yamakashi", 
	description = "Plugin umożliwia ustawienie własnej muzyki MVP.", 
	version = "1.0", 
	url = "https://steamcommunity.com/id/yamakashisteam"
};

/* [ Plugin Startup ] */
public void OnPluginStart()
{
	/* [ Commands ] */
	RegConsoleCmd("sm_mvp", MvpMusic_CMD, "[MVP Music] Główne menu");
	RegConsoleCmd("sm_mvpmusic", MvpMusic_CMD, "[MVP Music] Główne menu");
	RegConsoleCmd("sm_music", MvpMusic_CMD, "[MVP Music] Główne menu");
	RegConsoleCmd("sm_muzyka", MvpMusic_CMD, "[MVP Music] Główne menu");
	RegConsoleCmd("sm_testmvp", TestMvp_CMD, "[MVP Music] Puszcza losową piosenkę");
	
	/* [ Cookies ] */
	g_hCookie = RegClientCookie("yamakashi_mvpmusic", "Głośność pisoenki", CookieAccess_Private);
	g_hCookie2 = RegClientCookie("yamakashi_mvpmusic2", "Wyświetlana głośność piosenki", CookieAccess_Private);
	g_hCookie3 = RegClientCookie("yamakashi_mvpmusic3", "Numer piosenki", CookieAccess_Private);
	g_hCookie4 = RegClientCookie("yamakashi_mvpmusic4", "Pierwsze połączenie", CookieAccess_Private);
	
	/* [ Hooks ] */
	HookEvent("round_mvp", Event_RoundMVP);
	
	/* [ Arrays ] */
	g_arSounds = new ArrayList(512);
	g_arFlag = new ArrayList(32);
	g_arMusicName = new ArrayList(64);
	g_arPlayerMusic = new ArrayList(64);
	
	/* [ Check Player ] */
	for (int i = 1; i <= MaxClients; i++)
		if (IsValidClient(i))
			OnClientCookiesCached(i);
			
	/* [ LogFile ] */
	char sDate[16];
	FormatTime(sDate, sizeof(sDate), "%Y-%m-%d", GetTime());
	BuildPath(Path_SM, g_sLogFile, sizeof(g_sLogFile), "logs/yLogs/%s.log", sDate);
}

/* [ Standart Actions ] */
public void OnClientAuthorized(int client, const char[] sAuth)
{
	g_iClientMusic[client] = -1;
	g_iClientVolume[client] = 100;
	g_fClientVolume[client] = 1.0;
}

public void OnClientPutInServer(int client)
{
	g_iFirstConnect[client] = 1;
}

public void OnClientCookiesCached(int client)
{
	char sValue[16];
	GetClientCookie(client, g_hCookie4, sValue, sizeof(sValue));
	g_iFirstConnect[client] = StringToInt(sValue);
	if(!g_iFirstConnect[client])
	{
		g_iClientMusic[client] = -1;
		g_iClientVolume[client] = 100;
		g_fClientVolume[client] = 1.0;
		return;
	}	
	GetClientCookie(client, g_hCookie, sValue, sizeof(sValue));
	g_fClientVolume[client] = StringToFloat(sValue);
	GetClientCookie(client, g_hCookie2, sValue, sizeof(sValue));
	g_iClientVolume[client] = StringToInt(sValue);
	GetClientCookie(client, g_hCookie3, sValue, sizeof(sValue));
	g_iClientMusic[client] = StringToInt(sValue);
}

public void OnClientDisconnect(int client)
{
	if (AreClientCookiesCached(client))
	{
		char sValue[16];
		Format(sValue, sizeof(sValue), "%.2f", g_fClientVolume[client]);
		SetClientCookie(client, g_hCookie, sValue);
		Format(sValue, sizeof(sValue), "%d", g_iClientVolume[client]);
		SetClientCookie(client, g_hCookie2, sValue);
		Format(sValue, sizeof(sValue), "%d", g_iClientMusic[client]);
		SetClientCookie(client, g_hCookie3, sValue);
		Format(sValue, sizeof(sValue), "%d", g_iFirstConnect[client]);
		SetClientCookie(client, g_hCookie4, sValue);
	}
	g_iClientMusic[client] = -1;
	g_iClientVolume[client] = 100;
	g_fClientVolume[client] = 1.0;
	g_iFirstConnect[client] = 0;
}

public void OnMapStart()
{
	MVP_LoadMusic();
	MVP_Initialize_Items();
	MVP_LoadTestMvp(g_arSounds);
}

public void OnMapEnd()
{
	g_arFlag.Clear();
	g_arMusicName.Clear();
	g_arPlayerMusic.Clear();
}

/* [ Events ] */
public Action Event_RoundMVP(Event event, const char[] name, bool dontBroadcast)
{
	int client = GetClientOfUserId(event.GetInt("userid"));
	if (!IsValidClient(client))
		return Plugin_Continue;
	
	char sName[128], sFile[128];
	g_arMusicName.GetString(g_iClientMusic[client], sName, sizeof(sName));
	g_arPlayerMusic.GetString(g_iClientMusic[client], sFile, sizeof(sFile));
	if (g_iClientMusic[client] > -1)
	{
		CPrintToChatAll("%s {lime}Aktualnie leci piosenka: {lightred}%s{lime}, która należy do gracza {lightred}%N{lime}.", PluginTag, sName, client);
		for(int i = 1; i < MaxClients; i++)
			if (IsValidClient(i))
			{
				PrecacheSound(sFile, true);
				ClientCommand(i, "playgamesound Music.StopAllMusic");
				EmitSoundToClient(i, sFile, _, _, _, _, g_fClientVolume[i]);
			}
	}
	return Plugin_Continue;
}

/* [ Commands ] */
public Action MvpMusic_CMD(int client, int args)
{
	char sBuffer[512], sName[128];
	if(g_iClientMusic[client] > -1)
		g_arMusicName.GetString(g_iClientMusic[client], sName, sizeof(sName));
	Menu mvp = new Menu(MvpMusic_Handler);
	
	Format(sBuffer, sizeof(sBuffer), "[ # MVP Music :: Główne Menu # ]\n");
	if (g_iClientMusic[client] == -1)
		Format(sBuffer, sizeof(sBuffer), "%s\nAktualna piosenka: Brak\n", sBuffer);
	else
		Format(sBuffer, sizeof(sBuffer), "%s\nAktualna piosenka: %s\n", sBuffer, sName);
	Format(sBuffer, sizeof(sBuffer), "%s\nAktualna głośność: %d%%%", sBuffer, g_iClientVolume[client]);
	mvp.SetTitle(sBuffer);
	mvp.AddItem("1", "»Wybierz muzykę.");
	mvp.AddItem("2", "»Dostosuj głośność");
	mvp.Display(client, MENU_TIME_FOREVER);
}

public int MvpMusic_Handler(Menu menu, MenuAction action, int client, int position)
{
	if (action == MenuAction_Select)
	{
		char sItem[32];
		menu.GetItem(position, sItem, sizeof(sItem));
		if (StrEqual(sItem, "1"))
			ShowMvpList(client);
		else if (StrEqual(sItem, "2"))
			Mvp_ChangeVolume(client);
	}
	else if (action == MenuAction_End)
		menu.Close();
}

public void ShowMvpList(int client)
{
	char sNumber[128], sText[512], sBuffer[512], sFlag[32];
	Menu mvp_music = new Menu(ShowMvpList_Handler);
	mvp_music.SetTitle("[ # MVP Music :: Wybierz Piosenkę # ]");
	if(g_iClientMusic[client] > -1)
		mvp_music.AddItem("default", "Usuń piosenkę");
	for(int i = 0; i < g_iMusics; i++)
	{
		Format(sNumber, sizeof(sNumber), "%d", i);
		if(g_iClientMusic[client] == i)
		{
			g_arMusicName.GetString(i, sText, sizeof(sText));
			Format(sBuffer, sizeof(sBuffer), "%s | [ # Aktualna # ]", sText);
			mvp_music.AddItem(sNumber, sBuffer, ITEMDRAW_DISABLED);
		}
		else
		{
			g_arFlag.GetString(i, sFlag, sizeof(sFlag));
			g_arMusicName.GetString(i, sText, sizeof(sText));
			mvp_music.AddItem(sNumber, sText, CheckFlags(client, sFlag));
		}
	}
	mvp_music.Display(client, MENU_TIME_FOREVER);
}

public int ShowMvpList_Handler(Menu menu, MenuAction action, int client, int position)
{
	if (action == MenuAction_Select)
	{
		char sItem[512];
		menu.GetItem(position, sItem, sizeof(sItem));
		int music = StringToInt(sItem);
		
		if(StrEqual(sItem, "default"))
		{
			g_iClientMusic[client] = -1;
			CPrintToChat(client, "%s Usunąłeś swoją piosenkę.", PluginTag);
		}
		else
		{
			g_iClientMusic[client] = music;
			char sName[128];
			g_arMusicName.GetString(g_iClientMusic[client], sName, sizeof(sName));
			CPrintToChat(client, "%s Ustawiłeś piosenkę: {lime}%s{default} .", PluginTag, sName);
		}
		ShowMvpList(client);
	}
	else if (action == MenuAction_End)
		menu.Close();
}

public void Mvp_ChangeVolume(int client)
{
	char sBuffer[512];
	Menu volume = new Menu(ChangeVolume_Handler);
	Format(sBuffer, sizeof(sBuffer), "[ # MVP Music :: Zmiana głośności # ]");
	Format(sBuffer, sizeof(sBuffer), "%s\nAktualna głośność: %d%%%", sBuffer, g_iClientVolume[client]);
	Format(sBuffer, sizeof(sBuffer), "%s\nAby przetestować głośność wpisz !testmvp\n ", sBuffer);
	volume.SetTitle(sBuffer);
	volume.AddItem("1", "Pogłoś o 10%");
	volume.AddItem("2", "Ścisz o 10%");
	volume.AddItem("3", "Wycisz");
	volume.Display(client, MENU_TIME_FOREVER);
}

public int ChangeVolume_Handler(Menu menu, MenuAction action, int client, int position)
{
	if (action == MenuAction_Select)
	{
		char sItem[32];
		menu.GetItem(position, sItem, sizeof(sItem));
		if (StrEqual(sItem, "1"))
		{
			g_fClientVolume[client] = g_fClientVolume[client] + 0.1;
			g_iClientVolume[client] += 10;
			if (g_fClientVolume[client] > 1.0)
			{
				g_fClientVolume[client] = 1.0;
				g_iClientVolume[client] = 100;
			}
		}
		else if (StrEqual(sItem, "2"))
		{
			g_fClientVolume[client] = g_fClientVolume[client] - 0.1;
			g_iClientVolume[client] -= 10;
			if(g_fClientVolume[client] < 0.0)
			{
				g_fClientVolume[client] = 0.0;
				g_iClientVolume[client] = 0;
			}
		}
		else if(StrEqual(sItem, "3"))
		{
			g_fClientVolume[client] = 0.0;
			g_iClientVolume[client] = 0;
		}
		
		Mvp_ChangeVolume(client);
		
	}
	else if (action == MenuAction_End)
		menu.Close();
}

public Action TestMvp_CMD(int client, int args)
{
	char szSound[512] = "mvp_yamakashi/";
	GetSound(g_arSounds, szSound, sizeof(szSound));
	
	ClientCommand(client, "playgamesound Music.StopAllMusic");
	EmitSoundToClient(client, szSound, _, _, _, _, g_fClientVolume[client]);
}

/* [ Config ] */
public void MVP_LoadMusic()
{
	int Music_ID;
	KeyValues kv = CreateKeyValues("MVP Musics");
	char sPathMusicsCfg[256], stPathMusicsCfg[256];
	
	Format(stPathMusicsCfg, sizeof(stPathMusicsCfg), "configs/MvpMusics.cfg");
	BuildPath(Path_SM, sPathMusicsCfg, sizeof(sPathMusicsCfg), stPathMusicsCfg);

	kv.ImportFromFile(sPathMusicsCfg);
	if (!kv.GotoFirstSubKey())
	{
		LogError("[X MVP MUSIC X]	Nie znaleziono piosenek.");
		SetFailState("[X MVP MUSIC X]	Nie znaleziono piosenek.");
		return;
	}
	do
	{
		char sBuffer[128];
		kv.GetSectionName(sBuffer, sizeof(sBuffer));
		g_arMusicName.PushString(sBuffer);
		kv.GetString("song_file", sBuffer, sizeof(sBuffer));
		g_arPlayerMusic.PushString(sBuffer);
		kv.GetString("flag", sBuffer, sizeof(sBuffer));
		g_arFlag.PushString(sBuffer);
		Music_ID++;
	} while (kv.GotoNextKey());
	delete kv;
	g_iMusics = Music_ID;
	LogMessage("[✔ MVP MUSIC ✔]	| Załadowano %i piosenek z configu!", Music_ID);
	return;
}

public void MVP_Initialize_Items()
{
	KeyValues kv = CreateKeyValues("MVP Musics");
	if (!kv.ImportFromFile("configs/MvpMusics.cfg"))return;
	if (!kv.GotoFirstSubKey())return;
	do
	{
		char sMp3Path[128], sBuffer[512];
		kv.GetString("mp3", sMp3Path, sizeof(sMp3Path));
		Format(sBuffer, sizeof(sBuffer), "sound/%s", sMp3Path);
		AddFileToDownloadsTable(sBuffer);
		
	} while (kv.GotoNextKey());
	delete kv;
}

/* [ Helpers ] */
int MVP_LoadTestMvp(ArrayList arraySounds)
{
	arraySounds.Clear();
	char soundPathFull[PLATFORM_MAX_PATH];
	Format(soundPathFull, sizeof(soundPathFull), "sound/mvp_yamakashi/");
	DirectoryListing pluginsDir = OpenDirectory(soundPathFull);
	
	if (pluginsDir != null)
	{
		char fileName[128];
		while (pluginsDir.GetNext(fileName, sizeof(fileName)))
		{
			int extPosition = strlen(fileName) - 4;
			if (StrContains(fileName, ".mp3", false) == extPosition)
			{
				char soundName[512];
				Format(soundName, sizeof(soundName), "sound/mvp_yamakashi/%s", fileName);
				AddFileToDownloadsTable(soundName);
				
				Format(soundName, sizeof(soundName), "mvp_yamakashi/%s", fileName);
				PrecacheSound(soundName, true);
				arraySounds.PushString(soundName);
			}
		}
	}
	return arraySounds.Length;
}

bool GetSound(ArrayList arraySounds, char[] szSound, int soundSize)
{
	if (arraySounds.Length <= 0)return false;
	
	int soundToPlay = GetRandomInt(0, arraySounds.Length - 1);
	
	arraySounds.GetString(soundToPlay, szSound, soundSize);
	
	if (arraySounds.Length == 0)
		MVP_LoadTestMvp(arraySounds);
	
	return true;
}

public int CheckFlags(int client, const char[] sFlag)
{
	if(GetUserFlagBits(client) & ADMFLAG_ROOT) return ITEMDRAW_DEFAULT;
	if(GetUserFlagBits(client) & ReadFlagString(sFlag)) return ITEMDRAW_DEFAULT;
	if(StrEqual(sFlag, "")) return ITEMDRAW_DEFAULT;
	
	return ITEMDRAW_DISABLED;
}

stock bool IsValidClient(int client)
{
	if(client <= 0 ) return false;
	if(client > MaxClients) return false;
	if(!IsClientConnected(client)) return false;
	if(IsFakeClient(client)) return false;
	return IsClientInGame(client);
}

 

Download:

MVP Music.rar

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

Pamiętaj CS-Hejdz.pl to nie tylko forum !

Dołącz do nas na:

×
×
  • Create New...