Discord sunucumuz açılmıştır, hepinizi bekleriz

https://discord.gg/43gGDQe6tS

Kural İhlali

Eklenti sorunlarınız ve özel eklenti istekleriniz

Moderatör: Moderatörler


Konu Sahibi
tepegoz
Mesajlar: 266
Kayıt: Pzr Kas 19, 2017 2:06 am
Clan İsmi: -

Kural İhlali

Mesaj gönderen tepegoz »

Eklentiyi kural ihlalinden geçirebilecek var mı ?
mapchooser_multimod.sma

Kod: Tümünü seç

/*

 This code is based on mapchooser.sma by the AMXX Dev Team
 and the majority of the default map chooser is unchanged.

*/

#include <amxmodx>
#include <amxmisc>

#define SELECTMAPS  5
#define STR_LEN 64 // Max length of plugin filename including .amxx
#define MODS_MAX 4
#define MODS_STRLEN 12

#define charsof(%1) (sizeof(%1)-1)

new Array:g_mapName;
new g_mapNums[MODS_MAX];
new g_iModMapStart[MODS_MAX]
new g_iMapPointer = 0

new g_nextName[SELECTMAPS]
new g_voteCount[SELECTMAPS + 2]
new g_mapVoteNum
new g_teamScore[2]
new g_lastMap[32]

new g_coloredMenus
new bool:g_selected = false

new g_szModNames[MODS_MAX][MODS_STRLEN+1]
new g_iModsNum = 0
new g_VoteModCount[MODS_MAX+1]

new g_iNextMod

public plugin_init()
{
	register_plugin("Nextmap Chooser: MultiMod", "1.0", "Fysiks")
	register_cvar("MapChooserMultiMod", "v2.0 by Fysiks", FCVAR_SERVER|FCVAR_SPONLY)
	register_dictionary("mapchooser.txt")
	register_dictionary("common.txt")
	// register_concmd("nextmod", "cmdTest", 0, "stuff") // Debug
	
	g_mapName=ArrayCreate(32);
	
	new MenuName[64]
	
	format(MenuName, 63, "%L", "en", "CHOOSE_NEXTM")
	register_menucmd(register_menuid(MenuName), (-1^(-1<<(SELECTMAPS+2))), "countVote")
	register_menucmd(register_menuid("Vote Nextmod"), 1023, "countModVote")
	register_cvar("amx_extendmap_max", "90")
	register_cvar("amx_extendmap_step", "15")
	
	register_cvar("amx_nextmod","")

	if (cstrike_running())
		register_event("TeamScore", "team_score", "a")

	get_localinfo("lastMap", g_lastMap, 31)
	set_localinfo("lastMap", "")
	
	set_task(15.0, "voteNextMod", 987456, "", 0, "b")

	g_coloredMenus = colored_menus()
}

