Скриптер
Моделлер
Участник
Пользователь
- Сообщения
- 855
- Реакции
- 532
- Помог
- 13 раз(а)
Прошу помощи у зрителей, так как звонок другу не дал нужных результатов
Есть такой код
где-то в этом плагине есть код, который крашит сервер ~примерно на спавне или связанным с ним событием раз в миллион лет. Проверял через код перезапуска карты каждые 10 секунд
прошу помощи в поиске
сразу скажу что за модули используются:
customentdata - это аналог этого модуля , написанный с нуля - 100% стабилен. Set_ced, get_ced - его нативы
zp50_api_server_vallet - это тот же zp50_ammopacks , с добавлением своих фишек - так же стабилен, проверял
zfh_utils - файл с утилями и доп. данными к customentdata
код такой какой он есть на момент написания поста - все отключенные хуки и т.п. в данный момент не работают
p.s. эта катавасия с крашем уже неделю выловить не могу
p.s.s советы по коду так же приму к сведению (без фанатизма конечно же)
Есть такой код
где-то в этом плагине есть код, который крашит сервер ~примерно на спавне или связанным с ним событием раз в миллион лет. Проверял через код перезапуска карты каждые 10 секунд
прошу помощи в поиске
сразу скажу что за модули используются:
customentdata - это аналог этого модуля , написанный с нуля - 100% стабилен. Set_ced, get_ced - его нативы
zp50_api_server_vallet - это тот же zp50_ammopacks , с добавлением своих фишек - так же стабилен, проверял
zfh_utils - файл с утилями и доп. данными к customentdata
код такой какой он есть на момент написания поста - все отключенные хуки и т.п. в данный момент не работают
p.s. эта катавасия с крашем уже неделю выловить не могу
p.s.s советы по коду так же приму к сведению (без фанатизма конечно же)
C-like:
#include < amxmodx >
#include < amxmisc >
#include < reapi >
#include < fakemeta>
#include < hamsandwich >
#include < zp50_core >
#include < zp50_api_server_vallet >
#include < zp50_items_const >
#include < zp50_gamemodes >
#include < customentdata >
#include < zfh_utils >
#include <zpu_level_system>
new const g_szBuyCommands[ ][ ] =
{
"usp", "glock", "deagle", "p228", "elites",
"fn57", "m3", "xm1014", "mp5", "tmp", "p90",
"mac10", "ump45", "ak47", "galil", "famas",
"sg552", "m4a1", "aug", "scout", "awp", "g3sg1",
"sg550", "m249", "vest", "vesthelm", "flash",
"hegren", "sgren", "defuser", "nvgs", "shield",
"primammo", "secammo", "km45", "9x19mm", "nighthawk",
"228compact", "fiveseven", "12gauge", "autoshotgun",
"mp", "c90", "cv47", "defender", "clarion", "krieg552",
"bullpup", "magnum", "d3au1", "krieg550",
"buy", "buyequip", "cl_autobuy",
"cl_rebuy", "cl_setautobuy", "cl_setrebuy", "client_buy_open"
};
new const g_szItemSlots[ ][ ] =
{
"PISTOLS",
"SHOTGUN",
"AUTOMATES",
"RIFLES",
"MACHINE GUNS",
"BIG GUNS",
"EQUIPMENT HUMAN",
"TACTICALS HUMAN",
"TACTICAL",
"EQUIPMENT ZOMBIE"
};
new const g_szItemPermission[ ][ ] =
{
"ALL",
"ADMIN",
"VIP"
};
new const g_szNamePermission[ ][ ] =
{
"",
"\r[Admins]",
"\r[VIP]"
}
#define CHAT_PREFIX "!y[!gBuyMenu!y]" // Префикс в чате при сообщениях от плалина BuyMenu
#define FLAG_VIP ADMIN_LEVEL_H
#define FLAG_ADMIN ADMIN_KICK // moders
#define TASK_SHOWHUD 4001 // Таск айди худа
#define TASK_LOAD_DATA 4002 // Таск айди загрузки базы
#define MAX_ITEMS 256 // Максимально айтемов с лимитами
#define MAX_CLIENTS 32 // Максимально клиентов (не менять)
#define BM_PLUGIN_HANDLED 98 // Айди возвращения функции
#define BUYMENU_ITEMS_FILE "zp_extraitems.ini" // Название ini файла от бай меню
#define BUYMENU_CONFIG_FILE "zp_buymenu.cfg" // Название конфиг файла от бай меню
#define BUYMENU_LANG_FILE "zp_buymenu.txt" // Название ланг файла от бай меню
// Настройка валюты
#define BM_SetUserMoney(%0,%1) zp_ammopacks_set(%0,%1)
#define BM_GetUserMoney(%0) zp_ammopacks_get(%0)
// new Array: g_PrecacheModels;
enum eItemData
{
eItemData_szName[32],
eItemData_szRealName[32],
eItemData_Cost,
eItemData_Level,
eItemData_Pos,
eItemData_Type,
eItemData_Permission,
eItemData_MinPlayers,
eItemData_UserLimit,
eItemData_UserMapLimit,
eItemData_RoundLimit,
eItemData_MapLimit,
eItemData_RandomChance,
Float:eItemData_CD,
Float:eItemData_BaseDmg,
Float:eItemData_DmgMultiHead,
Float:eItemData_DmgMultiChest,
Float:eItemData_DmgMultiStomach,
Float:eItemData_DmgMultiLeg,
Float:eItemData_DmgMultiArm,
Float:eItemData_DmgMultiBreakable,
Float:eItemData_DmgMultiInfoTarget,
Float:eItemData_KnockBackPower,
Float:eItemData_KnockBackDistance,
Float:eItemData_KnockBackByDamageLimiter,
Float:eItemData_KnockBackByDamageRelated,
Float:eItemData_DecreaseZombie,
eItemData_AmmoBackup,
eItemData_BackModel[128],
eItemData_BackModelBody,
eItemData_BackModelSkin,
eItemData_WeaponModel[128],
eItemData_WeaponModelBody,
eItemData_WeaponModelSkin,
eItemData_DeathIcon[32],
eItemData_DeathMsg[32],
}
new Array:g_aItemData, Array:g_aItemData2;
new Array: aItemNew;
new Array: aItemsPosSort;
new g_AdditionalMenuText[32];
// new g_LastMenu[33];
new g_iItemId[33], Float:g_flLastTimeBuy[33], g_iBuyCounter, g_iPlayerItemCounterId[33];
new g_bitsAlive, g_bitsZombie;
new g_ItemIndex[33][8];
new g_iSkipFirstItemId;
enum _: eCvarList
{
Discount_Enable = 0,
Discount_VIP,
Discount_Admin,
Discount_Steam,
BuyMenu_After_Infection,
BuyMenu_Block_Weapons
};
enum _: eMessages
{
SayText = 0,
BuyClose,
StatusIcon
};
enum _: eData
{
Level = 0,
Exp
};
enum _: eCallBack
{
CB_Items = 0,
CB_Rifles,
CB_Pistols,
CB_Knives
};
enum _: eWeaponType
{
Primary = 0,
Secondary
}
enum
{
All_Users = 0,
VIP_Player,
};
enum _:_FORWARDS
{
FW_ITEM_SELECT_PRE,
FW_ITEM_SELECT_POST
}
new pCvar[ eCvarList ];
new g_fwItemSelect[_FORWARDS];
new g_iMsgID[ eMessages ];
new g_ItemCount, g_ItemsCount[16];
new g_iMaxPlayers;
new g_iForwardResult;
new g_iUserDiscount[ MAX_CLIENTS + 1 ];
new g_iUserBackMoney[ MAX_CLIENTS + 1 ];
new g_iMapItemLimit[ MAX_ITEMS ];
new g_iRoundItemLimit[ MAX_ITEMS ];
new g_iUserItemLimit[ MAX_CLIENTS + 1 ][ MAX_ITEMS ];
new Float:g_flUserItemCD[ MAX_CLIENTS + 1 ][ MAX_ITEMS ];
new g_iUserMapItemLimit[ MAX_CLIENTS + 1 ][ MAX_ITEMS ];
new bool: g_bArraysCreated;
new bool: g_bSuperUser[ MAX_CLIENTS + 1 char ];
new bool: g_bUserLoaded[ MAX_CLIENTS + 1 char ];
new bool: g_bItemSelected[ MAX_CLIENTS + 1 ][ eWeaponType ];
public plugin_init( )
{
register_plugin( "[BIO] Buy Menu + Level System", "1.1", "t3rkecorejz" );
// register_dictionary( BUYMENU_LANG_FILE );
// register_event( "HLTV", "EV_RoundStart", "a", "1=0", "2=0" );
// RegisterHam(Ham_AddPlayerItem,"player","fw_AddPlayerItem", true, true);
// register_forward(FM_SetModel, "fw_SetModel", true);
// RegisterHam(Ham_Touch, "weaponbox", "Ham_PlayerTouch");
register_menu("BM Items Menu", 1023, "menu_extraitems");
register_menu("BMenu Weapons", 1023, "BuyMenu_Menu_Handler");
register_menucmd(register_menuid("BuyMenu Categories"), 1023, "Handle_MenuCategories");
g_iMsgID[ SayText ] = get_user_msgid( "SayText" );
g_iMsgID[ BuyClose ] = get_user_msgid( "BuyClose" );
g_iMsgID[ StatusIcon ] = get_user_msgid( "StatusIcon" );
g_iMaxPlayers = get_maxplayers();
g_fwItemSelect[FW_ITEM_SELECT_PRE] = CreateMultiForward( "zp_fw_items_select_pre", ET_CONTINUE, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_CELL);
g_fwItemSelect[FW_ITEM_SELECT_POST] = CreateMultiForward( "zp_fw_items_select_post", ET_CONTINUE, FP_CELL, FP_CELL, FP_CELL, FP_CELL);
pCvar[ Discount_Enable ] = register_cvar( "bm_discount_enable", "1" );
pCvar[ Discount_VIP ] = register_cvar( "bm_discount_vip", "10" );
pCvar[ Discount_Admin ] = register_cvar( "bm_discount_admin", "10" );
pCvar[ Discount_Steam ] = register_cvar( "bm_discount_steam", "5" );
pCvar[ BuyMenu_After_Infection ] = register_cvar( "bm_buymenu_after_infection", "0" );
pCvar[ BuyMenu_Block_Weapons ] = register_cvar( "bm_buymenu_block_weapons", "0" );
new iBuyCommands;
for ( iBuyCommands = 0; iBuyCommands < sizeof g_szBuyCommands; iBuyCommands++ )
register_clcmd( g_szBuyCommands[ iBuyCommands ], "Command_BuyMenu" );
register_clcmd( "123123", "Command_SuperUser" );
}
public plugin_precache()
{
}
public plugin_cfg( )
{
new szConfigDir[ 32 ];
get_configsdir( szConfigDir, charsmax( szConfigDir ) );
// server_cmd("exec %s/%s", szConfigDir, BUYMENU_CONFIG_FILE );
g_bArraysCreated = false;
CFile__SaveCustomization( );
new iMaxValue = -1, iIndex, iValue1, iValue2, iItem1, iItem2, i, j, iSize = ArraySize(g_aItemData), szData[eItemData], szData2[eItemData];
for (i = 0; i<iSize; i++)
{
// ArrayGetArray(g_aItemData, i, szData);
ArrayPushCell(aItemsPosSort, i);
}
for (i = 0; i<iSize; i++)
{
for (j = i+1; j<iSize; j++)
{
iItem1 = ArrayGetCell(aItemsPosSort, i);
if (j == iSize)
continue;
ArrayGetArray(g_aItemData, j, szData2);
iItem2 = ArrayGetCell(aItemsPosSort, j);
if (szData[eItemData_Pos] < szData2[eItemData_Pos])
{
ArraySetCell(aItemsPosSort, i, iItem2);
ArraySetCell(aItemsPosSort, j, iItem1);
}
}
}
}
public client_putinserver( iPlayer )
{
if ( get_pcvar_num( pCvar[ Discount_Enable ] ) )
{
new iFlags = get_user_flags(iPlayer);
if( iFlags & FLAG_VIP )
g_iUserDiscount[ iPlayer ] = get_pcvar_num( pCvar[ Discount_VIP ] );
if( iFlags & FLAG_ADMIN )
g_iUserDiscount[ iPlayer ] = g_iUserDiscount[ iPlayer ] + get_pcvar_num( pCvar[ Discount_Admin ] );
if( is_user_steam( iPlayer ) )
g_iUserDiscount[ iPlayer ] = g_iUserDiscount[ iPlayer ] + get_pcvar_num( pCvar[ Discount_Steam ] );
}
g_iUserDiscount[ iPlayer ] = 0;
}
public plugin_natives( )
{
aItemsPosSort = ArrayCreate( 1, 1 );
aItemNew = ArrayCreate( 1, 1 );
g_aItemData = ArrayCreate(eItemData);
g_aItemData2 = ArrayCreate(eItemData);
g_bArraysCreated = true;
new szData[eItemData];
g_iSkipFirstItemId = ArrayPushArray(g_aItemData, szData);
ArrayPushCell( aItemNew, 0 );
g_ItemCount++;
CFile__LoadCustomization( );
register_library("zp50_items");
register_native("zp_items_register", "Native_Register_Item", 1);
register_native("zp_items_get_id", "native_items_get_id")
register_native("zp_items_get_name", "native_items_get_name")
register_native("zp_items_get_real_name", "native_items_get_name")
register_native("zp_items_get_cost", "native_items_get_cost")
register_native("zp_items_show_menu", "native_items_show_menu")
register_native("zp_items_force_buy", "native_items_force_buy")
register_native("zp_items_menu_text_add", "native_items_menu_text_add")
register_native("zp_items_total", "native_items_total");
register_native("zp_items_get_random", "native_items_get_random");
register_native("zp_items_select_pre", "native_select_item_pre");
register_native("zp_items_text_get", "native_get_text");
set_module_filter("fw_ModuleFilter");
set_native_filter("fw_NativeFilter");
}
public fw_NativeFilter(szNative[])
{
if (equal(szNative, "zp_ammopacks_get") || equal(szNative, "zp_ammopacks_set") || equal(szNative, "get_user_level"))
return PLUGIN_HANDLED;
return PLUGIN_CONTINUE;
}
public fw_ModuleFilter(szNative[])
{
if (equal(szNative, "zp50_api_server_vallet"))
return PLUGIN_HANDLED;
return PLUGIN_CONTINUE;
}
public zp_fw_gamemodes_start(gameid)
{
for( new iPlayer = 1; iPlayer <= g_iMaxPlayers; iPlayer++ )
{
if( is_user_alive( iPlayer ) )
{
if( zp_core_is_zombie( iPlayer ) )
{
BM_SetUserMoney( iPlayer, BM_GetUserMoney( iPlayer ) + g_iUserBackMoney[ iPlayer ] );
g_iUserBackMoney[ iPlayer ] = 0;
show_menu( iPlayer, 0, "^n", 1 );
// menu_cancel( iPlayer );
}
}
}
}
public Command_BuyMenu( iPlayer )
{
if( !is_user_alive( iPlayer ) )
return PLUGIN_CONTINUE;
message_begin( MSG_ONE, g_iMsgID[ BuyClose ], _, iPlayer );
message_end( );
if( g_bSuperUser{ iPlayer } )
{
if( zp_core_is_zombie( iPlayer ) ) Show_Menu_BuyItem( iPlayer, Extras_Zombie );
ShowMenu_Categories( iPlayer );
return PLUGIN_HANDLED;
}
if( get_pcvar_num( pCvar[ BuyMenu_After_Infection ] ) )
{
if( zp_gamemodes_get_current() > 0)
{
if( zp_core_is_zombie( iPlayer ) ) Show_Menu_BuyItem( iPlayer, Extras_Zombie );
Show_Menu_BuyItem( iPlayer, Extras_Human );
}
ShowMenu_Categories( iPlayer );
}
else
{
if( zp_core_is_zombie( iPlayer ) )
Show_Menu_BuyItem( iPlayer, Extras_Zombie );
ShowMenu_Categories( iPlayer );
}
return PLUGIN_HANDLED;
}
public ShowMenu_Categories(id)
{
if (!is_user_alive(id) || zp_core_is_zombie(id))
return PLUGIN_HANDLED;
new szMenu[512], iKeys, len, iNum;
len += formatex(szMenu[len], charsmax(szMenu) - len, "\r%L^n^n", id, "BM_MENU_CATEGORIES");
len += formatex(szMenu[len], charsmax(szMenu) - len, "\r%d. %L^n", iNum + 1, id, "BM_MENU_WEAPONS"); iKeys |= (1<<(iNum++));
len += formatex(szMenu[len], charsmax(szMenu) - len, "\r%d. %L^n", iNum + 1, id, "BM_BUYMENU_EXTRAS_HM"); iKeys |= (1<<(iNum++));
len += formatex(szMenu[len], charsmax(szMenu) - len, "\r%d. %L^n", iNum + 1, id, "BM_BUYMENU_EXTRAS_EHM"); iKeys |= (1<<(iNum++));
len += formatex(szMenu[len], charsmax(szMenu) - len, "\r%d. %L^n", iNum + 1, id, "BM_BUYMENU_EXTRAS_EH"); iKeys |= (1<<(iNum++));
len += formatex(szMenu[len], charsmax(szMenu) - len, "\r%d. %L^n", iNum + 1, id, "BM_BUYMENU_VIP"); iKeys |= (1<<(iNum++));
len += formatex(szMenu[len], charsmax(szMenu) - len, "^n\r6. %L^n", id, "MENU_EXIT"); iKeys |= (1<<(iNum++));
show_menu(id, iKeys, szMenu, -1, "BuyMenu Categories");
return PLUGIN_HANDLED;
}
public Handle_MenuCategories(id, iKeys)
{
switch ((iKeys + 1) % 10)
{
case 1:
{
Show_Menu_BuyMenu( id );
}
case 2:
{
Show_Menu_BuyItem( id, Extras_Human, 0);
}
case 3:
{
Show_Menu_BuyItem( id, Tacticals_Human, 0);
}
case 4:
{
Show_Menu_BuyItem( id, Tactical, 0);
}
case 5:
{
client_cmd(id, "vip_menu");
}
case 0:
{
}
}
}
public Command_SuperUser( iPlayer )
{
if( ~get_user_flags( iPlayer ) & ADMIN_IMMUNITY )
return PLUGIN_HANDLED;
g_bSuperUser{ iPlayer } = !g_bSuperUser{ iPlayer };
UTIL_ColorChat( iPlayer, "Super User: [%s]", g_bSuperUser{ iPlayer } ? "ON" : "OFF" );
return PLUGIN_HANDLED;
}
public EV_RoundStart( )
{
for( new iPlayer = 1; iPlayer <= g_iMaxPlayers; iPlayer++ )
{
if( !is_user_connected( iPlayer ) )
continue;
arrayset( g_bItemSelected[ iPlayer ], false, 2 );
for( new iItemID = 0; iItemID <= g_ItemCount; iItemID++ )
{
g_iUserItemLimit[ iPlayer ][ iItemID ] = 0;
g_iRoundItemLimit[ iItemID ] = 0;
g_iUserBackMoney[ iPlayer ] = 0;
g_flUserItemCD[ iPlayer ][ iItemID ] = 0.0;
show_menu( iPlayer, 0, "^n", 1 );
// menu_cancel( iPlayer );
}
}
}
public Show_Menu_BuyMenu( iPlayer )
{
if( !is_user_alive( iPlayer ) )
return PLUGIN_HANDLED;
new iMenuIndex, szMenu[ 512 ], len, iKeys, szDiscount[ 128 ], punkt;
if( get_pcvar_num( pCvar[ Discount_Enable ] ) )
formatex( szDiscount, charsmax( szDiscount ), "^n%L", iPlayer, "BM_BUYMENU_DISCOUNT", g_iUserDiscount[ iPlayer ] );
formatex( szDiscount, charsmax( szDiscount ), "" );
len += formatex( szMenu[len], charsmax( szMenu ) - len, "\w%L%s", iPlayer, "BM_BUYMENU_TITLE", szDiscount );
// iMenuIndex = menu_create( szMenu, "BuyMenu_Menu_Handler" );
len += formatex( szMenu[len], charsmax( szMenu ) - len, "\w%d. %L^n",punkt+1, iPlayer, "BM_BUYMENU_PISTOLS" ); iKeys |= (1<<punkt++);
// menu_additem( iMenuIndex, szMenu, _, _, g_iMenuCallBack[ CB_Pistols ] );
len += formatex( szMenu[len], charsmax( szMenu ) - len, "\w%d. %L^n",punkt+1, iPlayer, "BM_BUYMENU_SHOTGUNS" ); iKeys |= (1<<punkt++);
// menu_additem( iMenuIndex, szMenu, _, _, g_iMenuCallBack[ CB_Rifles ] );
len += formatex( szMenu[len], charsmax( szMenu ) - len, "\w%d. %L^n",punkt+1, iPlayer, "BM_BUYMENU_AUTOMATES" ); iKeys |= (1<<punkt++);
// menu_additem( iMenuIndex, szMenu, _, _, g_iMenuCallBack[ CB_Rifles ] );
len += formatex( szMenu[len], charsmax( szMenu ) - len, "\w%d. %L^n",punkt+1, iPlayer, "BM_BUYMENU_RIFLES" ); iKeys |= (1<<punkt++);
// menu_additem( iMenuIndex, szMenu, _, _, g_iMenuCallBack[ CB_Rifles ] );
len += formatex( szMenu[len], charsmax( szMenu ) - len, "\w%d. %L^n",punkt+1, iPlayer, "BM_BUYMENU_MACHINEGUNS" ); iKeys |= (1<<punkt++);
// menu_additem( iMenuIndex, szMenu, _, _, g_iMenuCallBack[ CB_Rifles ] );
len += formatex( szMenu[len], charsmax( szMenu ) - len, "\w%d. %L^n",punkt+1, iPlayer, "BM_BUYMENU_BIG_GUNS" ); iKeys |= (1<<punkt++);
// menu_additem( iMenuIndex, szMenu, _, _, g_iMenuCallBack[ CB_Rifles ] );
// len += formatex( szMenu[len], charsmax( szMenu ) - len, "\w%d. %L^n",punkt+1, iPlayer, "BM_MENU_BACK" ); iKeys |= MENU_KEY_9;
// menu_setprop( iMenuIndex, MPROP_BACKNAME, szMenu );
len += formatex( szMenu[len], charsmax( szMenu ) - len, "\w0. %L^n",punkt+1, iPlayer, "MENU_BACK" ); iKeys |= MENU_KEY_0;
// menu_setprop( iMenuIndex, MPROP_NEXTNAME, szMenu );
// len += formatex( szMenu[len], charsmax( szMenu ) - len, "%L%s", iPlayer, "BM_MENU_EXIT", g_bSuperUser{ iPlayer } ? "^n \dSuper User activated!" : "" );
// menu_setprop( iMenuIndex, MPROP_EXITNAME, szMenu );
if( pev_valid( iPlayer ) == 2 )
set_member( iPlayer, m_iMenu, 0);
// menu_display( iPlayer, iMenuIndex, 0 );
show_menu(iPlayer, iKeys, szMenu, -1, "BMenu Weapons");
return PLUGIN_HANDLED;
}
public BuyMenu_Menu_Handler( iPlayer, iMenuKey )
{
if( !is_user_alive( iPlayer ) )
return PLUGIN_HANDLED;
switch( (iMenuKey+1)%10 )
{
case 1:
{
Show_Menu_BuyItem( iPlayer, Pistols, 0);
}
case 2:
{
Show_Menu_BuyItem( iPlayer, Shotguns, 0);
}
case 3:
{
Show_Menu_BuyItem( iPlayer, Automates, 0)
}
case 4:
{
Show_Menu_BuyItem( iPlayer, Rifles, 0);
}
case 5:
{
Show_Menu_BuyItem( iPlayer, Machines, 0);
}
case 6:
{
Show_Menu_BuyItem( iPlayer, Bigguns, 0);
return PLUGIN_HANDLED;
}
}
return PLUGIN_HANDLED
}
stock Show_Menu_BuyItem(id, type = Pistols, page = 0)
{
if (!is_user_alive(id))
return PLUGIN_CONTINUE;
if (g_ItemsCount[type] <= 0)
{
Show_Menu_BuyMenu(id);
client_print_color(id, print_team_red, "%L", id, "NO_EXTRA_ITEMS");
return PLUGIN_HANDLED;
}
new menu[1024], len, len2, Keys = MENU_KEY_0, szItemName[128], punkt, cost, transkey[128], team;
new items_count_by_type;
new pages_count;
new Items_leftover_for_page;
new szTemp[512];
new szSymb[8];
new iItemsNum;
new iMoney;
new szCost[16];
//new iStartMenu_LastAvailableItem = get_ced(id, ced_int, ced_player_start_weapon_last_selected_index);
new szMenuName[32], iSelectedItem;
new iLevel = get_user_level(id),
iFlags = get_user_flags(id),
iMinPlayers,iPlayersnum, iCurPlayersNum = GetPlayingCount();
new szData[eItemData];
//g_MenuInfo[id][TYPE] = type;
//g_MenuInfo[id][PAGE] = page;
set_ced(id, ced_int, ced_player_buymenu_type_weapon, type);
set_ced(id, ced_int, ced_player_buymenu_page, page);
switch (type)
{
case Pistols:
{
iItemsNum = 8;
}
case Shotguns:
{
iItemsNum = 8;
}
case Automates:
{
iItemsNum = 8;
}
case Rifles:
{
iItemsNum = 8;
}
case Machines:
{
iItemsNum = 8;
}
case Bigguns:
{
iItemsNum = 8;
}
// case KNIFES:
// {
// iItemsNum = 7;
// }
default:
{
iItemsNum = 8;
}
}
set_ced(id, ced_int, ced_player_buymenu_items_num, iItemsNum);
for (new item, iPos; iPos < g_ItemCount; iPos++)
{
// team = ArrayGetCell(g_extraitem_team, item);
// if ((g_zombie[id] && g_ePlayerData[id][e_iNemesis] == NEMESIS_NONE && !(team & ZP_TEAM_ZOMBIE)) || (!g_zombie[id] && !g_survivor[id] && !(team & ZP_TEAM_HUMAN)) || (g_ePlayerData[id][e_iNemesis] > NEMESIS_NONE && !(team & ZP_TEAM_NEMESIS)) || (g_survivor[id] && !(team & ZP_TEAM_SURVIVOR)))
// continue;
// if (type != ArrayGetCell(aItemMenu, item))
// continue;
if (szData[eItemData_Type] != type)
continue;
// server_print("item %s is type: %s", szData[eItemData_szName], g_szItemSlots[ szData[eItemData_Type] ]);
// switch (type)
// {
// case PISTOLS, SHOTGUNS, ASSAULTS, RIFLES, MACHINEGUNS, HEAVYS, KNIFES:
// {
// if (get_ced(id, ced_int, ced_player_buymenu_tier_weapon) != ArrayGetCell(g_extraitem_tier, item))
// continue;
// }
// }
items_count_by_type++;
if ((page*iItemsNum)>=items_count_by_type) continue;
if (((page+1)*iItemsNum)<items_count_by_type) continue;
g_AdditionalMenuText[0] = g_iForwardResult = 0;
// g_szItemRename[0] = EOS;
ExecuteForward(g_fwItemSelect[FW_ITEM_SELECT_PRE],g_iForwardResult, id, item, false, floatround( szData[eItemData_Cost] - szData[eItemData_Cost] / 100.0 * g_iUserDiscount[ id ] ), false);
if (g_iForwardResult >= ZP_ITEM_DONT_SHOW)
continue;
if (g_iForwardResult == ZP_ITEM_AVAILABLE)
{
//if (ArrayGetCell( aItemLevel, item) > iLevel)
if (szData[eItemData_Level] > iLevel)
{
if (g_AdditionalMenuText[0] != EOS)
formatex(g_AdditionalMenuText, charsmax(g_AdditionalMenuText), "LVL:%d", szData[eItemData_Level]);
g_iForwardResult = ZP_ITEM_NOT_AVAILABLE;
}
else if (szData[eItemData_Permission] && (( ~iFlags & FLAG_VIP || ~iFlags & FLAG_ADMIN)))
{
if (g_AdditionalMenuText[0] != EOS)
formatex(g_AdditionalMenuText, charsmax(g_AdditionalMenuText), "%s", g_szNamePermission[ szData[eItemData_Level] ]);
g_iForwardResult = ZP_ITEM_NOT_AVAILABLE;
}
else if (szData[eItemData_MinPlayers] && szData[eItemData_MinPlayers] < iCurPlayersNum)
{
if (g_AdditionalMenuText[0] != EOS)
formatex(g_AdditionalMenuText, charsmax(g_AdditionalMenuText), "PN: %d/%d", iCurPlayersNum, szData[eItemData_MinPlayers]);
g_iForwardResult = ZP_ITEM_NOT_AVAILABLE;
}
else if (szData[eItemData_UserLimit] && g_iUserItemLimit[ id ][ item ] >= szData[eItemData_UserLimit])
{
if (g_AdditionalMenuText[0] != EOS)
formatex(g_AdditionalMenuText, charsmax(g_AdditionalMenuText), "UL:%d/%d",szData[eItemData_UserLimit], g_iUserItemLimit[ id ][ item ]);
g_iForwardResult = ZP_ITEM_NOT_AVAILABLE;
}
else if (szData[eItemData_UserMapLimit] && ( g_iUserMapItemLimit[ id ][ item ] >= szData[eItemData_UserMapLimit] ))
{
if (g_AdditionalMenuText[0] != EOS)
formatex(g_AdditionalMenuText, charsmax(g_AdditionalMenuText), "UML:%d/%d",szData[eItemData_UserMapLimit], g_iUserMapItemLimit[ id ][ item ]);
g_iForwardResult = ZP_ITEM_NOT_AVAILABLE;
}
else if (szData[eItemData_RoundLimit] && ( g_iRoundItemLimit[ item ] >= szData[eItemData_RoundLimit] ))
{
if (g_AdditionalMenuText[0] != EOS)
formatex(g_AdditionalMenuText, charsmax(g_AdditionalMenuText), "RL:%d/%d",szData[eItemData_RoundLimit], g_iRoundItemLimit[ item ]);
g_iForwardResult = ZP_ITEM_NOT_AVAILABLE;
}
else if(szData[eItemData_MapLimit] && ( g_iMapItemLimit[ item ] >= szData[eItemData_MapLimit] ) )
{
if (g_AdditionalMenuText[0] != EOS)
formatex(g_AdditionalMenuText, charsmax(g_AdditionalMenuText), "ML:%d/%d", szData[eItemData_MapLimit], g_iMapItemLimit);
g_iForwardResult = ZP_ITEM_NOT_AVAILABLE;
}
}
// iSelectedItem = CheckSelectedItemByPlayer(item, id);
// if (g_szItemRename[0] != EOS)
// {
// copy(szItemName, charsmax(szItemName), g_szItemRename);
// }
// else
// {
// switch (item)
// {
// case EXTRA_NVISION:
// {
// if (!get_pcvar_num(cvar_extranvision)) continue;
// formatex(szItemName, charsmax(szItemName), "%L", id, "MENU_EXTRA1")
// }
// case EXTRA_ANTIDOTE:
// {
// if (!get_pcvar_num(cvar_extraantidote) || g_antidotecounter >= get_pcvar_num(cvar_antidotelimit))
// formatex(szItemName, charsmax(szItemName), "\d%L", id, "MENU_EXTRA2")
// else
// formatex(szItemName, charsmax(szItemName), "%L", id, "MENU_EXTRA2")
// }
// default:
// {
// if (item >= EXTRA_WEAPONS_STARTID && item <= EXTRAS_CUSTOM_STARTID-1 && !get_pcvar_num(cvar_extraweapons)) continue;
// ArrayGetString(g_extraitem_name, item, szItemName, charsmax(szItemName))
// }
// }
// }
//ArrayGetString( g_ItemName, item, szItemName, charsmax( szItemName ) );
copy(szItemName, charsmax(szItemName), szData[eItemData_szName]);
// if (g_zombie[id])
// {
// iMoney = g_iMadnessPoints[id];
// copy(szSymb, charsmax(szSymb), "ZPoint");
// }
// else if (bStartMenu)
// {
// iMoney = get_ced(id, ced_int, ced_player_start_buy_worth);
// copy(szSymb, charsmax(szSymb), "Worth");
// }
// else
{
iMoney = zp_ammopacks_get(id);
copy(szSymb, charsmax(szSymb), "$");
}
cost = szData[eItemData_Cost]
cost = floatround(float(cost) - float(floatround(float(cost) / 100.0 * g_iUserDiscount[id], floatround_ceil)), floatround_ceil);
formatex(transkey, charsmax(transkey), "ITEMNAME %s", szItemName)
if (GetLangTransKey(transkey) != TransKey_Bad)
formatex(szItemName, charsmax(szItemName), "%L", id, transkey)
else {
formatex(transkey, charsmax(transkey), "%s", szItemName);
if (GetLangTransKey(transkey) != TransKey_Bad) formatex(szItemName, charsmax(szItemName), "%L", id, transkey)
}
if (g_iForwardResult == ZP_ITEM_AVAILABLE)
{
if (cost <= 0) // non-cost items
{
len2 += formatex(szTemp[ len2], charsmax(szTemp)- len2, "\d/\y%i\d/\w.%s %s^n", punkt+1, szItemName, g_AdditionalMenuText);
Keys |= (1<<punkt);
g_ItemIndex[id][punkt] = item;
}
else
{
if (cost <= iMoney) // enough vallet to purchase
{
len2 += formatex(szTemp[ len2], charsmax(szTemp)- len2, "\d/\y%i\d/\w.%s %s\r %d %s^n", punkt+1, szItemName, g_AdditionalMenuText, cost, szSymb);
Keys |= (1<<punkt);
g_ItemIndex[id][punkt] = item;
}
else // not enough vallet, skip item
{
g_ItemIndex[id][punkt] = item;
Keys |= (1<<punkt);
len2 += formatex(szTemp[ len2], charsmax(szTemp)- len2, "\d/%i/.%s %s\r %d %s^n", punkt+1, szItemName, g_AdditionalMenuText, cost, szSymb);
}
}
}
else
{ // item is not available by some of reasons
if (cost)
{
formatex(szCost, charsmax(szCost), "%d %s", cost, szSymb)
}
else
{
szCost[0] = EOS;
}
len2 += formatex(szTemp[ len2], charsmax(szTemp)- len2, "\d/%i/.%s \r%s \d%s^n", punkt+1, szItemName, g_AdditionalMenuText, szCost);
g_ItemIndex[id][punkt] = item;
Keys |= (1<<punkt);
}
arrayset(g_AdditionalMenuText, 0, sizeof(g_AdditionalMenuText));
//if (++punkt > 7)
if (++punkt >= iItemsNum)
continue;
}
pages_count = (items_count_by_type/iItemsNum);
Items_leftover_for_page = items_count_by_type % iItemsNum;
if (!Items_leftover_for_page)
pages_count -= 1;
switch (type)
{
case Pistols:
{
formatex(szMenuName, charsmax(szMenuName), "%L", LANG_PLAYER, "ML_PISTOLS");
}
case Shotguns:
{
formatex(szMenuName, charsmax(szMenuName), "%L", LANG_PLAYER, "ML_SHOTGUNS");
}
case Automates:
{
formatex(szMenuName, charsmax(szMenuName), "%L", LANG_PLAYER, "ML_ASSAULT");
}
case Rifles:
{
formatex(szMenuName, charsmax(szMenuName), "%L", LANG_PLAYER, "ML_RIFLES");
}
case Machines:
{
formatex(szMenuName, charsmax(szMenuName), "%L", LANG_PLAYER, "ML_MACHINEGUNS");
}
case Bigguns:
{
formatex(szMenuName, charsmax(szMenuName), "%L", LANG_PLAYER, "ML_HEAVYS");
}
case Extras_Human:
{
formatex(szMenuName, charsmax(szMenuName), "%L", LANG_PLAYER, "ML_EQUIPMENTS");
}
case Tacticals_Human:
{
formatex(szMenuName, charsmax(szMenuName), "%L", LANG_PLAYER, "ML_TACTICALS");
}
case Extras_Zombie:
{
formatex(szMenuName, charsmax(szMenuName), "%L", LANG_PLAYER, "ML_EXTRA_ZOMBIE");
}
// case KNIFES:
// {
// formatex(szMenuName, charsmax(szMenuName), "%L", LANG_PLAYER, "ML_KNIFES");
// }
}
len += formatex(menu[len], charsmax(menu)-len, "\y%s \d[%i/%i][%L:%d%%]^n^n", szMenuName, page+1, pages_count+1, id, "ML_DISCOUNT", g_iUserDiscount[id]);
len += formatex(menu[len], charsmax(menu)-len, "%s", szTemp);
//if (punkt != iItemsNum)
// for(new i = punkt; i<iItemsNum; i++) len += formatex(menu[len], charsmax(menu)-len, "\d/%i./^n", i+1);
// switch (type)
// {
// case PISTOLS, SHOTGUNS, ASSAULTS, RIFLES, MACHINEGUNS, HEAVYS, KNIFES:
// {
// len += formatex(menu[len], charsmax(menu)-len, "^n\d/\y%i.\d/\w TIER: [ %d ]^n^n", iItemsNum + 1, get_ced(id, ced_int, ced_player_buymenu_tier_weapon)); Keys |= (1<<(get_ced(id, ced_int, ced_player_buymenu_items_num)));
// }
// }
if (page<pages_count)
{
Keys |= MENU_KEY_9;
len += formatex(menu[len], charsmax(menu)-len, "^n\d/\y9.\d/\w %L^n\d/\y0.\d/\w %L", LANG_PLAYER, "MENU_NEXT", LANG_PLAYER, "MENU_BACK");
}
else
len += formatex(menu[len], charsmax(menu)-len, "^n\d/\y9.\d/ %L^n\d/\y0.\d/\w %L", LANG_PLAYER, "MENU_NEXT", LANG_PLAYER, "MENU_BACK");
set_member(id, m_iMenu, Menu_OFF);
show_menu(id, Keys, menu, -1, "BM Items Menu");
return PLUGIN_HANDLED;
}
public menu_extraitems(id, item)
{
if (!is_user_alive(id))
return PLUGIN_CONTINUE;
new ignorecost;
new iType = get_ced(id, ced_int, ced_player_buymenu_type_weapon);
new iRequireWorth, iWorth;
switch ((item+1)%10)
{
case 1..8:
{
if (item < get_ced(id, ced_int, ced_player_buymenu_items_num)) // check player items max num (7 / 8)
{
buy_item(id, g_ItemIndex[id][item], ignorecost);
if (get_entvar(id, var_button) & IN_USE)
{
switch (iType)
{
case Pistols, Shotguns, Automates, Rifles, Machines, Bigguns/*, KNIFES*/ :
{
// set_ced(id, ced_float, ced_player_float_last_buy_weapon_time, get_gametime());
// set_ced(id, ced_int, ced_player_int_last_buy_weapon_type, iType);
}
default:
{
Show_Menu_BuyItem(id, iType, get_ced(id, ced_int, ced_player_buymenu_page));
}
}
}
else
{
//ShowMenuStart(id);
switch (iType)
{
case Pistols, Shotguns, Automates, Rifles, Machines, Bigguns/*, KNIFES*/:
{
// set_ced(id, ced_float, ced_player_float_last_buy_weapon_time, get_gametime());
// set_ced(id, ced_int, ced_player_int_last_buy_weapon_type, iType);
}
default:
{
}
}
}
}
// else
// {
// switch (iType)
// {
// case PISTOLS, SHOTGUNS, ASSAULTS, RIFLES, MACHINEGUNS, HEAVYS, KNIFES:
// {
// new iTier = get_ced(id, ced_int, ced_player_buymenu_tier_weapon);
// if (~get_entvar(id, var_button) & IN_USE)
// {
// //g_MenuInfo[id][TIER] = ++g_MenuInfo[id][TIER] > 4 ? 1 : g_MenuInfo[id][TIER];
// set_ced(id, ced_int, ced_player_buymenu_tier_weapon, ++iTier > 4 ? 1 : iTier);
// Show_Menu_BuyItem(id, iType, get_ced(id, ced_int, ced_player_buymenu_page));
// }
// else
// {
// //g_MenuInfo[id][TIER] = --g_MenuInfo[id][TIER] < 1 ? 4 : g_MenuInfo[id][TIER];
// set_ced(id, ced_int, ced_player_buymenu_tier_weapon, --iTier < 1 ? 4 : iTier);
// Show_Menu_BuyItem(id, iType, get_ced(id, ced_int, ced_player_buymenu_page));
// }
// }
// default:
// {
// }
// }
// }
}
case 9: { // далее
//if (g_MenuInfo[id][PAGE]>g_ItemsCount[ iType ])
return Show_Menu_BuyItem(id, iType, (get_ced(id, ced_int, ced_player_buymenu_page)) + 1);
}
case 0:
{ // Назад/Выход
// if (get_entvar(id, var_button) & IN_USE)
// {
//
//}
//else
if (get_ced(id, ced_int, ced_player_buymenu_page) > 0)
return Show_Menu_BuyItem(id, iType, (get_ced(id, ced_int, ced_player_buymenu_page)) - 1)
else
{
if (zp_core_is_zombie(id))
return PLUGIN_HANDLED;
else
{
switch(iType)
{
case Pistols, Shotguns, Automates, Rifles, Machines, Bigguns/*, KNIFES*/:
{
ShowMenu_Categories(id);
}
case Extras_Human, Tacticals_Human:
{
Show_Menu_BuyMenu(id);
}
default:{} // zombie
}
}
}
}
}
return PLUGIN_HANDLED;
}
stock GetPlayingCount()
{
new iPlaying, id;
for (id = 1; id <= MaxClients; id++)
{
if (!is_user_connected(id) || is_user_hltv(id))
continue;
if ( CS_TEAM_UNASSIGNED < get_member(id, m_iTeam) < CS_TEAM_SPECTATOR)
iPlaying++
}
return iPlaying;
}
buy_item(iPlayer, iItemID, ignorecost)
{
new szData[eItemData];
ArrayGetArray(g_aItemData, iItemID, szData);
new Float:flGameTime, iCurPlayersNum = GetPlayingCount(), iRealCost, iItemCost = szData[eItemData_Cost];
iRealCost = floatround( iItemCost - iItemCost / 100.0 * g_iUserDiscount[ iPlayer ] );
flGameTime = get_gametime();
ExecuteForward( g_fwItemSelect[FW_ITEM_SELECT_PRE], g_iForwardResult, iPlayer, iItemID, ignorecost, iRealCost, false);
if (g_iForwardResult >= ZP_ITEM_NOT_AVAILABLE)
{
// BM_SetUserMoney( iPlayer, BM_GetUserMoney( iPlayer ) + floatround( iItemCost - iItemCost / 100.0 * g_iUserDiscount[ iPlayer ] ) );
return;
}
else
{
new iFlags = get_user_flags(iPlayer);
if (szData[eItemData_Level] > get_user_level(iPlayer))
{
client_print_color(iPlayer, print_team_red, "%L", iPlayer, "ML_LOW_LEVEL");
return;
}
else if (szData[eItemData_Level] && (( ~iFlags & FLAG_VIP || ~iFlags & FLAG_ADMIN )))
{
client_print_color(iPlayer, print_team_red, "%L", iPlayer, "ML_NO_PERMISSION");
return;
}
else if (szData[eItemData_MinPlayers] && szData[eItemData_MinPlayers] < iCurPlayersNum)
{
client_print_color(iPlayer, print_team_red, "%L[%d/%d]", iPlayer, "ML_LOW_PLAYERS_NUM", iCurPlayersNum, szData[eItemData_MinPlayers]);
return;
}
else if (szData[eItemData_UserLimit] && g_iUserItemLimit[ iPlayer ][ iItemID ] >= szData[eItemData_UserLimit])
{
client_print_color(iPlayer, print_team_red, "%L[%d/%d]", iPlayer, "ML_USER_LIMIT", g_iUserItemLimit[ iPlayer ][ iItemID ], szData[eItemData_UserLimit]);
return;
}
else if (szData[eItemData_UserMapLimit] && ( g_iUserMapItemLimit[ iPlayer ][ iItemID ] >= szData[eItemData_UserMapLimit]))
{
client_print_color(iPlayer, print_team_red, "%L[%d/%d]", iPlayer, "ML_USER_MAP_LIMIT", g_iUserMapItemLimit[ iPlayer ][ iItemID ], szData[eItemData_UserMapLimit]);
return;
}
else if (szData[eItemData_RoundLimit] && ( g_iRoundItemLimit[ iItemID ] >= szData[eItemData_RoundLimit]))
{
client_print_color(iPlayer, print_team_red, "%L[%d/%d]", iPlayer, "ML_ROUND_LIMIT", g_iRoundItemLimit[ iItemID ], szData[eItemData_RoundLimit]);
return;
}
else if(szData[eItemData_MapLimit] && ( g_iMapItemLimit[ iItemID ] >= szData[eItemData_MapLimit] ) )
{
client_print_color(iPlayer, print_team_red, "%L[%d/%d]", iPlayer, "ML_MAP_LIMIT", g_iMapItemLimit[ iItemID ], szData[eItemData_MapLimit]);
return;
}
}
static Float: flItemDelay; flItemDelay = szData[eItemData_CD];
if (!ignorecost)
{
if (iRealCost > zp_ammopacks_get(iPlayer))
{
client_print_color(iPlayer, print_team_red, "%L", iPlayer, "ML_NO_MONEY");
return;
}
if (g_flUserItemCD[iPlayer][iItemID] && g_flUserItemCD[iPlayer][iItemID] >= flGameTime)
{
client_print_color(iPlayer, print_team_red, "^x04[%s]^x03 %L", MODE_PREFIX, iPlayer, "ML_ITEM_CD", floatmax(1.0, g_flUserItemCD[iPlayer][iItemID] - flGameTime));
return;
}
if (g_flLastTimeBuy[iPlayer] < flGameTime)
{
//g_bitsItems |= (1<<(31 & ArrayGetCell(aItemMenu, iItemID)));
g_iItemId[iPlayer] = iItemID;
}
g_flLastTimeBuy[iPlayer] = flGameTime;
g_iPlayerItemCounterId[iPlayer] = ++g_iBuyCounter;
}
ExecuteForward( g_fwItemSelect[FW_ITEM_SELECT_POST], g_iForwardResult, iPlayer, iItemID, ignorecost, iRealCost );
if( !g_bSuperUser{ iPlayer } && !ignorecost)
{
//BM_SetUserMoney( iPlayer, BM_GetUserMoney( iPlayer ) - floatround( iItemCost - iItemCost / 100.0 * g_iUserDiscount[ iPlayer ] ) );
g_iUserBackMoney[ iPlayer ] += iRealCost;
if( szData[eItemData_UserLimit] ) g_iUserItemLimit[ iPlayer ][ iItemID ] += 1;
if( szData[eItemData_UserMapLimit] ) g_iUserMapItemLimit[ iPlayer ][ iItemID ] += 1;
if( szData[eItemData_RoundLimit] ) g_iRoundItemLimit[ iItemID ] += 1;
if( szData[eItemData_MapLimit] ) g_iMapItemLimit[ iItemID ] += 1;
if( flItemDelay ) g_flUserItemCD[ iPlayer ][ iItemID ] = get_gametime() + flItemDelay;
if( get_pcvar_num( pCvar[ BuyMenu_Block_Weapons ] ) )
{
switch( szData[eItemData_Type] )
{
case Pistols: g_bItemSelected[ iPlayer ][ Secondary ] = true;
case Shotguns..Machines: g_bItemSelected[ iPlayer ][ Primary ] = true;
}
}
}
}
CFile__LoadCustomization()
{
new szPath[ 64 ], szData[eItemData];
get_localinfo( "amxx_configsdir", szPath, charsmax( szPath ) );
format( szPath, charsmax( szPath ), "%s/%s", szPath, BUYMENU_ITEMS_FILE );
if( !file_exists( szPath ) )
{
new szError[ 100 ];
formatex( szError, charsmax( szError ), "Cannot load customization file %s!", szPath );
set_fail_state( szError );
return;
}
new szText[ 1024 ], szLastName[64], szKey[ 128 ], szValue[ 960 ], iItemId;
new iFile = fopen( szPath, "rt" );
if( file_exists( szPath ) )
{
iFile = fopen( szPath, "rt" );
while( iFile && !feof( iFile ) )
{
fgets( iFile, szText, charsmax( szText ) );
replace( szText, charsmax( szText ), "^n", "" );
if( !szText[ 0 ] || szText[ 0 ] == ';' )
continue;
if( szText[ 0 ] == '[' )
{
szText[ strlen( szText ) - 1 ] = 0;
copy( szText, charsmax( szText ), szText[ 1 ] );
copy(szData[eItemData_szName], 31, szText);
continue;
}
copy(szData[eItemData_szRealName], 31, szData[eItemData_szName]);
strtok( szText, szKey, charsmax( szKey ), szValue, charsmax( szValue ), '=' );
trim( szKey );
trim( szValue );
if( equal( szKey, "NAME" ) )
{
// ArraySetString( aItem2Name, iItemId, szValue );
copy(szData[eItemData_szName], 31, szValue);
}
if( equal( szKey, "COST" ) )
{
// ArraySetCell( aItem2Cost, iItemId, str_to_num( szValue ) );
szData[eItemData_Cost] = str_to_num(szValue);
}
if( equal( szKey, "LEVEL" ) )
{
// ArraySetCell( aItem2Level, iItemId, str_to_num( szValue ) );
szData[eItemData_Level] = str_to_num(szValue);
}
if( equal( szKey, "POS" ) )
{
// ArraySetCell( aItem2Pos, iItemId, str_to_num( szValue ) );
szData[eItemData_Pos] = str_to_num(szValue);
}
if( equal( szKey, "SLOT" ) )
{
new i;
for( i = 0; i < sizeof g_szItemSlots; i++ )
{
if( equal( g_szItemSlots[ i ], szValue ) )
{
// ArraySetCell( aItem2Menu, iItemId, i );
szData[eItemData_Type] = i;
// server_print("item %s is type: %s", szData[eItemData_szName], g_szItemSlots[i]);
server_print("ar2: item %s is %s", szData[eItemData_szName], g_szItemSlots[ szData[eItemData_Type] ]);
break;
}
}
}
if( equal( szKey, "PERMISSIONS" ) )
{
new i;
for( i = 0; i < sizeof g_szItemPermission; i++ )
{
if( equal( g_szItemPermission[ i ], szValue ) )
{
// ArraySetCell( aItem2Permission, iItemId, i );
szData[eItemData_Permission] = i;
break;
}
}
}
if( equal( szKey, "MIN PLAYERS" ) )
{
// ArraySetCell( aItem2MinimumPlayers, iItemId, str_to_num( szValue ) );
szData[eItemData_MinPlayers] = str_to_num(szValue);
}
if( equal( szKey, "USER ROUND LIMIT" ) )
{
// ArraySetCell( aItem2UserLimit, iItemId, str_to_num( szValue ) );
szData[eItemData_UserLimit] = str_to_num(szValue);
}
if( equal( szKey, "USER MAP LIMIT" ) )
{
// ArraySetCell( aItem2UserMapLimit, iItemId,str_to_num( szValue ) );
szData[eItemData_MapLimit] = str_to_num(szValue);
}
if( equal( szKey, "ROUND LIMIT" ) )
{
// ArraySetCell( aItem2RoundLimit, iItemId, str_to_num( szValue ) );
szData[eItemData_RoundLimit] = str_to_num(szValue);
}
if( equal( szKey, "MAP LIMIT" ) )
{
// ArraySetCell( aItem2MapLimit, iItemId, str_to_num( szValue ) );
szData[eItemData_MapLimit] = str_to_num(szValue);
}
if( equal( szKey, "RANDOM CHANCE" ) )
{
// ArraySetCell( aItem2RandomValue, iItemId, str_to_num( szValue ) );
szData[eItemData_RandomChance] = str_to_num(szValue);
}
if( equal( szKey, "(CD) BUY DELAY" ) )
{
// ArraySetCell( aItem2CD, iItemId, str_to_float( szValue ) );
szData[eItemData_CD] = str_to_float(szValue);
}
if( equal( szKey, "WEAPON BASE DAMAGE" ) )
{
// ArraySetCell( aItem2BaseDmg, iItemId, str_to_float( szValue ) );
szData[eItemData_BaseDmg] = str_to_float(szValue);
}
if( equal( szKey, "WEAPON MULTI HEAD" ) )
{
// ArraySetCell( aItem2DmgMultiHead, iItemId, str_to_float( szValue ) );
szData[eItemData_DmgMultiHead] = str_to_float(szValue);
}
if( equal( szKey, "WEAPON MULTI CHEST" ) )
{
// ArraySetCell( aItem2DmgMultiChest, iItemId, str_to_float( szValue ) );
szData[eItemData_DmgMultiChest] = str_to_float(szValue);
}
if( equal( szKey, "WEAPON MULTI STOMACH" ) )
{
// ArraySetCell( aItem2DmgMultiStomach, iItemId, str_to_float( szValue ) );
szData[eItemData_DmgMultiStomach] = str_to_float(szValue);
}
if( equal( szKey, "WEAPON MULTI LEG" ) )
{
// ArraySetCell( aItem2DmgMultiLeg, iItemId, str_to_float( szValue ) );
szData[eItemData_DmgMultiLeg] = str_to_float(szValue);
}
if( equal( szKey, "WEAPON MULTI ARM" ) )
{
// ArraySetCell( aItem2DmgMultiArm, iItemId, str_to_float( szValue ) );
szData[eItemData_DmgMultiArm] = str_to_float(szValue);
}
if( equal( szKey, "WEAPON MULTI BREAKABLE" ) )
{
// ArraySetCell( aItem2DmgMultiBreakable, iItemId, str_to_float( szValue ) );
szData[eItemData_DmgMultiBreakable] = str_to_float(szValue);
}
if( equal( szKey, "WEAPON MULTI IT" ) )
{
// ArraySetCell( aItem2DmgMultiInfoTarget, iItemId, str_to_float( szValue ) );
szData[eItemData_DmgMultiInfoTarget] = str_to_float(szValue);
}
if( equal( szKey, "WEAPON KNOCKBACK POWER" ) )
{
// ArraySetCell( aItem2KnockBackPower, iItemId, str_to_float( szValue ) );
szData[eItemData_KnockBackPower] = str_to_float(szValue);
}
if( equal( szKey, "WEAPON KNOCKBACK DISTANCE" ) )
{
// ArraySetCell( aItem2KnockBackDistance, iItemId, str_to_float( szValue ) );
szData[eItemData_KnockBackDistance] = str_to_float(szValue);
}
if( equal( szKey, "WEAPON KNOCKBACK DAMAGE LIMITER" ) )
{
// ArraySetCell( aItem2KnockBackByDamageLimiter, iItemId, str_to_float( szValue ) );
szData[eItemData_KnockBackByDamageLimiter] = str_to_float(szValue);
}
if( equal( szKey, "WEAPON DECREASE ZOMBIE ARMOR" ) )
{
// ArraySetCell( aItem2DeacreaseZombie, iItemId, str_to_float( szValue ) );
szData[eItemData_DecreaseZombie] = str_to_float(szValue);
}
if( equal( szKey, "WEAPON AMMO BACKUP" ) )
{
// ArraySetCell( aItem2AmmoBackup, iItemId, str_to_num( szValue ) );
szData[eItemData_AmmoBackup] = str_to_num(szValue);
}
if( equal( szKey, "WEAPON BACK MODEL" ) )
{
// ArraySetString( aItem2BackModel, iItemId, szValue );
copy(szData[eItemData_BackModel], 127, szValue);
}
if( equal( szKey, "WEAPON BACK MODEL BODY" ) )
{
// ArraySetCell( aItem2BackModelBody, iItemId, str_to_num(szValue) );
szData[eItemData_BackModelBody] = str_to_num(szValue);
}
if( equal( szKey, "WEAPON BACK MODEL SKIN" ) )
{
// ArraySetCell( aItem2BackModelBody, iItemId, str_to_num(szValue) );
szData[eItemData_BackModelSkin] = str_to_num(szValue);
}
if( equal( szKey, "WEAPON MODEL" ) )
{
// ArraySetString( aItem2WeaponModel, iItemId, szValue );
copy(szData[eItemData_WeaponModel], 127, szValue);
}
if( equal( szKey, "WEAPON MODEL BODY" ) )
{
// ArraySetCell( aItem2WeaponModelBody, iItemId, str_to_num(szValue) );
szData[eItemData_WeaponModelBody] = str_to_num(szValue);
}
if( equal( szKey, "WEAPON MODEL SKIN" ) )
{
// ArraySetCell( aItem2WeaponModelBody, iItemId, str_to_num(szValue) );
szData[eItemData_WeaponModelSkin] = str_to_num(szValue);
}
if( equal( szKey, "DEATH ICON" ) )
{
// ArraySetString( aItem2DeathIcon, iItemId, szValue );
copy(szData[eItemData_DeathIcon], 31, szValue);
}
if( equal( szKey, "DEATH MSG" ) )
{
// ArraySetString( aItem2DeathMsg, iItemId, szValue);
copy(szData[eItemData_DeathMsg], 31, szValue);
}
ArrayPushArray(g_aItemData2, szData);
}
if( iFile ) fclose( iFile );
}
}
CFile__SaveCustomization()
{
new i, szBuffer[ 512 ], szPath[ 64 ];
get_localinfo( "amxx_configsdir", szPath, charsmax( szPath ) );
format( szPath, charsmax( szPath ), "%s/%s", szPath, BUYMENU_ITEMS_FILE );
/*
;NAME = <имя предмета>
;COST = <цена>
;LEVEL = <уровень>
;POS = <число-приоритет для сортировки позиции в бай меню. Чем выше число, тем выше оно по списку> [Можно не указывать]
;SLOT = <подтип предмета>: {"PISTOLS","SHOTGUN","AUTOMATES","RIFLES","MACHINE GUNS","BIG GUNS","EQUIPMENT HUMAN","TACTICALS HUMAN","TACTICAL","EQUIPMENT ZOMBIE"}
;PERMISSIONS = <доступ к предмету>
;MIN PLAYERS = <мин.игроков>
;USER ROUND LIMIT = <Лимит за раунд для игрока>
;USER MAP LIMIT = <Лимит за карту для игрока>
;ROUND LIMIT = <общий Лимит за раунд>
;MAP LIMIT = <общий Лимит за карту>
;RANDOM CHANCE = <Шанс выпадения предмета в vip/box'ах> [Если не указывать - не выпадает][Можно не указывать]
;(CD) BUY DELAY = <Время перезарядки предмета> [Можно не указывать]
;WEAPON BASE DAMAGE = <Базовый урон пушки (только огнестрел)> [Нецелочисленное][Можно не указывать]
;WEAPON MULTI HEAD = <Множитель от базового урона(голова): damage = [<WEAPON BASE DAMAGE> * <WEAPON MULTI HEAD>]> [Нецелочисленное] [Default: 1.5] [Можно не указывать]
;WEAPON MULTI CHEST = <Множитель от базового урона(Грудь): damage = [<WEAPON BASE DAMAGE> * <WEAPON MULTI CHEST>]> [Нецелочисленное] [Default: 1.1] [Можно не указывать]
;WEAPON MULTI STOMACH = <Множитель от базового урона(Таз): damage = [<WEAPON BASE DAMAGE> * <WEAPON MULTI STOMACH>]> [Нецелочисленное] [Default: 1.0] [Можно не указывать]
;WEAPON MULTI LEG = <Множитель от базового урона(Ноги): damage = [<WEAPON BASE DAMAGE> * <WEAPON MULTI LEG>]> [Нецелочисленное] [Default: 0.8] [Можно не указывать]
;WEAPON MULTI ARM = <Множитель от базового урона(Руки): damage = [<WEAPON BASE DAMAGE> * <WEAPON MULTI ARM>]> [Нецелочисленное] [Default: 0.5] [Можно не указывать]
;WEAPON MULTI BREAKABLE = <Множитель от базового урона(func_brekable - разбиваемые объекты карт): damage = [<WEAPON BASE DAMAGE> * <WEAPON MULTI BREAKABLE>]> [Нецелочисленное] [Default: 1.0][Можно не указывать]
;WEAPON MULTI IT = <Множитель от базового урона(кастомные объекты от плагинов amxx info_target): damage = [<WEAPON BASE DAMAGE> * <WEAPON MULTI IT>]> [Нецелочисленное] [Default: 1.0][Можно не указывать]
;WEAPON KNOCKBACK POWER = <Множитель сила отталкивания по стандарту. от 0.0 до 10.0> [Можно не указывать]
;WEAPON KNOCKBACK DISTANCE = <Расстояние при котором срабатывает отталкивание> [Можно не указывать]
;WEAPON KNOCKBACK DAMAGE LIMITER = <Значение, которое измеряется как сила отталкивания, зависимое от нанесенного урона. Этот пункт ставит ограничение на силу отталкивания (по факту является множителем направления скорости)>[Можно не указывать]
;WEAPON DECREASE ZOMBIE ARMOR = <Процент снижения сопротивления урону зомбиков. от 0.0 до 1.0, где 1.0 == 100% , 0.2 = 20%. Просчет урона будет Damage * (<Дефолтное сопротивление - процент снижения>)>[Можно не указывать]
;BUY MENU = <PRIMARY/SECONDARY/GRENADES> [Включает предметы в меню закупки при спавне] [Можно не указывать]
*/
new iFile = fopen( szPath, "at" );
new szData[eItemData];
for( i = 0; i < g_ItemCount; i++ )
{
if( ArrayGetCell( aItemNew, i ) )
{
ArrayGetArray(g_aItemData, i, szData);
// ArrayGetString( g_ItemName, i, szBuffer, charsmax( szBuffer ) );
format( szBuffer, charsmax( szBuffer ), "^n[%s]", szData[eItemData_szRealName] );
fputs( iFile, szBuffer );
// ArrayGetString( g_ItemName, i, szBuffer, charsmax( szBuffer ) );
format( szBuffer, charsmax( szBuffer ), "^nNAME = %s", szData[eItemData_szName] );
fputs( iFile, szBuffer );
formatex( szBuffer, charsmax( szBuffer ), "^nCOST = %i", szData[eItemData_Cost] );
fputs( iFile, szBuffer );
// formatex( szBuffer, charsmax( szBuffer ), "^nLEVEL = 0" );
// fputs( iFile, szBuffer );
formatex( szBuffer, charsmax( szBuffer ), "^nSLOT = EQUIPMENT HUMAN" );
fputs( iFile, szBuffer );
formatex( szBuffer, charsmax( szBuffer ), "^nPOS = 0" );
fputs( iFile, szBuffer );
formatex( szBuffer, charsmax( szBuffer ), "^n" );
fputs( iFile, szBuffer );
}
}
if (iFile) fclose( iFile );
ArrayDestroy( aItemNew );
ArrayDestroy( g_aItemData2 );
}
public Native_Register_Item( const szItemName[ ], iItemCost )
{
param_convert( 1 );
if( !g_bArraysCreated )
{
log_error( AMX_ERR_NATIVE, "Can't register item yet (%s).", szItemName );
return -1;
}
new szData[eItemData], szData2[eItemData];
for (new i; i<ArraySize(g_aItemData); i++) {
ArrayGetArray(g_aItemData, i, szData);
if (equal(szItemName, szData[eItemData_szRealName])) {
log_error( AMX_ERR_NATIVE, "Already registred (%s).", szItemName );
return -1;
}
}
ArrayPushCell( aItemNew, 1 );
new i, iSize = ArraySize( g_aItemData2 );
new bFounded, iType;
for( i = 0; i < iSize; i++ )
{
ArrayGetArray(g_aItemData2, i, szData2);
if( !equal( szItemName, szData2[eItemData_szRealName]))
{
continue;
}
iType = szData2[eItemData_Type];
ArraySetCell( aItemNew, g_ItemCount, 0 );
// if (file_exists(szData[eItemData_BackModel]))
// {
// engfunc(EngFunc_PrecacheModel, szData[eItemData_BackModel]);
// }
// else
// {
// szData[eItemData_BackModel][0] = EOS;
// }
// if (file_exists(szData[eItemData_WeaponModel]))
// {
// engfunc(EngFunc_PrecacheModel, szData[eItemData_WeaponModel]);
// }
// else
// {
// szData[eItemData_WeaponModel][0] = EOS;
// }
bFounded = true;
break;
}
if (bFounded)
{
ArrayPushArray(g_aItemData, szData2);
server_print("fitem %s is type: %s ff", szData2[eItemData_szName], g_szItemSlots[ szData2[eItemData_Type] ]);
}
else
{
new szData3[eItemData];
formatex(szData3[eItemData_szName], 31, "%s", szItemName);
szData3[eItemData_Cost] = iItemCost;
ArrayPushArray(g_aItemData, szData3);
server_print("item %s is type: %s nf", szData3[eItemData_szName], g_szItemSlots[ szData3[eItemData_Type] ]);
}
// server_print("itemid %d %s", g_ItemCount, szData[eItemData_szName]);
g_ItemsCount[ iType ]++;
g_ItemCount++;
return g_ItemCount - 1;
}
public native_items_get_id(plugin_id, num_params)
{
new real_name[32]
get_string(1, real_name, charsmax(real_name))
new item_name[64], szData[eItemData];
for (new index = 0; index < g_ItemCount; index++)
{
ArrayGetArray(g_aItemData, index, szData);
if (equali(real_name, szData[eItemData_szRealName]))
return index;
}
return ZP_INVALID_ITEM;
}
public native_items_get_name(plugin_id, num_params)
{
new item_id = get_param(1)
if (item_id < 0 || item_id >= g_ItemCount)
{
log_error(AMX_ERR_NATIVE, "[ZP] Invalid item id (%d)", item_id)
return false;
}
new szData[eItemData];
// ArrayGetString(g_ItemName, item_id, name, charsmax(name))
ArrayGetArray(g_aItemData, item_id, szData);
new len = get_param(3)
set_string(2, szData[eItemData_szName], len);
return true;
}
public native_items_get_cost(plugin_id, num_params)
{
new item_id = get_param(1)
if (item_id < 0 || item_id >= g_ItemCount)
{
log_error(AMX_ERR_NATIVE, "[ZP] Invalid item id (%d)", item_id)
return -1;
}
new szData[eItemData];
ArrayGetArray(g_aItemData, item_id, szData);
return szData[eItemData_Cost];
}
public native_items_show_menu(plugin_id, num_params)
{
new id = get_param(1)
if (!is_user_connected(id))
{
log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
return false;
}
Command_BuyMenu( id );
return true;
}
public native_items_force_buy(plugin_id, num_params)
{
new id = get_param(1)
if (!is_user_connected(id))
{
log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
return false;
}
new item_id = get_param(2)
if (item_id < 0 || item_id >= g_ItemCount)
{
log_error(AMX_ERR_NATIVE, "[ZP] Invalid item id (%d)", item_id)
return false;
}
new ignorecost = get_param(3)
buy_item(id, item_id, ignorecost)
return true;
}
public native_items_menu_text_add(plugin_id, num_params)
{
new text[32]
get_string(1, text, charsmax(text))
format(g_AdditionalMenuText, charsmax(g_AdditionalMenuText), "%s%s", g_AdditionalMenuText, text)
}
public native_get_text(plugin_id, num_params)
{
set_string(1, g_AdditionalMenuText, charsmax(g_AdditionalMenuText));
}
public native_items_total()
{
return ArraySize(g_aItemData);
}
public native_items_get_random(plugid, params_num)
{
new id = get_param(1);
if (id && !is_user_connected(id))
return ZP_INVALID_ITEM;
new bForTargetPlayer = id ? true : false;
new iItemType = get_param(2);
enum eRandomChance
{
eRandom_Index,
eRandom_StartValue,
eRandom_EndValue,
eRandom_Value
}
new szRandomData[eRandomChance], Array:aRandom = ArrayCreate(eRandomChance);
new iMaxRandom, iRandom, iBestValue, szData[eItemData];
for (new i = 1; i<g_ItemCount; i++)
{
if (i == g_iSkipFirstItemId)
continue;
ArrayGetArray(g_aItemData, i, szData);
if (iItemType == szData[eItemData_Type])
{
if (bForTargetPlayer)
{
ExecuteForward( g_fwItemSelect[FW_ITEM_SELECT_PRE], g_iForwardResult, id, i, true, 0, false);
if (g_iForwardResult != ZP_ITEM_AVAILABLE)
continue;
}
arrayset(szRandomData, false, sizeof(szRandomData));
if ((iRandom = szData[eItemData_RandomChance]))
{
szRandomData[eRandom_Index] = i;
szRandomData[eRandom_StartValue] = iMaxRandom ? iMaxRandom + 1 : iMaxRandom;
iMaxRandom += iRandom;
szRandomData[eRandom_StartValue] = iMaxRandom;
szRandomData[eRandom_Value] = iRandom;
ArrayPushArray(aRandom, szRandomData);
}
}
}
for (new j, iMaxValue, iMaxIndex, szData2[eRandomChance], iSize = ArraySize(aRandom), i = iSize - 1; i>=0;i--)
{
iMaxValue = -1;
ArrayGetArray(aRandom, i, szRandomData);
for (j = i - 1; j>=0; j--)
{
if (j < 0) continue;
ArrayGetArray(aRandom, j, szData2);
if (szRandomData[eRandom_Value] > szData2[eRandom_Value])
{
iMaxValue = szData2[eRandom_Value];
iMaxIndex = j;
}
}
if (iMaxValue == -1)
continue;
ArrayGetArray(aRandom, iMaxIndex, szData2);
ArraySetArray(aRandom, i, szData2);
ArraySetArray(aRandom, iMaxIndex, szRandomData);
}
for (new i, iMaxRandom = 0, iSize = ArraySize(aRandom); i<iSize; i++)
{
ArrayGetArray(aRandom, i, szRandomData);
szRandomData[eRandom_StartValue] = iMaxRandom ? iMaxRandom + 1 : iMaxRandom;
iMaxRandom += szRandomData[eRandom_Value];
szRandomData[eRandom_EndValue] = iMaxRandom;
ArraySetArray(aRandom, i, szRandomData);
}
iRandom = random_num(1, iMaxRandom);
for (new i, iSize = ArraySize(aRandom); i<iSize; i++)
{
ArrayGetArray(aRandom, i, szRandomData);
if (szRandomData[eRandom_StartValue] <= iRandom <= szRandomData[eRandom_EndValue])
{
iBestValue = szRandomData[eRandom_Index];
break;
}
}
ArrayDestroy(aRandom);
return iBestValue;
}
public native_select_item_pre(id, itemid)
{
new id = get_param(1);
if (!is_user_alive(id))
return -1;
new itemid = get_param(2);
if (itemid >= g_ItemCount || itemid < 0)
return -1;
new szData[eItemData];
ArrayGetArray(g_aItemData, itemid, szData);
new iRealCost, iItemCost = szData[eItemData_Cost];
iRealCost = floatround( iItemCost - iItemCost / 100.0 * g_iUserDiscount[ id ] );
ExecuteForward( g_fwItemSelect[FW_ITEM_SELECT_PRE], g_iForwardResult, id, itemid, true, iRealCost, false);
return g_iForwardResult;
}
stock UTIL_ColorChat( iPlayer, const szMessage[], any:... )
{
new szBuffer[ 190 ], i, iArgsCount;
iArgsCount = numargs( );
if( !iPlayer )
{
new iPlayer;
for( iPlayer = 1; iPlayer <= g_iMaxPlayers; iPlayer++ )
{
if( !is_user_connected( iPlayer ) )
continue;
new iChanged[ 5 ], iChangedCount;
iChangedCount = 0;
for( i = 2; i < iArgsCount; i++ )
{
if( getarg( i ) == LANG_PLAYER )
{
setarg( i, 0, iPlayer );
iChanged[ iChangedCount ] = i;
iChangedCount++
}
}
vformat( szBuffer, charsmax( szBuffer ), szMessage, 3 );
format( szBuffer, charsmax( szBuffer ), "%s %s", CHAT_PREFIX, szBuffer );
replace_all( szBuffer, charsmax( szBuffer ), "!g", "^x04" );
replace_all( szBuffer, charsmax( szBuffer ), "!t", "^x03" );
replace_all( szBuffer, charsmax( szBuffer ), "!y", "^x01" );
UTIL_SayText( iPlayer, szBuffer );
for( i = 0; i < iChangedCount; i++ )
setarg( iChanged[ i ], 0, LANG_PLAYER );
}
}
else
{
vformat( szBuffer, charsmax( szBuffer ), szMessage, 3 );
format (szBuffer, charsmax( szBuffer ), "%s %s", CHAT_PREFIX, szBuffer );
replace_all( szBuffer, charsmax( szBuffer ), "!g", "^x04" );
replace_all( szBuffer, charsmax( szBuffer ), "!t", "^x03" );
replace_all( szBuffer, charsmax( szBuffer) , "!y", "^x01" );
UTIL_SayText( iPlayer, szBuffer );
}
return PLUGIN_CONTINUE;
}
stock UTIL_SayText( iPlayer, szMessage[] )
{
message_begin (MSG_ONE, g_iMsgID[ SayText ], _, iPlayer );
write_byte( iPlayer );
write_string( szMessage );
message_end( );
}
// stock bool: is_user_steam( iPlayer )
// {
// static pDproto;
// if( pDproto || ( pDproto = get_cvar_pointer( "dp_r_id_provider" ) ) )
// {
// server_cmd( "dp_clientinfo %i", iPlayer );
// server_exec( );
// return ( get_pcvar_num( pDproto ) == 2 ) ? true : false;
// }
// return false;
// }
public fw_SetModel(iWeaponBox)
{
if (is_nullent(iWeaponBox))
{
return FMRES_IGNORED;
}
if(!FClassnameIs(iWeaponBox, "weaponbox"))
{
return FMRES_IGNORED;
}
for (new iItem, i = 0; i < 6; i++)
{
//client_print(0, print_chat, "called spawn, slot %d", i);
iItem = get_member(iWeaponBox, m_WeaponBox_rgpPlayerItems, i);
if (!is_nullent(iItem))
{
//client_print(0, print_chat, "...set");
set_ced(iWeaponBox, ced_int, ced_weapon_int_item_buyer, get_ced(iItem, ced_int, ced_weapon_int_item_buyer));
set_ced(iWeaponBox, ced_int, ced_weapon_int_weaponkey, get_ced(iItem, ced_int, ced_weapon_int_weaponkey));
}
}
return FMRES_IGNORED;
}
public fw_AddPlayerItem(id, iItem)
{
if (!is_user_alive(id) || is_nullent(iItem))
return;
if (zp_core_is_zombie(id))
return;
if (g_flLastTimeBuy[id] == get_gametime() && g_iPlayerItemCounterId[id] == g_iBuyCounter)
{
new szData[eItemData];
new szPath[128];
//ArrayGetString(aItemBackModel, g_iItemId[id], szPath, charsmax(szPath));
ArrayGetArray(g_aItemData, g_iItemId[id], szData);
//client_print(0, print_chat, "add %s %d",szPath, g_iItemId[id]);
set_ced(iItem, ced_string, ced_weapon_string_backmodel_path, szData[eItemData_BackModel]);
set_ced(iItem, ced_int, ced_weapon_int_backmodel_body, szData[eItemData_BackModelBody]);
set_ced(iItem, ced_int, ced_weapon_int_backmodel_skin, szData[eItemData_BackModelSkin]);
// ArrayGetString(aItemWeaponModel, g_iItemId[id], szPath, charsmax(szPath));
//client_print(0, print_chat, "add %s %d",szPath, g_iItemId[id]);
set_ced(iItem, ced_string, ced_weapon_string_weapon_model, szData[eItemData_WeaponModel]);
set_ced(iItem, ced_int, ced_weapon_int_weapon_model_body, szData[eItemData_WeaponModelBody]);
set_ced(iItem, ced_int, ced_weapon_int_backmodel_skin, szData[eItemData_WeaponModelSkin]);
// ArrayGetString(aItemDeathIcon, g_iItemId[id], szPath, charsmax(szPath));
set_ced(iItem, ced_string, ced_weapon_str_icon, szData[eItemData_DeathIcon]);
// ArrayGetString(aItemDeathMsg, g_iItemId[id], szPath, charsmax(szPath));
set_ced(iItem, ced_string, ced_weapon_str_name, szData[eItemData_DeathMsg]);
set_ced(iItem, ced_int, ced_weapon_int_item_buyer, id);
set_ced(iItem, ced_int, ced_weapon_int_weaponkey, g_iItemId[id]);
set_ced(iItem, ced_float, ced_weapon_float_base_damage, szData[eItemData_BaseDmg]);
set_ced(iItem, ced_float, ced_weapon_float_dmg_multi_head, szData[eItemData_DmgMultiHead]);
set_ced(iItem, ced_float, ced_weapon_float_dmg_multi_chest, szData[eItemData_DmgMultiChest]);
set_ced(iItem, ced_float, ced_weapon_float_dmg_multi_stomach, szData[eItemData_DmgMultiStomach]);
set_ced(iItem, ced_float, ced_weapon_float_dmg_multi_leg, szData[eItemData_DmgMultiLeg]);
set_ced(iItem, ced_float, ced_weapon_float_dmg_multi_arm, szData[eItemData_DmgMultiArm]);
set_ced(iItem, ced_float, ced_weapon_float_dmg_multi_breakable, szData[eItemData_DmgMultiArm]);
set_ced(iItem, ced_float, ced_weapon_float_dmg_multi_info_target, szData[eItemData_DmgMultiInfoTarget]);
set_ced(iItem, ced_float, ced_weapon_float_knockback_power, szData[eItemData_KnockBackPower]);
set_ced(iItem, ced_float, ced_weapon_float_knockback_distance, szData[eItemData_KnockBackDistance]);
set_ced(iItem, ced_float, ced_weapon_float_knockback_by_damage_limiter, szData[eItemData_KnockBackByDamageLimiter]);
set_ced(iItem, ced_float, ced_weapon_float_knockback_by_damage_related, szData[eItemData_KnockBackByDamageRelated]);
set_ced(iItem, ced_float, ced_weapon_float_decrease_zombie_armor, szData[eItemData_DecreaseZombie]);
// new iAmmo = ArrayGetCell(aItemAmmoBackup, g_iItemId[id]);
set_ced(iItem, ced_int, ced_weapon_int_ammobackup, szData[eItemData_AmmoBackup] ? szData[eItemData_AmmoBackup] : rg_get_iteminfo(iItem, ItemInfo_iMaxAmmo1));
//static szName[32]; ArrayGetString(g_ItemName, g_iItemId[id], szName, charsmax(szName));
//client_print(id, print_console, "[Weapon: %s]", szName);
//client_print(id, print_console, "[Base Dmg: %.2f]", Float:ArrayGetCell(aItemBaseDmg, g_iItemId[id]));
}
}
public Ham_PlayerTouch(iItem, id)
{
if (!id || id > MaxClients || /*BIT_NOT_VALID(g_bitsAlive, id)*/ !is_user_alive(id) || is_nullent(iItem))
return HAM_IGNORED;
if (BIT_VALID(g_bitsZombie, id))
return HAM_SUPERCEDE;
static iItemId; iItemId = get_ced(iItem, ced_int, ced_weapon_int_weaponkey);
static Float:flLastMsg[33];
if (flLastMsg[id] < get_gametime())
{
flLastMsg[id] = get_gametime() + 1.0;
//client_print(id, print_chat, "ItemId: %d | Lvl:%d", iItemId, ArrayGetCell(aItemLevel, iItemId));
}
if (iItemId > 0)
{
new szData[eItemData];
ArrayGetArray(g_aItemData, iItemId, szData);
//todo
if (get_user_level(id) < szData[eItemData_Level] && get_ced(iItem, ced_int, ced_weapon_int_item_buyer) != id)
{
client_print(id, print_center, "Чтобы взять данный предмет, нужнен %d LeVeL!", szData[eItemData_Level]);
return HAM_SUPERCEDE;
}
}
return HAM_IGNORED;
}
public zp_fw_core_spawn_post(id)
{
BIT_ADD(g_bitsAlive, id);
BIT_SUB(g_bitsZombie, id);
// if (is_user_bot(id)) {
// remove_task(id);
// set_task(0.5, "task_buy_bot_weapon", id);
// }
}
public task_buy_bot_weapon(id)
{
if (is_user_bot(id) && is_user_alive(id) && !zp_core_is_zombie(id)) {
new iPrimaryWeapon, iSecondaryWeapon;
new szData[eItemData];
for (new i = 1; i<ArraySize(g_aItemData); i++) {
ArrayGetArray(g_aItemData, i, szData);
switch (szData[eItemData_Type]) {
case Pistols: {
if (iSecondaryWeapon)
continue;
if (random_num(1, 5) == 5) {
iSecondaryWeapon = i;
}
}
case Shotguns: {
if (iPrimaryWeapon)
continue;
if (random_num(1, 5) == 5) {
iPrimaryWeapon = i;
}
}
case Automates: {
if (iPrimaryWeapon)
continue;
if (random_num(1, 5) == 5) {
iPrimaryWeapon = i;
}
}
case Rifles: {
if (iPrimaryWeapon)
continue;
if (random_num(1, 5) == 5) {
iPrimaryWeapon = i;
}
}
case Machines: {
if (iPrimaryWeapon)
continue;
if (random_num(1, 5) == 5) {
iPrimaryWeapon = i;
}
}
case Bigguns: {
if (iPrimaryWeapon)
continue;
if (random_num(1, 5) == 5) {
iPrimaryWeapon = i;
}
}
}
}
if (iPrimaryWeapon) {
rg_drop_items_by_slot(id, PRIMARY_WEAPON_SLOT);
buy_item(id, iPrimaryWeapon, true);
}
if (iSecondaryWeapon) {
rg_drop_items_by_slot(id, PISTOL_SLOT);
buy_item(id, iSecondaryWeapon, true);
}
}
}
public zp_fw_core_kill_post(id)
{
BIT_SUB(g_bitsAlive, id);
BIT_SUB(g_bitsZombie, id);
}
public zp_fw_core_cure_post(id)
{
BIT_SUB(g_bitsZombie, id);
}
public zp_fw_core_infect_post( iPlayer, iInfector )
{
BIT_ADD(g_bitsZombie, iPlayer);
if( !is_user_alive( iPlayer ) || !is_user_alive( iInfector ) || iPlayer == iInfector )
return;
show_menu( iPlayer, 0, "^n", 1 );
// menu_cancel( iPlayer );
}
public client_disconnected( iPlayer )
{
BIT_SUB(g_bitsAlive, iPlayer);
BIT_SUB(g_bitsZombie, iPlayer);
if( !g_bUserLoaded{ iPlayer } || is_user_bot( iPlayer ) )
return;
g_bSuperUser{ iPlayer } = false;
g_iUserDiscount[ iPlayer ] = 0;
}
public plugin_end()
{
ArrayDestroy(aItemsPosSort);
ArrayDestroy(g_aItemData);
}