Официалният форум на iPlay.bg 

Този раздел е създаден специално за проблеми и въпроси за направата на плъгини или преработката на вече съществуващи кодове.
 #390765  от southdivision
 съб май 21, 2016 7:11 pm
Проблема е следния,че когато желая да отворя менюто - то не се отваря. Отваря се само ако махна от менюто:
Код: Избери всички
formatex(HeadLine, charsmax(HeadLine), "\yUSP \r[\d 300$ \r]  [\y%i\r/\y%i\r]",get_user_limit(id, 5), itemlimit(5))
	menu_additem(Grenades, HeadLine, "5", 0)
	
	formatex(HeadLine, charsmax(HeadLine), "\yGlock \r[\d 300$ \r]  [\y%i\r/\y%i\r]",get_user_limit(id, 6), itemlimit(6))
	menu_additem(Grenades, HeadLine, "6", 0)
	
	formatex(HeadLine, charsmax(HeadLine), "\yM4A1 Carbon \r[\d 750$ \r]  [\y%i\r/\y%i\r]",get_user_limit(id, 7), itemlimit(7))
	menu_additem(Grenades, HeadLine, "7", 0)
	
	formatex(HeadLine, charsmax(HeadLine), "\yAK47 Kalachnicov \r[\d 750$ \r] [\y%i\r/\y%i\r]", get_user_limit(id, 8), itemlimit(8))
	menu_additem(Grenades, HeadLine, "8", 0)
	
Ето целия код:
Код: Избери всички
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
#include <fun>
#include <hamsandwich>
#include <nvault>
#include < dhudmessage >
#include < fakemeta_util >
#include < fvault >
 
 
new const g_vaultName[]  = "Shop"

new SmokeLimit, FlashBangLimit, HeLimit, AllNadesLimit, DeagleLimit, GlockLimit, UspLimit, CarbonLimit, KalashnikovLimit
new userlimit[33][33]

new Shop, Cash[33], HeadLine[110];
new menu;
#define MAX_ITEMS 23


public plugin_init() {
        register_plugin("Shop", "1.0", "No Author")
        register_clcmd("say /shop", "pShop")
        register_clcmd("say !shop", "pShop")

		
		RegisterHam(Ham_Spawn, "player", "player_spawn", 1)
        register_logevent("RoundEnd", 2, "1=Round_End")
		
	SmokeLimit = register_cvar("smoke_limit", "2")
	FlashBangLimit = register_cvar("flashbang_limit", "2")
	HeLimit = register_cvar("he_limit", "2")
	AllNadesLimit = register_cvar("allnades_limit", "2")
	GlockLimit = register_cvar("glock_limit", "1")
	UspLimit = register_cvar("usp_limit", "1")
	CarbonLimit = register_cvar("carbon_limit", "1")
	KalashnikovLimit = register_cvar("kalashnikov_limit", "1")
	}
public player_spawn(id)
{
	for(new i = 0; i < MAX_ITEMS + 1; i++)
		set_user_limit(id, i, 0)
}

public RoundEnd()
{
server_cmd("mp_friendlyfire 0")    
}


stock set_user_limit(id, item, limit)
	userlimit[id][item] = limit

stock get_user_limit(id, item)
	return userlimit[id][item]

