ошибка в плагине подарков

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
16
Реакции
0
Ошибка
L 01/15/2018 - 11:40:38: [FUN] Invalid player 11
L 01/15/2018 - 11:40:38: [AMXX] Displaying debug trace (plugin "next21_gifts.amxx")
L 01/15/2018 - 11:40:38: [AMXX] Run time error 10: native error (native "set_user_gravity")
L 01/15/2018 - 11:40:38: [AMXX] [0] next21_gifts.sma::fw_PlayerSpawn (line 163)
ОС
Linux
Билд
Protocol version 48
Exe version 1.1.2.7/Stdio (cstrike)
Exe build: 13:12:29 Aug 29 2013 (6153)
ReGamedll
cs 1.6
Список метамодулей
[ 1] dproto_EF RUN - dproto_i386.so v0.9.582 ini Start Never
[ 2] AMX Mod X RUN - amxmodx_mm_i386. v1.8.2-d ini Start ANY
[ 3] VoiceTranscoder RUN - VoiceTranscoder. v2017RC3 ini ANY ANY
[ 4] FakeDetector RUN - fakedetector_mm_ v2.1.3 ini Start Never
[ 5] Semiclip RUN - semiclip_mm_i386 v2.2 ini ANY ANY
[ 6] WHBlocker RUN - whblocker_mm_i38 v1.5.695 ini Chlvl ANY
[ 7] Fun RUN - fun_amxx_i386.so v1.8.2-d pl2 ANY ANY
[ 8] CStrike RUN - cstrike_amxx_i38 v1.8.2-d pl2 ANY ANY
[ 9] CSX RUN - csx_amxx_i386.so v1.8.2-d pl2 ANY ANY
[10] Engine RUN - engine_amxx_i386 v1.8.2-d pl2 ANY ANY
[11] FakeMeta RUN - fakemeta_amxx_i3 v1.8.2-d pl2 ANY ANY
[12] okapi RUN - okapi_amxx_i386. v1.0 pl2 ANY ANY
[13] Orpheu RUN - orpheu_amxx_i386 v2.6.3 pl2 ANY ANY
[14] MySQL RUN - mysql_amxx_i386. v1.8.2-d pl2 ANY ANY
[15] Ham Sandwich RUN - hamsandwich_amxx v1.8.2-d pl2 ANY ANY
15 plugins, 15 running
Список плагинов
[ 1] opengl detector 0.8.32ob kanagava opengl32.amxx running 
[ 2] FreshBans 1.3.7b kanagava fresh_bans.amxx running
[ 3] DopBan 2.8.2b kanagava dop_ban2.amxx running
[ 4] AIM detector 0.7.4e kanagava aim_detector.am running
[ 5] Aliases checker 0.8.2 kanagava alias_detector0 running
[ 6] WallHack Viewer 15.07.15 SKAJIbnEJIb wallhack_viewer running
[ 7] fb_forwards 0.1.5 Kanagava & Realu fb_forwards.amx running
[ 8] Admin Base 1.8.2 AMXX Dev Team admin.amxx running
[ 9] Admin Commands 1.8.2 AMXX Dev Team admincmd.amxx running
[ 10] Menus Front-End 1.8.2 AMXX Dev Team menufront.amxx running
[ 11] Commands Menu 1.8.2 AMXX Dev Team cmdmenu.amxx running
[ 12] Players Menu 1.8.2 AMXX Dev Team plmenu.amxx running
[ 13] Maps Menu 1.8.2 AMXX Dev Team mapsmenu.amxx running
[ 14] Plugin Menu 1.8.2 AMXX Dev Team pluginmenu.amxx running
[ 15] Admin Chat 1.8.1.3746 AMXX Dev Team adminchat.amxx running
[ 16] Anti Flood 1.8.2 AMXX Dev Team antiflood.amxx running
[ 17] Scrolling Message 1.8.2 AMXX Dev Team scrollmsg.amxx running
[ 18] Info. Messages 1.8.2 AMXX Dev Team imessage.amxx running
[ 19] Admin Votes 1.8.2 AMXX Dev Team adminvote.amxx running
[ 20] Map Manager 2.5.61 Mistrick mapmanager.amxx running
[ 21] NextMap 1.8.2 AMXX Dev Team nextmap.amxx stopped
[ 22] Nextmap Chooser 1.8.2 AMXX Dev Team mapchooser.amxx stopped
[ 23] TimeLeft 1.8.2 AMXX Dev Team timeleft.amxx running
[ 24] Pause Plugins 1.8.2 AMXX Dev Team pausecfg.amxx running
[ 25] Stats Configuration 1.8.2 AMXX Dev Team statscfg.amxx running
[ 26] Restrict Weapons 1.8.2 AMXX Dev Team restmenu.amxx running
[ 27] Vip Menu Ultimate 1.0 Skriptoon goldvipmenu.amx running
[ 28] AES: StatsX 0.2 serfreeman1337 aes_statsx_cstr running
[ 29] StatsX 1.8.2 AMXX Dev Team statsx.amxx running
[ 30] CS Misc. Stats 1.8.2 AMXX Dev Team miscstats.amxx running
[ 31] Lite Admin ESP 1.0 neygomon admin_esp.amxx running
[ 32] Server Menu 1.0 Skriptoon server_menu.amx running
[ 33] New Plug-In 1.0 author vip_menu.amxx running
[ 34] V.I.P Custom Weapons 1.0.0 Vaqtincha vip_custom.amxx running
[ 35] V.I.P Custom AK-47 1.0.0 Vaqtincha custom_ak47.amx running
[ 36] V.I.P Custom AWP 1.0.0 Vaqtincha custom_awp.amxx running
[ 37] V.I.P Custom DEAGLE 1.0.0 Vaqtincha custom_deagle.a running
[ 38] V.I.P Custom KNIFE 1.0.0 Vaqtincha custom_knife.am running
[ 39] V.I.P Custom M4A1 1.0.0 Vaqtincha custom_m4a1.amx running
[ 40] Advanced Experience Sy 0.4 serfreeman1337 aes_main.amxx running
[ 41] AES: Bonus CSTRIKE 0.4 serfreeman1337 aes_bonus_cstri running
[ 42] AES: Bonus System 0.2 serfreeman1337 aes_bonus_syste running
[ 43] AES: Exp CSTRIKE 0.3 serfreeman1337 aes_exp_cstrike running
[ 44] AES: Experience Editor 0.1 serfreeman1337 aes_exp_editor. running
[ 45] AES: Informer 0.2 serfreeman1337 aes_informer.am running
[ 46] Admin Menu 1.0 Skriptoon admin_menu.amxx running
[ 47] Reklama Hud 1.0 Freeman4iK hud_reklama.amx running
[ 48] Autoresponder/Advertis 0.5 MaximusBrood ad_manager.amxx running
[ 49] Admin Check 1.51 OneEyed admin_check.amx running
[ 50] Lady Admin 2.0 AhmetBro lady_admin.amxx debug
[ 51] New Year Admin Models 2.0 Prayer/slash admin_models.am running
[ 52] Afk Control 0.5.1 neygomon afk_control.amx running
[ 53] AMXX Gag 1.3 xPaw & Exolent amx_gag.amxx running
[ 54] High Ping Kicker 1.0 Shadow/Bo0m! amx_hpk.amxx running
[ 55] AMXX Piss 2.0 KRoTaL amxx_piss.amxx running
[ 56] Auto Restart KNIFE 2.0 Leo_[BH] auto_rr.amxx running
[ 57] buy_admin 1.0 sergeychavko buy_admin.amxx running
[ 58] buy_vip 1.0 sergeychavko buy_vip.amxx running
[ 59] Damager 1.0 Prayer damager.amxx running
[ 60] Auto Demo Recorder 2.2.1 F@nt0M demo_recorder.a running
[ 61] Fake Ping 1.1 MeRcyLeZZ/gyxoBk FakePing.amxx running
[ 62] Killer screen fade 1.0 Flazh kill_fade.amxx running
[ 63] Lite Kill Assist 1.17 neygomon lite_kill_assis running
[ 64] Money Transferer 1.3 kalash1k, Edit b money_transfere running
[ 65] Mute 1.0 Makenzo mute.amxx running
[ 66] Parachute 1.3 Fixed KRoT@L/JTP10181 parachute.amxx running
[ 67] Lite TeamBalancer 1.20 neygomon lite_balancer.a running
[ 68] Reset Score 1.0 Silenttt resetscore.amxx running
[ 69] SF Bets 0.1.5 serfreeman1337 sf_bets.amxx running
[ 70] SF MultiJump 0.2 serfreeman1337 sf_multijump.am running
[ 71] SpecList 1.2a FatalisDK speclist.amxx running
[ 72] Screen Shot Menu 1.2 Bonaqua | DimaS ss_menu.amxx running
[ 73] Time Bonus 1.1 SKOBAR1K time_bonus.amxx running
[ 74] Name Change Control 0.1 unnamed changename.amxx running
[ 75] Christmas hat 0.3 AMXX.Shop christmas_hat.a running
[ 76] Gifts 0.8.1 Psycrow next21_gifts.am debug
[ 77] Kill Effect 0.2 neugomon kill_effect.amx running
[ 78] Snow 0.1 XXX snow.amxx running
[ 79] Snowball 0.6 alpha s1lent snowball.amxx debug
[ 80] Snowballs 1.1 FragOwn snowballs.amxx running
[ 81] Lite Translit 2.8 neygomon lite_translit.a running
81 plugins, 79 running
Исходный код
#include <amxmodx>
#include <amxmisc>
#include <fakemeta_util>
#include <hamsandwich>
#include <fun>
#include <WPMGPrintChatColor>