public plugin_cfg()
{
	// Set current mod
	
	/*  Maybe edit plugins.ini instead of pausing, idk */
	
	// Retrieve Nextmod
	new szThisMod[MODS_STRLEN+1]
	get_cvar_string("amx_nextmod", szThisMod, MODS_STRLEN)
	// g_iNextMod = Mod_Index(szThisMod)
	
	new szMultiModFile[64], szConfigDir[64]
	get_configsdir(szConfigDir, sizeof(szConfigDir) - 1)
	formatex(szMultiModFile, sizeof(szMultiModFile) - 1, "%s/%s", szConfigDir, "mapchooser_multimod.ini")
	
	if( !file_exists(szMultiModFile) )
	{
		return
	}
	
	new f = fopen(szMultiModFile, "rt")
	
	new szData[STR_LEN+1]
	new bool:bDoPause = false

	while( !feof(f) )
	{
		fgets(f, szData, STR_LEN)
		
		trim(szData)
		if( !szData[0] || szData[0] == ';'
		    || szData[0] == '/' && szData[1] == '/' ) continue;
		
		if(szData[0] == '[')
		{ // Parse "MOD" name and mapfile
			replace_all(szData, STR_LEN, "[", "")
			replace_all(szData, STR_LEN, "]", "")
			
			new szFilename[32], sztModName[MODS_STRLEN+1], szMapsFullPath[64]
			strtok(szData, sztModName, MODS_STRLEN, szFilename, 31, ':')
			formatex(szMapsFullPath, 63, "%s/%s", szConfigDir, szFilename)
			
			// server_print("ModName: %s <<>> Filename: %s", sztModName, szMapsFullPath) // Debug
			/* If there is a mapfile for the mod with maps in it then allow it to be voted for.
			 * If 
			 */
			if(loadSettings(szMapsFullPath, g_iModsNum) && g_iModsNum < MODS_MAX)
			{
				g_iModMapStart[g_iModsNum] = g_iMapPointer - g_mapNums[g_iModsNum]
				// server_print("Start Index: %d", g_iModMapStart[g_iModsNum]) // Debug
				copy(g_szModNames[g_iModsNum], MODS_STRLEN, sztModName)
				g_iModsNum++
				if(equal(sztModName,szThisMod))
				{
					bDoPause = false
				}
				else
				{
					bDoPause = true
				}
			}
			else
			{
				bDoPause = true
			}
			continue
		}
		
		if(bDoPause)
		{
			// server_print("Do pause: >>%s<<", szData) // Debug
			if(find_plugin_byfile(szData) != INVALID_PLUGIN_ID)
			{
				if(!pause("ac",szData))
				{
					log_amx("[mapchooser_multimod.amxx] Failed to pause %s")
				}
				// server_print("Found Plugin: >>%s<<",szData) Debug
			}
		}
	}
	
	fclose(f)
	
	if(!szThisMod[0])
	{
		set_cvar_string("amx_nextmod", g_szModNames[0])
	}
}

public checkVotes()
{
	new b = 0
	
	for (new a = 0; a < g_mapVoteNum; ++a)
		if (g_voteCount[b] < g_voteCount[a])
			b = a

	
	if (g_voteCount[SELECTMAPS] > g_voteCount[b]
	    && g_voteCount[SELECTMAPS] > g_voteCount[SELECTMAPS+1])
	{
		new mapname[32]
		
		get_mapname(mapname, 31)
		new Float:steptime = get_cvar_float("amx_extendmap_step")
		set_cvar_float("mp_timelimit", get_cvar_float("mp_timelimit") + steptime)
		client_print(0, print_chat, "%L", LANG_PLAYER, "CHO_FIN_EXT", steptime)
		log_amx("Vote: Voting for the nextmap finished. Map %s will be extended to next %.0f minutes", mapname, steptime)
		
		return
	}
	
	new smap[32]
	if (g_voteCount[b] && g_voteCount[SELECTMAPS + 1] <= g_voteCount[b])
	{
		ArrayGetString(g_mapName, g_nextName[b], smap, charsof(smap));
		set_cvar_string("amx_nextmap", smap);
	}

	
	get_cvar_string("amx_nextmap", smap, 31)
	client_print(0, print_chat, "%L", LANG_PLAYER, "CHO_FIN_NEXT", smap)
	log_amx("Vote: Voting for the nextmap finished. The nextmap will be %s", smap)
}

public checkModVotes()
{
	new b = 0
	
	for (new a = 0; a < g_iModsNum; ++a)
		if (g_VoteModCount[b] < g_VoteModCount[a])
			b = a

	g_iNextMod = b
	set_cvar_string("amx_nextmod", g_szModNames[g_iNextMod])
	// server_print("b: -%d- <> g_iNextMod: -%d- <> String: -%s-", b, g_iNextMod, g_szModNames[g_iNextMod]) // Debug
	new szTemp[25]
	formatex(szTemp, 24,"running the %s Mod", g_szModNames[g_iNextMod])
	client_print(0, print_chat, "%L", LANG_PLAYER, "CHO_FIN_NEXT", szTemp) // Add custom ML??
	log_amx("Vote: Voting for the next MOD finished. The next MOD will be %s", g_szModNames[b])
}