stock itemlimit(item)
{
	new limit

	switch(item)
	{
		case 0: limit = get_pcvar_num(SmokeLimit)
		case 1: limit = get_pcvar_num(FlashBangLimit)
		case 2: limit = get_pcvar_num(HeLimit)
		case 3: limit = get_pcvar_num(AllNadesLimit)
		
		case 4: limit = get_pcvar_num(DeagleLimit)
		case 5: limit = get_pcvar_num(UspLimit)
		case 6: limit = get_pcvar_num(GlockLimit)
		case 7: limit = get_pcvar_num(CarbonLimit)
		case 8: limit = get_pcvar_num(KalashnikovLimit)
}
	
	return limit
}
public pShop(id) {
	if (is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_T) {
		Cash[id] = cs_get_user_money(id);
		formatex(HeadLine, charsmax(HeadLine),
			"\rShop's ^n\y$ \w: \r[\d %d \r]^nNachalno Menu", Cash[id])
		Shop = menu_create(HeadLine, "Handler")
		menu_additem(Shop, "\yGranati Market", "1", 0)
		menu_setprop(Shop, MPROP_EXITNAME, "\yIzhod");
		menu_setprop(Shop, MPROP_NUMBER_COLOR, "\d");
		menu_setprop(Shop, MPROP_EXIT, MEXIT_ALL)
		menu_display(id, Shop, 0)
	} else {
		ColorChat(id, "Ti ne si ^3Jiv ^4Ili ne si ^3Terorist^4 za da izpolzvash tova Menu.")
	}
	return PLUGIN_HANDLED;
}
public Handler(id, Shop, item, client) {
	if (item == MENU_EXIT || cs_get_user_team(id) == CS_TEAM_CT || !is_user_alive(id)) {
		menu_destroy(Shop)
		return PLUGIN_HANDLED;
	}
	new data[6], szName[33];
	new access, callback;
	menu_item_getinfo(Shop, item, access, data, 5, szName, 32, callback)
	new key = str_to_num(data);
	switch (key)
	{
		case 1:
			GrenadesMenu(id)
	}
	return PLUGIN_HANDLED;
}
public GrenadesMenu(id)
{
	Cash[id] = cs_get_user_money(id);
	formatex(HeadLine, charsmax(HeadLine), "\rShop ^n\y$ \w: \r[\d %d \r]^nNades",Cash[id])
	new Grenades = menu_create(HeadLine, "GHandler")
	
	formatex(HeadLine, charsmax(HeadLine), "\ySmoke Granata \r[\d 15 $ \r] [\y%i\r/\y%i\r]",get_user_limit(id, 0), itemlimit(0))
	menu_additem(Grenades, HeadLine, "0", 0)
	
	formatex(HeadLine, charsmax(HeadLine), "\yFlashBang Granata \r[\d 30 $ \r] [\y%i\r/\y%i\r]", get_user_limit(id, 1), itemlimit(1))
	menu_additem(Grenades, HeadLine, "1", 0)
	
	formatex(HeadLine, charsmax(HeadLine), "\yHE-Granata  \r[\d 45 $ \r] [\y%i\r/\y%i\r]", get_user_limit(id, 2), itemlimit(2))
	menu_additem(Grenades, HeadLine, "2", 0)
	
	formatex(HeadLine, charsmax(HeadLine), "\yPaket Granati \r[\d 60 $ \r] [\y%i\r/\y%i\r]", get_user_limit(id,3), itemlimit(3))
	menu_additem(Grenades, HeadLine, "3", 0)
	
	formatex(HeadLine, charsmax(HeadLine), "\yDeagle \r[\d 150$ \r] [\y%i\r/\y%i\r]",get_user_limit(id, 4), itemlimit(4))
	menu_additem(Grenades, HeadLine, "4", 0)
	
	formatex(HeadLine, charsmax(HeadLine), "\yUSP \r[\d 300$ \r]  [\y%i\r/\y%i\r]",get_user_limit(id, 5), itemlimit(5))
	menu_additem(Grenades, HeadLine, "5", 0)
	
	formatex(HeadLine, charsmax(HeadLine), "\yGlock \r[\d 300$ \r]  [\y%i\r/\y%i\r]",get_user_limit(id, 6), itemlimit(6))
	menu_additem(Grenades, HeadLine, "6", 0)
	
	formatex(HeadLine, charsmax(HeadLine), "\yM4A1 Carbon \r[\d 750$ \r]  [\y%i\r/\y%i\r]",get_user_limit(id, 7), itemlimit(7))
	menu_additem(Grenades, HeadLine, "7", 0)
	
	formatex(HeadLine, charsmax(HeadLine), "\yAK47 Kalachnicov \r[\d 750$ \r] [\y%i\r/\y%i\r]", get_user_limit(id, 8), itemlimit(8))
	menu_additem(Grenades, HeadLine, "8", 0)
	
	menu_setprop(Grenades, MPROP_EXITNAME, "\yMain Menu");
	menu_setprop(Grenades, MPROP_NUMBER_COLOR, "\d");
	menu_setprop(Grenades, MPROP_EXIT, MEXIT_ALL)
	menu_display(id, Grenades, 0)
}
public GHandler(id, Grenades, item) {
	Cash[id] = cs_get_user_money(id);
	if (item == MENU_EXIT) {
		pShop(id);
		return PLUGIN_HANDLED;
	}
	new data[6], szName[33]
	new access, callback;
	menu_item_getinfo(Grenades, item, access, data, 5, szName, 32, callback)
	new key = str_to_num(data);
	if (get_user_limit(id, item) < itemlimit(item))
	{
		switch (key)
		{
			case 0:
				{
					if (Cash[id] >= 15) {
						fm_give_item(id, "weapon_smokegrenade")
						cs_set_user_bpammo(id, CSW_SMOKEGRENADE, 1)
						ColorChat(id, "You Bought SmokeGrenade Successfully")
						set_user_limit(id, item, get_user_limit(id, item) + 1)
						cs_set_user_money(id, cs_get_user_money(id) - 15)
					} else {
						ColorChat(id, "You Don't Have Enough Cash To Buy ^3SmokeGrenade")
					}
				}
			case 1:
				{
					if (Cash[id] >= 30) {
						fm_give_item(id, "weapon_flashbang")
						cs_set_user_bpammo(id, CSW_FLASHBANG, 1)
						ColorChat(id, "You Bought FlashBang Successfully")
						set_user_limit(id, item, get_user_limit(id, item) + 1)
						cs_set_user_money(id, cs_get_user_money(id) - 30)
					} else {
						ColorChat(id, "You Don't Have Enough Cash To Buy ^3FlashBang")
					}
				}
			case 2:
				{
					if (Cash[id] >= 45) {
						fm_give_item(id, "weapon_hegrenade")
						cs_set_user_bpammo(id, CSW_HEGRENADE, 1)
						ColorChat(id, "You Bought HeGrenade Successfully")
						set_user_limit(id, item, get_user_limit(id, item) + 1)
						cs_set_user_money(id, cs_get_user_money(id) - 45)
					} else {
						ColorChat(id, "You Don't Have Enough Cash To Buy ^3HeGrenade")
					}
				}
			case 3:
				{
					if (Cash[id] >= 60) {
						fm_give_item(id, "weapon_smokegrenade")
						cs_set_user_bpammo(id, CSW_SMOKEGRENADE, 1)
						fm_give_item(id, "weapon_hegrenade")
						cs_set_user_bpammo(id, CSW_HEGRENADE, 1)
						fm_give_item(id, "weapon_flashbang")
						cs_set_user_bpammo(id, CSW_FLASHBANG, 1)
						ColorChat(id, "You Bought All Grenades Package Successfully")
						set_user_limit(id, item, get_user_limit(id, item) + 1)
						cs_set_user_money(id, cs_get_user_money(id) - 60)
					} else {
						ColorChat(id, "You Don't Have Enough Cash To Buy ^3All Grenades Package")
					}
				}
				
				case 4:
				{
					if (Cash[id] >= 150) {
						cs_set_weapon_ammo(fm_give_item(id, "weapon_deagle"), 1);
						ColorChat(id, "You Bought Deagle [ 1 BULLET ] Successfully")
						cs_set_user_money(id, cs_get_user_money(id) - 150)
						set_user_limit(id, item, get_user_limit(id, item) + 1)
					} else {
						ColorChat(id, "You Don't Have Enough Cash To Buy ^3Deagle")
					}
				}
			case 5:
				{
					if (Cash[id] >= 300) {
						cs_set_weapon_ammo(fm_give_item(id, "weapon_usp"), 2);
						ColorChat(id, "You Bought USP [ 2 BULLETS ] Successfully")
						cs_set_user_money(id, cs_get_user_money(id) - 300)
						set_user_limit(id, item, get_user_limit(id, item) + 1)
					} else {
						ColorChat(id, "You Don't Have Enough Cash To Buy ^3USP")
					}
				}
			case 6:
				{
					if (Cash[id] >= 300) {
						cs_set_weapon_ammo(fm_give_item(id, "weapon_glock"), 2);
						ColorChat(id, "You Bought GLOCK [ 2 BULLETS ] Successfully")
						cs_set_user_money(id, cs_get_user_money(id) - 300)
						set_user_limit(id, item, get_user_limit(id, item) + 1)
					} else {
						ColorChat(id, "You Don't Have Enough Cash To Buy ^3USP")
					}
				}
			case 7:
				{
					if (Cash[id] >= 700) {
						cs_set_weapon_ammo(fm_give_item(id, "weapon_m4a1"), 5);
						ColorChat(id, "You Bought M4A1 Carbon [ 5 BULLETS ] Successfully")
						cs_set_user_money(id, cs_get_user_money(id) - 700)
						set_user_limit(id, item, get_user_limit(id, item) + 1)
					} else {
						ColorChat(id, "You Don't Have Enough Cash To Buy ^3M4A1 Carbon")
					}
				}
			case 8:
				{
					if (Cash[id] >= 700) {
						cs_set_weapon_ammo(fm_give_item(id, "weapon_ak47"), 5);
						ColorChat(id, "You Bought AK47 Kalachnicov [ 5 BULLETS ] Successfully")
						cs_set_user_money(id, cs_get_user_money(id) - 700)
						set_user_limit(id, item, get_user_limit(id, item) + 1)
					} else {
						ColorChat(id, "You Don't Have Enough Cash To Buy ^3AK47 Kalachnicov")
					}
				}
		}
	}
	else {
		if (get_user_limit(id, item) == itemlimit(item))
		{
			ColorChat(id, "^1You can buy this ^3item ^1only ^4%i ^1times per ^4spawn", itemlimit(item))
		}
	}
	menu_destroy(Grenades);
	return PLUGIN_HANDLED;
}


stock ColorChat(const id,
	const string[], {
		Float,
		Sql,
		Resul,
		_
	}: ...) {
	new msg[191], players[32], count = 1;
	static len;
	len = formatex(msg, charsmax(msg), "^3[^1Shop^3]^1 ");
	vformat(msg[len], charsmax(msg) - len, string, 3);
	if (id) players[0] = id;
	else get_players(players, count, "ch");
	for (new i = 0; i < count; i++)
	{
		if (is_user_connected(players[i]))
		{
			message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
			write_byte(players[i]);
			write_string(msg);
			message_end();
		}
	}
}
 #390782  от OciXCrom™
 съб май 21, 2016 8:55 pm
Покажи debug log от конзолата с добавените предмети.
 #390784  от zolfeca
 съб май 21, 2016 8:58 pm
Забравил си да добавиш cvar за deagle limit, което щеше да разбереш ако беше направил debug.
DeagleLimit = register_cvar("deagle_limit", "1");
 #390814  от southdivision
 нед май 22, 2016 12:28 am
Благодаря ти, zolfeca :) Не бях го забелязал в продължение на 1 месец и повече дори ...