#define PLUGIN "Gifts"
#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 16000 // Максимальное кол-во денег у игрока

#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","a") // Флаг доступа к меню
register_cvar("cv_gift_money_min","1000") // Минимальная награда за собрынный подарок
register_cvar("cv_gift_money_max","5000") // Максимальная награда за собрынный подарок
register_cvar("cv_gift_silent_walk","1") // Добавить ли в подарки бесшумный бег
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","50") // Сколько HP можно получить в подарках. 0 - убрать такой вид подарка
register_cvar("cv_gift_timerate","120.0") // Сколько секунд до появление подарка
register_cvar("cv_gift_get_times_round","3") // Сколько максимум можно собрать подарков за раундов. 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(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
}
помогите исправить, я думаю это из за плагина multijumpа ( двойной прыжок)
 
В этой теме было размещено решение! Перейти к решению.
Сообщения
432
Реакции
410
Помог
14 раз(а)
я думаю это из за плагина multijumpа ( двойной прыжок)
Нет, просто автор - редиска, забыл элементарный чек


Код:
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
}
 
Сообщения
16
Реакции
0
voed, спасибо, я вот только не пойму ваш код вместо какого кода ставить?
 
Сообщения
2,143
Реакции
1,225
Помог
44 раз(а)
Чувствую, что проще просто готовый код дать, чем объяснять, что и где изменить.
C++:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta_util>
#include <hamsandwich>
#include <fun>
#include <WPMGPrintChatColor>
 
#define PLUGIN "Gifts"
#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       16000 // Максимальное кол-во денег у игрока
 
#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","a")       // Флаг доступа к меню
   register_cvar("cv_gift_money_min","1000")    // Минимальная награда за собрынный подарок
   register_cvar("cv_gift_money_max","5000")    // Максимальная награда за собрынный подарок
   register_cvar("cv_gift_silent_walk","1")    // Добавить ли в подарки бесшумный бег
   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","50")       // Сколько HP можно получить в подарках. 0 - убрать такой вид подарка
   register_cvar("cv_gift_timerate","120.0")    // Сколько секунд до появление подарка
   register_cvar("cv_gift_get_times_round","3")    // Сколько максимум можно собрать подарков за раундов. 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
}
 
Статус
В этой теме нельзя размещать новые ответы.

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

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