public countVote(id, key)
{
	if (get_cvar_float("amx_vote_answers"))
	{
		new name[32]
		get_user_name(id, name, 31)
		
		if (key == SELECTMAPS)
			client_print(0, print_chat, "%L", LANG_PLAYER, "CHOSE_EXT", name)
		else if (key < SELECTMAPS)
		{
			new map[32];
			ArrayGetString(g_mapName, g_nextName[key], map, charsof(map));
			client_print(0, print_chat, "%L", LANG_PLAYER, "X_CHOSE_X", name, map);
		}
	}
	++g_voteCount[key]
	
	return PLUGIN_HANDLED
}

public countModVote(id, key)
{
	// client_print(0,print_chat,"Vote counted - Key: %d", key) // Debug
	if (get_cvar_float("amx_vote_answers"))
	{
		new name[32]
		get_user_name(id, name, 31)
		
		if (key < g_iModsNum)
		{
			client_print(0, print_chat, "%L", LANG_PLAYER, "X_CHOSE_X", name, g_szModNames[key]);
		}
	}
	++g_VoteModCount[key]
	
	return PLUGIN_HANDLED
}

bool:isInMenu(id)
{
	for (new a = 0; a < g_mapVoteNum; ++a)
		if (id == g_nextName[a])
			return true
	return false
}

public voteNextMod()
{
	new winlimit = get_cvar_num("mp_winlimit")
	new maxrounds = get_cvar_num("mp_maxrounds")
	
	if (winlimit)
	{
		new c = winlimit - 2
		
		if ((c > g_teamScore[0]) && (c > g_teamScore[1]))
		{
			g_selected = false
			return
		}
	}
	else if (maxrounds)
	{
		if ((maxrounds - 2) > (g_teamScore[0] + g_teamScore[1]))
		{
			g_selected = false
			return
		}
	} else {
	new timeleft = get_timeleft()

	if (timeleft < 1 || timeleft > 129)
	{
		g_selected = false
		return
	}
	}

	if (g_selected)
		return

	g_selected = true

	new menu[512], mkeys, i

	// new pos = format(menu, 511, g_coloredMenus ? "\y%L:\w^n^n" : "%L:^n^n", LANG_SERVER, "CHOOSE_NEXTMOD")
	new pos = format(menu, 511, g_coloredMenus ? "\y%s:\w^n^n" : "%s:^n^n", "Choose Next Mod")

	for(i = 0; i < g_iModsNum; i++)
	{
		pos += format(menu[pos], 511, "%d. %s^n", i + 1, g_szModNames[i])
		g_VoteModCount[i] = 0
		mkeys |= (1<<i)
	}

	format(menu[pos], 511, "^n%d. %L", i+1, LANG_SERVER, "NONE")
	g_VoteModCount[i] = 0
	mkeys |= (1<<i)

	show_menu(0, mkeys, menu, 15, "Vote Nextmod")
	set_task(15.0, "checkModVotes")
	set_task(25.0, "voteNextmap")
	client_cmd(0, "spk Gman/Gman_Choose2")
	log_amx("Vote: Voting for the next MOD started")
}

