Next21 gifts

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
345
Реакции
77
Помог
14 раз(а)
Ошибка
Отсутствует
ОС
Linux
Amx Mod X
AMX Mod X 1.8.3-dev+5201 (http://www.amxmodx.org)
Authors:
David "BAILOPAN" Anderson, Pavol "PM OnoTo" Marko
Felix "SniperBeamer" Geyer, Jonny "Got His Gun" Bergstrom
Lukasz "SidLuke" Wlasinski, Christian "Basic-Master" Hammacher
Borja "faluco" Ferrer, Scott "DS" Ehlert
Compiled: Sep 1 2018 09:52:22
Built from: https://github.com/alliedmodders/amxmodx/commit/8c0f97d
Build ID: 5201:8c0f97d
Core mode: JIT+ASM32
Билд
Protocol version 48
Exe version 1.1.2.7/Stdio (cstrike)
ReHLDS version: 3.4.0.668-dev
Build date: 17:58:00 Oct 5 2018 (1637)
Build from: https://github.com/dreamstalker/rehlds/commit/89be216
ReGamedll
ReGameDLL version: 5.7.0.318-dev
Build date: 21:07:26 Oct 30 2018
Build from: https://github.com/s1lentq/ReGameDLL_CS/commit/932001b
Версия Metamod
Metamod-r v1.3.0.128, API (5:13)
Metamod-r build: 17:47:54 Aug 24 2018
Metamod-r from: https://github.com/theAsmodai/metamod-r/commit/0cf2f70
Список метамодулей
[ 1] Reunion          RUN   -    reunion_mm_i386.so         v0.1.0.92        ini  Start Never
[ 2] Rechecker RUN - rechecker_mm_i386.so v2.5 ini Chlvl ANY
[ 3] hackdetector RUN - hackdetector_amxx_i386.so v0.15.328.lite ini ANY ANY
[ 4] VoiceTranscoder RUN - VoiceTranscoder.so v2017RC3 ini ANY ANY
[ 5] ReAuthCheck RUN - reauthcheck_mm_i386.so v0.1.6 ini Start Never
[ 6] AMX Mod X RUN - amxmodx_mm_i386.so v1.8.3-dev+5201 ini Start ANY
[ 7] ReParachute RUN - parachute_amxx_i386.so v1.1 Beta pl6 ANY ANY
[ 8] ReAPI RUN - reapi_amxx_i386.so v5.6.0.159-dev pl6 ANY Never
[ 9] MySQL RUN - mysql_amxx_i386.so v1.8.3-dev+5201 pl6 ANY ANY
[10] FakeMeta RUN - fakemeta_amxx_i386.so v1.8.3-dev+5201 pl6 ANY ANY
[11] Ham Sandwich RUN - hamsandwich_amxx_i386.so v1.8.3-dev+5201 pl6 ANY ANY
[12] CStrike RUN - cstrike_amxx_i386.so v1.8.3-dev+5201 pl6 ANY ANY
[13] Engine RUN - engine_amxx_i386.so v1.8.3-dev+5201 pl6 ANY ANY
[14] Fun RUN - fun_amxx_i386.so v1.8.3-dev+5201 pl6 ANY ANY
14 plugins, 14 running
Список плагинов
[  1] Admin Loader            3.4         neygomon          admin_loader.am  running  
[ 2] FreshBans 1.4.0b kanagava fresh_bans_140_ running
[ 3] Aliases checker 0.8.2 kanagava alias_detector0 running
[ 4] Teleport Menu 1.8.3-dev+ AMXX Dev Team telemenu.amxx running
[ 5] CSStatsX SQL 0.7.4 serfreeman1337 csstatsx_sql.am running
[ 6] Stats Configuration 1.8.3-dev+ AMXX Dev Team statscfg.amxx running
[ 7] Admin Commands 1.8.3-dev+ AMXX Dev Team admincmd.amxx running
[ 8] Ultimate Chats Control 4.5 neygomon ucc.amxx running
[ 9] Players Menu 1.7 neugomon players_menu.am running
[ 10] [SWPlug] Knife Duel 1.0 Trendy swp_2.amxx debug
[ 11] menufront_cheto_tam 99 grust' <3 menufront_end.a running
[ 12] Shop for Knife 1.0 bristol shop_knife.amxx running
[ 13] FrostNades 2.09 Avalanche frostnades.amxx running
[ 14] Knife DeathMatch: VIP 1.0.3 Salvatore vipmenu.amxx running
[ 15] [Reapi] Custom Models 1.6.1 neygomon custom_models.a running
[ 16] [ReAPI] SF Level Skins 0.1 serfreeman1337 sf_level_skins. running
[ 17] Spec Money Save 0.2 F@nt0M spec_money_save running
[ 18] DemoRecoder 1.2 neygomon amx_demorec.amx running
[ 19] Ping Checker 26.0.1 RC1 h1k3 ping_checker.am running
[ 20] Kill Distance (mod) 0.3f Nightscream kill_distance_m running
[ 21] NoRound Balancer 1.3a neygomon noround_balance running
[ 22] menu 1 grust' <3 menu.amxx running
[ 23] Change Team 1.0 neygomon changeteam.amxx running
[ 24] resetscore(ReAPI) 1.0 Phantom resetscore.amxx running
[ 25] Train Killer 1.0 Pastout! trainkiller_1.a running
[ 26] CamChenger 1.0 qazwsxedc CamChenger.amxx running
[ 27] Bhop Menu 1.2a gyxoBka BhopMenu.amxx running
[ 28] Hook 1.0 xxx hook.amxx running
[ 29] Invise Water IDK IDK hide_water.amxx running
[ 30] [ReAPI] Block 'Fire in 0.0.1 sergrib reapi_block_FIT running
[ 31] BlockRadio 1.1 Phantom block_radio.amx running
[ 32] NameChangeTime 0.0.1 Vaqtincha block_change_ni running
[ 33] Rules Menu 1.1 nacya RulesMenu_2.amx running
[ 34] gram_naciya 1.0 grus' <3 vrode_grab.amxx running
[ 35] Snowball 0.6 alpha s1lent snowball.amxx running
[ 36] Menu Greetings 1.0 OverGame mg.amxx running
[ 37] [KH] System XmasTree 1.0 Kulogram KH_System_Xmas_ debug
[ 38] gifts 0.8.1 Psycrow next21_gifts.am running
[ 39] Night Sky + Lighint 1.0 Leo_[BH] night_sky.amxx running
[ 40] Chat Manager 1.1.1-11 Mistrick chatmanager.amx running
[ 41] Chat Manager: Addon 0.0.4-70 Mistrick chatmanager_add running
[ 42] Advanced Experience Sy 0.5.9 [REA serfreeman1337/s aes_main.amxx running
[ 43] AES: CStrike Addon 0.5.9 [REA serfreeman1337/s aes_exp_cstrike running
[ 44] AES: Informer 0.5.9 [REA serfreeman1337/s aes_informer.am running
[ 45] AES: StatsX 0.5.9 [REA serfreeman1337/s aes_statsx_cstr running
45 plugins, 45 running
Автор плагина
Psycrow
Версия плагина
0.8.1
Исходный код
#include <amxmodx>
#include <amxmisc>
#include <fakemeta_util>
#include <hamsandwich>
#include <fun>
#include <WPMGPrintChatColor>

#define PLUGIN "Нация Ножей"
#define VERSION "0.8.1"
#define AUTHOR "Psycrow"

#define is_entity_player(%1) (1<=%1<=g_maxPlayers)
#define PRESENT_CLASSNAME "next21_gift"
#define pev_lifes pev_euser1

#define MODEL_PRESENT "models/next21_knife_v2/presents/presents.mdl"
#define MODEL_SKINS 3
#define MODEL_SUBMODELS 5

#define MAX_MONEY 20000 // Максимальное кол-во денег у игрока

#if cellbits == 32
#define OFFSET_CSMONEY 115
#else
#define OFFSET_CSMONEY 140
#endif

new
g_msgMoney,
g_infoTarget,
g_maxPlayers,
g_menuId = -1,
bool: g_registration,
g_totalGifts, //Кол-во загруженных подарков на карте
g_get_round_times[33], //Сколько раз игрок поднял подарков за раунд
g_get_game_times[33], //Сколько раз игрок поднял подарков за игру
g_disconnections, //Сколько игроков покинуло сервер
bool: g_have_speed[33], //Имеет ли игрок добавленную скорость
bool: g_have_gravity[33], //Имеет ли игрок добавленную гравитацию
bool: g_have_sw[33], //Имеет ли игрок заглушенные шаги
bool: g_save_cpl, //Изменения в расположении подарков
Float: g_massage_rate[33], //Ограничение оповещений о попытке собрать подарок ограниченному игроку

Array:g_gift_id, //Индексы подарков
Array:g_gift_x,
Array:g_gift_y,
Array:g_gift_z,
Array:g_plr_steamid,
Array:g_plr_times


public plugin_precache()
{
precache_model(MODEL_PRESENT)
}

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)

register_cvar("cv_gift_access","l") // Флаг доступа к меню
register_cvar("cv_gift_money_min","500") // Минимальная награда за собрынный подарок
register_cvar("cv_gift_money_max","8000") // Максимальная награда за собрынный подарок
register_cvar("cv_gift_silent_walk","0") // Добавить ли в подарки бесшумный бег
register_cvar("cv_gift_gravitation","0.5") // Значение гравитации. 0.0 - убрать такой вид подарка
register_cvar("cv_gift_speed","300.0") // Значение скорости. 0.0 - убрать такой вид подарка
register_cvar("cv_gift_HE","2") // Сколько HE гранат можно получить в подарках. 0 - убрать такой вид подарка
register_cvar("cv_gift_health","35") // Сколько HP можно получить в подарках. 0 - убрать такой вид подарка
register_cvar("cv_gift_timerate","500.0") // Сколько секунд до появление подарка
register_cvar("cv_gift_get_times_round","0") // Сколько максимум можно собрать подарков за раундов. 0 - снимает ограничение
register_cvar("cv_gift_get_times_game","0") // Сколько максимум можно собрать подарков за игру (карту). 0 - снимает ограничение
register_cvar("cv_gift_lifes","0") // Сколько раз может появиться подарок в одном и том же месте (0 - неограниченно, 1 - после сбора больше не появляеться...)

register_clcmd("say /gift", "gift_menu")
register_clcmd("say_team /gift", "gift_menu" )
register_clcmd("say /gifts", "gift_menu" )
register_clcmd("say_team /gifts", "gift_menu" )

g_infoTarget = engfunc(EngFunc_AllocString, "info_target")
}

public plugin_cfg()
{
new map[32]
get_mapname(map, charsmax(map))
formatex(map, charsmax(map),"%s.ini",map)

new cfgDir[64], iDir, iFile[128]
get_configsdir(cfgDir, charsmax(cfgDir))
formatex(cfgDir, charsmax(cfgDir), "%s/next21_gifts", cfgDir)

iDir = open_dir(cfgDir, iFile, charsmax(iFile))

if(iDir)
{
while(next_file(iDir, iFile, charsmax(iFile)))
{
if (iFile[0] == '.')
continue

if(equal(map, iFile))
{
format(iFile, 128, "%s/%s", cfgDir, iFile)
get_gifts(iFile)
break
}
}
}
else server_print("[%s] Gifts was not loaded", PLUGIN)
}

public client_putinserver(id)
{
if(!g_registration) return

if(get_cvar_num("cv_gift_get_times_game"))
{
new steamId[32], arraySteamId[32]
get_user_authid(id, steamId, 31)

for(new i = 0; i < g_disconnections; i++)
{
ArrayGetString(g_plr_steamid, i, arraySteamId, 31)
if(equal(steamId, arraySteamId))
{
g_get_game_times[id] = ArrayGetCell(g_plr_times, i)
return
}
}
g_get_game_times[id] = 0
}
}

public client_disconnect(id)
{
if(!g_registration) return

if(get_cvar_num("cv_gift_get_times_game"))
{
new steamId[32], arraySteamId[32]
get_user_authid(id, steamId, 31)

for(new i = 0; i < g_disconnections; i++)
{
ArrayGetString(g_plr_steamid, i, arraySteamId, 31)
if(equal(steamId, arraySteamId))
{
ArraySetCell(g_plr_times, i, g_get_game_times[id])
return
}
}

ArrayPushString(g_plr_steamid, steamId)
ArrayPushCell(g_plr_times, g_get_game_times[id])
g_disconnections++
}
}

public fw_PlayerSpawn(id)
{
if(!is_user_alive(id)) return;
if(g_have_gravity[id])
{
set_user_gravity(id)
g_have_gravity[id] = false
}

if(g_have_sw[id])
{
set_user_footsteps(id, 0)
g_have_sw[id] = false
}

g_have_speed[id] = false
}

public CurWeapon(id)
{
if(g_have_speed[id])
set_user_maxspeed(id, get_cvar_float("cv_gift_speed"))
}

public fw_RoundStart()
{
for(new i = 1; i <= g_maxPlayers; i++)
g_get_round_times[i] = 0

new lifes = get_cvar_num("cv_gift_lifes")
if(lifes)
{
new ent
while((ent = fm_find_ent_by_class(ent, PRESENT_CLASSNAME)))
set_pev(ent, pev_lifes, lifes)
}
}

public fw_TouchGift(ent, id)
{
if(!is_entity_player(id))
return

if(g_massage_rate[id] > get_gametime() || !is_user_alive(id) || !pev_valid(ent))
return

static className[32]
pev(ent, pev_classname, className, 31)
if(!equal(className, PRESENT_CLASSNAME))
return

new times = get_cvar_num("cv_gift_get_times_round")
if(times && g_get_round_times[id] >= times)
{
PrintChatColor(id, PRINT_COLOR_PLAYERTEAM, "!g[%s] !tВы привысили лимит сбора подарков за раунд", PLUGIN)
g_massage_rate[id] = get_gametime() + 3.0
return
}

times = get_cvar_num("cv_gift_get_times_game")
if(times && g_get_game_times[id] >= times)
{
PrintChatColor(id, PRINT_COLOR_PLAYERTEAM, "!g[%s] !tВы привысили лимит сбора подарков за игру", PLUGIN)
g_massage_rate[id] = get_gametime() + 3.0
return
}

engfunc(EngFunc_SetModel, ent, MODEL_PRESENT)
set_pev(ent, pev_skin, random_num(0, MODEL_SKINS - 1))
set_pev(ent, pev_body, random_num(0, MODEL_SUBMODELS - 1))

hide_gift(ent)
give_gift(id)

if(get_cvar_num("cv_gift_get_times_game")) g_get_game_times[id]++
if(get_cvar_num("cv_gift_get_times_round")) g_get_round_times[id]++
if(get_cvar_num("cv_gift_lifes")) set_pev(ent, pev_lifes, pev(ent, pev_lifes) - 1)
}

public set_gift()
{
if(!g_totalGifts) return

new valid_gifts_count = 0
new ent, lifes_active = get_cvar_num("cv_gift_lifes")
while((ent = fm_find_ent_by_class(ent, PRESENT_CLASSNAME)))
{
if(pev(ent, pev_solid) != SOLID_NOT || (lifes_active && !pev(ent, pev_lifes)))
valid_gifts_count++
}

if(valid_gifts_count == g_totalGifts) return

new bool: check = false, id
while(check == false)
{
id = random_num(0, g_totalGifts - 1)
ent = ArrayGetCell(g_gift_id ,id)
if(pev(ent, pev_solid) == SOLID_NOT && (!lifes_active || pev(ent, pev_lifes)))
{
set_pev(ent, pev_solid, SOLID_TRIGGER)
unhide_gift(ent)
check = true
}
}
}

public gift_menu(id)
{
if(!is_user_access(id))
{
PrintChatColor(id, PRINT_COLOR_PLAYERTEAM, "!g[%s] !tУ вас нет прав на эту функцию", PLUGIN)
return
}

new menu_name[90]
format(menu_name, 89, "\rРасстановка подарков^n\dТекущий подарок: %d", g_totalGifts + 1)

g_menuId = menu_create(menu_name, "menu_handler")

menu_additem(g_menuId, "\wУстановить Подарок", "1", 0)

if(!g_totalGifts)
{
menu_additem(g_menuId, "\dУдалить предыдущий Подарок", "2", 0)
menu_additem(g_menuId, "\dУдалить все Подарки", "3", 0)
}
else
{
menu_additem(g_menuId, "\wУдалить предыдущий Подарок", "2", 0)
menu_additem(g_menuId, "\wУдалить все Подарки", "3", 0)
}

if(!g_save_cpl)
menu_additem(g_menuId, "\dСохранить изменения", "4", 0)
else menu_additem(g_menuId, "\wСохранить изменения", "4", 0)

menu_setprop(g_menuId, MPROP_EXIT, MEXIT_ALL)
menu_setprop(g_menuId, MPROP_EXITNAME, "\yВыход")
menu_display(id, g_menuId, 0)

new keys
get_user_menu(id, g_menuId, keys)

for(new i = 0; i < g_totalGifts; i++)
unhide_gift(ArrayGetCell(g_gift_id, i))
}

public menu_handler(id, menu, item)
{
if(item == MENU_EXIT)
{
new ent
for(new i = 0; i < g_totalGifts; i++)
{
ent = ArrayGetCell(g_gift_id, i)
if(pev(ent, pev_solid) == SOLID_NOT) hide_gift(ent)
}

menu_destroy(menu)
return PLUGIN_HANDLED
}

switch(item)
{
case 0:
{
new Float:fOrigin[3]
fm_get_aim_origin(id, fOrigin)

if(create_gift(fOrigin))
g_save_cpl = true

menu_destroy(menu)
gift_menu(id)
}
case 1:
{
if(!g_totalGifts)
{
PrintChatColor(id, PRINT_COLOR_PLAYERTEAM, "!g[%s] !tНа карте нет Подарков", PLUGIN)
menu_destroy(menu)
gift_menu(id)
return PLUGIN_HANDLED
}

g_save_cpl = true
PrintChatColor(id, PRINT_COLOR_PLAYERTEAM, "!g[%s] !tПодарок удален", PLUGIN)


g_totalGifts--
engfunc(EngFunc_RemoveEntity, ArrayGetCell(g_gift_id, g_totalGifts))
ArrayDeleteItem(g_gift_id, g_totalGifts)
ArrayDeleteItem(g_gift_x, g_totalGifts)
ArrayDeleteItem(g_gift_y, g_totalGifts)
ArrayDeleteItem(g_gift_z, g_totalGifts)

menu_destroy(menu)
gift_menu(id)
}
case 2:
{
if(!g_totalGifts)
{
PrintChatColor(id, PRINT_COLOR_PLAYERTEAM, "!g[%s] !tНа карте нет Подарков", PLUGIN)
menu_destroy(menu)
gift_menu(id)
return PLUGIN_HANDLED
}

g_save_cpl = true
PrintChatColor(id, PRINT_COLOR_PLAYERTEAM, "!g[%s] !tБыло удалено !g%d !tПодарков", PLUGIN, g_totalGifts)

new ent
while((ent = fm_find_ent_by_class(ent, PRESENT_CLASSNAME)))
engfunc(EngFunc_RemoveEntity, ent)

g_totalGifts = 0

ArrayClear(g_gift_id)
ArrayClear(g_gift_x)
ArrayClear(g_gift_y)
ArrayClear(g_gift_z)

menu_destroy(menu)
gift_menu(id)

}
case 3:
{
if(!g_save_cpl)
{
menu_destroy(menu)
gift_menu(id)
return PLUGIN_HANDLED
}

g_save_cpl = false

PrintChatColor(id, PRINT_COLOR_PLAYERTEAM, "!g[%s] !t%s", PLUGIN, save_gifts() ? "Сохранено" : "Не сохранено")

menu_destroy(menu)
gift_menu(id)
}
}
return PLUGIN_HANDLED
}

bool: save_gifts()
{
new map[32]
get_mapname(map, charsmax(map))
formatex(map, charsmax(map), "%s.ini", map)

new cfgDir[64], iFile[128]
get_configsdir(cfgDir, charsmax(cfgDir))
formatex(cfgDir, charsmax(cfgDir), "%s/next21_gifts", cfgDir)
formatex(iFile, charsmax(iFile), "%s/%s", cfgDir, map)

if(!dir_exists(cfgDir))
if(!mkdir(cfgDir))
return false

delete_file(iFile)

if(!g_totalGifts)
return true

for(new i = 0; i < g_totalGifts; i++)
{
new text[128], Float:fOrigin[3], ent = ArrayGetCell(g_gift_id, i)
pev(ent, pev_origin, fOrigin)
format(text, charsmax(text),"^"%f^" ^"%f^" ^"%f^"",fOrigin[0], fOrigin[1], fOrigin[2])
write_file(iFile, text, i)
}

return true
}

get_gifts(const iFile[128])
{
new file = fopen(iFile, "rt")

if(!file)
{
server_print("[%s] Gifts was not loaded", PLUGIN)
return
}

while(file && !feof(file))
{
new sfLineData[512]
fgets(file, sfLineData, charsmax(sfLineData))

if(sfLineData[0] == ';')
continue

if(equal(sfLineData, ""))
continue

new origins[3][32], Float: fOrigin[3]
parse(sfLineData, origins[0], 31, origins[1], 31, origins[2], 31)

fOrigin[0] = str_to_float(origins[0])
fOrigin[1] = str_to_float(origins[1])
fOrigin[2] = str_to_float(origins[2])

create_gift(fOrigin)
}

fclose(file)

if(!g_totalGifts)
server_print("[%s] Gifts was not loaded", PLUGIN)
else if(g_totalGifts == 1)
server_print("[%s] Loaded one gift", PLUGIN)
else
server_print("[%s] Loaded %d gifts", PLUGIN, g_totalGifts)
}

bool: create_gift(const Float: fOrigin[3])
{
new ent = engfunc(EngFunc_CreateNamedEntity, g_infoTarget)
if(!pev_valid(ent)) return false

if(!g_registration)
{
register_event("CurWeapon", "CurWeapon", "be","1=1")
register_event("HLTV", "fw_RoundStart", "a", "1=0", "2=0")

RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn", 1)
RegisterHamFromEntity(Ham_Touch, ent, "fw_TouchGift")

set_task(get_cvar_float("cv_gift_timerate"), "set_gift", _, _, _, "b")

g_gift_id = ArrayCreate()
g_gift_x = ArrayCreate()
g_gift_y = ArrayCreate()
g_gift_z = ArrayCreate()

if(get_cvar_num("cv_gift_get_times_game"))
{
g_plr_steamid = ArrayCreate(32)
g_plr_times = ArrayCreate(32)
}

g_maxPlayers = get_maxplayers()
g_msgMoney = get_user_msgid("Money")

g_registration = true

fw_RoundStart()
}

ArrayPushCell(g_gift_id, ent)

ArrayPushCell(g_gift_x, fOrigin[0])
ArrayPushCell(g_gift_y, fOrigin[1])
ArrayPushCell(g_gift_z, fOrigin[2])

engfunc(EngFunc_SetModel, ent, MODEL_PRESENT)
set_pev(ent, pev_origin, fOrigin)
set_pev(ent, pev_solid, SOLID_NOT)
set_pev(ent, pev_movetype, MOVETYPE_FLY)
set_pev(ent, pev_gravity, 1.0)
set_pev(ent, pev_classname, PRESENT_CLASSNAME)
set_pev(ent, pev_skin, random_num(0, MODEL_SKINS - 1))
set_pev(ent, pev_body, random_num(0, MODEL_SUBMODELS - 1))
engfunc(EngFunc_SetSize, ent, Float:{-15.0, -15.0, 0.0}, Float:{15.0, 15.0, 30.0})

hide_gift(ent)

g_totalGifts++

return true
}

hide_gift(ent)
{
set_pev(ent, pev_solid, SOLID_NOT)
for(new i = 1; i <= g_maxPlayers; i++)
{
new mid, keys
get_user_menu(i, mid, keys)
if(mid == g_menuId)
{
fm_set_rendering(ent, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 150)
return
}
}
fm_set_rendering(ent, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 0)
}

unhide_gift(ent)
{
if(pev(ent, pev_solid) == SOLID_NOT)
fm_set_rendering(ent, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 150)
else
fm_set_rendering(ent, kRenderFxGlowShell, random_num(0,255), random_num(0,255), random_num(0,255), kRenderNormal, 15)
}

give_gift(id) //Выдает случайный бонус с подарка. Добавьте case, если хотите доавить свой.
{
static loopDestroy
loopDestroy++

if(loopDestroy > 20)
{
PrintChatColor(id, PRINT_COLOR_PLAYERTEAM, "!g[%s] !tПодарок оказался пустым", PLUGIN)
loopDestroy = 0
return
}

new max_random_gift = 6//Сколько видов бонусов в подарках
switch(random_num(1, max_random_gift))
{
case 1:
{
new reward = random_num(get_cvar_num("cv_gift_money_min"), get_cvar_num("cv_gift_money_max"))
new curr_money = get_pdata_int(id, OFFSET_CSMONEY)
if(curr_money + reward > MAX_MONEY)
reward = MAX_MONEY - curr_money

if(reward)
{
set_pdata_int(id, OFFSET_CSMONEY, curr_money + reward)

message_begin(MSG_ONE, g_msgMoney, _, id)
write_long(curr_money + reward)
write_byte(1)
message_end()

PrintChatColor(id, PRINT_COLOR_PLAYERTEAM, "!g[%s] !tВы получаете !g%d$", PLUGIN, reward)
loopDestroy = 0
}
else give_gift(id)
}

case 2:
{
if(!g_have_sw[id] && !get_user_footsteps(id) && get_cvar_num("cv_gift_silent_walk"))
{
g_have_sw[id] = true
set_user_footsteps(id)
PrintChatColor(id, PRINT_COLOR_PLAYERTEAM, "!g[%s] !tВы получаете !gбесшумный бег", PLUGIN)
loopDestroy = 0
}
else give_gift(id)
}

case 3:
{
new Float: gravity = get_cvar_float("cv_gift_gravitation")
if(!g_have_gravity[id] && get_user_gravity(id) > gravity && gravity)
{
g_have_gravity[id] = true
set_user_gravity(id, gravity)
PrintChatColor(id, PRINT_COLOR_PLAYERTEAM, "!g[%s] !tВы получаете !gгравитацию", PLUGIN)
loopDestroy = 0
}
else give_gift(id)
}

case 4:
{
new Float: speed = get_cvar_float("cv_gift_speed")
if(!g_have_speed[id] && get_user_maxspeed(id) < speed && speed)
{
g_have_speed[id] = true
set_user_maxspeed(id, speed)
PrintChatColor(id, PRINT_COLOR_PLAYERTEAM, "!g[%s] !tВы получаете !gскорость", PLUGIN)
loopDestroy = 0
}
else give_gift(id)
}

case 5:
{
new hes = get_cvar_num("cv_gift_HE")
if(hes)
{
if(!user_has_weapon(id, CSW_HEGRENADE))
{
fm_give_item(id, "weapon_hegrenade")
cs_set_user_bpammo(id, CSW_HEGRENADE, hes)
}
else cs_set_user_bpammo(id, CSW_HEGRENADE, cs_get_user_bpammo(id, CSW_HEGRENADE) + hes)

PrintChatColor(id, PRINT_COLOR_PLAYERTEAM, "!g[%s] !tВы получаете !gкомплект гранат (%d HE)", PLUGIN, hes)
loopDestroy = 0
}
else give_gift(id)
}

case 6:
{
new hp = get_cvar_num("cv_gift_health")
if(hp)
{
fm_set_user_health(id, pev(id, pev_health) + hp)
PrintChatColor(id, PRINT_COLOR_PLAYERTEAM, "!g[%s] !tВы получаете !gздоровье (%d hp)", PLUGIN, hp)
loopDestroy = 0
}
else give_gift(id)
}
//case 7: тут по примерам выше
}
}

bool: is_user_access(id)
{
new flag_access[24]
get_cvar_string("cv_gift_access", flag_access, charsmax(flag_access))

new flags = get_user_flags(id)

if(contain(flag_access, "a") > -1 && (flags & ADMIN_IMMUNITY))
return true

if(contain(flag_access, "b") > -1 && (flags & ADMIN_RESERVATION))
return true

if(contain(flag_access, "c") > -1 && (flags & ADMIN_KICK))
return true

if(contain(flag_access, "d") > -1 && (flags & ADMIN_BAN))
return true

if(contain(flag_access, "e") > -1 && (flags & ADMIN_SLAY))
return true

if(contain(flag_access, "f") > -1 && (flags & ADMIN_MAP))
return true

if(contain(flag_access, "g") > -1 && (flags & ADMIN_CVAR))
return true

if(contain(flag_access, "h") > -1 && (flags & ADMIN_CFG))
return true

if(contain(flag_access, "i") > -1 && (flags & ADMIN_CHAT))
return true

if(contain(flag_access, "j") > -1 && (flags & ADMIN_VOTE))
return true

if(contain(flag_access, "k") > -1 && (flags & ADMIN_PASSWORD))
return true

if(contain(flag_access, "l") > -1 && (flags & ADMIN_RCON))
return true

if(contain(flag_access, "m") > -1 && (flags & ADMIN_LEVEL_A))
return true

if(contain(flag_access, "n") > -1 && (flags & ADMIN_LEVEL_B))
return true

if(contain(flag_access, "o") > -1 && (flags & ADMIN_LEVEL_C))
return true

if(contain(flag_access, "p") > -1 && (flags & ADMIN_LEVEL_D))
return true

if(contain(flag_access, "q") > -1 && (flags & ADMIN_LEVEL_E))
return true

if(contain(flag_access, "r") > -1 && (flags & ADMIN_LEVEL_F))
return true

if(contain(flag_access, "s") > -1 && (flags & ADMIN_LEVEL_G))
return true

if(contain(flag_access, "t") > -1 && (flags & ADMIN_LEVEL_H))
return true

if(contain(flag_access, "u") > -1 && (flags & ADMIN_MENU))
return true

if(contain(flag_access, "y") > -1 && (flags & ADMIN_ADMIN))
return true

if(contain(flag_access, "z") > -1 && (flags & ADMIN_USER))
return true

return false
}
Доброе утро.
Просьба подтолкнуть на исправление проблемы.
"mp_maxmoney 20000", "#define MAX_MONEY 20000"

Суть проблемы: Если у игрока на балансе 20к, то при получении денег с подарка, баланс уходит в минус .
Почему так и как это исправить?
 
В этой теме было размещено решение! Перейти к решению.
Сообщения
3,593
Реакции
1,576
Помог
141 раз(а)
Код:
if(curr_money + reward > MAX_MONEY)
            reward = MAX_MONEY - curr_money
Ошибка тут.
 
Статус
В этой теме нельзя размещать новые ответы.

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу