Добавяне на "duration" към "golden weapon".

В този раздел можете да подавате всякакви заявки за намиране, изработка или преработка на плъгини/модове.
Потребителски аватар

Автор на темата
iv69
Потребител
Потребител
Мнения: 355
Регистриран: 17 мар 2018, 15:34
Се отблагодари: 100 пъти
Получена благодарност: 10 пъти

Добавяне на "duration" към "golden weapon".

Мнение от iv69 » 11 май 2019, 13:48

Искам да попитам, може ли да се редактира плъгина по-долу, така че закупения "gold weapon" да остава в играча не до края на рунда или до смъртта му, а за определено време,без значение колко пъти е умрял( ще има добър ефект най-вече при CSDM)- например за 180sek, или 300sek, просто да има duration на покупката и квар за стойността?
Ако може, моля редактирайте ми плъгина.
Благодаря!

Код: Избери всички

#include <amxmodx>
#include <cromchat>
#include <cstrike>
#include <fakemeta>
#include <fun>
#include <hamsandwich>

//#define USING_REAPI
#define REPLACE_OLD_WEAPONS

#if defined USING_REAPI
	#include <reapi>
#else
	#if defined REPLACE_OLD_WEAPONS
		#include <stripweapons>
	#endif
#endif

#define PLUGIN_VERSION "1.0"
#define SOUND_BUY "items/gunpickup2.wav"
#define NO_WEAPON -1

enum _:ItemInfo
{
	Name[32],
	Price,
	Weapon[16],
	Ammo,
	Csw,
	VModel[32],
	PModel[32],
	CsTeams:Team,
	Health
}

new const g_eItems[][ItemInfo] = 
{
	/* "Name", Price, "weapon_id", Bullets, CSW_ID, "v_model", "p_model", "team" */
	{ "Golden Deagle", 	5000, 	"weapon_deagle", 	35, 	CSW_DEAGLE, 	"models/v_deagle.mdl", 		"models/p_deagle.mdl", 		CS_TEAM_CT, 5 },
	{ "Golden M4A1", 	10000, 	"weapon_m4a1", 		90, 	CSW_M4A1, 		"models/v_m4a1.mdl", 		"models/p_m4a1.mdl", 		CS_TEAM_CT, 10 },
	{ "Golden Glock", 	5000, 	"weapon_glock18", 	30, 	CSW_GLOCK18, 	"models/v_glock18.mdl",	 	"models/p_glock18.mdl", 	CS_TEAM_T, 5 },
	{ "Golden AK47", 	10000, 	"weapon_ak47", 		90, 	CSW_AWP, 		"models/v_ak47.mdl", 		"models/p_ak47.mdl",	 	CS_TEAM_T, 10 },
	{ "Golden AWP", 	16000, 	"weapon_awp", 		30, 	CSW_AWP, 		"models/v_awp.mdl", 		"models/p_awp.mdl",			CS_TEAM_CT|CS_TEAM_T, 20 }
}

new g_iWeapon[33]
	
public plugin_init()
{
	register_plugin("Golden Shop", PLUGIN_VERSION, "OciXCrom")
	register_cvar("CRXGoldenShop", PLUGIN_VERSION, FCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
	register_event("CurWeapon", "OnChangeWeapon", "be", "1=1")
	register_event("DeathMsg", "OnPlayerKilled", "a")
	RegisterHam(Ham_Spawn, "player", "OnPlayerSpawn", 1)
	RegisterHam(Ham_TakeDamage, "player", "PreTakeDamage", 0)
	register_clcmd("say /gold", "Cmd_Shop")
	register_clcmd("say_team /gold", "Cmd_Shop")
	CC_SetPrefix("[&x04GOLD&x01]")
}

public plugin_precache()
{
	precache_sound(SOUND_BUY)
	
	for(new i; i < sizeof(g_eItems); i++)
	{
		if(g_eItems[i][VModel][0])
			precache_model(g_eItems[i][VModel])
			
		if(g_eItems[i][PModel][0])
			precache_model(g_eItems[i][PModel])
	}
}
	
public client_putinserver(id)
	g_iWeapon[id] = NO_WEAPON
	
public OnPlayerSpawn(id)
	g_iWeapon[id] = NO_WEAPON
	
public PreTakeDamage(iVictim, iInflictor, iAttacker, Float:fDamage, iDamageBits)
{
	if(g_iWeapon[iAttacker] != NO_WEAPON)
		SetHamParamFloat(4, fDamage * 2)
}

public OnPlayerKilled()
{
	new iAttacker = read_data(1), iVictim = read_data(2)
	
	if(is_user_connected(iAttacker) && is_user_connected(iVictim) && g_iWeapon[iAttacker] != NO_WEAPON)
		set_user_health(iAttacker, get_user_health(iAttacker) + g_eItems[g_iWeapon[iAttacker]][Health])
}

public OnChangeWeapon(id)
{
	if(g_iWeapon[id] == NO_WEAPON || read_data(2) != g_eItems[g_iWeapon[id]][Csw])
		return
		
	if(g_eItems[g_iWeapon[id]][VModel][0])
		set_pev(id, pev_viewmodel2, g_eItems[g_iWeapon[id]][VModel])
		
	if(g_eItems[g_iWeapon[id]][PModel][0])
		set_pev(id, pev_weaponmodel2, g_eItems[g_iWeapon[id]][PModel])
}
	
public Cmd_Shop(id)
{
	if(!is_user_alive(id))
		CC_SendMessage(id, "You need to be alive.")
	else
	{
		new iMenu = menu_create("\rGold Shop", "Shop_Handler")
		new szItem[64], iMoney = cs_get_user_money(id)
		
		for(new CsTeams:iTeam = cs_get_user_team(id), i; i < sizeof(g_eItems); i++)
		{
			if(g_eItems[i][Team] & iTeam)
			{
				if(g_iWeapon[id] == i)
					formatex(szItem, charsmax(szItem), "\d%s \y[OWNED]", g_eItems[i][Name])
				else
					formatex(szItem, charsmax(szItem), "%s%s \r[%i$]", iMoney >= g_eItems[i][Price] ? "\w" : "\d", g_eItems[i][Name], g_eItems[i][Price])
					
				menu_additem(iMenu, szItem)
			}
		}
		
		menu_display(id, iMenu)
	}
	
	return PLUGIN_HANDLED
}

public Shop_Handler(id, iMenu, iItem)
{
	if(iItem != MENU_EXIT && is_user_alive(id))
	{
		if(g_iWeapon[id] == iItem)
			CC_SendMessage(id, "You already have this item.")
		else
		{
			new iMoney = cs_get_user_money(id)
			
			if(iMoney < g_eItems[iItem][Price])
				CC_SendMessage(id, "You don't have enough money to purchase this item.")
			else
			{
				cs_set_user_money(id, iMoney - g_eItems[iItem][Price])
				CC_SendMessage(id, "You have bought ^3%s ^1for ^4%i$", g_eItems[iItem][Name], g_eItems[iItem][Price])
				emit_sound(id, CHAN_ITEM, SOUND_BUY, 1.0, ATTN_NORM, 0, PITCH_NORM)
				g_iWeapon[id] = iItem
				
				#if defined USING_REAPI
					#if defined REPLACE_OLD_WEAPONS
					rg_give_item(id, g_eItems[iItem][Weapon], GT_REPLACE)
					#else
					rg_give_item(id, g_eItems[iItem][Weapon], GT_APPEND)
					#endif
				#else
					#if defined REPLACE_OLD_WEAPONS
					StripWeapons(id, Primary)
					#endif
					
					give_item(id, g_eItems[iItem][Weapon])
				#endif
				
				cs_set_user_bpammo(id, g_eItems[iItem][Csw], g_eItems[iItem][Ammo])
				OnChangeWeapon(id)
			}
		}
	}

	menu_destroy(iMenu)
	return PLUGIN_HANDLED
}

Потребителски аватар

blazz3rzbg NSFW
Потребител
Потребител
Мнения: 34
Регистриран: 22 фев 2019, 14:38
Местоположение: Стара Загора
Се отблагодари: 7 пъти
Получена благодарност: 11 пъти
Години: 18

Добавяне на "duration" към "golden weapon".

Мнение от blazz3rzbg NSFW » 13 май 2019, 17:27

1. Плъгина който си дал е бъгнат - замених го с поправената версия на OcixCrom.
2. Чрез квар-а goldweap_duration_sec "300" можеш да променяш колко секунди да стои златното оръжие в играча
3. Добавил съм и HUD съобщение под радара на играча което показва колко секунди от златното оръжие му остават

Ако има някакъв проблем или нещо друго за добавяне пипши

Код: Избери всички

#include <amxmodx>
#include <cromchat>
#include <cstrike>
#include <fakemeta>
#include <fun>
#include <hamsandwich>

//#define USING_REAPI
#define REPLACE_OLD_WEAPONS

#if defined USING_REAPI
	#include <reapi>
#else
	#if defined REPLACE_OLD_WEAPONS
		#include <stripweapons>
	#endif
#endif

#define PLUGIN_VERSION "1.0"
#define SOUND_BUY "items/gunpickup2.wav"
#define NO_WEAPON -1

enum _:ItemInfo
{
	Name[32],
	Price,
	Weapon[16],
	Ammo,
	Csw,
	VModel[32],
	PModel[32],
	CsTeams:Team
}

new const g_eItems[][ItemInfo] = 
{
	/* "Name", Price, "weapon_id", Bullets, CSW_ID, "v_model", "p_model", "team" */
	{ "Golden Deagle", 	5000, 	"weapon_deagle", 	35, 	CSW_DEAGLE, 	"models/v_deagle.mdl", 		"models/p_deagle.mdl", 		CS_TEAM_CT },
	{ "Golden M4A1", 	10000, 	"weapon_m4a1", 		90, 	CSW_M4A1, 		"models/v_m4a1.mdl", 		"models/p_m4a1.mdl", 		CS_TEAM_CT },
	{ "Golden Glock", 	5000, 	"weapon_glock18", 	30, 	CSW_GLOCK18, 	"models/v_glock18.mdl",	 	"models/p_glock18.mdl", 	CS_TEAM_T },
	{ "Golden AK47", 	10000, 	"weapon_ak47", 		90, 	CSW_AWP, 		"models/v_ak47.mdl", 		"models/p_ak47.mdl",	 	CS_TEAM_T },
	{ "Golden AWP", 	16000, 	"weapon_awp", 		30, 	CSW_AWP, 		"models/v_awp.mdl", 		"models/p_awp.mdl",			CS_TEAM_CT|CS_TEAM_T }
}

new g_iWeapon[33]

const TIMER_ID = 123456;

new pCvar_duration;
new g_iCounter[33];
new g_MsgSync;
	
public plugin_init()
{
	register_plugin("Golden Shop", PLUGIN_VERSION, "OciXCrom")
	register_cvar("CRXGoldenShop", PLUGIN_VERSION, FCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
	register_event("CurWeapon", "OnChangeWeapon", "be", "1=1")
	//RegisterHam(Ham_Spawn, "player", "OnPlayerSpawn", 1)
	RegisterHam(Ham_TakeDamage, "player", "PreTakeDamage", 0)
	register_clcmd("say /gold", "Cmd_Shop")
	register_clcmd("say_team /gold", "Cmd_Shop")
	CC_SetPrefix("[&x04GOLD&x01]")
	
	g_MsgSync = CreateHudSyncObj();
	pCvar_duration = register_cvar("goldweap_duration_sec", "300");
}

public plugin_precache()
{
	precache_sound(SOUND_BUY)
	
	for(new i; i < sizeof(g_eItems); i++)
	{
		if(g_eItems[i][VModel][0])
			precache_model(g_eItems[i][VModel])
			
		if(g_eItems[i][PModel][0])
			precache_model(g_eItems[i][PModel])
	}
}
	
public client_putinserver(id)
	g_iWeapon[id] = NO_WEAPON
	
//public OnPlayerSpawn(id)
//	g_iWeapon[id] = NO_WEAPON
	
public PreTakeDamage(iVictim, iInflictor, iAttacker, Float:fDamage, iDamageBits)
{
	if(g_iWeapon[iAttacker] != NO_WEAPON)
		SetHamParamFloat(4, fDamage * 2)
}

public OnChangeWeapon(id)
{
	if(g_iWeapon[id] == NO_WEAPON || read_data(2) != g_eItems[g_iWeapon[id]][Csw])
		return
		
	if(g_eItems[g_iWeapon[id]][VModel][0])
		set_pev(id, pev_viewmodel2, g_eItems[g_iWeapon[id]][VModel])
		
	if(g_eItems[g_iWeapon[id]][PModel][0])
		set_pev(id, pev_weaponmodel2, g_eItems[g_iWeapon[id]][PModel])
}
	
public Cmd_Shop(id)
{
	if(!is_user_alive(id))
		CC_SendMessage(id, "You need to be alive.")
	else
	{
		new iMenu = menu_create("\rGold Shop", "Shop_Handler")
		new szItem[64], iMoney = cs_get_user_money(id)
		
		for(new szKey[4], CsTeams:iTeam = cs_get_user_team(id), i; i < sizeof(g_eItems); i++)
		{
			if(g_eItems[i][Team] & iTeam)
			{
				if(g_iWeapon[id] == i)
					formatex(szItem, charsmax(szItem), "\d%s \y[OWNED]", g_eItems[i][Name])
				else
					formatex(szItem, charsmax(szItem), "%s%s \r[%i$]", iMoney >= g_eItems[i][Price] ? "\w" : "\d", g_eItems[i][Name], g_eItems[i][Price])
					
				num_to_str(i, szKey, charsmax(szKey))
				menu_additem(iMenu, szItem, szKey)
			}
		}
		
		menu_display(id, iMenu)
	}
	
	return PLUGIN_HANDLED
}

public Shop_Handler(id, iMenu, iItem)
{
	if(iItem != MENU_EXIT && is_user_alive(id))
	{
		new szKey[4], iUnused
		menu_item_getinfo(iMenu, iItem, iUnused, szKey, charsmax(szKey), .callback = iUnused)
		
		new iKey = str_to_num(szKey)
		
		if(g_iWeapon[id] == iKey)
			CC_SendMessage(id, "You already have this item.")
		else
		{
			new iMoney = cs_get_user_money(id)
			
			if(iMoney < g_eItems[iKey][Price])
				CC_SendMessage(id, "You don't have enough money to purchase this item.")
			else
			{
				cs_set_user_money(id, iMoney - g_eItems[iKey][Price])
				CC_SendMessage(id, "You have bought ^3%s ^1for ^4%i$", g_eItems[iKey][Name], g_eItems[iKey][Price])
				emit_sound(id, CHAN_ITEM, SOUND_BUY, 1.0, ATTN_NORM, 0, PITCH_NORM)
				g_iWeapon[id] = iKey
				
				#if defined USING_REAPI
					#if defined REPLACE_OLD_WEAPONS
					rg_give_item(id, g_eItems[iKey][Weapon], GT_REPLACE)
					#else
					rg_give_item(id, g_eItems[iKey][Weapon], GT_APPEND)
					#endif
				#else
					#if defined REPLACE_OLD_WEAPONS
					StripWeapons(id, Primary)
					#endif
					
					give_item(id, g_eItems[iKey][Weapon])
				#endif
				
				cs_set_user_bpammo(id, g_eItems[iKey][Csw], g_eItems[iKey][Ammo])
				OnChangeWeapon(id)
				
				new iTask = id + TIMER_ID;
				if(task_exists(iTask))
					remove_task(iTask);
				
				g_iCounter[id] = get_pcvar_num(pCvar_duration);
				set_task(1.0, "goldweap_timer", id+TIMER_ID, .flags = "b");
			}
		}
	}

	menu_destroy(iMenu)
	return PLUGIN_HANDLED
}

public goldweap_timer(id)
{
	id -= TIMER_ID;
	
	if(is_user_connected(id) && is_user_alive(id) && g_iWeapon[id] != NO_WEAPON)
	{
		g_iCounter[id] --;
		
		set_hudmessage(255, 215, 0, 0.0, 0.20, 0, 0.0, 0.0, 0.1, 0.9);
		ShowSyncHudMsg(id, g_MsgSync, "%s expires in: %i", g_eItems[g_iWeapon[id]][Name], g_iCounter[id]);

		if(g_iCounter[id] == 1)
		{
			set_hudmessage(255, 215, 0, -1.0, 0.32, 1, 0.0, 4.0, 1.0, 1.0, -1);
			ShowSyncHudMsg(id, g_MsgSync, "Your %s Expired!", g_eItems[g_iWeapon[id]][Name]);
			
			g_iWeapon[id] = NO_WEAPON;
			
			new iTask = id + TIMER_ID;
			if(task_exists(iTask))
				remove_task(iTask);
		}
	}
}

#if AMXX_VERSION_NUM <= 182
public client_disconnect(id)
	#else
public client_connected(id)
#endif
{
	new iTask = id + TIMER_ID;
	if(task_exists(iTask))
		remove_task(iTask);
}

Потребителски аватар

Автор на темата
iv69
Потребител
Потребител
Мнения: 355
Регистриран: 17 мар 2018, 15:34
Се отблагодари: 100 пъти
Получена благодарност: 10 пъти

Добавяне на "duration" към "golden weapon".

Мнение от iv69 » 13 май 2019, 20:47

blazz3rzbg написа:
13 май 2019, 17:27
1. Плъгина който си дал е бъгнат - замених го с поправената версия на OcixCrom.
2. Чрез квар-а goldweap_duration_sec "300" можеш да променяш колко секунди да стои златното оръжие в играча
3. Добавил съм и HUD съобщение под радара на играча което показва колко секунди от златното оръжие му остават

Ако има някакъв проблем или нещо друго за добавяне пипши

Код: Избери всички

#include <amxmodx>
#include <cromchat>
#include <cstrike>
#include <fakemeta>
#include <fun>
#include <hamsandwich>

//#define USING_REAPI
#define REPLACE_OLD_WEAPONS

#if defined USING_REAPI
	#include <reapi>
#else
	#if defined REPLACE_OLD_WEAPONS
		#include <stripweapons>
	#endif
#endif

#define PLUGIN_VERSION "1.0"
#define SOUND_BUY "items/gunpickup2.wav"
#define NO_WEAPON -1

enum _:ItemInfo
{
	Name[32],
	Price,
	Weapon[16],
	Ammo,
	Csw,
	VModel[32],
	PModel[32],
	CsTeams:Team
}

new const g_eItems[][ItemInfo] = 
{
	/* "Name", Price, "weapon_id", Bullets, CSW_ID, "v_model", "p_model", "team" */
	{ "Golden Deagle", 	5000, 	"weapon_deagle", 	35, 	CSW_DEAGLE, 	"models/v_deagle.mdl", 		"models/p_deagle.mdl", 		CS_TEAM_CT },
	{ "Golden M4A1", 	10000, 	"weapon_m4a1", 		90, 	CSW_M4A1, 		"models/v_m4a1.mdl", 		"models/p_m4a1.mdl", 		CS_TEAM_CT },
	{ "Golden Glock", 	5000, 	"weapon_glock18", 	30, 	CSW_GLOCK18, 	"models/v_glock18.mdl",	 	"models/p_glock18.mdl", 	CS_TEAM_T },
	{ "Golden AK47", 	10000, 	"weapon_ak47", 		90, 	CSW_AWP, 		"models/v_ak47.mdl", 		"models/p_ak47.mdl",	 	CS_TEAM_T },
	{ "Golden AWP", 	16000, 	"weapon_awp", 		30, 	CSW_AWP, 		"models/v_awp.mdl", 		"models/p_awp.mdl",			CS_TEAM_CT|CS_TEAM_T }
}

new g_iWeapon[33]

const TIMER_ID = 123456;

new pCvar_duration;
new g_iCounter[33];
new g_MsgSync;
	
public plugin_init()
{
	register_plugin("Golden Shop", PLUGIN_VERSION, "OciXCrom")
	register_cvar("CRXGoldenShop", PLUGIN_VERSION, FCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
	register_event("CurWeapon", "OnChangeWeapon", "be", "1=1")
	//RegisterHam(Ham_Spawn, "player", "OnPlayerSpawn", 1)
	RegisterHam(Ham_TakeDamage, "player", "PreTakeDamage", 0)
	register_clcmd("say /gold", "Cmd_Shop")
	register_clcmd("say_team /gold", "Cmd_Shop")
	CC_SetPrefix("[&x04GOLD&x01]")
	
	g_MsgSync = CreateHudSyncObj();
	pCvar_duration = register_cvar("goldweap_duration_sec", "300");
}

public plugin_precache()
{
	precache_sound(SOUND_BUY)
	
	for(new i; i < sizeof(g_eItems); i++)
	{
		if(g_eItems[i][VModel][0])
			precache_model(g_eItems[i][VModel])
			
		if(g_eItems[i][PModel][0])
			precache_model(g_eItems[i][PModel])
	}
}
	
public client_putinserver(id)
	g_iWeapon[id] = NO_WEAPON
	
//public OnPlayerSpawn(id)
//	g_iWeapon[id] = NO_WEAPON
	
public PreTakeDamage(iVictim, iInflictor, iAttacker, Float:fDamage, iDamageBits)
{
	if(g_iWeapon[iAttacker] != NO_WEAPON)
		SetHamParamFloat(4, fDamage * 2)
}

public OnChangeWeapon(id)
{
	if(g_iWeapon[id] == NO_WEAPON || read_data(2) != g_eItems[g_iWeapon[id]][Csw])
		return
		
	if(g_eItems[g_iWeapon[id]][VModel][0])
		set_pev(id, pev_viewmodel2, g_eItems[g_iWeapon[id]][VModel])
		
	if(g_eItems[g_iWeapon[id]][PModel][0])
		set_pev(id, pev_weaponmodel2, g_eItems[g_iWeapon[id]][PModel])
}
	
public Cmd_Shop(id)
{
	if(!is_user_alive(id))
		CC_SendMessage(id, "You need to be alive.")
	else
	{
		new iMenu = menu_create("\rGold Shop", "Shop_Handler")
		new szItem[64], iMoney = cs_get_user_money(id)
		
		for(new szKey[4], CsTeams:iTeam = cs_get_user_team(id), i; i < sizeof(g_eItems); i++)
		{
			if(g_eItems[i][Team] & iTeam)
			{
				if(g_iWeapon[id] == i)
					formatex(szItem, charsmax(szItem), "\d%s \y[OWNED]", g_eItems[i][Name])
				else
					formatex(szItem, charsmax(szItem), "%s%s \r[%i$]", iMoney >= g_eItems[i][Price] ? "\w" : "\d", g_eItems[i][Name], g_eItems[i][Price])
					
				num_to_str(i, szKey, charsmax(szKey))
				menu_additem(iMenu, szItem, szKey)
			}
		}
		
		menu_display(id, iMenu)
	}
	
	return PLUGIN_HANDLED
}

public Shop_Handler(id, iMenu, iItem)
{
	if(iItem != MENU_EXIT && is_user_alive(id))
	{
		new szKey[4], iUnused
		menu_item_getinfo(iMenu, iItem, iUnused, szKey, charsmax(szKey), .callback = iUnused)
		
		new iKey = str_to_num(szKey)
		
		if(g_iWeapon[id] == iKey)
			CC_SendMessage(id, "You already have this item.")
		else
		{
			new iMoney = cs_get_user_money(id)
			
			if(iMoney < g_eItems[iKey][Price])
				CC_SendMessage(id, "You don't have enough money to purchase this item.")
			else
			{
				cs_set_user_money(id, iMoney - g_eItems[iKey][Price])
				CC_SendMessage(id, "You have bought ^3%s ^1for ^4%i$", g_eItems[iKey][Name], g_eItems[iKey][Price])
				emit_sound(id, CHAN_ITEM, SOUND_BUY, 1.0, ATTN_NORM, 0, PITCH_NORM)
				g_iWeapon[id] = iKey
				
				#if defined USING_REAPI
					#if defined REPLACE_OLD_WEAPONS
					rg_give_item(id, g_eItems[iKey][Weapon], GT_REPLACE)
					#else
					rg_give_item(id, g_eItems[iKey][Weapon], GT_APPEND)
					#endif
				#else
					#if defined REPLACE_OLD_WEAPONS
					StripWeapons(id, Primary)
					#endif
					
					give_item(id, g_eItems[iKey][Weapon])
				#endif
				
				cs_set_user_bpammo(id, g_eItems[iKey][Csw], g_eItems[iKey][Ammo])
				OnChangeWeapon(id)
				
				new iTask = id + TIMER_ID;
				if(task_exists(iTask))
					remove_task(iTask);
				
				g_iCounter[id] = get_pcvar_num(pCvar_duration);
				set_task(1.0, "goldweap_timer", id+TIMER_ID, .flags = "b");
			}
		}
	}

	menu_destroy(iMenu)
	return PLUGIN_HANDLED
}

public goldweap_timer(id)
{
	id -= TIMER_ID;
	
	if(is_user_connected(id) && is_user_alive(id) && g_iWeapon[id] != NO_WEAPON)
	{
		g_iCounter[id] --;
		
		set_hudmessage(255, 215, 0, 0.0, 0.20, 0, 0.0, 0.0, 0.1, 0.9);
		ShowSyncHudMsg(id, g_MsgSync, "%s expires in: %i", g_eItems[g_iWeapon[id]][Name], g_iCounter[id]);

		if(g_iCounter[id] == 1)
		{
			set_hudmessage(255, 215, 0, -1.0, 0.32, 1, 0.0, 4.0, 1.0, 1.0, -1);
			ShowSyncHudMsg(id, g_MsgSync, "Your %s Expired!", g_eItems[g_iWeapon[id]][Name]);
			
			g_iWeapon[id] = NO_WEAPON;
			
			new iTask = id + TIMER_ID;
			if(task_exists(iTask))
				remove_task(iTask);
		}
	}
}

#if AMXX_VERSION_NUM <= 182
public client_disconnect(id)
	#else
public client_connected(id)
#endif
{
	new iTask = id + TIMER_ID;
	if(task_exists(iTask))
		remove_task(iTask);
}
...ще го пробвам , благодаря !

Потребителски аватар

Автор на темата
iv69
Потребител
Потребител
Мнения: 355
Регистриран: 17 мар 2018, 15:34
Се отблагодари: 100 пъти
Получена благодарност: 10 пъти

Добавяне на "duration" към "golden weapon".

Мнение от iv69 » 15 май 2019, 15:07

Пробвах: плъгина се компилира, работи чудесно(хареса ми много идеята за брояча) , но имам една молба: може ли да се пропусне последната опция от този ред:
/* "Name", Price, "weapon_id", Bullets, CSW_ID, "v_model", "p_model", "team" */
т.е. да си купуват всички играчи всички оръжия безпрепятствено и безусловно...(опитах се да добавя на всички редове да е така: CS_TEAM_CT|CS_TEAM_T
, но нещо се бъгва и като получи играча например оръжието дето е за другия отбор, след умиране не му го дава ,а брояча си брои , че е у него. Просто ако може без опцията: "team" * , плюс ако е възможно - да се добави накрая на това място - увеличена щета от златните оръжия, нещо подобно :define DMG_MULTIPLIER 1.5 до define DMG_MULTIPLIER 3 за всяко оръжие(или ако не може за всяко - да има увеличена щета като цяло за златните оръжия), и още ако не е проблем - оръжията да са и с безкрайни пълнители да нямат нужда от презареждане, извинявам се за "безкрайните" ми желания, но това е за последно, така де- като ще са златни , да са златни :gamer3: .
Благодаря.

p.s. Иначе плъгина работи като по часовник!

Потребителски аватар

blazz3rzbg NSFW
Потребител
Потребител
Мнения: 34
Регистриран: 22 фев 2019, 14:38
Местоположение: Стара Загора
Се отблагодари: 7 пъти
Получена благодарност: 11 пъти
Години: 18

Добавяне на "duration" към "golden weapon".

Мнение от blazz3rzbg NSFW » 15 май 2019, 18:18

безкрайни пълнители ???? искаш да задържаш ляв бутон без спирка ли ? :D

Добавено преди 7 минути 45 секунди:

Код: Избери всички

#include <amxmodx>
#include <cromchat>
#include <cstrike>
#include <fakemeta>
#include <fun>
#include <hamsandwich>

//#define USING_REAPI
#define REPLACE_OLD_WEAPONS

#if defined USING_REAPI
	#include <reapi>
#else
	#if defined REPLACE_OLD_WEAPONS
		#include <stripweapons>
	#endif
#endif

#define PLUGIN_VERSION "1.0"
#define SOUND_BUY "items/gunpickup2.wav"
#define NO_WEAPON -1

enum _:ItemInfo
{
	Name[32],
	Price,
	Weapon[16],
	Ammo,
	Csw,
	VModel[32],
	PModel[32],
	Float:DmgMulti
}

new const g_eItems[][ItemInfo] = 
{
	/* "Name", Price, "weapon_id", Bullets, CSW_ID, "v_model", "p_model", "Damage Multiplier" */
	{ "Golden Deagle", 	0, 	"weapon_deagle", 	35, 	CSW_DEAGLE, 	"models/v_deagle.mdl", 		"models/p_deagle.mdl", 		2.0 },
	{ "Golden M4A1", 	0, 	"weapon_m4a1", 		90, 	CSW_M4A1, 		"models/v_m4a1.mdl", 		"models/p_m4a1.mdl", 		2.0 },
	{ "Golden Glock", 	0, 	"weapon_glock18", 	30, 	CSW_GLOCK18, 	"models/v_glock18.mdl",	 	"models/p_glock18.mdl", 	2.0 },
	{ "Golden AK47", 	0, 	"weapon_ak47", 		90, 	CSW_AWP, 		"models/v_ak47.mdl", 		"models/p_ak47.mdl",	 	2.0 },
	{ "Golden AWP", 	0, 	"weapon_awp", 		30, 	CSW_AWP, 		"models/v_awp.mdl", 		"models/p_awp.mdl",			2.0 }
}

// CS Player CBase Offsets (win32)
const PDATA_SAFE = 2
const OFFSET_ACTIVE_ITEM = 373

// Max BP ammo for weapons
new const MAXBPAMMO[] = { -1, 52, -1, 90, 1, 32, 1, 100, 90, 1, 120, 100, 100, 90, 90, 90, 100, 120,
			30, 120, 200, 32, 90, 120, 90, 2, 35, 90, 90, -1, 100 };

// Max Clip for weapons
new const MAXCLIP[] = { -1, 13, -1, 10, -1, 7, -1, 30, 30, -1, 30, 20, 25, 30, 35, 25, 12, 20,
			10, 30, 100, 8, 30, 30, 20, -1, 7, 30, 30, -1, 50 };

new g_iWeapon[33]

const TIMER_ID = 123456;

new pCvar_duration;
new g_iCounter[33];

new g_MsgSync;
	
public plugin_init()
{
	register_plugin("Golden Shop", PLUGIN_VERSION, "OciXCrom")
	register_cvar("CRXGoldenShop", PLUGIN_VERSION, FCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
	register_event("CurWeapon", "OnChangeWeapon", "be", "1=1")
	RegisterHam(Ham_TakeDamage, "player", "PreTakeDamage", 0)
	register_clcmd("say /gold", "Cmd_Shop")
	register_clcmd("say_team /gold", "Cmd_Shop")
	CC_SetPrefix("[&x04GOLD&x01]")
	
	g_MsgSync = CreateHudSyncObj();
	pCvar_duration = register_cvar("goldweap_duration_sec", "300");
	register_message(get_user_msgid("CurWeapon"), "message_cur_weapon");
}

public plugin_precache()
{
	precache_sound(SOUND_BUY)
	
	for(new i; i < sizeof(g_eItems); i++)
	{
		if(g_eItems[i][VModel][0])
			precache_model(g_eItems[i][VModel])
			
		if(g_eItems[i][PModel][0])
			precache_model(g_eItems[i][PModel])
	}
}
	
public client_putinserver(id)
	g_iWeapon[id] = NO_WEAPON
	
public PreTakeDamage(iVictim, iInflictor, iAttacker, Float:fDamage, iDamageBits)
{
	if(g_iWeapon[iAttacker] != NO_WEAPON)
		SetHamParamFloat(4, fDamage * g_eItems[g_iWeapon[iAttacker]][DmgMulti])
}

public OnChangeWeapon(id)
{
	if(g_iWeapon[id] == NO_WEAPON || read_data(2) != g_eItems[g_iWeapon[id]][Csw])
		return
		
	if(g_eItems[g_iWeapon[id]][VModel][0])
		set_pev(id, pev_viewmodel2, g_eItems[g_iWeapon[id]][VModel])
		
	if(g_eItems[g_iWeapon[id]][PModel][0])
		set_pev(id, pev_weaponmodel2, g_eItems[g_iWeapon[id]][PModel])
}
	
public Cmd_Shop(id)
{
	if(!is_user_alive(id))
		CC_SendMessage(id, "You need to be alive.")
	else
	{
		new iMenu = menu_create("\rGold Shop", "Shop_Handler")
		new szItem[64], iMoney = cs_get_user_money(id)
		
		for(new szKey[4], i; i < sizeof(g_eItems); i++)
		{
			if(g_iWeapon[id] == i)
				formatex(szItem, charsmax(szItem), "\d%s \y[OWNED]", g_eItems[i][Name])
			else
				formatex(szItem, charsmax(szItem), "%s%s \r[%i$]", iMoney >= g_eItems[i][Price] ? "\w" : "\d", g_eItems[i][Name], g_eItems[i][Price])
					
			num_to_str(i, szKey, charsmax(szKey))
			menu_additem(iMenu, szItem, szKey)
		}
		
		menu_display(id, iMenu)
	}
	
	return PLUGIN_HANDLED
}

public Shop_Handler(id, iMenu, iItem)
{
	if(iItem != MENU_EXIT && is_user_alive(id))
	{
		new szKey[4], iUnused
		menu_item_getinfo(iMenu, iItem, iUnused, szKey, charsmax(szKey), .callback = iUnused)
		
		new iKey = str_to_num(szKey)
		
		if(g_iWeapon[id] == iKey)
			CC_SendMessage(id, "You already have this item.")
		else
		{
			new iMoney = cs_get_user_money(id)
			
			if(iMoney < g_eItems[iKey][Price])
				CC_SendMessage(id, "You don't have enough money to purchase this item.")
			else
			{
				cs_set_user_money(id, iMoney - g_eItems[iKey][Price])
				CC_SendMessage(id, "You have bought ^3%s ^1for ^4%i$", g_eItems[iKey][Name], g_eItems[iKey][Price])
				emit_sound(id, CHAN_ITEM, SOUND_BUY, 1.0, ATTN_NORM, 0, PITCH_NORM)
				g_iWeapon[id] = iKey
				
				#if defined USING_REAPI
					#if defined REPLACE_OLD_WEAPONS
					rg_give_item(id, g_eItems[iKey][Weapon], GT_REPLACE)
					#else
					rg_give_item(id, g_eItems[iKey][Weapon], GT_APPEND)
					#endif
				#else
					#if defined REPLACE_OLD_WEAPONS
					StripWeapons(id, Primary)
					#endif
					
					give_item(id, g_eItems[iKey][Weapon])
				#endif
				
				cs_set_user_bpammo(id, g_eItems[iKey][Csw], g_eItems[iKey][Ammo])
				OnChangeWeapon(id)
				
				new iTask = id + TIMER_ID;
				if(task_exists(iTask))
					remove_task(iTask);
				
				g_iCounter[id] = get_pcvar_num(pCvar_duration);
				set_task(1.0, "goldweap_timer", id+TIMER_ID, .flags = "b");
			}
		}
	}

	menu_destroy(iMenu)
	return PLUGIN_HANDLED
}

public goldweap_timer(id)
{
	id -= TIMER_ID;
	
	if(is_user_connected(id) && is_user_alive(id) && g_iWeapon[id] != NO_WEAPON)
	{
		g_iCounter[id] --;
		
		set_hudmessage(255, 215, 0, 0.0, 0.20, 0, 0.0, 0.0, 0.1, 0.9);
		ShowSyncHudMsg(id, g_MsgSync, "%s expires in: %i", g_eItems[g_iWeapon[id]][Name], g_iCounter[id]);

		if(g_iCounter[id] == 1)
		{
			set_hudmessage(255, 215, 0, -1.0, 0.32, 1, 0.0, 4.0, 1.0, 1.0, -1);
			ShowSyncHudMsg(id, g_MsgSync, "Your %s Expired!", g_eItems[g_iWeapon[id]][Name]);
			
			g_iWeapon[id] = NO_WEAPON;
			
			new iTask = id + TIMER_ID;
			if(task_exists(iTask))
				remove_task(iTask);
		}
	}
}

// Current Weapon info
public message_cur_weapon(msg_id, msg_dest, msg_entity)
{
	// Not alive
	if (!is_user_alive(msg_entity) || g_iWeapon[msg_entity] == NO_WEAPON)
		return;
	
	// Not an active weapon
	if (get_msg_arg_int(1) != 1)
		return;
	
	// Get weapon's id
	new weapon = get_msg_arg_int(2)
	
	// Primary and secondary only
	if (MAXBPAMMO[weapon] <= 2)
		return;
	
	// Max out clip ammo
	new weapon_ent = fm_cs_get_current_weapon_ent(msg_entity)
	if (pev_valid(weapon_ent)) cs_set_weapon_ammo(weapon_ent, MAXCLIP[weapon])
	
	// HUD should show full clip all the time
	set_msg_arg_int(3, get_msg_argtype(3), MAXCLIP[weapon])
}

// Get User Current Weapon Entity
stock fm_cs_get_current_weapon_ent(id)
{
	// Prevent server crash if entity's private data not initalized
	if (pev_valid(id) != PDATA_SAFE)
		return -1;
	
	return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM);
}

#if AMXX_VERSION_NUM <= 182
public client_disconnect(id)
	#else
public client_connected(id)
#endif
{
	new iTask = id + TIMER_ID;
	if(task_exists(iTask))
		remove_task(iTask);
}
добавих Damage Multiplier, и безкрайни патрони (задържанка) на златните оръжия , махнах опцията за TEAM но провери дали работи правилно и пиши

Потребителски аватар

Автор на темата
iv69
Потребител
Потребител
Мнения: 355
Регистриран: 17 мар 2018, 15:34
Се отблагодари: 100 пъти
Получена благодарност: 10 пъти

Добавяне на "duration" към "golden weapon".

Мнение от iv69 » 15 май 2019, 19:07

blazz3rzbg написа:
15 май 2019, 18:26
безкрайни пълнители ???? искаш да задържаш ляв бутон без спирка ли ? :D

Добавено преди 7 минути 45 секунди:

Код: Избери всички

#include <amxmodx>
#include <cromchat>
#include <cstrike>
#include <fakemeta>
#include <fun>
#include <hamsandwich>

//#define USING_REAPI
#define REPLACE_OLD_WEAPONS

#if defined USING_REAPI
	#include <reapi>
#else
	#if defined REPLACE_OLD_WEAPONS
		#include <stripweapons>
	#endif
#endif

#define PLUGIN_VERSION "1.0"
#define SOUND_BUY "items/gunpickup2.wav"
#define NO_WEAPON -1

enum _:ItemInfo
{
	Name[32],
	Price,
	Weapon[16],
	Ammo,
	Csw,
	VModel[32],
	PModel[32],
	Float:DmgMulti
}

new const g_eItems[][ItemInfo] = 
{
	/* "Name", Price, "weapon_id", Bullets, CSW_ID, "v_model", "p_model", "Damage Multiplier" */
	{ "Golden Deagle", 	0, 	"weapon_deagle", 	35, 	CSW_DEAGLE, 	"models/v_deagle.mdl", 		"models/p_deagle.mdl", 		2.0 },
	{ "Golden M4A1", 	0, 	"weapon_m4a1", 		90, 	CSW_M4A1, 		"models/v_m4a1.mdl", 		"models/p_m4a1.mdl", 		2.0 },
	{ "Golden Glock", 	0, 	"weapon_glock18", 	30, 	CSW_GLOCK18, 	"models/v_glock18.mdl",	 	"models/p_glock18.mdl", 	2.0 },
	{ "Golden AK47", 	0, 	"weapon_ak47", 		90, 	CSW_AWP, 		"models/v_ak47.mdl", 		"models/p_ak47.mdl",	 	2.0 },
	{ "Golden AWP", 	0, 	"weapon_awp", 		30, 	CSW_AWP, 		"models/v_awp.mdl", 		"models/p_awp.mdl",			2.0 }
}

// CS Player CBase Offsets (win32)
const PDATA_SAFE = 2
const OFFSET_ACTIVE_ITEM = 373

// Max BP ammo for weapons
new const MAXBPAMMO[] = { -1, 52, -1, 90, 1, 32, 1, 100, 90, 1, 120, 100, 100, 90, 90, 90, 100, 120,
			30, 120, 200, 32, 90, 120, 90, 2, 35, 90, 90, -1, 100 };

// Max Clip for weapons
new const MAXCLIP[] = { -1, 13, -1, 10, -1, 7, -1, 30, 30, -1, 30, 20, 25, 30, 35, 25, 12, 20,
			10, 30, 100, 8, 30, 30, 20, -1, 7, 30, 30, -1, 50 };

new g_iWeapon[33]

const TIMER_ID = 123456;

new pCvar_duration;
new g_iCounter[33];

new g_MsgSync;
	
public plugin_init()
{
	register_plugin("Golden Shop", PLUGIN_VERSION, "OciXCrom")
	register_cvar("CRXGoldenShop", PLUGIN_VERSION, FCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
	register_event("CurWeapon", "OnChangeWeapon", "be", "1=1")
	RegisterHam(Ham_TakeDamage, "player", "PreTakeDamage", 0)
	register_clcmd("say /gold", "Cmd_Shop")
	register_clcmd("say_team /gold", "Cmd_Shop")
	CC_SetPrefix("[&x04GOLD&x01]")
	
	g_MsgSync = CreateHudSyncObj();
	pCvar_duration = register_cvar("goldweap_duration_sec", "300");
	register_message(get_user_msgid("CurWeapon"), "message_cur_weapon");
}

public plugin_precache()
{
	precache_sound(SOUND_BUY)
	
	for(new i; i < sizeof(g_eItems); i++)
	{
		if(g_eItems[i][VModel][0])
			precache_model(g_eItems[i][VModel])
			
		if(g_eItems[i][PModel][0])
			precache_model(g_eItems[i][PModel])
	}
}
	
public client_putinserver(id)
	g_iWeapon[id] = NO_WEAPON
	
public PreTakeDamage(iVictim, iInflictor, iAttacker, Float:fDamage, iDamageBits)
{
	if(g_iWeapon[iAttacker] != NO_WEAPON)
		SetHamParamFloat(4, fDamage * g_eItems[g_iWeapon[iAttacker]][DmgMulti])
}

public OnChangeWeapon(id)
{
	if(g_iWeapon[id] == NO_WEAPON || read_data(2) != g_eItems[g_iWeapon[id]][Csw])
		return
		
	if(g_eItems[g_iWeapon[id]][VModel][0])
		set_pev(id, pev_viewmodel2, g_eItems[g_iWeapon[id]][VModel])
		
	if(g_eItems[g_iWeapon[id]][PModel][0])
		set_pev(id, pev_weaponmodel2, g_eItems[g_iWeapon[id]][PModel])
}
	
public Cmd_Shop(id)
{
	if(!is_user_alive(id))
		CC_SendMessage(id, "You need to be alive.")
	else
	{
		new iMenu = menu_create("\rGold Shop", "Shop_Handler")
		new szItem[64], iMoney = cs_get_user_money(id)
		
		for(new szKey[4], i; i < sizeof(g_eItems); i++)
		{
			if(g_iWeapon[id] == i)
				formatex(szItem, charsmax(szItem), "\d%s \y[OWNED]", g_eItems[i][Name])
			else
				formatex(szItem, charsmax(szItem), "%s%s \r[%i$]", iMoney >= g_eItems[i][Price] ? "\w" : "\d", g_eItems[i][Name], g_eItems[i][Price])
					
			num_to_str(i, szKey, charsmax(szKey))
			menu_additem(iMenu, szItem, szKey)
		}
		
		menu_display(id, iMenu)
	}
	
	return PLUGIN_HANDLED
}

public Shop_Handler(id, iMenu, iItem)
{
	if(iItem != MENU_EXIT && is_user_alive(id))
	{
		new szKey[4], iUnused
		menu_item_getinfo(iMenu, iItem, iUnused, szKey, charsmax(szKey), .callback = iUnused)
		
		new iKey = str_to_num(szKey)
		
		if(g_iWeapon[id] == iKey)
			CC_SendMessage(id, "You already have this item.")
		else
		{
			new iMoney = cs_get_user_money(id)
			
			if(iMoney < g_eItems[iKey][Price])
				CC_SendMessage(id, "You don't have enough money to purchase this item.")
			else
			{
				cs_set_user_money(id, iMoney - g_eItems[iKey][Price])
				CC_SendMessage(id, "You have bought ^3%s ^1for ^4%i$", g_eItems[iKey][Name], g_eItems[iKey][Price])
				emit_sound(id, CHAN_ITEM, SOUND_BUY, 1.0, ATTN_NORM, 0, PITCH_NORM)
				g_iWeapon[id] = iKey
				
				#if defined USING_REAPI
					#if defined REPLACE_OLD_WEAPONS
					rg_give_item(id, g_eItems[iKey][Weapon], GT_REPLACE)
					#else
					rg_give_item(id, g_eItems[iKey][Weapon], GT_APPEND)
					#endif
				#else
					#if defined REPLACE_OLD_WEAPONS
					StripWeapons(id, Primary)
					#endif
					
					give_item(id, g_eItems[iKey][Weapon])
				#endif
				
				cs_set_user_bpammo(id, g_eItems[iKey][Csw], g_eItems[iKey][Ammo])
				OnChangeWeapon(id)
				
				new iTask = id + TIMER_ID;
				if(task_exists(iTask))
					remove_task(iTask);
				
				g_iCounter[id] = get_pcvar_num(pCvar_duration);
				set_task(1.0, "goldweap_timer", id+TIMER_ID, .flags = "b");
			}
		}
	}

	menu_destroy(iMenu)
	return PLUGIN_HANDLED
}

public goldweap_timer(id)
{
	id -= TIMER_ID;
	
	if(is_user_connected(id) && is_user_alive(id) && g_iWeapon[id] != NO_WEAPON)
	{
		g_iCounter[id] --;
		
		set_hudmessage(255, 215, 0, 0.0, 0.20, 0, 0.0, 0.0, 0.1, 0.9);
		ShowSyncHudMsg(id, g_MsgSync, "%s expires in: %i", g_eItems[g_iWeapon[id]][Name], g_iCounter[id]);

		if(g_iCounter[id] == 1)
		{
			set_hudmessage(255, 215, 0, -1.0, 0.32, 1, 0.0, 4.0, 1.0, 1.0, -1);
			ShowSyncHudMsg(id, g_MsgSync, "Your %s Expired!", g_eItems[g_iWeapon[id]][Name]);
			
			g_iWeapon[id] = NO_WEAPON;
			
			new iTask = id + TIMER_ID;
			if(task_exists(iTask))
				remove_task(iTask);
		}
	}
}

// Current Weapon info
public message_cur_weapon(msg_id, msg_dest, msg_entity)
{
	// Not alive
	if (!is_user_alive(msg_entity) || g_iWeapon[msg_entity] == NO_WEAPON)
		return;
	
	// Not an active weapon
	if (get_msg_arg_int(1) != 1)
		return;
	
	// Get weapon's id
	new weapon = get_msg_arg_int(2)
	
	// Primary and secondary only
	if (MAXBPAMMO[weapon] <= 2)
		return;
	
	// Max out clip ammo
	new weapon_ent = fm_cs_get_current_weapon_ent(msg_entity)
	if (pev_valid(weapon_ent)) cs_set_weapon_ammo(weapon_ent, MAXCLIP[weapon])
	
	// HUD should show full clip all the time
	set_msg_arg_int(3, get_msg_argtype(3), MAXCLIP[weapon])
}

// Get User Current Weapon Entity
stock fm_cs_get_current_weapon_ent(id)
{
	// Prevent server crash if entity's private data not initalized
	if (pev_valid(id) != PDATA_SAFE)
		return -1;
	
	return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM);
}

#if AMXX_VERSION_NUM <= 182
public client_disconnect(id)
	#else
public client_connected(id)
#endif
{
	new iTask = id + TIMER_ID;
	if(task_exists(iTask))
		remove_task(iTask);
}
добавих Damage Multiplier, и безкрайни патрони (задържанка) на златните оръжия , махнах опцията за TEAM но провери дали работи правилно и пиши
ОК , Благодаря, бягам да тествам !

Значи, имам въпрос, и се извинявам за неговото естество,но не съм чак толкова "навътре в естеството на нещата": Компилирах плъгина, всички нови и стари функции си работят на 6, но пак ми остана проблема с оръжието. Като купя например същото с което съм но златно - то се заменя директно със златно а старото ми го "изхвърля" каквато мисля, че е и идеята на плъгина. Но ако купя примерно ак47 а съм бил с м4а1 , ми добавя ак-то, а емката си остава у мене(т.е.съм с две "секундари уепон". След като ме убият вече нямям новото оръжие - а всички функции и екстри се "прехвърлят" на старото- в случая на м4а1. А брояча си остава и брои - свърши ли времето - свършват и екстрите върху старото. Въпроса ми е: каква е тази функция от 8-12 редове и тази библиотека include <reapi> ; тук https://www.amxx-bg.info/inc/ намерих само reapi_version.inc - , трябва ли да я слагам тази или... не разбирам.. , а и друго, аз не съм с REHLDS ... Или просто трябва да закоментирам тези редове така:

//#if defined USING_REAPI
#include <reapi>
//#else
#if defined REPLACE_OLD_WEAPONS
#include <stripweapons>
#endif
Възможно ли е от това да е проблема или си внушавам.
Грам не разбирам от вашето криптиране и сприптиране :) Може ли да ми обясните малко по-подробно ?
Благодаря

Добавено преди 1 час 11 минути 10 секунди:
Оп, извинявам се - намерих тази бибиотека там дето и компилирам плъгина, а сървъра е на съвсем друг сайт ... трябва ли да я има и там за да няма проблемa и изобщо може ли да е от това проблема, или ?

Потребителски аватар

blazz3rzbg NSFW
Потребител
Потребител
Мнения: 34
Регистриран: 22 фев 2019, 14:38
Местоположение: Стара Загора
Се отблагодари: 7 пъти
Получена благодарност: 11 пъти
Години: 18

Добавяне на "duration" към "golden weapon".

Мнение от blazz3rzbg NSFW » 15 май 2019, 20:50

ReApi не е проблем. това е просто библиотека с новите финкции от rehlds и в случая не ти трябва щом си hlds.

Моля прати ми csdm weapons menu-то мисля да ти добавя 4. Golden Weapons.

Вариант №1
Когато си купиш оръжие да ти маха старото каквото и да е то а когато умреш и се spawn-неш а таймер-а още е на лице и ти изкочи менюто за оръжията да излизат примено така
1. AK47
2. M4A1 [Golden]
Понеже вече си закупил golden оръжието и имаш още X секунди и при избор на (в случая) M4A1 тя още ще е златна а вече когато таймера не е на лице да ти излизат по обичайният начин.

Вариан №2
При закупено златно оръжие когато умреш и се преродиш автоматично да ти го дава а вече от менюто ти да си избираш дали да го затвориш или да играеш с автоматично даденото златно оръжие.

Потребителски аватар

Автор на темата
iv69
Потребител
Потребител
Мнения: 355
Регистриран: 17 мар 2018, 15:34
Се отблагодари: 100 пъти
Получена благодарност: 10 пъти

Добавяне на "duration" към "golden weapon".

Мнение от iv69 » 15 май 2019, 21:03

blazz3rzbg написа:
15 май 2019, 20:50
ReApi не е проблем. това е просто библиотека с новите финкции от rehlds и в случая не ти трябва щом си hlds.

Моля прати ми csdm weapons menu-то мисля да ти добавя 4. Golden Weapons.

Вариант №1
Когато си купиш оръжие да ти маха старото каквото и да е то а когато умреш и се spawn-неш а таймер-а още е на лице и ти изкочи менюто за оръжията да излизат примено така
1. AK47
2. M4A1 [Golden]
Понеже вече си закупил golden оръжието и имаш още X секунди и при избор на (в случая) M4A1 тя още ще е златна а вече когато таймера не е на лице да ти излизат по обичайният начин.

Вариан №2
При закупено златно оръжие когато умреш и се преродиш автоматично да ти го дава а вече от менюто ти да си избираш дали да го затвориш или да играеш с автоматично даденото златно оръжие.
Да попитам: като казваш csdm weapons menu-то - имаш впредвид файла csdm.cfg ли ? Ще го кача като код в отворен вид. А за вариантите; ами май 2 е по удобен ? Ето cs dm.cfg :

Код: Избери всички

;CSDM Configuration File
; Default settings by BAILOPAN

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;You must be running the Main plugin for this section
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[settings]

;Sets whether CSDM is enabled or not.
enabled = 1

;Sets whether or not players should be stripped of weapons on round start
; (excludes knife)
strip_weapons = 1

;Sets how long weapons should stay on the ground for after being dropped
;in seconds.  note that enabling this can create lots of lag for clients 
; AND server.  0 is immediate, -1 is infinite.
weapons_stay = 0

;Sets the spawn mode.
; "none" - users spawn at normal map spawn points
; "preset" - csdm_spawn_preset.amxx required, uses predefined spawns in config files
; -- others may be supplied by 3rd party plugins
spawnmode = preset

;Sets whether the bomb is removed
remove_bomb = 1

;Sets the spawn waiting time
spawn_wait_time = 0.9

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;You must be running the FFA plugin for this section
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[ffa]
;Set whether free for all mode is enabled by default
enabled = 1

;Set whether the radar is scrambled (0) or hidden at all (1)
radar_disable = 1

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;You must be running the Misc plugin for this section
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[misc]
;Map objectives are removed by their flags.
; a - as_ maps
; b - buyzones are removed
; c - cs_ maps
; d - de_ maps
remove_objectives = abcd

;Blocks people from using all buy commands
block_buy = 1

;Auto-refills ammo when it gets depleted
ammo_refill = 1

;Says a radio command to a player when they respawn
spawn_radio_msg = 0

;Hide money if block_buy is 1
hide_money = 0

;Hide timer if remove_objectives is acd or abcd
hide_timer = 1


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;You must be running the Stripper plugin for this section
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[stripper]
;Is stripping entities enabled?
enabled = 1

;write here the list of entities You want to remove from the map
;Note: 
;It's not recommended to put more then these listed below.
;HL sometimes behaves strange when You want to remove some entities
;so the plugin author cannot give You the warranty it will work
;with all entities You will write here. 
;These default ones below are tested and the game is not crashing with them

class = player_weaponstrip
class = game_player_equip
class = item_healthkit
class = item_battery
class = armoury_entity
class = item_longjump


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;You must be running the ticketing plugin for this section
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[ticketing]

;Is round ticketing enabled?
enabled = 0

;Number of times a team can have players respawn before they stop
;being able to respawn or (if the ticketing_player is enabled)
;number of times the player is able to respawn during one round
tickets = 10

;Shows the state of tickets: 0 - disabled, 1 - as HUD, 2 - as chat
show_state = 1

;Ticketing is counted for team (0) or separatelly for each player (1)
ticketing_player = 0

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;You must be running the protection plugin for this section
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[protection]

;Is spawn protection enabled?
enabled = 1

;Is glowing enabled if protection is on?
glowing = 1

;Colors of glow shell, leave this in quotes
;The digits are R, G, B, A where A is the alpha transparency
; (as A gets higher, the glow shell is thicker)
colorst = "255 0 0 200"
colorsct = "0 0 255 200"
colorsffa = "0 255 0 200"

;Number of seconds someone is protected after respawn.
time = 3

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;You must be running the equip plugin for these sections
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[equip]

;Equip Menu flags: 
; p - primary
; s - secondary
; a - armor
; g - grenade
; b - buy
menus = ps

;Autoitem flags:
; a - armor
; h - helmet
; g - grenades
; d - defusekit (CTs only!)
; n - nightvision
autoitems = g

;Grenade flags:
; f - flashbang
; h - he grenade
; s - smoke grenade
grenades = h

;Sets number of flashbangs given if
; grenades are enabled
fnadesnum = 2

;Enables the guns menu always when the players uses say "guns"
always_allow_gunmenu = 0

;;;;;;;;;;;;;;;;
;;WEAPON MENUS;;
;;;;;;;;;;;;;;;;

;Format for weapon menus is:
;shortname "Display Name" menupage
;Change the '1' to a '0' to block the weapon
;Removing or moving things 
;  from the list will change the order of the menus!

[secondary]
deagle Deagle 1
usp USP 1
elite Elite 1
fiveseven "Five Seven" 1
glock18 Glock 1
;p228 P228 1


[primary]
m4a1 M4A1 1
ak47 AK47 1
famas Famas 1
aug AUG 1
awp AWP 1
m249 M249 1
xm1014 XM1014 1

;sg552 SG552 1
;galil Galil 1
;scout Scout 1
;sg550 SG550 1
;g3sg1 G3SG1 1
;ump45 "UMP 45" 1
;mp5navy "MP5 Navy" 1
;m3 M3 1
;tmp TMP 1
;mac10 "Mac 10" 1
;p90 P90 1


;List weapons here the bots can randomly have
;The short name must match one in the list above
[botsecondary]
deagle

[botprimary]
tmp



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;You must be running the item mode plugin for this section
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[items]

;Is item mode enabled?
enabled = 0

;If set to 1, players will drop a pack of goodies when they die 
; (include weapon, ammo & jetpack); if set to 2  - same as one 
; but includes armor & heatlh also
drop_packs = 0

;Sets the number of armor given by a battery. Default is 15.
battery = 15

;Sets the number of health given by a medkit. Default is 15.
medkit = 15

;Sets the time to wait for an item to reappear on its place. Default is 20 (0 = permanent)
item_time = 20

;Sets how long packs stay on the ground. (Max is 30 seconds)
drop_time = 10

;If set to 1 the item will not have the falling down effect. Default is 0.
persistent_items = 0

;Sets how many he nades the user may keep in his hands. Default is 1.
max_hnades = 1

;Sets how many flashbangs the user may keep in his hands. Default is 2.
max_fnades = 2

;Sets how many smoke nades the user may keep in his hands. Default is 1.
max_snades = 1

;Allows/disallows to use gun menu if item mode is enabled.
;For example to pickup ammo You need item mode enabled, but guns You may 
;want to get from the menu instead from the ground.
no_gun_menu = 1


;Remove semicolons to restrict any of the following items
; or add the short weapon names of the weapons you want to restrict (m4a1, ak47, awp ...)
[item_restrictions]
;m4a1
;ak47
;aug
;sg552
;galil
;famas
;scout
;awp
;sg550
;m249
;g3sg1
;ump45
;mp5navy
;m3
;xm1014
;tmp
;mac10
;p90
;elite
;longjump
;medkit
;battery
;pistolammo
;rifleammo
;shotammo
;smgammo
;awpammo
;paraammo
;fullammo
;armor
;flashbang
;hegrenade
;smokegrenade
Или по-скоро искаш кода на плъгина който изкарваше менюто за оръжията: csdm_equip.amxx ?
Ето това ли:

Код: Избери всички

/**
 * csdm_equip.sma
 * Allows for Counter-Strike to be played as DeathMatch.
 *
 * CSDM Equipment Menu
 *
 * By Freecode and BAILOPAN
 * (C)2003-2014 David "BAILOPAN" Anderson
 *
 *  Give credit where due.
 *  Share the source - it sets you free
 *  http://www.opensource.org/
 *  http://www.gnu.org/
 */
 
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <csdm>
#include <fakemeta>

//Tampering with the author and name lines can violate the copyright
new PLUGINNAME[] = "CSDM Equip"
new VERSION[] = CSDM_VERSION
new AUTHORS[] = "CSDM Team"

#define	EQUIP_PRI	(1<<0)
#define	EQUIP_SEC	(1<<1)
#define	EQUIP_ARMOR	(1<<2)
#define	EQUIP_GREN	(1<<3)
#define EQUIP_ITEMS	(1<<4)
#define	EQUIP_ALL	(EQUIP_PRI|EQUIP_SEC|EQUIP_ARMOR|EQUIP_GREN|EQUIP_ITEMS)

#define ITEMTYPES_NUM	42

new bool:IsRestricted[ITEMTYPES_NUM] = {false, ...}	// Contains if an item is restricted or not
new RestrictWps[ITEMTYPES_NUM] = {32, ...}
new UsedWpsT[ITEMTYPES_NUM] = {0, ...}
new UsedWpsCT[ITEMTYPES_NUM] = {0, ...}

//Menus
new g_SecMenu[] = "CSDM: Secondary Weapons"		// Menu Name
new g_SecMenuID = -1							// Menu ID
new g_cSecondary								// Menu Callback
new bool:g_mSecStatus = true					// Menu Available?

new g_PrimMenu[] = "CSDM: Primary Weapons"
new g_PrimMenuID = -1
new g_cPrimary
new bool:g_mPrimStatus = true

new g_ArmorMenu[] = "CSDM: Armor"
new g_ArmorMenuID = -1
new bool:g_mArmorStatus = true

new g_NadeMenu[] = "CSDM: Grenades"
new g_NadeMenuID = -1
new bool:g_mNadeStatus = true

new g_EquipMenu[] = "CSDM: Equip"
new g_EquipMenuID = -1
new g_cEquip

new bool:g_mShowuser[33] = true

new bool:g_mAutoNades = false
new bool:g_mAutoArmor = false
new bool:g_AlwaysAllowGunMenu = false
new bool:g_AmmoRefill = false
new g_WeaponStayTime = 0

//Weapon Selections
new g_SecWeapons[33][18]
new g_PrimWeapons[33][18]
new bool:g_mNades[33]
new bool:g_mArmor[33]

//Config weapon storage holders
new g_BotPrim[MAX_WEAPONS][18]
new g_iNumBotPrim

new g_BotSec[MAX_WEAPONS][18]
new g_iNumBotSec

new g_Secondary[MAX_SECONDARY][18]
new bool:g_DisabledSec[MAX_WEAPONS]
new g_iNumSec
new g_iNumUsedSec = 0

new g_Primary[MAX_PRIMARY][18]
new bool:g_DisabledPrim[MAX_WEAPONS]
new g_iNumPrim
new g_iNumUsedPrim = 0

new pv_csdm_additems

#define SILENCED_M4A1	0
#define SILENCED_USP		1
new bool:g_Silenced[33][2]

//Misc
new g_Armor = 0
new fnadesnum = 0
new bool:g_Flash = false
new bool:g_Nade = false
new bool:g_Smoke = false
new bool:g_NightVision = false
new bool:g_DefuseKit = false

// page info for settings in CSDM Setting Menu
new g_SettingsMenu = 0
new g_EquipSettMenu = 0
new g_ItemsInMenuNr = 0
new g_PageSettMenu = 0

//Quick Fix for menu pages
new g_MenuState[33] = {0}

new Float:g_maxdelmenutime = 30.0

public csdm_Init(const version[])
{
	if (version[0] == 0)
	{
		set_fail_state("CSDM failed to load.")
		return
	}

	// Menus and callbacks
	g_SecMenuID = menu_create(g_SecMenu, "m_SecHandler", 0)
	g_PrimMenuID = menu_create(g_PrimMenu, "m_PrimHandler", 0)
	g_ArmorMenuID = menu_create(g_ArmorMenu, "m_ArmorHandler", 0)
	g_NadeMenuID = menu_create(g_NadeMenu, "m_NadeHandler", 0)
	g_EquipMenuID = menu_create(g_EquipMenu, "m_EquipHandler", 0)

	menu_setprop(g_PrimMenuID, MPROP_EXIT, MEXIT_NEVER)
	menu_setprop(g_SecMenuID, MPROP_EXIT, MEXIT_NEVER)

	g_cSecondary = menu_makecallback("c_Secondary")
	g_cPrimary = menu_makecallback("c_Primary")
	g_cEquip = menu_makecallback("c_Equip")
}

public csdm_CfgInit()
{
	csdm_reg_cfg("settings", "cfgMainSettings")
	csdm_reg_cfg("misc", "cfgMiscSettings")

	// Config reader
	csdm_reg_cfg("equip", "cfgSetting")

	// In order for weapon menu
	csdm_reg_cfg("secondary", "cfgSecondary")
	csdm_reg_cfg("primary", "cfgPrimary")
	csdm_reg_cfg("botprimary", "cfgBotPrim")
	csdm_reg_cfg("botsecondary", "cfgBotSec")
	csdm_reg_cfg("item_restrictions", "cfgrestricts")
	set_task(2.0, "check_cvar_pointers", 790)
}

public check_cvar_pointers()
{
	pv_csdm_additems = get_cvar_pointer("csdm_add_items")
}

public plugin_init()
{
	register_plugin(PLUGINNAME, VERSION, AUTHORS)

	// Build Armor/Nade/Equip Menu's
	buildMenu()
	
	register_clcmd("say guns", "enableMenu")
	register_clcmd("say /guns", "enableMenu")
	register_clcmd("say menu", "enableMenu")
	register_clcmd("say enablemenu", "enableMenu")
	register_clcmd("say enable_menu", "enableMenu")
	register_concmd("csdm_es_menu", "csdm_es_menu", ADMIN_MAP, "CSDM Equip Settings Menu")
	register_event("TextMsg","eRestart","a","2&#Game_C","2&#Game_w")

	new main_plugin = module_exists("csdm_main") ? true : false

	if (main_plugin)
	{
		g_SettingsMenu = csdm_settings_menu()
		g_ItemsInMenuNr = menu_items(g_SettingsMenu)
		g_PageSettMenu = g_ItemsInMenuNr / 7

		g_EquipSettMenu = menu_create("CSDM Equip Settings Menu", "use_csdm_equip_menu")

		menu_additem(g_SettingsMenu, "CSDM Equip Settings", "csdm_es_menu", ADMIN_MAP)

		if (g_EquipSettMenu)
		{
			new callback = menu_makecallback("hook_equip_sett_display")
			menu_additem(g_EquipSettMenu, "Equip Menu Primary Enabled/Disabled", "1", ADMIN_MAP, callback)
			menu_additem(g_EquipSettMenu, "Equip Menu Secondary Enabled/Disabled", "2", ADMIN_MAP, callback)
			menu_additem(g_EquipSettMenu, "Equip Menu Armor Enabled/Disabled", "3", ADMIN_MAP, callback)
			menu_additem(g_EquipSettMenu, "Equip Menu Grenades Enabled/Disabled", "4", ADMIN_MAP, callback)
			menu_additem(g_EquipSettMenu, "Auto equip with Armor Enabled/Disabled", "5", ADMIN_MAP, callback)
			menu_additem(g_EquipSettMenu, "Auto equip with Helmet Enabled/Disabled", "6", ADMIN_MAP, callback)
			menu_additem(g_EquipSettMenu, "Auto equip with Grenades Enabled/Disabled", "7", ADMIN_MAP, callback)
			menu_additem(g_EquipSettMenu, "Auto equip with Defuser Enabled/Disabled", "8", ADMIN_MAP, callback)
			menu_additem(g_EquipSettMenu, "Auto equip with Nightvision Enabled/Disabled", "9", ADMIN_MAP, callback)
			menu_additem(g_EquipSettMenu, "Flashbang Enabled/Disabled", "10", ADMIN_MAP, callback)
			menu_additem(g_EquipSettMenu, "Smoke grenade Enabled/Disabled", "11", ADMIN_MAP, callback)
			menu_additem(g_EquipSettMenu, "HE grenade Enabled/Disabled", "12", ADMIN_MAP, callback)
			menu_additem(g_EquipSettMenu, "Always Allow Gun Menu Enabled/Disabled", "13", ADMIN_MAP, callback)
			menu_additem(g_EquipSettMenu, "Back", "14", 0, -1)
		}
	}
	else 
		log_amx("CSDM - csdm_equip - no main plugin loaded")

	if (g_iNumUsedSec == 0)
		g_mSecStatus = false
	if (g_iNumUsedPrim == 0)
		g_mPrimStatus = false
}

public eRestart()
{
	arrayset(UsedWpsT, 0, ITEMTYPES_NUM)
	arrayset(UsedWpsCT, 0, ITEMTYPES_NUM)
	return PLUGIN_CONTINUE
}

public client_connect(id)
{
	g_mShowuser[id] = true
	g_mNades[id] = false
	g_mArmor[id] = false
	g_Silenced[id][SILENCED_M4A1] = false
	g_Silenced[id][SILENCED_USP] = false
	
	return PLUGIN_CONTINUE
}

public client_disconnect(id)
{
	g_mShowuser[id] = true
	g_mNades[id] = false
	g_mArmor[id] = false

	new weapons[MAX_WEAPONS], num
	new weapid
	new team = get_user_team(id)

	get_user_weapons(id, weapons, num)

	for (new i=0; i<num; i++)
	{
		weapid = weapons[i]
		if ((IsRestricted[weapid]) && (UsedWpsT[weapid] > 0) && (team == _TEAM_T))
		{
			UsedWpsT[weapid]--
		}
		if ((IsRestricted[weapid]) && (UsedWpsCT[weapid] > 0) && (team == _TEAM_CT))
		{
			UsedWpsCT[weapid]--
		}
	}
	return PLUGIN_CONTINUE
}

public csdm_RemoveWeapon(owner, entity_id, boxed_id)
{
	new classname[32], weapon
	new team
	if (!pev_valid(entity_id))
		return PLUGIN_HANDLED

	pev(entity_id, pev_classname, classname, 31)
	weapon = get_weaponid(classname)

	if (weapon == CSW_M4A1)
	{
		g_Silenced[owner][SILENCED_M4A1] = cs_get_weapon_silen(entity_id) ? true : false
	} else if (weapon == CSW_USP) {
		g_Silenced[owner][SILENCED_USP] = cs_get_weapon_silen(entity_id) ? true : false
	}

	if ((owner) && (weapon))
	{
		team = get_user_team(owner)

		if ((IsRestricted[weapon]) && (UsedWpsT[weapon] > 0) && (team == _TEAM_T))
		{
			UsedWpsT[weapon]--
//			log_amx("[DEBUG] CSDM - restricted weapon %s removed. Currently there is %d such weapons on the map.", classname, UsedWpsT[weapon])
		}
		if ((IsRestricted[weapon]) && (UsedWpsCT[weapon] > 0) && (team == _TEAM_CT))
		{
			UsedWpsCT[weapon]--
//			log_amx("[DEBUG] CSDM - restricted weapon %s removed. Currently there is %d such weapons on the map.", classname, UsedWpsCT[weapon])
		}
	}

	return PLUGIN_CONTINUE
}

public csdm_PostDeath(killer, victim, headshot, const weapon[])
{
	/* Clean up any defusal kits we might have made! */
	if (!g_DefuseKit)
	{
		return
	}
	
	/* This might have a race condition for team switches... */
	if (get_user_team(victim) == _TEAM_CT)
	{
		cs_set_user_defuse(victim, 0)
	}
}

public cfgSecondary(readAction, line[], section[])
{
	if (readAction == CFG_READ)
	{
		if (g_iNumSec >= MAX_SECONDARY)
			return PLUGIN_HANDLED
		
		new wep[16], display[48], dis[4]
		new cmd[6]

		parse(line, wep, 15, display, 47, dis, 3)
		
		new disabled = str_to_num(dis)
		
		//Copy weapon into array
		format(g_Secondary[g_iNumSec], 17, "weapon_%s", wep)

		g_DisabledSec[g_iNumSec] = disabled ? false : true		

		format(cmd,5,"%d ",g_iNumSec)
		g_iNumSec++

		if (disabled > 0)
		{
			g_iNumUsedSec++
		}

		//TODO: Add menu_destroy_items to remake menu on cfg reload
		menu_additem(g_SecMenuID, display, cmd, 0, g_cSecondary)
	}
	else if (readAction == CFG_RELOAD)
	{
		g_SecMenuID = menu_create(g_SecMenu, "m_SecHandler", 0)
		g_iNumSec = 0
		g_iNumUsedSec = 0
	}
	else if (readAction == CFG_DONE)
	{
		//Nothing for now
		return PLUGIN_HANDLED
	}
	
	return PLUGIN_HANDLED
}

public cfgPrimary(readAction, line[], section[])
{
	if (readAction == CFG_READ)
	{
		if (g_iNumPrim >= MAX_PRIMARY)	
			return PLUGIN_HANDLED
			
		new wep[16], display[48], dis[4]
		new cmd[6]

		parse(line, wep, 15, display, 47, dis, 3)
		
		new disabled = str_to_num(dis)
		
		//Copy weapon into array
		format(g_Primary[g_iNumPrim], 17, "weapon_%s", wep)
		g_DisabledPrim[g_iNumPrim] = disabled ? false : true
		
		format(cmd, 5, "%d", g_iNumPrim)
		g_iNumPrim++

		if (disabled > 0)
			g_iNumUsedPrim++


		//TODO: Add menu_destroy_items to remake menu on cfg reload
		menu_additem(g_PrimMenuID, display, cmd, 0, g_cPrimary)
	} else if (readAction == CFG_RELOAD) {
		g_PrimMenuID = menu_create(g_PrimMenu, "m_PrimHandler", 0)
		g_iNumPrim = 0
		g_iNumUsedPrim = 0
	} else if (readAction == CFG_DONE) {
		//Nothing for now
		return PLUGIN_HANDLED
	}
	
	return PLUGIN_HANDLED
}
	
	
public cfgBotPrim(readAction, line[], section[])
{
	if (readAction == CFG_READ)
	{
	
		new wep[16], display[32]

		parse(line, wep, 15, display, 31)
		
		//Copy weapon into array
		format(g_BotPrim[g_iNumBotPrim], 17, "weapon_%s", wep)
		g_iNumBotPrim++
	} else if (readAction == CFG_RELOAD) {
		g_iNumBotPrim = 0
	} else if (readAction == CFG_DONE) {
		//Nothing for now
		return PLUGIN_HANDLED
	}
	
	return PLUGIN_HANDLED
}

public cfgBotSec(readAction, line[], section[])
{
	if (readAction == CFG_READ)
	{
	
		new wep[16], display[32]

		parse(line, wep, 15, display, 31)
		
		//Copy weapon into array
		format(g_BotSec[g_iNumBotSec], 17, "weapon_%s", wep)
		g_iNumBotSec++
	} else if (readAction == CFG_RELOAD) {
		g_iNumBotSec = 0
	} else if (readAction == CFG_DONE) {
		//Nothing for now
		return PLUGIN_HANDLED
	}
	
	return PLUGIN_HANDLED
}

public cfgSetting(readAction, line[], section[])
{
	if (readAction == CFG_READ)
	{

		new setting[24], sign[3], value[6]

		parse(line, setting, 23, sign, 2, value, 5)
		
		// Menus settings
		if (contain(setting,"menus") != -1)
		{
			if (containi(value, "p") != -1)
			{
				g_mPrimStatus = true
			}
			
			if (containi(value, "s") != -1)
			{
				g_mSecStatus = true
			}
			
			if (containi(value, "a") != -1)
			{
				g_mArmorStatus = true
			}
			
			if (containi(value, "g") != -1)
			{
				g_mNadeStatus = true
			}
			
			return PLUGIN_HANDLED
		} else if (contain(setting, "autoitems") != -1) {

			if (containi(value, "a")  != -1)
			{
				//Disable Armor Menu
				g_mArmorStatus = false
				g_mAutoArmor = true
				
				g_Armor = 1
			}
						
			if (containi(value, "h") != -1)
			{
				//Disable Armor Menu
				g_mArmorStatus = false
				g_mAutoArmor = true
				g_Armor = 2
			}
			
			if (containi(value, "g") != -1)
			{
				//Disable Grenade Menu
				g_mNadeStatus = false
				g_mAutoNades = true
			}
			
			if (containi(value, "d") != -1)
			{
				g_DefuseKit = true
			}
			
			if (containi(value, "n") != -1)
			{
				g_NightVision = true
			}
			
			return PLUGIN_HANDLED
		} else if (contain(setting, "grenades") != -1) {
			if (containi(value, "f") != -1)
			{
				g_Flash = true
			}
			
			if (containi(value, "h") != -1)
			{
				g_Nade = true
			}
			
			if (containi(value, "s") != -1)
			{
				g_Smoke = true
			}
		} else if (contain(setting, "fnadesnum") != -1) {
			fnadesnum = str_to_num(value)
		} else if (contain(setting, "always_allow_gunmenu") != -1) {
			g_AlwaysAllowGunMenu = str_to_num(value)? true : false
		}
		return PLUGIN_HANDLED
	} else if (readAction == CFG_RELOAD) {
		g_mArmorStatus = false
		g_mNadeStatus = false
		g_Flash = false
		g_Nade = false
		g_Smoke = false
		g_Armor = 0
		g_mSecStatus = false
		g_mPrimStatus = false
		g_mAutoNades = false
		g_DefuseKit = false
		g_NightVision = false
		fnadesnum = 1
	} else if (readAction == CFG_DONE) {
		//Nothing for now
		return PLUGIN_HANDLED
	}
	
	return PLUGIN_HANDLED
}

public cfgrestricts(readAction, line[], section[])
{
	if (readAction == CFG_READ)
	{
		new itemname[24], value[32], limit
		parse(line, itemname, 23, value, 31)

		limit = 0
		if (value[0] != '0')
    	limit = str_to_num(value)

		new weapname[24], weaptype

		format(weapname, 23, "weapon_%s", itemname)

		weaptype = getWeapId(weapname)
//		weaptype = get_weaponid(weapname) // why this crap doesn't work here but works correctly during the game ?!?
//		log_amx("[DEBUG] CSDM - reading restrictions, weapon %s (weaptype = %d).", itemname, weaptype)
		if (weaptype != 0)
    {
			IsRestricted[weaptype] = true
			RestrictWps[weaptype] = limit
		}
//		log_amx("[DEBUG] CSDM - reading restrictions, restricted %s (weaptype = %d) = %d", itemname, weaptype, limit)
	}
	else if (readAction == CFG_RELOAD)
	{
		// Reset all restrictions
		arrayset(IsRestricted, false, ITEMTYPES_NUM)
		arrayset(RestrictWps, 32, ITEMTYPES_NUM)
		return PLUGIN_HANDLED
	}
	else if (readAction == CFG_DONE)
	{
		//Nothing for now
		return PLUGIN_HANDLED
	}
	return PLUGIN_HANDLED
}

public cfgMainSettings(readAction, line[], section[])
{
	if (readAction == CFG_READ)
	{
		new setting[24], sign[3], value[32];

		parse(line, setting, 23, sign, 2, value, 31);
		
		if (equali(setting, "weapons_stay")) {
			g_WeaponStayTime = str_to_num(value)
		}
	}
}

public cfgMiscSettings(readAction, line[], section[])
{		
	if (readAction == CFG_READ)
	{
		new setting[24], sign[3], value[32];

		parse(line, setting, 23, sign, 2, value, 31);
		
		if (equali(setting, "ammo_refill")) {
			g_AmmoRefill = str_to_num(value) ? true : false
		}
	} else if (readAction == CFG_RELOAD) {
		g_AmmoRefill = true
	}
}

//Equipment Menu callback
public c_Equip(id, menu, item)
{
	if( item < 0 ) return PLUGIN_CONTINUE

	new cmd[6], iName[64]
	new access, callback
	
	menu_item_getinfo(menu, item, access, cmd,5, iName, 63, callback)

	new weapon_s, weapon_p
	weapon_s = get_weaponid(g_SecWeapons[id])
	weapon_p = get_weaponid(g_PrimWeapons[id])
	if ( ((weapon_s == 0) && g_mSecStatus) || ((weapon_p == 0) && g_mPrimStatus) || IsRestricted[weapon_s] || IsRestricted[weapon_p] )
		return ITEM_DISABLED
	else
		return ITEM_ENABLED
	return PLUGIN_HANDLED
}

//Secondary Weapon Callback
public c_Secondary(id, menu, item)
{
	if( item < 0 ) return PLUGIN_CONTINUE
	
	new cmd[6], iName[64]
	new access, callback
	
	menu_item_getinfo(menu, item, access, cmd,5, iName, 63, callback)
	
	new dis = str_to_num(cmd)
	new team = get_user_team(id)
	new weaptype = get_weaponid(g_Secondary[dis])

	//Check to see if item is disabled
	if (g_DisabledSec[dis])
	{
		return ITEM_DISABLED
	}
	else if (!IsRestricted[weaptype])
	{
		return ITEM_ENABLED
	}
	else if ((UsedWpsT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_T) 
		|| (UsedWpsCT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_CT))
	{
		return ITEM_ENABLED
	}
	else
	{
		return ITEM_DISABLED
	}	
	return PLUGIN_HANDLED
}

//Primary Weapon Callback
public c_Primary(id, menu, item)
{

	if (item < 0)
		return PLUGIN_CONTINUE
	
	// Get item info
	new cmd[6], iName[64]
	new access, callback
	
	menu_item_getinfo(menu, item, access, cmd,5, iName, 63, callback)
	
	new dis = str_to_num(cmd)
	new team = get_user_team(id)
	new weaptype = get_weaponid(g_Primary[dis])

	//Check to see if item is disabled
	if (g_DisabledPrim[dis])
	{
		return ITEM_DISABLED
	}
	else if (!IsRestricted[weaptype])
	{
		return ITEM_ENABLED
	}
	else if ((UsedWpsT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_T) 
					|| (UsedWpsCT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_CT))
	{
		return ITEM_ENABLED
	}
	else
	{
		return ITEM_DISABLED
	}		
	return PLUGIN_HANDLED
}

//Equipment Menu handler
public m_EquipHandler(id, menu, item)
{
	if (item < 0)
	{
		return PLUGIN_CONTINUE
	}

	// Get item info
	new cmd[2], iName[64]
	new access, callback
	
	menu_item_getinfo(menu, item, access, cmd, 1, iName, 63, callback)
	
	new choice = str_to_num(cmd)
	
	switch(choice)
	{
		case 1:
		{
			if (g_mSecStatus)
			{
				menu_display(id, g_SecMenuID, 0)
			}
			else if (g_mPrimStatus)
			{
				menu_display(id, g_PrimMenuID, 0)
			}
			else if (g_mArmorStatus)
			{
				menu_display(id, g_ArmorMenuID, 0)
			}
			else if (g_mNadeStatus)
			{
				if (g_mAutoArmor)
				{
					equipUser(id, EQUIP_ARMOR)
				}
				menu_display(id, g_NadeMenuID, 0)
			} else {
				if (g_mAutoArmor)
				{
					equipUser(id, EQUIP_ARMOR)
				}
				if (g_mAutoNades)
				{
					equipUser(id, EQUIP_GREN)
				}
				equipUser(id, EQUIP_ITEMS)
			}
		}
		case 2:
		{
			// Equip person with last settings
			equipUser(id, EQUIP_ALL)
		}
		case 3:
		{
			g_mShowuser[id] = false
			client_print(id, print_chat, "[CSDM] Type ^"guns^" in chat to re-enable your equip menu.")
			equipUser(id, EQUIP_ALL)
		}
	}
	
	return PLUGIN_HANDLED
}


//Secondary Weapon Menu handler
public m_SecHandler(id, menu, item)
{
	// Get item info
	new cmd[6], iName[64]
	new access, callback
	
	menu_item_getinfo(menu, item, access, cmd,5, iName, 63, callback)
	
	new wep = str_to_num(cmd)
	
	new team = get_user_team(id)
	new weaptype = get_weaponid(g_Secondary[wep])

	if (((UsedWpsT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_T) 
			|| (UsedWpsCT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_CT))
      && !g_DisabledSec[wep])
	{
		copy(g_SecWeapons[id],17,g_Secondary[wep])
		equipUser(id, EQUIP_SEC)
	}
	else if (g_mSecStatus)
	{
		menu_display(id, g_SecMenuID, 0)
		return PLUGIN_HANDLED
	}

	// Show next menu here
	
	if (g_mPrimStatus)
	{
		menu_display(id, g_PrimMenuID, 0)
	}
	else if (g_mArmorStatus)
	{
		menu_display(id, g_ArmorMenuID, 0)
	}
	else if (g_mNadeStatus)
	{
		if (g_mAutoArmor)
		{
			equipUser(id, EQUIP_ARMOR)
		}
		menu_display(id, g_NadeMenuID, 0)
	}
	else
	{
		if (g_mAutoArmor)
		{
			equipUser(id, EQUIP_ARMOR)
		}
		if (g_mAutoNades)
		{
			equipUser(id, EQUIP_GREN)
		}
		equipUser(id, EQUIP_ITEMS)
	}
	
	return PLUGIN_HANDLED
}

//Primary Weapon Menu handler
public m_PrimHandler(id, menu, item)
{
	if (item < 0)  return PLUGIN_HANDLED
	
	// Get item info
	new cmd[6], iName[64]
	new access, callback
	
	if (menu_item_getinfo(menu, item, access, cmd,5, iName, 63, callback))
	{
		new wep = str_to_num(cmd)
	
		new team = get_user_team(id)
		new weaptype = get_weaponid(g_Primary[wep])

		if (((UsedWpsT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_T) 
			|| (UsedWpsCT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_CT))
         && !g_DisabledPrim[wep])
		{
			copy(g_PrimWeapons[id], 17, g_Primary[wep])
			equipUser(id, EQUIP_PRI)
		}
		else if (g_mPrimStatus)
		{
			menu_display(id, g_PrimMenuID, 0)
			return PLUGIN_HANDLED
		}
	}

	// Show next menu here
		
	if (g_mArmorStatus)
	{
		menu_display(id, g_ArmorMenuID, 0)
	}
	else if (g_mNadeStatus)
	{
		if (g_mAutoArmor)
		{
			equipUser(id, EQUIP_ARMOR)
		}
		menu_display(id, g_NadeMenuID, 0)
	} else {
		if (g_mAutoArmor)
		{
			equipUser(id, EQUIP_ARMOR)
		}
		if (g_mAutoNades)
		{
			equipUser(id, EQUIP_GREN)
		}
		equipUser(id, EQUIP_ITEMS)
	}
	
	return PLUGIN_HANDLED
}

//Armor Menu handler
public m_ArmorHandler(id, menu, item)
{
	if (item < 0) return PLUGIN_CONTINUE
	
	// Get item info
	new cmd[6], iName[64]
	new access, callback

	menu_item_getinfo(menu, item, access, cmd,5, iName, 63, callback)
	
	new choice = str_to_num(cmd)
	
	if (choice == 1)
	{
		g_mArmor[id] = true
	}
	else if (choice == 2)
	{
		g_mArmor[id] = false
	}
	equipUser(id, EQUIP_ARMOR)
	
	// Show next menu here
	
	if (g_mNadeStatus)
	{
		menu_display(id, g_NadeMenuID, 0)
	} else {
		if (g_mAutoNades)
		{
			equipUser(id, EQUIP_GREN)
		}
		equipUser(id, EQUIP_ITEMS)
	}
	
	return PLUGIN_HANDLED
}

//Nade Menu handler
public m_NadeHandler(id, menu, item)
{
	if (item < 0) return PLUGIN_CONTINUE
	
	new cmd[6], iName[64]
	new access, callback
	
	menu_item_getinfo(menu, item, access, cmd, 5, iName, 63, callback)
	
	new choice = str_to_num(cmd)
	
	if (choice == 1)
	{
		g_mNades[id] = true
	}
	else if (choice == 2)
	{
		g_mNades[id] = false
	}
	
	equipUser(id, EQUIP_GREN)
	equipUser(id, EQUIP_ITEMS)

	return PLUGIN_HANDLED
}

buildMenu()
{
	//Equip Menu
	menu_additem(g_EquipMenuID, "New Weapons", "1", 0, -1)
	menu_additem(g_EquipMenuID, "Previous Setup", "2", 0, g_cEquip)
	menu_additem(g_EquipMenuID, "2+Don't show menu again", "3", 0, g_cEquip)
	menu_setprop(g_EquipMenuID, MPROP_EXIT, MEXIT_NEVER)

	//Armor Menu
	menu_additem(g_ArmorMenuID, "Yes, armor up", "1", 0, -1)
	menu_additem(g_ArmorMenuID, "No Armor", "2", 0, -1)
	menu_setprop(g_ArmorMenuID, MPROP_EXIT, MEXIT_NEVER)
	
	//Nade Menu
	menu_additem(g_NadeMenuID, "All Grenades", "1", 0, -1)
	menu_additem(g_NadeMenuID, "No Grenades", "2", 0, -1)
	menu_setprop(g_NadeMenuID, MPROP_EXIT, MEXIT_NEVER)
	
	return PLUGIN_HANDLED
}

equipUser(id, to)
{
	if (!is_user_alive(id) )
		return
	
	new weaptype
	new team = get_user_team(id)

	if ((to & EQUIP_SEC) && get_weaponid(g_SecWeapons[id]))
	{
		//Give Secondary
		GiveUserFullWeapon(id, g_SecWeapons[id])
	}
	
	if ((to & EQUIP_PRI) && get_weaponid(g_PrimWeapons[id]))
	{
		//Give Primary
		GiveUserFullWeapon(id, g_PrimWeapons[id])
	}
	
	if (to & EQUIP_ARMOR)
	{
		//Give Armor
		if (g_mAutoArmor || g_mArmor[id])
		{
			new armor = g_mArmor[id] ? 2 : g_Armor
			cs_set_user_armor(id, DEFAULT_ARMOR, CsArmorType:armor)
		}
	}
	
	if (to & EQUIP_GREN)
	{
		//Give Nades
		if (g_mNades[id] || g_mAutoNades)
		{
				
			if (g_Nade)
			{
				weaptype = get_weaponid("weapon_hegrenade")

				if (IsRestricted[weaptype])
				{
					if ((UsedWpsT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_T))
					{
						UsedWpsT[weaptype]++
						GiveUserFullWeapon(id,"weapon_hegrenade")
					}
					if ((UsedWpsCT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_CT))
					{
						UsedWpsCT[weaptype]++
						GiveUserFullWeapon(id,"weapon_hegrenade")
					}
				}
				else
					GiveUserFullWeapon(id,"weapon_hegrenade")
			}
			
			if (g_Smoke)
			{
				weaptype = get_weaponid("weapon_smokegrenade")

				if (IsRestricted[weaptype])
				{
					if ((UsedWpsT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_T))
					{
						UsedWpsT[weaptype]++
						GiveUserFullWeapon(id,"weapon_smokegrenade")
					}
					if ((UsedWpsCT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_CT))
					{
						UsedWpsCT[weaptype]++
						GiveUserFullWeapon(id,"weapon_smokegrenade")
					}
				}
				else
					GiveUserFullWeapon(id, "weapon_smokegrenade")
			}
		
			if (g_Flash && fnadesnum)
			{
				weaptype = get_weaponid("weapon_flashbang")
				if (IsRestricted[weaptype])
				{
					if ((UsedWpsT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_T))
					{
						UsedWpsT[weaptype]++
						GiveUserFullWeapon(id, "weapon_flashbang")
					}
					if ((UsedWpsCT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_CT))
					{
						UsedWpsCT[weaptype]++
						GiveUserFullWeapon(id, "weapon_flashbang")
					}
				}
				else
					GiveUserFullWeapon(id, "weapon_flashbang")
				if (fnadesnum == 2)
				{
					if (IsRestricted[weaptype])
					{
						if ((UsedWpsT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_T))
						{
							UsedWpsT[weaptype]++
							GiveUserFullWeapon(id, "weapon_flashbang")
						}
						if ((UsedWpsCT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_CT))
						{
							UsedWpsCT[weaptype]++
							GiveUserFullWeapon(id, "weapon_flashbang")
						}
					}
					else 
						GiveUserFullWeapon(id, "weapon_flashbang")
				}
			}
		}
	}
	
	if (to & EQUIP_ITEMS)
	{
		if (g_DefuseKit && (get_user_team(id) == _TEAM_CT))
		{
			cs_set_user_defuse(id, 1)
		}
		if (g_NightVision)
		{
			cs_set_user_nvg(id, 1)
		}
	}
}

GiveUserFullWeapon(id, const wp[])
{
	/** First check to make sure the user does not have a weapon in this slot */
	new wpnid = get_weaponid(wp)
	new weapons[MAX_WEAPONS], num
	new name[24], weap
	new slot

	if (!is_user_connected(id)) return

	new team = get_user_team(id)

	if (wpnid == 0)
	{
		if (equal(wp, "weapon_shield"))
		{
			slot = SLOT_PRIMARY
			wpnid = -1
		}
	} else {
		slot = g_WeaponSlots[wpnid]
	}
	if ((slot == SLOT_SECONDARY || slot == SLOT_PRIMARY)
		 && wpnid > 0)
	{
		get_user_weapons(id, weapons, num)
		for (new i=0; i<num; i++)
		{
			weap = weapons[i]
			if (weap == wpnid)
			{
				continue
			}
			if (g_WeaponSlots[weap] == slot)
			{
				if (slot == SLOT_SECONDARY && cs_get_user_shield(id))
				{
					//temporary fix!
					drop_with_shield(id, weap)
				} else {
					get_weaponname(weap, name, 23)
					csdm_force_drop(id, name)
				}
			}
		}
	} else if (slot == SLOT_PRIMARY && wpnid == -1 && cs_get_user_shield(id)) {
		return
	}
	
	if (slot == SLOT_PRIMARY && cs_get_user_shield(id) && wpnid > 0)
	{
		csdm_fwd_drop(id, -1, "weapon_shield")
	}
	
	new item_id = csdm_give_item(id, wp)
	if (item_id > 0)
	{
		if (wpnid == CSW_M4A1)
		{
			cs_set_weapon_silen(item_id, g_Silenced[id][SILENCED_M4A1], 1)
		} else if (wpnid == CSW_USP) {
			cs_set_weapon_silen(item_id, g_Silenced[id][SILENCED_USP], 1)
		}
	}

	if (wpnid > 0)
	{
		new bpammo = g_MaxBPAmmo[wpnid]
		if (bpammo)
		{
			cs_set_user_bpammo(id, wpnid, bpammo)
		}

		if (IsRestricted[wpnid])
		{
			if ((UsedWpsT[wpnid] < RestrictWps[wpnid]) && (team == _TEAM_T))
			{
				UsedWpsT[wpnid]++
			}
			if ((UsedWpsCT[wpnid] < RestrictWps[wpnid]) && (team == _TEAM_CT))
			{
				UsedWpsCT[wpnid]++
			}
		}
	}
}

// MAIN FUNCTION OF THE PLUGIN
public csdm_PostSpawn(player)
{
	if (pv_csdm_additems)
	{
	if (get_pcvar_num(pv_csdm_additems))
		return PLUGIN_CONTINUE
	}

	if (is_user_bot(player))
	{
			new i, weapon_p, weapon_s
			new randPrim = random_num(0, g_iNumBotPrim-1)
			new randSec = random_num(0, g_iNumBotSec-1)

			new team = get_user_team(player)
			weapon_p = get_weaponid(g_BotPrim[randPrim])

			i = 0
			while ((i < 10) && (IsRestricted[weapon_p]) 
					&& ((UsedWpsT[weapon_p] >= RestrictWps[weapon_p]) && (team == _TEAM_T) 
							|| (UsedWpsCT[weapon_p] >= RestrictWps[weapon_p]) && (team == _TEAM_CT)))
			{
				randPrim++
				if (randPrim >= g_iNumBotPrim)
					randPrim = 0
				weapon_p = get_weaponid(g_BotPrim[randPrim])
				i++
			}

			weapon_s = get_weaponid(g_BotSec[randSec])
			i = 0
			while ((i < 10) && (IsRestricted[weapon_s]) 
					&& ((UsedWpsT[weapon_s] >= RestrictWps[weapon_s]) && (team == _TEAM_T) 
							|| (UsedWpsCT[weapon_s] >= RestrictWps[weapon_s]) && (team == _TEAM_CT)))
			{
				randSec++
				if (randSec >= g_iNumBotSec)
					randSec = 0
				weapon_s = get_weaponid(g_BotSec[randSec])
				i++
			}

			new randArm = random_num(0, 2)
			new randGre = random_num(0, 2)
			
			if (g_mPrimStatus)
				GiveUserFullWeapon(player, g_BotPrim[randPrim])
			if (g_mSecStatus)
				GiveUserFullWeapon(player, g_BotSec[randSec])

			g_mArmor[player] = (g_mArmorStatus && randArm)
			g_mNades[player] = (g_mNadeStatus && randGre)
	
			if (g_mAutoArmor || g_mArmor[player])
			{
				equipUser(player, EQUIP_ARMOR)
			}

			if (g_mAutoNades || g_mNades[player])
			{
				equipUser(player, EQUIP_GREN)
			}
			if (g_DefuseKit)
			{
				equipUser(player, EQUIP_ITEMS)
			}
	} else {
		if (g_mShowuser[player])
		{
			new oldmenuid, newmenuid
			new bool:bEquipMenuDisp = false

			player_menu_info(player, oldmenuid, newmenuid) // main thing to prevent overwrite some menu by gun menu

			if ((newmenuid != -1) && ((newmenuid == g_SecMenuID) || (newmenuid == g_PrimMenuID) 
				|| (newmenuid == g_ArmorMenuID) || (newmenuid == g_EquipMenuID)))
				bEquipMenuDisp = true

			if ((bEquipMenuDisp) || (oldmenuid<=0) || (g_maxdelmenutime==0))
			{
				g_MenuState[player] = 1
				menu_display(player, g_EquipMenuID, 0)
			}
			else
			{
				new param[1]
				param[0] = player
				if (g_maxdelmenutime>0)	set_task(1.0,	"checkmenu",	850+player,	param,	1,	"b")
				set_task(g_maxdelmenutime, "menu_delayed", 700+player, param, 1)
			}
		} else {
			g_MenuState[player] = 0
			set_task(0.2, "delay_equip", player)
//			equipUser(player, EQUIP_ALL)
		}
	}
	return PLUGIN_CONTINUE
}

public delay_equip(id)
{
	if (is_user_connected(id))
		equipUser(id, EQUIP_ALL)
}

public enableMenu(id)
{
	if (!csdm_active())
		return PLUGIN_CONTINUE
		
	if (!g_mShowuser[id])
	{
		g_mShowuser[id] = true
		client_print(id, print_chat, "[CSDM] Your equip menu has been re-enabled.")
		if (!g_MenuState[id])
		{
			g_MenuState[id] = 1
			menu_display(id, g_EquipMenuID, 0)
		}
	} 
	else if (!g_AlwaysAllowGunMenu || !g_AmmoRefill || (g_WeaponStayTime > 5))
	{
		if (!g_AlwaysAllowGunMenu)
			client_print(id, print_chat, "[CSDM] Your equip menu is already enabled - You should have a gun already.")
		else if (!g_AmmoRefill)
			client_print(id, print_chat, "[CSDM] You cannot use guns menu when You have a gun already and ammorefill is disabled.")
		else if (g_WeaponStayTime > 5)
			client_print(id, print_chat, "[CSDM] You cannot use guns menu when You have a gun already and weapon_stay time is too long.")
	}
	else
	{
		g_MenuState[id] = 1
		menu_display(id, g_EquipMenuID, 0)
	}
	return PLUGIN_HANDLED
}

public checkmenu(param[])
{
	new id = param[0]
	if (!id)
	{
		if (task_exists(850+id)) remove_task(850+id)
		return PLUGIN_CONTINUE
	}
	if (!is_user_connected(id))
	{
		if (task_exists(850+id)) remove_task(850+id)
		return PLUGIN_CONTINUE
	}

	new oldmenuid, newmenuid
	new bool:bEquipMenuDisp = false

	player_menu_info(id, oldmenuid, newmenuid)

	if ((newmenuid != -1) && ((newmenuid == g_SecMenuID) || (newmenuid == g_PrimMenuID) 
		|| (newmenuid == g_ArmorMenuID) || (newmenuid == g_EquipMenuID)))
		bEquipMenuDisp = true

	if ((oldmenuid<=0) || (bEquipMenuDisp))
	{
		g_MenuState[id] = 1
		menu_display(id, g_EquipMenuID, 0)
		if (task_exists(850+id)) remove_task(850+id)
		if (task_exists(700+id)) remove_task(700+id)
	}	
	return PLUGIN_CONTINUE
}

public menu_delayed(param[])
{
	new id = param[0]
	if (!id)
	{
		if (task_exists(700+id)) remove_task(700+id)
		return PLUGIN_HANDLED
	}

	if (!is_user_connected(id))
	{
		if (task_exists(850+id)) remove_task(850+id)
		return PLUGIN_HANDLED
	}

	g_MenuState[id] = 1
	menu_display(id, g_EquipMenuID, 0)
	
	if (task_exists(700+id))	remove_task(700+id)
	if (task_exists(850+id))  remove_task(850+id)	
	return PLUGIN_CONTINUE
}

stock getWeapId(wp[]) // this one is used, because get_weaponid doesn't work when csdm_CfgInit is called (something wrong with core intitialisation?
{
	if (equali(wp, "weapon_p228")) {
		return CSW_P228
	} else if (equali(wp, "weapon_scout")) {
		return CSW_SCOUT
	} else if (equali(wp, "weapon_hegrenade")) {
		return CSW_HEGRENADE
	} else if (equali(wp, "weapon_xm1014")) {
		return CSW_XM1014
	} else if (equali(wp, "weapon_c4")) {
		return CSW_C4
	} else if (equali(wp, "weapon_mac10")) {
		return CSW_MAC10
	} else if (equali(wp, "weapon_aug")) {
		return CSW_AUG
	} else if (equali(wp, "weapon_smokegrenade")) {
		return CSW_SMOKEGRENADE
	} else if (equali(wp, "weapon_elite")) {
		return CSW_ELITE
	} else if (equali(wp, "weapon_fiveseven")) {
		return CSW_FIVESEVEN
	} else if (equali(wp, "weapon_ump45")) {
		return CSW_UMP45
	} else if (equali(wp, "weapon_sg550")) {
		return CSW_SG550
	} else if (equali(wp, "weapon_galil")) {
		return CSW_GALIL
	} else if (equali(wp, "weapon_famas")) {
		return CSW_FAMAS
	} else if (equali(wp, "weapon_usp")) {
		return CSW_USP
	} else if (equali(wp, "weapon_glock18")) {
		return CSW_GLOCK18
	} else if (equali(wp, "weapon_awp")) {
		return CSW_AWP
	} else if (equali(wp, "weapon_mp5navy")) {
		return CSW_MP5NAVY
	} else if (equali(wp, "weapon_m249")) {
		return CSW_M249
	} else if (equali(wp, "weapon_m3")) {
		return CSW_M3
	} else if (equali(wp, "weapon_m4a1")) {
		return CSW_M4A1
	} else if (equali(wp, "weapon_tmp")) {
		return CSW_TMP
	} else if (equali(wp, "weapon_g3sg1")) {
		return CSW_G3SG1
	} else if (equali(wp, "weapon_flashbang")) {
		return CSW_FLASHBANG
	} else if (equali(wp, "weapon_deagle")) {
		return CSW_DEAGLE
	} else if (equali(wp, "weapon_sg552")) {
		return CSW_SG552
	} else if (equali(wp, "weapon_ak47")) {
		return CSW_AK47
	} else if (equali(wp, "weapon_knife")) {
		return CSW_KNIFE
	} else if (equali(wp, "weapon_p90")) {
		return CSW_P90
	}
	
	return 0
}

// stuff for settings menu - START

public csdm_es_menu(id, level, cid)
{
	if (!cmd_access(id, level, cid, 1) || !id)
		return PLUGIN_HANDLED

	menu_display(id, g_EquipSettMenu, 0)

	return PLUGIN_HANDLED
}

public use_csdm_equip_menu(id, menu, item)
{
	if (item < 0)
		return PLUGIN_CONTINUE

	new command[6], paccess, call
	if (!menu_item_getinfo(g_EquipSettMenu, item, paccess, command, 5, _, 0, call))
	{
		log_amx("Error: csdm_menu_item() failed (menu %d) (page %d) (item %d)", g_EquipSettMenu, 0, item)
		return PLUGIN_HANDLED
	}
	if (paccess && !(get_user_flags(id) & paccess))
	{
		client_print(id, print_chat, "You do not have access to this menu option.")
		return PLUGIN_HANDLED
	}

	new iChoice = str_to_num(command)
	
	switch(iChoice)
	{
		case 1:
		{
			g_mPrimStatus = g_mPrimStatus? false : true

			client_print(id, print_chat, "CSDM displaying primary gun menu %s.", g_mPrimStatus ? "enabled" : "disabled")
			log_amx("CSDM displaying primary gun menu %s.", g_mPrimStatus ? "enabled" : "disabled")

			menu_display(id, g_EquipSettMenu, 0)
			write_menus_settings(id)
			return PLUGIN_HANDLED
		}
		case 2:
		{
			g_mSecStatus = g_mSecStatus? false : true

			client_print(id, print_chat, "CSDM displaying secondary gun menu %s.", g_mSecStatus ? "enabled" : "disabled")
			log_amx("CSDM displaying secondary gun menu %s.", g_mSecStatus ? "enabled" : "disabled")

			menu_display(id, g_EquipSettMenu, 0)
			write_menus_settings(id)
			return PLUGIN_HANDLED
		}
		case 3:
		{
			g_mArmorStatus = g_mArmorStatus? false : true
			if (g_mArmorStatus)
				g_mAutoArmor = false

			client_print(id, print_chat, "CSDM displaying armor menu %s.", g_mArmorStatus ? "enabled" : "disabled")
			log_amx("CSDM displaying armor menu %s.", g_mArmorStatus ? "enabled" : "disabled")

			menu_display(id, g_EquipSettMenu, 0)
			write_menus_settings(id)
			return PLUGIN_HANDLED
		}
		case 4:
		{
			g_mNadeStatus = g_mNadeStatus? false : true
			if (g_mNadeStatus)
				g_mAutoNades = false

			client_print(id, print_chat, "CSDM displaying nades menu %s.", g_mNadeStatus ? "enabled" : "disabled")
			log_amx("CSDM displaying nades menu %s.", g_mNadeStatus ? "enabled" : "disabled")

			menu_display(id, g_EquipSettMenu, 0)
			write_menus_settings(id)
			return PLUGIN_HANDLED
		}
		case 5:
		{
			if ((g_Armor == 1) || (g_Armor == 2))
			{
				g_Armor = 0
				g_mAutoArmor = false
			}
			else if (g_Armor == 0)
			{
				g_Armor = 1
				g_mAutoArmor = true
				g_mArmorStatus = false
			}

			client_print(id, print_chat, "CSDM auto equiping players with armor %s.", g_mAutoArmor ? "enabled" : "disabled")
			log_amx("CSDM auto equiping players with armor %s.", g_mAutoArmor ? "enabled" : "disabled")

			menu_display(id, g_EquipSettMenu, 0)
			write_autoequip_settings(id)
			return PLUGIN_HANDLED
		}
		case 6:
		{
			if ((g_Armor == 0) || (g_Armor == 1))
			{
				g_Armor = 2
				g_mAutoArmor = true
				g_mArmorStatus = false
			}
			else if (g_Armor == 2)
			{
				g_Armor = 1
				g_mAutoArmor = true
				g_mArmorStatus = false
			}

			client_print(id, print_chat, "CSDM auto equiping players with helmet %s.", (g_Armor == 2) ? "enabled" : "disabled")
			log_amx("CSDM auto equiping players with helmet %s.", (g_Armor == 2) ? "enabled" : "disabled")

			menu_display(id, g_EquipSettMenu, 0)
			write_autoequip_settings(id)
			return PLUGIN_HANDLED
		}
		case 7:
		{
			g_mAutoNades = g_mAutoNades? false : true
			if (g_mAutoNades)
				g_mNadeStatus = false

			client_print(id, print_chat, "CSDM auto equiping players with grenades %s.", g_mAutoNades ? "enabled" : "disabled")
			log_amx("CSDM auto equiping players with grenades %s.", g_mAutoNades ? "enabled" : "disabled")

			menu_display(id, g_EquipSettMenu, 0)
			write_autoequip_settings(id)
			return PLUGIN_HANDLED
		}
		case 8:
		{
			g_DefuseKit = g_DefuseKit? false : true

			client_print(id, print_chat, "CSDM auto equiping players with defuser (CTs) %s.", g_DefuseKit ? "enabled" : "disabled")
			log_amx("CSDM auto equiping players with defuser (CTs) %s.", g_DefuseKit ? "enabled" : "disabled")

			menu_display(id, g_EquipSettMenu, 1)
			write_autoequip_settings(id)
			return PLUGIN_HANDLED
		}
		case 9:
		{
			g_NightVision = g_NightVision? false : true

			client_print(id, print_chat, "CSDM auto equiping players with nightvision %s.", g_NightVision ? "enabled" : "disabled")
			log_amx("CSDM auto equiping players with nightvision %s.", g_NightVision ? "enabled" : "disabled")

			menu_display(id, g_EquipSettMenu, 1)
			write_autoequip_settings(id)
			return PLUGIN_HANDLED
		}
		case 10:
		{
			g_Flash = g_Flash? false : true

			client_print(id, print_chat, "CSDM usage of flashbangs is %s.", g_Flash ? "enabled" : "disabled")
			log_amx("CSDM usage of flashbangs is %s.", g_Flash ? "enabled" : "disabled")

			menu_display(id, g_EquipSettMenu, 1)
			write_nades_settings(id)
			return PLUGIN_HANDLED
		}
		case 11:
		{
			g_Smoke = g_Smoke? false : true

			client_print(id, print_chat, "CSDM usage of smoke grenades is %s.", g_Smoke ? "enabled" : "disabled")
			log_amx("CSDM usage of smoke grenades is %s.", g_Smoke ? "enabled" : "disabled")

			menu_display(id, g_EquipSettMenu, 1)
			write_nades_settings(id)
			return PLUGIN_HANDLED
		}
		case 12:
		{
			g_Nade = g_Nade? false : true

			client_print(id, print_chat, "CSDM usage of he nades is %s.", g_Nade ? "enabled" : "disabled")
			log_amx("CSDM usage of he nades is %s.", g_Nade ? "enabled" : "disabled")

			menu_display(id, g_EquipSettMenu, 1)
			write_nades_settings(id)
			return PLUGIN_HANDLED
		}
		case 13:
		{
			g_AlwaysAllowGunMenu = g_AlwaysAllowGunMenu? false : true

			client_print(id, print_chat, "CSDM Always Allow Gun Menu is %s.", g_AlwaysAllowGunMenu ? "enabled" : "disabled")
			log_amx("CSDM Always Allow Gun Menu is %s.", g_AlwaysAllowGunMenu ? "enabled" : "disabled")

			menu_display(id, g_EquipSettMenu, 1)
			csdm_write_cfg(id, "equip", "always_allow_gunmenu", g_AlwaysAllowGunMenu ? "1" : "0")
			return PLUGIN_HANDLED
		}
		case 14:
		{
			menu_display(id, g_SettingsMenu, g_PageSettMenu)
			return PLUGIN_HANDLED
		}
	}
	return PLUGIN_HANDLED
}

public hook_equip_sett_display(player, menu, item)
{
	new paccess, command[24], call
	
	menu_item_getinfo(menu, item, paccess, command, 23, _, 0, call)
	
	if (equali(command, "1"))
	{
		if (g_mPrimStatus)
		{
			menu_item_setname(menu, item, "Equip Menu Primary Enabled")
		} else {
			menu_item_setname(menu, item, "Equip Menu Primary Disabled")
		}
	}
	if (equali(command, "2"))
	{
		if (g_mSecStatus)
		{
			menu_item_setname(menu, item, "Equip Menu Secondary Enabled")
		} else {
			menu_item_setname(menu, item, "Equip Menu Secondary Disabled")
		}
	}
	if (equali(command, "3"))
	{
		if (g_mArmorStatus)
		{
			menu_item_setname(menu, item, "Equip Menu Armor Enabled")
		} else {
			menu_item_setname(menu, item, "Equip Menu Armor Disabled")
		}
	}
	if (equali(command, "4"))
	{
		if (g_mNadeStatus)
		{
			menu_item_setname(menu, item, "Equip Menu Grenades Enabled")
		} else {
			menu_item_setname(menu, item, "Equip Menu Grenades Disabled")
		}
	}
	if (equali(command, "5"))
	{
		if (g_mAutoArmor)
		{
			menu_item_setname(menu, item, "Auto equip with Armor Enabled")
		} else {
			menu_item_setname(menu, item, "Auto equip with Armor Disabled")
		}
	}
	if (equali(command, "6"))
	{
		if ((g_mAutoArmor) && (g_Armor == 2))
		{
			menu_item_setname(menu, item, "Auto equip with Helmet Enabled")
		} else {
			menu_item_setname(menu, item, "Auto equip with Helmet Disabled")
		}
	}
	if (equali(command, "7"))
	{
		if (g_mAutoNades)
		{
			menu_item_setname(menu, item, "Auto equip with Grenades Enabled")
		} else {
			menu_item_setname(menu, item, "Auto equip with Grenades Disabled")
		}
	}
	if (equali(command, "8"))
	{
		if (g_DefuseKit)
		{
			menu_item_setname(menu, item, "Auto equip with Defuser Enabled")
		} else {
			menu_item_setname(menu, item, "Auto equip with Defuser Disabled")
		}
	}
	if (equali(command, "9"))
	{
		if (g_NightVision)
		{
			menu_item_setname(menu, item, "Auto equip with Nightvision Enabled")
		} else {
			menu_item_setname(menu, item, "Auto equip with Nightvision Disabled")
		}
	}
	if (equali(command, "10"))
	{
		if (g_Flash)
		{
			menu_item_setname(menu, item, "Flashbang Enabled")
		} else {
			menu_item_setname(menu, item, "Flashbang Disabled")
		}
	}
	if (equali(command, "11"))
	{
		if (g_Smoke)
		{
			menu_item_setname(menu, item, "Smoke grenade Enabled")
		} else {
			menu_item_setname(menu, item, "Smoke grenade Disabled")
		}
	}
	if (equali(command, "12"))
	{
		if (g_Nade)
		{
			menu_item_setname(menu, item, "HE grenade Enabled")
		} else {
			menu_item_setname(menu, item, "HE grenade Disabled")
		}
	}
	if (equali(command, "13"))
	{
		if (g_AlwaysAllowGunMenu)
		{
			menu_item_setname(menu, item, "Always Allow Gun Menu Enabled")
		} else {
			menu_item_setname(menu, item, "Always Allow Gun Menu Disabled")
		}
	}
}

public write_menus_settings(id)
{
	new flags[5] = ""
	new menu_flags = 0

	if (g_mPrimStatus)
	{
		menu_flags |= (1<<0)
	}
	if (g_mSecStatus)
	{
		menu_flags |= (1<<1)
	}
	if (g_mArmorStatus)
	{
		menu_flags |= (1<<2)
	}
	if (g_mNadeStatus)
	{
		menu_flags |= (1<<3)
	}

	get_flags(menu_flags, flags, 4)
	replace(flags, 4, "a", "p")
	replace(flags, 4, "b", "s")
	replace(flags, 4, "c", "a")
	replace(flags, 4, "d", "g")
	csdm_write_cfg(id, "equip", "menus", flags)
}

public write_autoequip_settings(id)
{
	new flags[6] = ""
	new auto_flags = 0

	if (g_mAutoArmor)
	{
		auto_flags |= (1<<0)
	}
	if ((g_mAutoArmor) && (g_Armor == 2))
	{
		auto_flags |= (1<<1)
	}
	if (g_mAutoNades)
	{
		auto_flags |= (1<<2)
	}
	if (g_DefuseKit)
	{
		auto_flags |= (1<<3)
	}
	if (g_NightVision)
	{
		auto_flags |= (1<<4)
	}

	get_flags(auto_flags, flags, 5)
//	replace(flags, 5, "a", "a")
	replace(flags, 5, "b", "h")
	replace(flags, 5, "c", "g")
//	replace(flags, 5, "d", "d")
	replace(flags, 5, "e", "n")
	csdm_write_cfg(id, "equip", "autoitems", flags)
}

public write_nades_settings(id)
{
	new flags[4] = ""
	new nade_flags = 0

	if (g_Flash)
	{
		nade_flags |= (1<<0)
	}
	if (g_Nade)
	{
		nade_flags |= (1<<1)
	}
	if (g_Smoke)
	{
		nade_flags |= (1<<2)
	}

	get_flags(nade_flags, flags, 3)
	replace(flags, 3, "a", "f")
	replace(flags, 3, "b", "h")
	replace(flags, 3, "c", "s")
	csdm_write_cfg(id, "equip", "grenades", flags)
}

// stuff for settings menu - END

Потребителски аватар

blazz3rzbg NSFW
Потребител
Потребител
Мнения: 34
Регистриран: 22 фев 2019, 14:38
Местоположение: Стара Загора
Се отблагодари: 7 пъти
Получена благодарност: 11 пъти
Години: 18

Добавяне на "duration" към "golden weapon".

Мнение от blazz3rzbg NSFW » 16 май 2019, 19:03

1. Fix: След избор на златно оръжие на играча ще му се замени оръжието с златно - ако предишното е било Primary в случая ще го махне и добави златното Primary оръжие така е и за Secondary няма да маха само Primary както беше до сега.

2. Fix: Всички екстри на златното оръжие вече ще работят само и единствено на него. Няма като купиш Golden AK47 и извадиш M4A1 да ти добавя екстрите и към M4A1.

3. Направих така че като купиш Golden оръжието при всеки Spawn на играча да му го дава ако все още таймер-а е активен.

Код: Избери всички

#include <amxmodx>
#include <cromchat>
#include <cstrike>
#include <fakemeta>
#include <fun>
#include <hamsandwich>

//#define USING_REAPI
#define REPLACE_OLD_WEAPONS

#if defined USING_REAPI
	#include <reapi>
#else
	#if defined REPLACE_OLD_WEAPONS
		#include <stripweapons>
	#endif
#endif

#define is_valid_player(%1) (1 <= %1 <= 32)

#define PLUGIN_VERSION "1.0"
#define SOUND_BUY "items/gunpickup2.wav"
#define NO_WEAPON -1

enum _:ItemInfo
{
	Name[32],
	Price,
	Weapon[16],
	Ammo,
	Csw,
	VModel[32],
	PModel[32],
	Float:DmgMulti
}

new const g_eItems[][ItemInfo] = 
{
	/* "Name", Price, "weapon_id", Bullets, CSW_ID, "v_model", "p_model", "Damage Multiplier" */
	{ "Golden Deagle", 	0, 	"weapon_deagle", 	35, 	CSW_DEAGLE, 	"models/v_deagle.mdl", 		"models/p_deagle.mdl", 		2.0 },
	{ "Golden M4A1", 	0, 	"weapon_m4a1", 		90, 	CSW_M4A1, 		"models/v_m4a1.mdl", 		"models/p_m4a1.mdl", 		2.0 },
	{ "Golden Glock", 	0, 	"weapon_glock18", 	30, 	CSW_GLOCK18, 	"models/v_glock18.mdl",	 	"models/p_glock18.mdl", 	2.0 },
	{ "Golden AK47", 	0, 	"weapon_ak47", 		90, 	CSW_AK47, 		"models/v_ak47.mdl", 		"models/p_ak47.mdl",	 	2.0 },
	{ "Golden AWP", 	0, 	"weapon_awp", 		30, 	CSW_AWP, 		"models/v_awp.mdl", 		"models/p_awp.mdl",			2.0 }
}

// CS Player CBase Offsets (win32)
const PDATA_SAFE = 2
const OFFSET_ACTIVE_ITEM = 373

// Max BP ammo for weapons
new const MAXBPAMMO[] = { -1, 52, -1, 90, 1, 32, 1, 100, 90, 1, 120, 100, 100, 90, 90, 90, 100, 120,
			30, 120, 200, 32, 90, 120, 90, 2, 35, 90, 90, -1, 100 };

// Max Clip for weapons
new const MAXCLIP[] = { -1, 13, -1, 10, -1, 7, -1, 30, 30, -1, 30, 20, 25, 30, 35, 25, 12, 20,
			10, 30, 100, 8, 30, 30, 20, -1, 7, 30, 30, -1, 50 };

const PRIMARY = CSW_XM1014 | CSW_M3 | CSW_MAC10 | CSW_UMP45 | CSW_MP5NAVY | CSW_TMP | CSW_P90 | CSW_AUG | CSW_GALIL | CSW_FAMAS | CSW_M249 | CSW_M4A1 | CSW_SG552 | CSW_AK47 | CSW_SCOUT | CSW_SG550 | CSW_AWP | CSW_G3SG1  
const SECONDARY = CSW_P228 | CSW_ELITE | CSW_FIVESEVEN | CSW_USP | CSW_GLOCK18 | CSW_DEAGLE

new g_iWeapon[33]

const TIMER_ID = 123456;

new pCvar_duration;
new g_iCounter[33];

new g_MsgSync;
	
public plugin_init()
{
	register_plugin("Golden Shop", PLUGIN_VERSION, "OciXCrom")
	register_cvar("CRXGoldenShop", PLUGIN_VERSION, FCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
	register_event("CurWeapon", "OnChangeWeapon", "be", "1=1")
	RegisterHam(Ham_Spawn, "player", "OnPlayerSpawn", 1)
	RegisterHam(Ham_TakeDamage, "player", "PreTakeDamage", 0)
	register_clcmd("say /gold", "Cmd_Shop")
	register_clcmd("say_team /gold", "Cmd_Shop")
	register_clcmd("golden_weapons_menu", "Cmd_Shop");
	CC_SetPrefix("[&x04GOLD&x01]")
	
	g_MsgSync = CreateHudSyncObj();
	pCvar_duration = register_cvar("goldweap_duration_sec", "300");
	register_message(get_user_msgid("CurWeapon"), "message_cur_weapon");
}

public plugin_precache()
{
	precache_sound(SOUND_BUY)
	
	for(new i; i < sizeof(g_eItems); i++)
	{
		if(g_eItems[i][VModel][0])
			precache_model(g_eItems[i][VModel])
			
		if(g_eItems[i][PModel][0])
			precache_model(g_eItems[i][PModel])
	}
}
	
public client_putinserver(id)
	g_iWeapon[id] = NO_WEAPON
	
public OnPlayerSpawn(id)
{
	if(!is_user_alive(id) || g_iWeapon[id] == NO_WEAPON)
		return HAM_IGNORED;
		
	give_item(id, g_eItems[g_iWeapon[id]][Weapon]);
				
	cs_set_user_bpammo(id, g_eItems[g_iWeapon[id]][Csw], g_eItems[g_iWeapon[id]][Ammo]);
	OnChangeWeapon(id);
	
	return HAM_HANDLED;
}
	
public PreTakeDamage(iVictim, iInflictor, iAttacker, Float:fDamage, iDamageBits)
{
	if(!is_valid_player(iAttacker))
		return HAM_IGNORED;
	
	if(g_iWeapon[iAttacker] != NO_WEAPON && get_user_weapon(iAttacker) == g_eItems[g_iWeapon[iAttacker]][Csw])
		SetHamParamFloat(4, fDamage * g_eItems[g_iWeapon[iAttacker]][DmgMulti]);
	
	return HAM_HANDLED;
}

public OnChangeWeapon(id)
{
	if(g_iWeapon[id] == NO_WEAPON || read_data(2) != g_eItems[g_iWeapon[id]][Csw])
		return
		
	if(g_eItems[g_iWeapon[id]][VModel][0])
		set_pev(id, pev_viewmodel2, g_eItems[g_iWeapon[id]][VModel])
		
	if(g_eItems[g_iWeapon[id]][PModel][0])
		set_pev(id, pev_weaponmodel2, g_eItems[g_iWeapon[id]][PModel])
}
	
public Cmd_Shop(id)
{
	if(!is_user_alive(id))
		CC_SendMessage(id, "You need to be alive.")
	else
	{
		new iMenu = menu_create("\rGold Shop", "Shop_Handler")
		new szItem[64], iMoney = cs_get_user_money(id)
		
		for(new szKey[4], i; i < sizeof(g_eItems); i++)
		{
			if(g_iWeapon[id] == i)
				formatex(szItem, charsmax(szItem), "\d%s \y[OWNED]", g_eItems[i][Name])
			else
				formatex(szItem, charsmax(szItem), "%s%s \r[%i$]", iMoney >= g_eItems[i][Price] ? "\w" : "\d", g_eItems[i][Name], g_eItems[i][Price])
					
			num_to_str(i, szKey, charsmax(szKey))
			menu_additem(iMenu, szItem, szKey)
		}
		
		menu_display(id, iMenu)
	}
	
	return PLUGIN_HANDLED
}

public Shop_Handler(id, iMenu, iItem)
{
	if(iItem != MENU_EXIT && is_user_alive(id))
	{
		new szKey[4], iUnused
		menu_item_getinfo(iMenu, iItem, iUnused, szKey, charsmax(szKey), .callback = iUnused)
		
		new iKey = str_to_num(szKey)
		
		if(g_iWeapon[id] == iKey)
			CC_SendMessage(id, "You already have this item.")
		else
		{
			new iMoney = cs_get_user_money(id)
			
			if(iMoney < g_eItems[iKey][Price])
				CC_SendMessage(id, "You don't have enough money to purchase this item.")
			else
			{
				cs_set_user_money(id, iMoney - g_eItems[iKey][Price])
				CC_SendMessage(id, "You have bought ^3%s ^1for ^4%i$", g_eItems[iKey][Name], g_eItems[iKey][Price])
				emit_sound(id, CHAN_ITEM, SOUND_BUY, 1.0, ATTN_NORM, 0, PITCH_NORM)
				g_iWeapon[id] = iKey
				
				#if defined USING_REAPI
					#if defined REPLACE_OLD_WEAPONS
					rg_give_item(id, g_eItems[iKey][Weapon], GT_REPLACE)
					#else
					rg_give_item(id, g_eItems[iKey][Weapon], GT_APPEND)
					#endif
				#else
					#if defined REPLACE_OLD_WEAPONS
					if(g_eItems[iKey][Csw] & PRIMARY)
						StripWeapons(id, Primary);
						
					else if(g_eItems[iKey][Csw] & SECONDARY)
							StripWeapons(id, Secondary);
					#endif
					
					give_item(id, g_eItems[iKey][Weapon]);
				#endif
				
				cs_set_user_bpammo(id, g_eItems[iKey][Csw], g_eItems[iKey][Ammo])
				OnChangeWeapon(id)
				
				new iTask = id + TIMER_ID;
				if(task_exists(iTask))
					remove_task(iTask);
				
				g_iCounter[id] = get_pcvar_num(pCvar_duration);
				set_task(1.0, "goldweap_timer", id+TIMER_ID, .flags = "b");
			}
		}
	}

	menu_destroy(iMenu)
	return PLUGIN_HANDLED
}

public goldweap_timer(id)
{
	id -= TIMER_ID;
	
	if(is_user_connected(id) && is_user_alive(id) && g_iWeapon[id] != NO_WEAPON)
	{
		g_iCounter[id] --;
		
		set_hudmessage(255, 215, 0, 0.0, 0.20, 0, 0.0, 0.0, 0.1, 0.9, -1);
		ShowSyncHudMsg(id, g_MsgSync, "%s expires in: %i", g_eItems[g_iWeapon[id]][Name], g_iCounter[id]);

		if(g_iCounter[id] == 1)
		{
			set_hudmessage(255, 215, 0, -1.0, 0.32, 1, 0.0, 4.0, 1.0, 1.0, -1);
			ShowSyncHudMsg(id, g_MsgSync, "Your %s Expired!", g_eItems[g_iWeapon[id]][Name]);
			
			g_iWeapon[id] = NO_WEAPON;
			
			new iTask = id + TIMER_ID;
			if(task_exists(iTask))
				remove_task(iTask);
		}
	}
}

// Current Weapon info
public message_cur_weapon(msg_id, msg_dest, msg_entity)
{
	// Not alive
	if (!is_user_alive(msg_entity) || g_iWeapon[msg_entity] == NO_WEAPON)
		return;
	
	// Not an active weapon
	if (get_msg_arg_int(1) != 1)
		return;
	
	// Get weapon's id
	new weapon = get_msg_arg_int(2)
	
	if(weapon != g_eItems[g_iWeapon[msg_entity]][Csw])
		return;
	
	// Primary and secondary only
	if (MAXBPAMMO[weapon] <= 2)
		return;
	
	// Max out clip ammo
	new weapon_ent = fm_cs_get_current_weapon_ent(msg_entity)
	if (pev_valid(weapon_ent)) cs_set_weapon_ammo(weapon_ent, MAXCLIP[weapon])
	
	// HUD should show full clip all the time
	set_msg_arg_int(3, get_msg_argtype(3), MAXCLIP[weapon])
}

// Get User Current Weapon Entity
stock fm_cs_get_current_weapon_ent(id)
{
	// Prevent server crash if entity's private data not initalized
	if (pev_valid(id) != PDATA_SAFE)
		return -1;
	
	return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM);
}

#if AMXX_VERSION_NUM <= 182
public client_disconnect(id)
	#else
public client_connected(id)
#endif
{
	new iTask = id + TIMER_ID;
	if(task_exists(iTask))
		remove_task(iTask);
}
4. Добавих ти 4. Buy Golden Weapons секция в csdm equip меню-то която ще работи с плъгина. (не съм тествал)

Код: Избери всички

/**
 * csdm_equip.sma
 * Allows for Counter-Strike to be played as DeathMatch.
 *
 * CSDM Equipment Menu
 *
 * By Freecode and BAILOPAN
 * (C)2003-2014 David "BAILOPAN" Anderson
 *
 *  Give credit where due.
 *  Share the source - it sets you free
 *  http://www.opensource.org/
 *  http://www.gnu.org/
 */
 
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <csdm>
#include <fakemeta>

//Tampering with the author and name lines can violate the copyright
new PLUGINNAME[] = "CSDM Equip"
new VERSION[] = CSDM_VERSION
new AUTHORS[] = "CSDM Team"

#define	EQUIP_PRI	(1<<0)
#define	EQUIP_SEC	(1<<1)
#define	EQUIP_ARMOR	(1<<2)
#define	EQUIP_GREN	(1<<3)
#define EQUIP_ITEMS	(1<<4)
#define	EQUIP_ALL	(EQUIP_PRI|EQUIP_SEC|EQUIP_ARMOR|EQUIP_GREN|EQUIP_ITEMS)

#define ITEMTYPES_NUM	42

new bool:IsRestricted[ITEMTYPES_NUM] = {false, ...}	// Contains if an item is restricted or not
new RestrictWps[ITEMTYPES_NUM] = {32, ...}
new UsedWpsT[ITEMTYPES_NUM] = {0, ...}
new UsedWpsCT[ITEMTYPES_NUM] = {0, ...}

//Menus
new g_SecMenu[] = "CSDM: Secondary Weapons"		// Menu Name
new g_SecMenuID = -1							// Menu ID
new g_cSecondary								// Menu Callback
new bool:g_mSecStatus = true					// Menu Available?

new g_PrimMenu[] = "CSDM: Primary Weapons"
new g_PrimMenuID = -1
new g_cPrimary
new bool:g_mPrimStatus = true

new g_ArmorMenu[] = "CSDM: Armor"
new g_ArmorMenuID = -1
new bool:g_mArmorStatus = true

new g_NadeMenu[] = "CSDM: Grenades"
new g_NadeMenuID = -1
new bool:g_mNadeStatus = true

new g_EquipMenu[] = "CSDM: Equip"
new g_EquipMenuID = -1
new g_cEquip

new bool:g_mShowuser[33] = true

new bool:g_mAutoNades = false
new bool:g_mAutoArmor = false
new bool:g_AlwaysAllowGunMenu = false
new bool:g_AmmoRefill = false
new g_WeaponStayTime = 0

//Weapon Selections
new g_SecWeapons[33][18]
new g_PrimWeapons[33][18]
new bool:g_mNades[33]
new bool:g_mArmor[33]

//Config weapon storage holders
new g_BotPrim[MAX_WEAPONS][18]
new g_iNumBotPrim

new g_BotSec[MAX_WEAPONS][18]
new g_iNumBotSec

new g_Secondary[MAX_SECONDARY][18]
new bool:g_DisabledSec[MAX_WEAPONS]
new g_iNumSec
new g_iNumUsedSec = 0

new g_Primary[MAX_PRIMARY][18]
new bool:g_DisabledPrim[MAX_WEAPONS]
new g_iNumPrim
new g_iNumUsedPrim = 0

new pv_csdm_additems

#define SILENCED_M4A1	0
#define SILENCED_USP		1
new bool:g_Silenced[33][2]

//Misc
new g_Armor = 0
new fnadesnum = 0
new bool:g_Flash = false
new bool:g_Nade = false
new bool:g_Smoke = false
new bool:g_NightVision = false
new bool:g_DefuseKit = false

// page info for settings in CSDM Setting Menu
new g_SettingsMenu = 0
new g_EquipSettMenu = 0
new g_ItemsInMenuNr = 0
new g_PageSettMenu = 0

//Quick Fix for menu pages
new g_MenuState[33] = {0}

new Float:g_maxdelmenutime = 30.0

public csdm_Init(const version[])
{
	if (version[0] == 0)
	{
		set_fail_state("CSDM failed to load.")
		return
	}

	// Menus and callbacks
	g_SecMenuID = menu_create(g_SecMenu, "m_SecHandler", 0)
	g_PrimMenuID = menu_create(g_PrimMenu, "m_PrimHandler", 0)
	g_ArmorMenuID = menu_create(g_ArmorMenu, "m_ArmorHandler", 0)
	g_NadeMenuID = menu_create(g_NadeMenu, "m_NadeHandler", 0)
	g_EquipMenuID = menu_create(g_EquipMenu, "m_EquipHandler", 0)

	menu_setprop(g_PrimMenuID, MPROP_EXIT, MEXIT_NEVER)
	menu_setprop(g_SecMenuID, MPROP_EXIT, MEXIT_NEVER)

	g_cSecondary = menu_makecallback("c_Secondary")
	g_cPrimary = menu_makecallback("c_Primary")
	g_cEquip = menu_makecallback("c_Equip")
}

public csdm_CfgInit()
{
	csdm_reg_cfg("settings", "cfgMainSettings")
	csdm_reg_cfg("misc", "cfgMiscSettings")

	// Config reader
	csdm_reg_cfg("equip", "cfgSetting")

	// In order for weapon menu
	csdm_reg_cfg("secondary", "cfgSecondary")
	csdm_reg_cfg("primary", "cfgPrimary")
	csdm_reg_cfg("botprimary", "cfgBotPrim")
	csdm_reg_cfg("botsecondary", "cfgBotSec")
	csdm_reg_cfg("item_restrictions", "cfgrestricts")
	set_task(2.0, "check_cvar_pointers", 790)
}

public check_cvar_pointers()
{
	pv_csdm_additems = get_cvar_pointer("csdm_add_items")
}

public plugin_init()
{
	register_plugin(PLUGINNAME, VERSION, AUTHORS)

	// Build Armor/Nade/Equip Menu's
	buildMenu()
	
	register_clcmd("say guns", "enableMenu")
	register_clcmd("say /guns", "enableMenu")
	register_clcmd("say menu", "enableMenu")
	register_clcmd("say enablemenu", "enableMenu")
	register_clcmd("say enable_menu", "enableMenu")
	register_concmd("csdm_es_menu", "csdm_es_menu", ADMIN_MAP, "CSDM Equip Settings Menu")
	register_event("TextMsg","eRestart","a","2&#Game_C","2&#Game_w")

	new main_plugin = module_exists("csdm_main") ? true : false

	if (main_plugin)
	{
		g_SettingsMenu = csdm_settings_menu()
		g_ItemsInMenuNr = menu_items(g_SettingsMenu)
		g_PageSettMenu = g_ItemsInMenuNr / 7

		g_EquipSettMenu = menu_create("CSDM Equip Settings Menu", "use_csdm_equip_menu")

		menu_additem(g_SettingsMenu, "CSDM Equip Settings", "csdm_es_menu", ADMIN_MAP)

		if (g_EquipSettMenu)
		{
			new callback = menu_makecallback("hook_equip_sett_display")
			menu_additem(g_EquipSettMenu, "Equip Menu Primary Enabled/Disabled", "1", ADMIN_MAP, callback)
			menu_additem(g_EquipSettMenu, "Equip Menu Secondary Enabled/Disabled", "2", ADMIN_MAP, callback)
			menu_additem(g_EquipSettMenu, "Equip Menu Armor Enabled/Disabled", "3", ADMIN_MAP, callback)
			menu_additem(g_EquipSettMenu, "Equip Menu Grenades Enabled/Disabled", "4", ADMIN_MAP, callback)
			menu_additem(g_EquipSettMenu, "Auto equip with Armor Enabled/Disabled", "5", ADMIN_MAP, callback)
			menu_additem(g_EquipSettMenu, "Auto equip with Helmet Enabled/Disabled", "6", ADMIN_MAP, callback)
			menu_additem(g_EquipSettMenu, "Auto equip with Grenades Enabled/Disabled", "7", ADMIN_MAP, callback)
			menu_additem(g_EquipSettMenu, "Auto equip with Defuser Enabled/Disabled", "8", ADMIN_MAP, callback)
			menu_additem(g_EquipSettMenu, "Auto equip with Nightvision Enabled/Disabled", "9", ADMIN_MAP, callback)
			menu_additem(g_EquipSettMenu, "Flashbang Enabled/Disabled", "10", ADMIN_MAP, callback)
			menu_additem(g_EquipSettMenu, "Smoke grenade Enabled/Disabled", "11", ADMIN_MAP, callback)
			menu_additem(g_EquipSettMenu, "HE grenade Enabled/Disabled", "12", ADMIN_MAP, callback)
			menu_additem(g_EquipSettMenu, "Always Allow Gun Menu Enabled/Disabled", "13", ADMIN_MAP, callback)
			menu_additem(g_EquipSettMenu, "Back", "14", 0, -1)
		}
	}
	else 
		log_amx("CSDM - csdm_equip - no main plugin loaded")

	if (g_iNumUsedSec == 0)
		g_mSecStatus = false
	if (g_iNumUsedPrim == 0)
		g_mPrimStatus = false
}

public eRestart()
{
	arrayset(UsedWpsT, 0, ITEMTYPES_NUM)
	arrayset(UsedWpsCT, 0, ITEMTYPES_NUM)
	return PLUGIN_CONTINUE
}

public client_connect(id)
{
	g_mShowuser[id] = true
	g_mNades[id] = false
	g_mArmor[id] = false
	g_Silenced[id][SILENCED_M4A1] = false
	g_Silenced[id][SILENCED_USP] = false
	
	return PLUGIN_CONTINUE
}

public client_disconnect(id)
{
	g_mShowuser[id] = true
	g_mNades[id] = false
	g_mArmor[id] = false

	new weapons[MAX_WEAPONS], num
	new weapid
	new team = get_user_team(id)

	get_user_weapons(id, weapons, num)

	for (new i=0; i<num; i++)
	{
		weapid = weapons[i]
		if ((IsRestricted[weapid]) && (UsedWpsT[weapid] > 0) && (team == _TEAM_T))
		{
			UsedWpsT[weapid]--
		}
		if ((IsRestricted[weapid]) && (UsedWpsCT[weapid] > 0) && (team == _TEAM_CT))
		{
			UsedWpsCT[weapid]--
		}
	}
	return PLUGIN_CONTINUE
}

public csdm_RemoveWeapon(owner, entity_id, boxed_id)
{
	new classname[32], weapon
	new team
	if (!pev_valid(entity_id))
		return PLUGIN_HANDLED

	pev(entity_id, pev_classname, classname, 31)
	weapon = get_weaponid(classname)

	if (weapon == CSW_M4A1)
	{
		g_Silenced[owner][SILENCED_M4A1] = cs_get_weapon_silen(entity_id) ? true : false
	} else if (weapon == CSW_USP) {
		g_Silenced[owner][SILENCED_USP] = cs_get_weapon_silen(entity_id) ? true : false
	}

	if ((owner) && (weapon))
	{
		team = get_user_team(owner)

		if ((IsRestricted[weapon]) && (UsedWpsT[weapon] > 0) && (team == _TEAM_T))
		{
			UsedWpsT[weapon]--
//			log_amx("[DEBUG] CSDM - restricted weapon %s removed. Currently there is %d such weapons on the map.", classname, UsedWpsT[weapon])
		}
		if ((IsRestricted[weapon]) && (UsedWpsCT[weapon] > 0) && (team == _TEAM_CT))
		{
			UsedWpsCT[weapon]--
//			log_amx("[DEBUG] CSDM - restricted weapon %s removed. Currently there is %d such weapons on the map.", classname, UsedWpsCT[weapon])
		}
	}

	return PLUGIN_CONTINUE
}

public csdm_PostDeath(killer, victim, headshot, const weapon[])
{
	/* Clean up any defusal kits we might have made! */
	if (!g_DefuseKit)
	{
		return
	}
	
	/* This might have a race condition for team switches... */
	if (get_user_team(victim) == _TEAM_CT)
	{
		cs_set_user_defuse(victim, 0)
	}
}

public cfgSecondary(readAction, line[], section[])
{
	if (readAction == CFG_READ)
	{
		if (g_iNumSec >= MAX_SECONDARY)
			return PLUGIN_HANDLED
		
		new wep[16], display[48], dis[4]
		new cmd[6]

		parse(line, wep, 15, display, 47, dis, 3)
		
		new disabled = str_to_num(dis)
		
		//Copy weapon into array
		format(g_Secondary[g_iNumSec], 17, "weapon_%s", wep)

		g_DisabledSec[g_iNumSec] = disabled ? false : true		

		format(cmd,5,"%d ",g_iNumSec)
		g_iNumSec++

		if (disabled > 0)
		{
			g_iNumUsedSec++
		}

		//TODO: Add menu_destroy_items to remake menu on cfg reload
		menu_additem(g_SecMenuID, display, cmd, 0, g_cSecondary)
	}
	else if (readAction == CFG_RELOAD)
	{
		g_SecMenuID = menu_create(g_SecMenu, "m_SecHandler", 0)
		g_iNumSec = 0
		g_iNumUsedSec = 0
	}
	else if (readAction == CFG_DONE)
	{
		//Nothing for now
		return PLUGIN_HANDLED
	}
	
	return PLUGIN_HANDLED
}

public cfgPrimary(readAction, line[], section[])
{
	if (readAction == CFG_READ)
	{
		if (g_iNumPrim >= MAX_PRIMARY)	
			return PLUGIN_HANDLED
			
		new wep[16], display[48], dis[4]
		new cmd[6]

		parse(line, wep, 15, display, 47, dis, 3)
		
		new disabled = str_to_num(dis)
		
		//Copy weapon into array
		format(g_Primary[g_iNumPrim], 17, "weapon_%s", wep)
		g_DisabledPrim[g_iNumPrim] = disabled ? false : true
		
		format(cmd, 5, "%d", g_iNumPrim)
		g_iNumPrim++

		if (disabled > 0)
			g_iNumUsedPrim++


		//TODO: Add menu_destroy_items to remake menu on cfg reload
		menu_additem(g_PrimMenuID, display, cmd, 0, g_cPrimary)
	} else if (readAction == CFG_RELOAD) {
		g_PrimMenuID = menu_create(g_PrimMenu, "m_PrimHandler", 0)
		g_iNumPrim = 0
		g_iNumUsedPrim = 0
	} else if (readAction == CFG_DONE) {
		//Nothing for now
		return PLUGIN_HANDLED
	}
	
	return PLUGIN_HANDLED
}
	
	
public cfgBotPrim(readAction, line[], section[])
{
	if (readAction == CFG_READ)
	{
	
		new wep[16], display[32]

		parse(line, wep, 15, display, 31)
		
		//Copy weapon into array
		format(g_BotPrim[g_iNumBotPrim], 17, "weapon_%s", wep)
		g_iNumBotPrim++
	} else if (readAction == CFG_RELOAD) {
		g_iNumBotPrim = 0
	} else if (readAction == CFG_DONE) {
		//Nothing for now
		return PLUGIN_HANDLED
	}
	
	return PLUGIN_HANDLED
}

public cfgBotSec(readAction, line[], section[])
{
	if (readAction == CFG_READ)
	{
	
		new wep[16], display[32]

		parse(line, wep, 15, display, 31)
		
		//Copy weapon into array
		format(g_BotSec[g_iNumBotSec], 17, "weapon_%s", wep)
		g_iNumBotSec++
	} else if (readAction == CFG_RELOAD) {
		g_iNumBotSec = 0
	} else if (readAction == CFG_DONE) {
		//Nothing for now
		return PLUGIN_HANDLED
	}
	
	return PLUGIN_HANDLED
}

public cfgSetting(readAction, line[], section[])
{
	if (readAction == CFG_READ)
	{

		new setting[24], sign[3], value[6]

		parse(line, setting, 23, sign, 2, value, 5)
		
		// Menus settings
		if (contain(setting,"menus") != -1)
		{
			if (containi(value, "p") != -1)
			{
				g_mPrimStatus = true
			}
			
			if (containi(value, "s") != -1)
			{
				g_mSecStatus = true
			}
			
			if (containi(value, "a") != -1)
			{
				g_mArmorStatus = true
			}
			
			if (containi(value, "g") != -1)
			{
				g_mNadeStatus = true
			}
			
			return PLUGIN_HANDLED
		} else if (contain(setting, "autoitems") != -1) {

			if (containi(value, "a")  != -1)
			{
				//Disable Armor Menu
				g_mArmorStatus = false
				g_mAutoArmor = true
				
				g_Armor = 1
			}
						
			if (containi(value, "h") != -1)
			{
				//Disable Armor Menu
				g_mArmorStatus = false
				g_mAutoArmor = true
				g_Armor = 2
			}
			
			if (containi(value, "g") != -1)
			{
				//Disable Grenade Menu
				g_mNadeStatus = false
				g_mAutoNades = true
			}
			
			if (containi(value, "d") != -1)
			{
				g_DefuseKit = true
			}
			
			if (containi(value, "n") != -1)
			{
				g_NightVision = true
			}
			
			return PLUGIN_HANDLED
		} else if (contain(setting, "grenades") != -1) {
			if (containi(value, "f") != -1)
			{
				g_Flash = true
			}
			
			if (containi(value, "h") != -1)
			{
				g_Nade = true
			}
			
			if (containi(value, "s") != -1)
			{
				g_Smoke = true
			}
		} else if (contain(setting, "fnadesnum") != -1) {
			fnadesnum = str_to_num(value)
		} else if (contain(setting, "always_allow_gunmenu") != -1) {
			g_AlwaysAllowGunMenu = str_to_num(value)? true : false
		}
		return PLUGIN_HANDLED
	} else if (readAction == CFG_RELOAD) {
		g_mArmorStatus = false
		g_mNadeStatus = false
		g_Flash = false
		g_Nade = false
		g_Smoke = false
		g_Armor = 0
		g_mSecStatus = false
		g_mPrimStatus = false
		g_mAutoNades = false
		g_DefuseKit = false
		g_NightVision = false
		fnadesnum = 1
	} else if (readAction == CFG_DONE) {
		//Nothing for now
		return PLUGIN_HANDLED
	}
	
	return PLUGIN_HANDLED
}

public cfgrestricts(readAction, line[], section[])
{
	if (readAction == CFG_READ)
	{
		new itemname[24], value[32], limit
		parse(line, itemname, 23, value, 31)

		limit = 0
		if (value[0] != '0')
    	limit = str_to_num(value)

		new weapname[24], weaptype

		format(weapname, 23, "weapon_%s", itemname)

		weaptype = getWeapId(weapname)
//		weaptype = get_weaponid(weapname) // why this crap doesn't work here but works correctly during the game ?!?
//		log_amx("[DEBUG] CSDM - reading restrictions, weapon %s (weaptype = %d).", itemname, weaptype)
		if (weaptype != 0)
    {
			IsRestricted[weaptype] = true
			RestrictWps[weaptype] = limit
		}
//		log_amx("[DEBUG] CSDM - reading restrictions, restricted %s (weaptype = %d) = %d", itemname, weaptype, limit)
	}
	else if (readAction == CFG_RELOAD)
	{
		// Reset all restrictions
		arrayset(IsRestricted, false, ITEMTYPES_NUM)
		arrayset(RestrictWps, 32, ITEMTYPES_NUM)
		return PLUGIN_HANDLED
	}
	else if (readAction == CFG_DONE)
	{
		//Nothing for now
		return PLUGIN_HANDLED
	}
	return PLUGIN_HANDLED
}

public cfgMainSettings(readAction, line[], section[])
{
	if (readAction == CFG_READ)
	{
		new setting[24], sign[3], value[32];

		parse(line, setting, 23, sign, 2, value, 31);
		
		if (equali(setting, "weapons_stay")) {
			g_WeaponStayTime = str_to_num(value)
		}
	}
}

public cfgMiscSettings(readAction, line[], section[])
{		
	if (readAction == CFG_READ)
	{
		new setting[24], sign[3], value[32];

		parse(line, setting, 23, sign, 2, value, 31);
		
		if (equali(setting, "ammo_refill")) {
			g_AmmoRefill = str_to_num(value) ? true : false
		}
	} else if (readAction == CFG_RELOAD) {
		g_AmmoRefill = true
	}
}

//Equipment Menu callback
public c_Equip(id, menu, item)
{
	if( item < 0 ) return PLUGIN_CONTINUE

	new cmd[6], iName[64]
	new access, callback
	
	menu_item_getinfo(menu, item, access, cmd,5, iName, 63, callback)

	new weapon_s, weapon_p
	weapon_s = get_weaponid(g_SecWeapons[id])
	weapon_p = get_weaponid(g_PrimWeapons[id])
	if ( ((weapon_s == 0) && g_mSecStatus) || ((weapon_p == 0) && g_mPrimStatus) || IsRestricted[weapon_s] || IsRestricted[weapon_p] )
		return ITEM_DISABLED
	else
		return ITEM_ENABLED
	return PLUGIN_HANDLED
}

//Secondary Weapon Callback
public c_Secondary(id, menu, item)
{
	if( item < 0 ) return PLUGIN_CONTINUE
	
	new cmd[6], iName[64]
	new access, callback
	
	menu_item_getinfo(menu, item, access, cmd,5, iName, 63, callback)
	
	new dis = str_to_num(cmd)
	new team = get_user_team(id)
	new weaptype = get_weaponid(g_Secondary[dis])

	//Check to see if item is disabled
	if (g_DisabledSec[dis])
	{
		return ITEM_DISABLED
	}
	else if (!IsRestricted[weaptype])
	{
		return ITEM_ENABLED
	}
	else if ((UsedWpsT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_T) 
		|| (UsedWpsCT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_CT))
	{
		return ITEM_ENABLED
	}
	else
	{
		return ITEM_DISABLED
	}	
	return PLUGIN_HANDLED
}

//Primary Weapon Callback
public c_Primary(id, menu, item)
{

	if (item < 0)
		return PLUGIN_CONTINUE
	
	// Get item info
	new cmd[6], iName[64]
	new access, callback
	
	menu_item_getinfo(menu, item, access, cmd,5, iName, 63, callback)
	
	new dis = str_to_num(cmd)
	new team = get_user_team(id)
	new weaptype = get_weaponid(g_Primary[dis])

	//Check to see if item is disabled
	if (g_DisabledPrim[dis])
	{
		return ITEM_DISABLED
	}
	else if (!IsRestricted[weaptype])
	{
		return ITEM_ENABLED
	}
	else if ((UsedWpsT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_T) 
					|| (UsedWpsCT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_CT))
	{
		return ITEM_ENABLED
	}
	else
	{
		return ITEM_DISABLED
	}		
	return PLUGIN_HANDLED
}

//Equipment Menu handler
public m_EquipHandler(id, menu, item)
{
	if (item < 0)
	{
		return PLUGIN_CONTINUE
	}

	// Get item info
	new cmd[2], iName[64]
	new access, callback
	
	menu_item_getinfo(menu, item, access, cmd, 1, iName, 63, callback)
	
	new choice = str_to_num(cmd)
	
	switch(choice)
	{
		case 1:
		{
			if (g_mSecStatus)
			{
				menu_display(id, g_SecMenuID, 0)
			}
			else if (g_mPrimStatus)
			{
				menu_display(id, g_PrimMenuID, 0)
			}
			else if (g_mArmorStatus)
			{
				menu_display(id, g_ArmorMenuID, 0)
			}
			else if (g_mNadeStatus)
			{
				if (g_mAutoArmor)
				{
					equipUser(id, EQUIP_ARMOR)
				}
				menu_display(id, g_NadeMenuID, 0)
			} else {
				if (g_mAutoArmor)
				{
					equipUser(id, EQUIP_ARMOR)
				}
				if (g_mAutoNades)
				{
					equipUser(id, EQUIP_GREN)
				}
				equipUser(id, EQUIP_ITEMS)
			}
		}
		case 2:
		{
			// Equip person with last settings
			equipUser(id, EQUIP_ALL)
		}
		case 3:
		{
			g_mShowuser[id] = false
			client_print(id, print_chat, "[CSDM] Type ^"guns^" in chat to re-enable your equip menu.")
			equipUser(id, EQUIP_ALL)
		}
		case 4: client_cmd(id, "golden_weapons_menu");
	}
	
	return PLUGIN_HANDLED
}


//Secondary Weapon Menu handler
public m_SecHandler(id, menu, item)
{
	// Get item info
	new cmd[6], iName[64]
	new access, callback
	
	menu_item_getinfo(menu, item, access, cmd,5, iName, 63, callback)
	
	new wep = str_to_num(cmd)
	
	new team = get_user_team(id)
	new weaptype = get_weaponid(g_Secondary[wep])

	if (((UsedWpsT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_T) 
			|| (UsedWpsCT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_CT))
      && !g_DisabledSec[wep])
	{
		copy(g_SecWeapons[id],17,g_Secondary[wep])
		equipUser(id, EQUIP_SEC)
	}
	else if (g_mSecStatus)
	{
		menu_display(id, g_SecMenuID, 0)
		return PLUGIN_HANDLED
	}

	// Show next menu here
	
	if (g_mPrimStatus)
	{
		menu_display(id, g_PrimMenuID, 0)
	}
	else if (g_mArmorStatus)
	{
		menu_display(id, g_ArmorMenuID, 0)
	}
	else if (g_mNadeStatus)
	{
		if (g_mAutoArmor)
		{
			equipUser(id, EQUIP_ARMOR)
		}
		menu_display(id, g_NadeMenuID, 0)
	}
	else
	{
		if (g_mAutoArmor)
		{
			equipUser(id, EQUIP_ARMOR)
		}
		if (g_mAutoNades)
		{
			equipUser(id, EQUIP_GREN)
		}
		equipUser(id, EQUIP_ITEMS)
	}
	
	return PLUGIN_HANDLED
}

//Primary Weapon Menu handler
public m_PrimHandler(id, menu, item)
{
	if (item < 0)  return PLUGIN_HANDLED
	
	// Get item info
	new cmd[6], iName[64]
	new access, callback
	
	if (menu_item_getinfo(menu, item, access, cmd,5, iName, 63, callback))
	{
		new wep = str_to_num(cmd)
	
		new team = get_user_team(id)
		new weaptype = get_weaponid(g_Primary[wep])

		if (((UsedWpsT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_T) 
			|| (UsedWpsCT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_CT))
         && !g_DisabledPrim[wep])
		{
			copy(g_PrimWeapons[id], 17, g_Primary[wep])
			equipUser(id, EQUIP_PRI)
		}
		else if (g_mPrimStatus)
		{
			menu_display(id, g_PrimMenuID, 0)
			return PLUGIN_HANDLED
		}
	}

	// Show next menu here
		
	if (g_mArmorStatus)
	{
		menu_display(id, g_ArmorMenuID, 0)
	}
	else if (g_mNadeStatus)
	{
		if (g_mAutoArmor)
		{
			equipUser(id, EQUIP_ARMOR)
		}
		menu_display(id, g_NadeMenuID, 0)
	} else {
		if (g_mAutoArmor)
		{
			equipUser(id, EQUIP_ARMOR)
		}
		if (g_mAutoNades)
		{
			equipUser(id, EQUIP_GREN)
		}
		equipUser(id, EQUIP_ITEMS)
	}
	
	return PLUGIN_HANDLED
}

//Armor Menu handler
public m_ArmorHandler(id, menu, item)
{
	if (item < 0) return PLUGIN_CONTINUE
	
	// Get item info
	new cmd[6], iName[64]
	new access, callback

	menu_item_getinfo(menu, item, access, cmd,5, iName, 63, callback)
	
	new choice = str_to_num(cmd)
	
	if (choice == 1)
	{
		g_mArmor[id] = true
	}
	else if (choice == 2)
	{
		g_mArmor[id] = false
	}
	equipUser(id, EQUIP_ARMOR)
	
	// Show next menu here
	
	if (g_mNadeStatus)
	{
		menu_display(id, g_NadeMenuID, 0)
	} else {
		if (g_mAutoNades)
		{
			equipUser(id, EQUIP_GREN)
		}
		equipUser(id, EQUIP_ITEMS)
	}
	
	return PLUGIN_HANDLED
}

//Nade Menu handler
public m_NadeHandler(id, menu, item)
{
	if (item < 0) return PLUGIN_CONTINUE
	
	new cmd[6], iName[64]
	new access, callback
	
	menu_item_getinfo(menu, item, access, cmd, 5, iName, 63, callback)
	
	new choice = str_to_num(cmd)
	
	if (choice == 1)
	{
		g_mNades[id] = true
	}
	else if (choice == 2)
	{
		g_mNades[id] = false
	}
	
	equipUser(id, EQUIP_GREN)
	equipUser(id, EQUIP_ITEMS)

	return PLUGIN_HANDLED
}

buildMenu()
{
	//Equip Menu
	menu_additem(g_EquipMenuID, "New Weapons", "1", 0, -1)
	menu_additem(g_EquipMenuID, "Previous Setup", "2", 0, g_cEquip)
	menu_additem(g_EquipMenuID, "2+Don't show menu again^n", "3", 0, g_cEquip)
	menu_additem(g_EquipMenuID, "\yBuy Golden Weapons", "4")
	menu_setprop(g_EquipMenuID, MPROP_EXIT, MEXIT_NEVER)

	//Armor Menu
	menu_additem(g_ArmorMenuID, "Yes, armor up", "1", 0, -1)
	menu_additem(g_ArmorMenuID, "No Armor", "2", 0, -1)
	menu_setprop(g_ArmorMenuID, MPROP_EXIT, MEXIT_NEVER)
	
	//Nade Menu
	menu_additem(g_NadeMenuID, "All Grenades", "1", 0, -1)
	menu_additem(g_NadeMenuID, "No Grenades", "2", 0, -1)
	menu_setprop(g_NadeMenuID, MPROP_EXIT, MEXIT_NEVER)
	
	return PLUGIN_HANDLED
}

equipUser(id, to)
{
	if (!is_user_alive(id) )
		return
	
	new weaptype
	new team = get_user_team(id)

	if ((to & EQUIP_SEC) && get_weaponid(g_SecWeapons[id]))
	{
		//Give Secondary
		GiveUserFullWeapon(id, g_SecWeapons[id])
	}
	
	if ((to & EQUIP_PRI) && get_weaponid(g_PrimWeapons[id]))
	{
		//Give Primary
		GiveUserFullWeapon(id, g_PrimWeapons[id])
	}
	
	if (to & EQUIP_ARMOR)
	{
		//Give Armor
		if (g_mAutoArmor || g_mArmor[id])
		{
			new armor = g_mArmor[id] ? 2 : g_Armor
			cs_set_user_armor(id, DEFAULT_ARMOR, CsArmorType:armor)
		}
	}
	
	if (to & EQUIP_GREN)
	{
		//Give Nades
		if (g_mNades[id] || g_mAutoNades)
		{
				
			if (g_Nade)
			{
				weaptype = get_weaponid("weapon_hegrenade")

				if (IsRestricted[weaptype])
				{
					if ((UsedWpsT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_T))
					{
						UsedWpsT[weaptype]++
						GiveUserFullWeapon(id,"weapon_hegrenade")
					}
					if ((UsedWpsCT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_CT))
					{
						UsedWpsCT[weaptype]++
						GiveUserFullWeapon(id,"weapon_hegrenade")
					}
				}
				else
					GiveUserFullWeapon(id,"weapon_hegrenade")
			}
			
			if (g_Smoke)
			{
				weaptype = get_weaponid("weapon_smokegrenade")

				if (IsRestricted[weaptype])
				{
					if ((UsedWpsT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_T))
					{
						UsedWpsT[weaptype]++
						GiveUserFullWeapon(id,"weapon_smokegrenade")
					}
					if ((UsedWpsCT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_CT))
					{
						UsedWpsCT[weaptype]++
						GiveUserFullWeapon(id,"weapon_smokegrenade")
					}
				}
				else
					GiveUserFullWeapon(id, "weapon_smokegrenade")
			}
		
			if (g_Flash && fnadesnum)
			{
				weaptype = get_weaponid("weapon_flashbang")
				if (IsRestricted[weaptype])
				{
					if ((UsedWpsT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_T))
					{
						UsedWpsT[weaptype]++
						GiveUserFullWeapon(id, "weapon_flashbang")
					}
					if ((UsedWpsCT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_CT))
					{
						UsedWpsCT[weaptype]++
						GiveUserFullWeapon(id, "weapon_flashbang")
					}
				}
				else
					GiveUserFullWeapon(id, "weapon_flashbang")
				if (fnadesnum == 2)
				{
					if (IsRestricted[weaptype])
					{
						if ((UsedWpsT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_T))
						{
							UsedWpsT[weaptype]++
							GiveUserFullWeapon(id, "weapon_flashbang")
						}
						if ((UsedWpsCT[weaptype] < RestrictWps[weaptype]) && (team == _TEAM_CT))
						{
							UsedWpsCT[weaptype]++
							GiveUserFullWeapon(id, "weapon_flashbang")
						}
					}
					else 
						GiveUserFullWeapon(id, "weapon_flashbang")
				}
			}
		}
	}
	
	if (to & EQUIP_ITEMS)
	{
		if (g_DefuseKit && (get_user_team(id) == _TEAM_CT))
		{
			cs_set_user_defuse(id, 1)
		}
		if (g_NightVision)
		{
			cs_set_user_nvg(id, 1)
		}
	}
}

GiveUserFullWeapon(id, const wp[])
{
	/** First check to make sure the user does not have a weapon in this slot */
	new wpnid = get_weaponid(wp)
	new weapons[MAX_WEAPONS], num
	new name[24], weap
	new slot

	if (!is_user_connected(id)) return

	new team = get_user_team(id)

	if (wpnid == 0)
	{
		if (equal(wp, "weapon_shield"))
		{
			slot = SLOT_PRIMARY
			wpnid = -1
		}
	} else {
		slot = g_WeaponSlots[wpnid]
	}
	if ((slot == SLOT_SECONDARY || slot == SLOT_PRIMARY)
		 && wpnid > 0)
	{
		get_user_weapons(id, weapons, num)
		for (new i=0; i<num; i++)
		{
			weap = weapons[i]
			if (weap == wpnid)
			{
				continue
			}
			if (g_WeaponSlots[weap] == slot)
			{
				if (slot == SLOT_SECONDARY && cs_get_user_shield(id))
				{
					//temporary fix!
					drop_with_shield(id, weap)
				} else {
					get_weaponname(weap, name, 23)
					csdm_force_drop(id, name)
				}
			}
		}
	} else if (slot == SLOT_PRIMARY && wpnid == -1 && cs_get_user_shield(id)) {
		return
	}
	
	if (slot == SLOT_PRIMARY && cs_get_user_shield(id) && wpnid > 0)
	{
		csdm_fwd_drop(id, -1, "weapon_shield")
	}
	
	new item_id = csdm_give_item(id, wp)
	if (item_id > 0)
	{
		if (wpnid == CSW_M4A1)
		{
			cs_set_weapon_silen(item_id, g_Silenced[id][SILENCED_M4A1], 1)
		} else if (wpnid == CSW_USP) {
			cs_set_weapon_silen(item_id, g_Silenced[id][SILENCED_USP], 1)
		}
	}

	if (wpnid > 0)
	{
		new bpammo = g_MaxBPAmmo[wpnid]
		if (bpammo)
		{
			cs_set_user_bpammo(id, wpnid, bpammo)
		}

		if (IsRestricted[wpnid])
		{
			if ((UsedWpsT[wpnid] < RestrictWps[wpnid]) && (team == _TEAM_T))
			{
				UsedWpsT[wpnid]++
			}
			if ((UsedWpsCT[wpnid] < RestrictWps[wpnid]) && (team == _TEAM_CT))
			{
				UsedWpsCT[wpnid]++
			}
		}
	}
}

// MAIN FUNCTION OF THE PLUGIN
public csdm_PostSpawn(player)
{
	if (pv_csdm_additems)
	{
	if (get_pcvar_num(pv_csdm_additems))
		return PLUGIN_CONTINUE
	}

	if (is_user_bot(player))
	{
			new i, weapon_p, weapon_s
			new randPrim = random_num(0, g_iNumBotPrim-1)
			new randSec = random_num(0, g_iNumBotSec-1)

			new team = get_user_team(player)
			weapon_p = get_weaponid(g_BotPrim[randPrim])

			i = 0
			while ((i < 10) && (IsRestricted[weapon_p]) 
					&& ((UsedWpsT[weapon_p] >= RestrictWps[weapon_p]) && (team == _TEAM_T) 
							|| (UsedWpsCT[weapon_p] >= RestrictWps[weapon_p]) && (team == _TEAM_CT)))
			{
				randPrim++
				if (randPrim >= g_iNumBotPrim)
					randPrim = 0
				weapon_p = get_weaponid(g_BotPrim[randPrim])
				i++
			}

			weapon_s = get_weaponid(g_BotSec[randSec])
			i = 0
			while ((i < 10) && (IsRestricted[weapon_s]) 
					&& ((UsedWpsT[weapon_s] >= RestrictWps[weapon_s]) && (team == _TEAM_T) 
							|| (UsedWpsCT[weapon_s] >= RestrictWps[weapon_s]) && (team == _TEAM_CT)))
			{
				randSec++
				if (randSec >= g_iNumBotSec)
					randSec = 0
				weapon_s = get_weaponid(g_BotSec[randSec])
				i++
			}

			new randArm = random_num(0, 2)
			new randGre = random_num(0, 2)
			
			if (g_mPrimStatus)
				GiveUserFullWeapon(player, g_BotPrim[randPrim])
			if (g_mSecStatus)
				GiveUserFullWeapon(player, g_BotSec[randSec])

			g_mArmor[player] = (g_mArmorStatus && randArm)
			g_mNades[player] = (g_mNadeStatus && randGre)
	
			if (g_mAutoArmor || g_mArmor[player])
			{
				equipUser(player, EQUIP_ARMOR)
			}

			if (g_mAutoNades || g_mNades[player])
			{
				equipUser(player, EQUIP_GREN)
			}
			if (g_DefuseKit)
			{
				equipUser(player, EQUIP_ITEMS)
			}
	} else {
		if (g_mShowuser[player])
		{
			new oldmenuid, newmenuid
			new bool:bEquipMenuDisp = false

			player_menu_info(player, oldmenuid, newmenuid) // main thing to prevent overwrite some menu by gun menu

			if ((newmenuid != -1) && ((newmenuid == g_SecMenuID) || (newmenuid == g_PrimMenuID) 
				|| (newmenuid == g_ArmorMenuID) || (newmenuid == g_EquipMenuID)))
				bEquipMenuDisp = true

			if ((bEquipMenuDisp) || (oldmenuid<=0) || (g_maxdelmenutime==0))
			{
				g_MenuState[player] = 1
				menu_display(player, g_EquipMenuID, 0)
			}
			else
			{
				new param[1]
				param[0] = player
				if (g_maxdelmenutime>0)	set_task(1.0,	"checkmenu",	850+player,	param,	1,	"b")
				set_task(g_maxdelmenutime, "menu_delayed", 700+player, param, 1)
			}
		} else {
			g_MenuState[player] = 0
			set_task(0.2, "delay_equip", player)
//			equipUser(player, EQUIP_ALL)
		}
	}
	return PLUGIN_CONTINUE
}

public delay_equip(id)
{
	if (is_user_connected(id))
		equipUser(id, EQUIP_ALL)
}

public enableMenu(id)
{
	if (!csdm_active())
		return PLUGIN_CONTINUE
		
	if (!g_mShowuser[id])
	{
		g_mShowuser[id] = true
		client_print(id, print_chat, "[CSDM] Your equip menu has been re-enabled.")
		if (!g_MenuState[id])
		{
			g_MenuState[id] = 1
			menu_display(id, g_EquipMenuID, 0)
		}
	} 
	else if (!g_AlwaysAllowGunMenu || !g_AmmoRefill || (g_WeaponStayTime > 5))
	{
		if (!g_AlwaysAllowGunMenu)
			client_print(id, print_chat, "[CSDM] Your equip menu is already enabled - You should have a gun already.")
		else if (!g_AmmoRefill)
			client_print(id, print_chat, "[CSDM] You cannot use guns menu when You have a gun already and ammorefill is disabled.")
		else if (g_WeaponStayTime > 5)
			client_print(id, print_chat, "[CSDM] You cannot use guns menu when You have a gun already and weapon_stay time is too long.")
	}
	else
	{
		g_MenuState[id] = 1
		menu_display(id, g_EquipMenuID, 0)
	}
	return PLUGIN_HANDLED
}

public checkmenu(param[])
{
	new id = param[0]
	if (!id)
	{
		if (task_exists(850+id)) remove_task(850+id)
		return PLUGIN_CONTINUE
	}
	if (!is_user_connected(id))
	{
		if (task_exists(850+id)) remove_task(850+id)
		return PLUGIN_CONTINUE
	}

	new oldmenuid, newmenuid
	new bool:bEquipMenuDisp = false

	player_menu_info(id, oldmenuid, newmenuid)

	if ((newmenuid != -1) && ((newmenuid == g_SecMenuID) || (newmenuid == g_PrimMenuID) 
		|| (newmenuid == g_ArmorMenuID) || (newmenuid == g_EquipMenuID)))
		bEquipMenuDisp = true

	if ((oldmenuid<=0) || (bEquipMenuDisp))
	{
		g_MenuState[id] = 1
		menu_display(id, g_EquipMenuID, 0)
		if (task_exists(850+id)) remove_task(850+id)
		if (task_exists(700+id)) remove_task(700+id)
	}	
	return PLUGIN_CONTINUE
}

public menu_delayed(param[])
{
	new id = param[0]
	if (!id)
	{
		if (task_exists(700+id)) remove_task(700+id)
		return PLUGIN_HANDLED
	}

	if (!is_user_connected(id))
	{
		if (task_exists(850+id)) remove_task(850+id)
		return PLUGIN_HANDLED
	}

	g_MenuState[id] = 1
	menu_display(id, g_EquipMenuID, 0)
	
	if (task_exists(700+id))	remove_task(700+id)
	if (task_exists(850+id))  remove_task(850+id)	
	return PLUGIN_CONTINUE
}

stock getWeapId(wp[]) // this one is used, because get_weaponid doesn't work when csdm_CfgInit is called (something wrong with core intitialisation?
{
	if (equali(wp, "weapon_p228")) {
		return CSW_P228
	} else if (equali(wp, "weapon_scout")) {
		return CSW_SCOUT
	} else if (equali(wp, "weapon_hegrenade")) {
		return CSW_HEGRENADE
	} else if (equali(wp, "weapon_xm1014")) {
		return CSW_XM1014
	} else if (equali(wp, "weapon_c4")) {
		return CSW_C4
	} else if (equali(wp, "weapon_mac10")) {
		return CSW_MAC10
	} else if (equali(wp, "weapon_aug")) {
		return CSW_AUG
	} else if (equali(wp, "weapon_smokegrenade")) {
		return CSW_SMOKEGRENADE
	} else if (equali(wp, "weapon_elite")) {
		return CSW_ELITE
	} else if (equali(wp, "weapon_fiveseven")) {
		return CSW_FIVESEVEN
	} else if (equali(wp, "weapon_ump45")) {
		return CSW_UMP45
	} else if (equali(wp, "weapon_sg550")) {
		return CSW_SG550
	} else if (equali(wp, "weapon_galil")) {
		return CSW_GALIL
	} else if (equali(wp, "weapon_famas")) {
		return CSW_FAMAS
	} else if (equali(wp, "weapon_usp")) {
		return CSW_USP
	} else if (equali(wp, "weapon_glock18")) {
		return CSW_GLOCK18
	} else if (equali(wp, "weapon_awp")) {
		return CSW_AWP
	} else if (equali(wp, "weapon_mp5navy")) {
		return CSW_MP5NAVY
	} else if (equali(wp, "weapon_m249")) {
		return CSW_M249
	} else if (equali(wp, "weapon_m3")) {
		return CSW_M3
	} else if (equali(wp, "weapon_m4a1")) {
		return CSW_M4A1
	} else if (equali(wp, "weapon_tmp")) {
		return CSW_TMP
	} else if (equali(wp, "weapon_g3sg1")) {
		return CSW_G3SG1
	} else if (equali(wp, "weapon_flashbang")) {
		return CSW_FLASHBANG
	} else if (equali(wp, "weapon_deagle")) {
		return CSW_DEAGLE
	} else if (equali(wp, "weapon_sg552")) {
		return CSW_SG552
	} else if (equali(wp, "weapon_ak47")) {
		return CSW_AK47
	} else if (equali(wp, "weapon_knife")) {
		return CSW_KNIFE
	} else if (equali(wp, "weapon_p90")) {
		return CSW_P90
	}
	
	return 0
}

// stuff for settings menu - START

public csdm_es_menu(id, level, cid)
{
	if (!cmd_access(id, level, cid, 1) || !id)
		return PLUGIN_HANDLED

	menu_display(id, g_EquipSettMenu, 0)

	return PLUGIN_HANDLED
}

public use_csdm_equip_menu(id, menu, item)
{
	if (item < 0)
		return PLUGIN_CONTINUE

	new command[6], paccess, call
	if (!menu_item_getinfo(g_EquipSettMenu, item, paccess, command, 5, _, 0, call))
	{
		log_amx("Error: csdm_menu_item() failed (menu %d) (page %d) (item %d)", g_EquipSettMenu, 0, item)
		return PLUGIN_HANDLED
	}
	if (paccess && !(get_user_flags(id) & paccess))
	{
		client_print(id, print_chat, "You do not have access to this menu option.")
		return PLUGIN_HANDLED
	}

	new iChoice = str_to_num(command)
	
	switch(iChoice)
	{
		case 1:
		{
			g_mPrimStatus = g_mPrimStatus? false : true

			client_print(id, print_chat, "CSDM displaying primary gun menu %s.", g_mPrimStatus ? "enabled" : "disabled")
			log_amx("CSDM displaying primary gun menu %s.", g_mPrimStatus ? "enabled" : "disabled")

			menu_display(id, g_EquipSettMenu, 0)
			write_menus_settings(id)
			return PLUGIN_HANDLED
		}
		case 2:
		{
			g_mSecStatus = g_mSecStatus? false : true

			client_print(id, print_chat, "CSDM displaying secondary gun menu %s.", g_mSecStatus ? "enabled" : "disabled")
			log_amx("CSDM displaying secondary gun menu %s.", g_mSecStatus ? "enabled" : "disabled")

			menu_display(id, g_EquipSettMenu, 0)
			write_menus_settings(id)
			return PLUGIN_HANDLED
		}
		case 3:
		{
			g_mArmorStatus = g_mArmorStatus? false : true
			if (g_mArmorStatus)
				g_mAutoArmor = false

			client_print(id, print_chat, "CSDM displaying armor menu %s.", g_mArmorStatus ? "enabled" : "disabled")
			log_amx("CSDM displaying armor menu %s.", g_mArmorStatus ? "enabled" : "disabled")

			menu_display(id, g_EquipSettMenu, 0)
			write_menus_settings(id)
			return PLUGIN_HANDLED
		}
		case 4:
		{
			g_mNadeStatus = g_mNadeStatus? false : true
			if (g_mNadeStatus)
				g_mAutoNades = false

			client_print(id, print_chat, "CSDM displaying nades menu %s.", g_mNadeStatus ? "enabled" : "disabled")
			log_amx("CSDM displaying nades menu %s.", g_mNadeStatus ? "enabled" : "disabled")

			menu_display(id, g_EquipSettMenu, 0)
			write_menus_settings(id)
			return PLUGIN_HANDLED
		}
		case 5:
		{
			if ((g_Armor == 1) || (g_Armor == 2))
			{
				g_Armor = 0
				g_mAutoArmor = false
			}
			else if (g_Armor == 0)
			{
				g_Armor = 1
				g_mAutoArmor = true
				g_mArmorStatus = false
			}

			client_print(id, print_chat, "CSDM auto equiping players with armor %s.", g_mAutoArmor ? "enabled" : "disabled")
			log_amx("CSDM auto equiping players with armor %s.", g_mAutoArmor ? "enabled" : "disabled")

			menu_display(id, g_EquipSettMenu, 0)
			write_autoequip_settings(id)
			return PLUGIN_HANDLED
		}
		case 6:
		{
			if ((g_Armor == 0) || (g_Armor == 1))
			{
				g_Armor = 2
				g_mAutoArmor = true
				g_mArmorStatus = false
			}
			else if (g_Armor == 2)
			{
				g_Armor = 1
				g_mAutoArmor = true
				g_mArmorStatus = false
			}

			client_print(id, print_chat, "CSDM auto equiping players with helmet %s.", (g_Armor == 2) ? "enabled" : "disabled")
			log_amx("CSDM auto equiping players with helmet %s.", (g_Armor == 2) ? "enabled" : "disabled")

			menu_display(id, g_EquipSettMenu, 0)
			write_autoequip_settings(id)
			return PLUGIN_HANDLED
		}
		case 7:
		{
			g_mAutoNades = g_mAutoNades? false : true
			if (g_mAutoNades)
				g_mNadeStatus = false

			client_print(id, print_chat, "CSDM auto equiping players with grenades %s.", g_mAutoNades ? "enabled" : "disabled")
			log_amx("CSDM auto equiping players with grenades %s.", g_mAutoNades ? "enabled" : "disabled")

			menu_display(id, g_EquipSettMenu, 0)
			write_autoequip_settings(id)
			return PLUGIN_HANDLED
		}
		case 8:
		{
			g_DefuseKit = g_DefuseKit? false : true

			client_print(id, print_chat, "CSDM auto equiping players with defuser (CTs) %s.", g_DefuseKit ? "enabled" : "disabled")
			log_amx("CSDM auto equiping players with defuser (CTs) %s.", g_DefuseKit ? "enabled" : "disabled")

			menu_display(id, g_EquipSettMenu, 1)
			write_autoequip_settings(id)
			return PLUGIN_HANDLED
		}
		case 9:
		{
			g_NightVision = g_NightVision? false : true

			client_print(id, print_chat, "CSDM auto equiping players with nightvision %s.", g_NightVision ? "enabled" : "disabled")
			log_amx("CSDM auto equiping players with nightvision %s.", g_NightVision ? "enabled" : "disabled")

			menu_display(id, g_EquipSettMenu, 1)
			write_autoequip_settings(id)
			return PLUGIN_HANDLED
		}
		case 10:
		{
			g_Flash = g_Flash? false : true

			client_print(id, print_chat, "CSDM usage of flashbangs is %s.", g_Flash ? "enabled" : "disabled")
			log_amx("CSDM usage of flashbangs is %s.", g_Flash ? "enabled" : "disabled")

			menu_display(id, g_EquipSettMenu, 1)
			write_nades_settings(id)
			return PLUGIN_HANDLED
		}
		case 11:
		{
			g_Smoke = g_Smoke? false : true

			client_print(id, print_chat, "CSDM usage of smoke grenades is %s.", g_Smoke ? "enabled" : "disabled")
			log_amx("CSDM usage of smoke grenades is %s.", g_Smoke ? "enabled" : "disabled")

			menu_display(id, g_EquipSettMenu, 1)
			write_nades_settings(id)
			return PLUGIN_HANDLED
		}
		case 12:
		{
			g_Nade = g_Nade? false : true

			client_print(id, print_chat, "CSDM usage of he nades is %s.", g_Nade ? "enabled" : "disabled")
			log_amx("CSDM usage of he nades is %s.", g_Nade ? "enabled" : "disabled")

			menu_display(id, g_EquipSettMenu, 1)
			write_nades_settings(id)
			return PLUGIN_HANDLED
		}
		case 13:
		{
			g_AlwaysAllowGunMenu = g_AlwaysAllowGunMenu? false : true

			client_print(id, print_chat, "CSDM Always Allow Gun Menu is %s.", g_AlwaysAllowGunMenu ? "enabled" : "disabled")
			log_amx("CSDM Always Allow Gun Menu is %s.", g_AlwaysAllowGunMenu ? "enabled" : "disabled")

			menu_display(id, g_EquipSettMenu, 1)
			csdm_write_cfg(id, "equip", "always_allow_gunmenu", g_AlwaysAllowGunMenu ? "1" : "0")
			return PLUGIN_HANDLED
		}
		case 14:
		{
			menu_display(id, g_SettingsMenu, g_PageSettMenu)
			return PLUGIN_HANDLED
		}
	}
	return PLUGIN_HANDLED
}

public hook_equip_sett_display(player, menu, item)
{
	new paccess, command[24], call
	
	menu_item_getinfo(menu, item, paccess, command, 23, _, 0, call)
	
	if (equali(command, "1"))
	{
		if (g_mPrimStatus)
		{
			menu_item_setname(menu, item, "Equip Menu Primary Enabled")
		} else {
			menu_item_setname(menu, item, "Equip Menu Primary Disabled")
		}
	}
	if (equali(command, "2"))
	{
		if (g_mSecStatus)
		{
			menu_item_setname(menu, item, "Equip Menu Secondary Enabled")
		} else {
			menu_item_setname(menu, item, "Equip Menu Secondary Disabled")
		}
	}
	if (equali(command, "3"))
	{
		if (g_mArmorStatus)
		{
			menu_item_setname(menu, item, "Equip Menu Armor Enabled")
		} else {
			menu_item_setname(menu, item, "Equip Menu Armor Disabled")
		}
	}
	if (equali(command, "4"))
	{
		if (g_mNadeStatus)
		{
			menu_item_setname(menu, item, "Equip Menu Grenades Enabled")
		} else {
			menu_item_setname(menu, item, "Equip Menu Grenades Disabled")
		}
	}
	if (equali(command, "5"))
	{
		if (g_mAutoArmor)
		{
			menu_item_setname(menu, item, "Auto equip with Armor Enabled")
		} else {
			menu_item_setname(menu, item, "Auto equip with Armor Disabled")
		}
	}
	if (equali(command, "6"))
	{
		if ((g_mAutoArmor) && (g_Armor == 2))
		{
			menu_item_setname(menu, item, "Auto equip with Helmet Enabled")
		} else {
			menu_item_setname(menu, item, "Auto equip with Helmet Disabled")
		}
	}
	if (equali(command, "7"))
	{
		if (g_mAutoNades)
		{
			menu_item_setname(menu, item, "Auto equip with Grenades Enabled")
		} else {
			menu_item_setname(menu, item, "Auto equip with Grenades Disabled")
		}
	}
	if (equali(command, "8"))
	{
		if (g_DefuseKit)
		{
			menu_item_setname(menu, item, "Auto equip with Defuser Enabled")
		} else {
			menu_item_setname(menu, item, "Auto equip with Defuser Disabled")
		}
	}
	if (equali(command, "9"))
	{
		if (g_NightVision)
		{
			menu_item_setname(menu, item, "Auto equip with Nightvision Enabled")
		} else {
			menu_item_setname(menu, item, "Auto equip with Nightvision Disabled")
		}
	}
	if (equali(command, "10"))
	{
		if (g_Flash)
		{
			menu_item_setname(menu, item, "Flashbang Enabled")
		} else {
			menu_item_setname(menu, item, "Flashbang Disabled")
		}
	}
	if (equali(command, "11"))
	{
		if (g_Smoke)
		{
			menu_item_setname(menu, item, "Smoke grenade Enabled")
		} else {
			menu_item_setname(menu, item, "Smoke grenade Disabled")
		}
	}
	if (equali(command, "12"))
	{
		if (g_Nade)
		{
			menu_item_setname(menu, item, "HE grenade Enabled")
		} else {
			menu_item_setname(menu, item, "HE grenade Disabled")
		}
	}
	if (equali(command, "13"))
	{
		if (g_AlwaysAllowGunMenu)
		{
			menu_item_setname(menu, item, "Always Allow Gun Menu Enabled")
		} else {
			menu_item_setname(menu, item, "Always Allow Gun Menu Disabled")
		}
	}
}

public write_menus_settings(id)
{
	new flags[5] = ""
	new menu_flags = 0

	if (g_mPrimStatus)
	{
		menu_flags |= (1<<0)
	}
	if (g_mSecStatus)
	{
		menu_flags |= (1<<1)
	}
	if (g_mArmorStatus)
	{
		menu_flags |= (1<<2)
	}
	if (g_mNadeStatus)
	{
		menu_flags |= (1<<3)
	}

	get_flags(menu_flags, flags, 4)
	replace(flags, 4, "a", "p")
	replace(flags, 4, "b", "s")
	replace(flags, 4, "c", "a")
	replace(flags, 4, "d", "g")
	csdm_write_cfg(id, "equip", "menus", flags)
}

public write_autoequip_settings(id)
{
	new flags[6] = ""
	new auto_flags = 0

	if (g_mAutoArmor)
	{
		auto_flags |= (1<<0)
	}
	if ((g_mAutoArmor) && (g_Armor == 2))
	{
		auto_flags |= (1<<1)
	}
	if (g_mAutoNades)
	{
		auto_flags |= (1<<2)
	}
	if (g_DefuseKit)
	{
		auto_flags |= (1<<3)
	}
	if (g_NightVision)
	{
		auto_flags |= (1<<4)
	}

	get_flags(auto_flags, flags, 5)
//	replace(flags, 5, "a", "a")
	replace(flags, 5, "b", "h")
	replace(flags, 5, "c", "g")
//	replace(flags, 5, "d", "d")
	replace(flags, 5, "e", "n")
	csdm_write_cfg(id, "equip", "autoitems", flags)
}

public write_nades_settings(id)
{
	new flags[4] = ""
	new nade_flags = 0

	if (g_Flash)
	{
		nade_flags |= (1<<0)
	}
	if (g_Nade)
	{
		nade_flags |= (1<<1)
	}
	if (g_Smoke)
	{
		nade_flags |= (1<<2)
	}

	get_flags(nade_flags, flags, 3)
	replace(flags, 3, "a", "f")
	replace(flags, 3, "b", "h")
	replace(flags, 3, "c", "s")
	csdm_write_cfg(id, "equip", "grenades", flags)
}

// stuff for settings menu - END

Потребителски аватар

Автор на темата
iv69
Потребител
Потребител
Мнения: 355
Регистриран: 17 мар 2018, 15:34
Се отблагодари: 100 пъти
Получена благодарност: 10 пъти

Добавяне на "duration" към "golden weapon".

Мнение от iv69 » 17 май 2019, 20:38

Тествано и работи всичко точно като швейцарски часовник. Брилянтна изработка, плъгина е велик и работи префектно. Не знам, но малко хора се наемат да правят такива неща, и най-вече ТОЛКОВА ДОБРЕ! Поне за сега : няма бъгове, всичко е супер. За изработки и идеи нямаш равен !!!
Препоръчвам плъгина на всички, няма да съжалявате...................... Ако бях в BG с удоволствие щях да те почерпя нещо за добрата работа.
Нека поостане темата отворена, ако някой иска нещо по него още да пита или да променя - но за мен е изгладен от всякъде и с допълнението към ЦСДМ-а е върха.

Отговори

Върни се в “Заявки за плъгини”

Кой е на линия

Потребители, разглеждащи този форум: Няма регистрирани потребители и 3 госта