public voteNextmap()
{
	
	new menu[512], a, mkeys = (1<<SELECTMAPS + 1)

	new pos = format(menu, 511, g_coloredMenus ? "\y%L:\w^n^n" : "%L:^n^n", LANG_SERVER, "CHOOSE_NEXTM")
	new dmax = (g_mapNums[g_iNextMod] > SELECTMAPS) ? SELECTMAPS : g_mapNums[g_iNextMod]
	
	for (g_mapVoteNum = 0; g_mapVoteNum < dmax; ++g_mapVoteNum)
	{
		a = g_iModMapStart[g_iNextMod] + random_num(0, g_mapNums[g_iNextMod] - 1)
		
		while (isInMenu(a))
			if (++a >= g_mapNums[g_iNextMod]) a = 0
		
		g_nextName[g_mapVoteNum] = a
		pos += format(menu[pos], 511, "%d. %a^n", g_mapVoteNum + 1, ArrayGetStringHandle(g_mapName, a));
		mkeys |= (1<<g_mapVoteNum)
		g_voteCount[g_mapVoteNum] = 0
	}
	
	menu[pos++] = '^n'
	g_voteCount[SELECTMAPS] = 0
	g_voteCount[SELECTMAPS + 1] = 0
	
	new mapname[32]
	get_mapname(mapname, 31)

	// if ((winlimit + maxrounds) == 0 && (get_cvar_float("mp_timelimit") < get_cvar_float("amx_extendmap_max")))
	// {
		// pos += format(menu[pos], 511, "%d. %L^n", SELECTMAPS + 1, LANG_SERVER, "EXTED_MAP", mapname)
		// mkeys |= (1<<SELECTMAPS)
	// }

	format(menu[pos], 511, "%d. %L", SELECTMAPS+2, LANG_SERVER, "NONE")
	new MenuName[64]
	
	format(MenuName, 63, "%L", "en", "CHOOSE_NEXTM")
	show_menu(0, mkeys, menu, 15, MenuName)
	set_task(15.0, "checkVotes")
	client_print(0, print_chat, "%L", LANG_SERVER, "TIME_CHOOSE")
	client_cmd(0, "spk Gman/Gman_Choose2")
	log_amx("Vote: Voting for the nextmap started")
}
stock bool:ValidMap(mapname[])
{
	if ( is_map_valid(mapname) )
	{
		return true;
	}
	// If the is_map_valid check failed, check the end of the string
	new len = strlen(mapname) - 4;
	
	// The mapname was too short to possibly house the .bsp extension
	if (len < 0)
	{
		return false;
	}
	if ( equali(mapname[len], ".bsp") )
	{
		// If the ending was .bsp, then cut it off.
		// the string is byref'ed, so this copies back to the loaded text.
		mapname[len] = '^0';
		
		// recheck
		if ( is_map_valid(mapname) )
		{
			return true;
		}
	}
	
	return false;
}

loadSettings(filename[], mod)
{
	if (!file_exists(filename))
		return 0

	new szText[32]
	new currentMap[32]
	
	new buff[256];
	
	get_mapname(currentMap, 31)

	new fp=fopen(filename,"r");
	
	while (!feof(fp))
	{
		buff[0]='^0';
		szText[0]='^0';
		
		fgets(fp, buff, charsof(buff));
		
		parse(buff, szText, charsof(szText));
		
		// server_print("Buffer: >%s<", buff) // Debug
		
		if (szText[0] != ';' &&
			ValidMap(szText) &&
			!equali(szText, g_lastMap) &&
			!equali(szText, currentMap))
		{
			ArrayPushString(g_mapName, szText);
			++g_mapNums[mod];
			++g_iMapPointer;
			// server_print("Map: %s", szText); // Debug
		}
		
	}
	
	fclose(fp);

	return g_mapNums[mod]
}

public team_score()
{
	new team[2]
	
	read_data(1, team, 1)
	g_teamScore[(team[0]=='C') ? 0 : 1] = read_data(2)
}

Mod_Index(modstring[])
{
	for(new i = 0; i < sizeof(g_szModNames); i++)
	{
		if(equal(g_szModNames[i], modstring))
		{
			return i
		}
	}
	return 0
}

public plugin_end()
{
	new current_map[32]
	
	get_mapname(current_map, 31)
	set_localinfo("lastMap", current_map)
}

// Debug
// public cmdTest(id)
// {
	// for(new i = 0; i < g_iModsNum; i++)
	// {
		// server_print("Mod: %s", g_szModNames[i])
	// }
	// new totalmaps = 0
	// for(new i = 0; i < MODS_MAX; i++)
	// {
		// totalmaps += g_mapNums[i]
	// }
	// server_print("Begin \/")
	// for(new i = 0; i < totalmaps; i++)
	// {
		// server_print("%a", ArrayGetStringHandle(g_mapName, i))
	// }
	// server_print("End /\")
// }
Bu mesaja eklenen dosyaları görüntülemek için gerekli izinlere sahip değilsiniz.

Link:
Linklerini gizle
Linki Kopyala

Konu Sahibi
tepegoz
Mesajlar: 266
Kayıt: Pzr Kas 19, 2017 2:06 am
Clan İsmi: -

Kural İhlali

Mesaj gönderen tepegoz »

güncel

Link:
Linklerini gizle
Linki Kopyala
Cevapla