new const PLUGIN_VERSION[] = "1.0"
// Серверная команда для внешней выдачи через BonusMenu RBS
// Формат "Команда #%userid% цена кол-во мин_раунд куллдаун доступ"
//
// Куллдаун - Задержка повторной покупки в раундах. Например, поставьте 1 чтобы можно было покупать 1 шприц за раунд
// Доступ - Флаги доступа, при наличии любого из которых игрок может купить шприц. Поставьте 0 чтобы доступ был для всех
//
// Чтобы добавить шприц в BonusMenu RBS
// Вам необходимо добавить в bonusmenu_rbs.ini (где "666" в обоих случаях - цена предмета; поставьте своё значение)
// "srvcmd" "666" "!acs_inj_bmrbs #%userid% 666 1 1 1 d" "" "0" "0" "Эпинефрин"
//
new const SRVCMD_BONUSMENU_RBS[] = "acs_inj_bmrbs"
/* ------------------------------------------------------------------ */
// BonusMenu RBS https://fungun.net/shop/?p=show&id=106
native bonusmenu_get_user_points(id)
native bonusmenu_add_user_points(id, points)
#include <amxmodx>
#include <reapi>
#include <acs_injection>
#define rg_get_current_round() (get_member_game(m_iTotalRoundsPlayed) + 1)
new g_iCooldown[MAX_PLAYERS + 1], g_iBuyzone
public plugin_init() {
register_plugin("[ACS] INJECTION BonusMenu RBS", PLUGIN_VERSION, "mx?!")
bind_pcvar_num(create_cvar("acs_inj_bmrbs_only_buyzone", "1"), g_iBuyzone)
register_srvcmd(SRVCMD_BONUSMENU_RBS, "srvcmd_GiveItem_BonusMenuRBS")
RegisterHookChain(RG_CSGameRules_RestartRound, "CSGameRules_RestartRound_Pre")
}
public srvcmd_GiveItem_BonusMenuRBS() {
enum { arg_userid = 1, arg_price, arg_count, arg_min_round, arg_cooldown, arg_access_flag }
new szUserId[16]
read_argv(arg_userid, szUserId, charsmax(szUserId))
new pPlayer = find_player("k", str_to_num(szUserId[1]))
if(!pPlayer) {
abort(AMX_ERR_GENERAL, "[1] Player '%s' not found", szUserId[1])
}
new iCount = read_argv_int(arg_count)
if(iCount < 1) {
log_error(AMX_ERR_NATIVE, "[1] Wrong count %i", iCount)
}
new szFlag[32]
read_argv(arg_access_flag, szFlag, charsmax(szFlag))
new bitFlag = read_flags(szFlag)
if(bitFlag && szFlag[0] != '0' && !(get_user_flags(pPlayer) & bitFlag)) {
client_print_color(pPlayer, print_team_red, "^3* ^1You do not have access to this menu item!")
return PLUGIN_HANDLED
}
if(!is_user_alive(pPlayer)) {
client_print_color(pPlayer, print_team_red, "^3* ^1Available only to live players!")
return PLUGIN_HANDLED
}
if(acs_inj_get_user_injections(pPlayer)) {
client_print_color(pPlayer, print_team_red, "^3* ^1You already have a specified item!")
return PLUGIN_HANDLED
}
new iCurrentRound = rg_get_current_round()
new iMinRound = read_argv_int(arg_min_round)
if(iCurrentRound < iMinRound) {
client_print_color(pPlayer, print_team_red, "^3* ^1Minimum round for purchases:^3 %i", iMinRound)
return PLUGIN_HANDLED
}
if(g_iCooldown[pPlayer]) {
new szRounds[32]
func_GetEnding(g_iCooldown[pPlayer], "rounds", "round", "rounds", szRounds, charsmax(szRounds))
client_print_color(pPlayer, print_team_red, "^3* ^1Wait a little longer^3 %i ^1%s", g_iCooldown[pPlayer], szRounds)
return PLUGIN_HANDLED
}
if(g_iBuyzone && !rg_get_user_buyzone(pPlayer)) {
client_print_color(pPlayer, print_team_red, "^3* ^1Available in the purchase zone only!")
return PLUGIN_HANDLED
}
new iPrice = read_argv_int(arg_price)
if(iPrice) {
if(bonusmenu_get_user_points(pPlayer) < iPrice) {
client_print_color(pPlayer, print_team_red, "^3* ^1You don't have enough points!")
return PLUGIN_HANDLED
}
bonusmenu_add_user_points(pPlayer, -iPrice)
}
g_iCooldown[pPlayer] = read_argv_int(arg_cooldown)
acs_inj_add_user_injections(pPlayer, iCount)
return PLUGIN_HANDLED
}
public CSGameRules_RestartRound_Pre() {
for(new i; i < sizeof(g_iCooldown); i++) {
if(g_iCooldown[i]) {
g_iCooldown[i]--
}
}
}
public client_disconnected(pPlayer) {
g_iCooldown[pPlayer] = 0
}
stock func_GetEnding(iValue, const szA[], const szB[], const szC[], szBuffer[], iMaxLen) {
new iValue100 = iValue % 100, iValue10 = iValue % 10;
if(iValue100 >= 5 && iValue100 <= 20 || iValue10 == 0 || iValue10 >= 5 && iValue10 <= 9) {
copy(szBuffer, iMaxLen, szA)
return
}
if(iValue10 == 1) {
copy(szBuffer, iMaxLen, szB)
return
}
/*if(iValue10 >= 2 && iValue10 <= 4) {
copy(szBuffer, iMaxLen, szC)
}*/
copy(szBuffer, iMaxLen, szC)
}
// Аналог cs_get_user_buyzone() https://dev-cs.ru/threads/222/post-32988
bool:rg_get_user_buyzone(pPlayer) {
new iSignals[UnifiedSignals]
get_member(pPlayer, m_signals, iSignals)
return bool:(SignalState:iSignals[US_State] & SIGNAL_BUY)
}