- Ошибка
-
//// afk_control.sma
//
// C:\Users\╨рьрчрэ\Desktop\cs serv\1 compilator_1_9_0\afk_control.sma(234) : error 017: undefined symbol "rg_disappear"
//
// 1 Error.
// Could not locate output file C:\Users\╨рьрчрэ\Desktop\cs serv\1 compilator_1_9_0\compiled\afk_control.amx (compile failed).
//
// Compilation Time: 0,52 sec
// ----------------------------------------
- Компилятор
- Локальный
- Amx Mod X
- 1.9.0
- Исходный код
-
#include <amxmisc> #include <reapi> #include <xs> // Helper macro #define VALID_PLAYER(%0) (1 <= %0 <= MaxClients) #define VALID_TEAM(%0) (TEAM_TERRORIST <= get_member(%0, m_iTeam) <= TEAM_CT) #define IS_MP3(%0) (equal(%0[strlen(%0) - 4], ".mp3")) enum (<<=1) { eNotification_SayText = 1, eNotification_Hud, eNotification_Sound, }; enum (<<=1) { eReset_Button = 1, eReset_Position, eReset_Aim, eReset_SayText, eReset_Menu, }; // Cvars new CVAR__SaveTime, CVAR__MinPlayers, Float:CVAR__MaxTime, CVAR__AFKPercent, CVAR__NotifyTimes, CVAR__ResetTime, CVAR__OnlyKick, CVAR__Notification, CVAR__Notify[64], CVAR__Alert[64], CVAR__AlertStage, CVAR__TransferC4Mode, CVAR__MoneySave, CVAR__ScenarioMode, CVAR__SpecPlayers, Float:CVAR__SpectatorCheckTime, Float:CVAR__SpectatorMaxTime, Float:CVAR__SpectatorMaxTimeVIP, Float:CVAR__SpectatorMenuTime, CVAR__SpecFunction, CVAR__SpecReason[64], CVAR__AFKReason[64]; // Forwards new g_iForward_Stage, g_iForward_Action, g_iForward_Toggle, g_iForward_Return; // Vars new g_pAFKFlag, g_pSPECFlag; new Float:g_LastActivity[33], Float:g_SaveActivity[33]; new Float:g_vecOldOrigin[33][3], Float:g_vecOldViewAngle[33][3]; new g_AFKStage[33], Float:g_flSpectatorThink[33], Float:g_fMarkedSpecTime[33]; public plugin_natives() { register_native("afkc_is_user_afk", "native_afkc_is_user_afk"); register_native("afkc_get_stage", "native_afkc_get_stage"); register_native("afkc_update_activity", "native_afkc_update_activity"); } public plugin_precache() { register_plugin("AFK Control", "2.1.0", "@emmajule"); if (!parseINI()) { set_fail_state("Something went wrong. Check plugin settings!"); return; } precache_sound_ex(CVAR__Notify); precache_sound_ex(CVAR__Alert); } public plugin_init() { register_dictionary("afk_control.txt"); register_event("TeamInfo", "Event_TeamInfo", "a", "1>0", "2=SPECTATOR"); register_menu("Show_AfkControlMenu", 1<<0, "Handle_AfkControlMenu"); register_clcmd("menuselect", "clcmd_menuselect"); RegisterHookChain(RG_CBasePlayer_PreThink, "CBasePlayer_PreThink", true); RegisterHookChain(RG_CBasePlayer_Killed, "CBasePlayer_Killed", false); RegisterHookChain(RG_CSGameRules_CheckWinConditions, "CSGameRules_CheckWinConditions", true); g_iForward_Stage = CreateMultiForward("afkc_stage", ET_IGNORE, FP_CELL, FP_FLOAT, FP_VAL_BYREF); g_iForward_Action = CreateMultiForward("afkc_action", ET_CONTINUE, FP_CELL); g_iForward_Toggle = CreateMultiForward("afkc_toggle", ET_IGNORE, FP_CELL, FP_CELL); } public client_putinserver(id) { g_SaveActivity[id] = g_LastActivity[id] = 0.0; g_flSpectatorThink[id] = get_gametime(); } /* public clcmd_hostsay(id) { g_LastActivity[id] = 0.0; } */ public clcmd_menuselect(id) { if (!(CVAR__ResetTime & eReset_Menu)) { return 0; } g_LastActivity[id] = 0.0; return 0; } public Event_TeamInfo() { new pClient = read_data(1); g_SaveActivity[pClient] = g_LastActivity[pClient] = 0.0; g_flSpectatorThink[pClient] = get_gametime(); } public CBasePlayer_Killed(const id, attacker, gib) { if (!CVAR__SaveTime) { g_SaveActivity[id] = get_gametime() - g_LastActivity[id]; } g_LastActivity[id] = 0.0; return HC_CONTINUE; } public CBasePlayer_PreThink(const id) { // Учет живых игроков AFK__Think(id); // Учет зрителей Spectator__Think(id); } AFK__Think(const id) { if (!is_user_alive(id)) { return; } new Float:fGameTime = get_gametime(); if (CheckActivityInGame(id) || !g_LastActivity[id]) { g_LastActivity[id] = fGameTime; // iWarnings = 0; } if (g_SaveActivity[id] > 0.0) { // g_LastActivity[id] = g_LastActivity[id] - (fGameTime - g_SaveActivity[id]); g_LastActivity[id] = g_LastActivity[id] - g_SaveActivity[id]; g_SaveActivity[id] = 0.0; } new currentStage = g_AFKStage[id]; new Float:fLastMovement = fGameTime - g_LastActivity[id]; new AFKStage = min(100, floatround(fLastMovement * 100.0 / CVAR__MaxTime, floatround_tozero)); new bIsWarning = (AFKStage % (100 / CVAR__NotifyTimes) == 0); new bIsVIP = (get_user_flags(id) & g_pAFKFlag); if (currentStage == AFKStage) { return; } else { // g_AFKStage[id] = AFKStage; } // forward afkc_stage(id, Float:lastActivity, &stage) ExecuteForward(g_iForward_Stage, _, id, g_LastActivity[id], AFKStage); if (AFKStage < GetAFKTime() <= currentStage) { if (CVAR__Alert[0] && currentStage >= CVAR__AlertStage) { client_cmd(id, ";mp3 stop"); } // forward afkc_toggle(id, bool:status) ExecuteForward(g_iForward_Toggle, _, id, false); } g_AFKStage[id] = AFKStage; if (!AFKStage) { return; } // Иммунитет от действия плагина if (bIsVIP || get_playersnum() < CVAR__MinPlayers) { g_LastActivity[id] = 0.0; return; } if (afkc_is_user_afk(id) && get_member(id, m_bHasC4)) { if (CVAR__TransferC4Mode == 1 || CVAR__TransferC4Mode == 2 && !transfer_c4(id)) { rg_drop_item(id, "weapon_c4"); } } // if (fLastMovement >= CVAR__MaxTime) if (AFKStage >= 100) { // forward afkc_action(id) ExecuteForward(g_iForward_Action, g_iForward_Return, id); if (g_iForward_Return > PLUGIN_CONTINUE) { // g_LastActivity[id] = 0.0; return; } if ((CVAR__OnlyKick == 1 && !bIsVIP) || CVAR__OnlyKick == 2) { // AFK_KICK = ^3%n ^1был кикнут с сервера, причина:^4 %s client_print_color(0, id, "%l %l", "AFK_PREFIX", "AFK_KICK", id, CVAR__AFKReason); rh_drop_client(id, CVAR__AFKReason); return; } rg_disappear(id); rg_join_team(id, TEAM_SPECTATOR); // AFK_TRANSFER_TO_SPECTATE = ^3%n^1 переведен в наблюдение за простой! client_print_color(0, id, "%l %l", "AFK_PREFIX", "AFK_TRANSFER_TO_SPECTATE", id); if (!CVAR__MoneySave) { rg_add_account(id, get_cvar_num("mp_startmoney"), AS_SET, false); } if (CVAR__Alert[0]) { client_cmd(id, ";mp3 stop"); } // Out of code return; } // В этот момент игрок получает статус AFK if (AFKStage == GetAFKTime()) { // forward afkc_toggle(id, bool:status) ExecuteForward(g_iForward_Toggle, _, id, true); if (bIsWarning) { } if (CVAR__ScenarioMode != 0) { rg_check_win_conditions(); } } if (AFKStage == CVAR__AlertStage) { PlaySoundToClients(id, CVAR__Alert); } // Уведомления if (bIsWarning) { if (CVAR__Notification & eNotification_SayText) { // AFK_NOTIFY_CHAT = ^3 Вы не проявляете активность! Через^4 %.0f сек.^3 вы будете кикнуты! client_print_color(id, print_team_red, "%l %l", "AFK_PREFIX", "AFK_NOTIFY_CHAT", CVAR__MaxTime - fLastMovement); } if (CVAR__Notification & eNotification_Hud) { // AFK_NOTIFY_HUD = Вы не проявляете активность!^nЧерез %.0f сек. вы будете кикнуты! set_hudmessage(0, 200, 200, -1.0, 0.75, 1, 2.0, 3.0, 0.2, 0.4); show_hudmessage(id, "%l", "AFK_NOTIFY_HUD", CVAR__MaxTime - fLastMovement); } if (CVAR__Notification & eNotification_Sound) { PlaySoundToClients(id, CVAR__Notify); } } // g_AFKStage[id] = AFKStage; } Spectator__Think(const id) { if (!g_flSpectatorThink[id]) { return; } new Float:fGameTime = get_gametime(); if (g_fMarkedSpecTime[id] > fGameTime) { return; } // check every 5 sec g_fMarkedSpecTime[id] = fGameTime + CVAR__SpectatorCheckTime; new bIsVIP = (get_user_flags(id) & g_pSPECFlag); new bPickTeam = (get_member(id, m_iMenu) == Menu_ChooseAppearance); // Выбор команды не должен считать нас как в игре if (is_user_hltv(id) || (VALID_TEAM(id) && !bPickTeam)) { g_flSpectatorThink[id] = 0.0; return; } // Игнорирование и апдейт метки if (get_playersnum() < CVAR__SpecPlayers || (bIsVIP && !CVAR__SpectatorMaxTimeVIP)) { g_flSpectatorThink[id] = fGameTime; return; } new Float:maxTime = bIsVIP ? CVAR__SpectatorMaxTimeVIP : CVAR__SpectatorMaxTime; new Float:timeElapsed = floatmax(0.0, fGameTime - g_flSpectatorThink[id]); new Float:timeLeft = maxTime - timeElapsed; if (timeLeft <= 0.0) { // AFK_KICK = ^3%n ^1был кикнут с сервера, причина:^4 %s client_print_color(0, id, "%l %l", "AFK_PREFIX", "AFK_KICK", id, CVAR__SpecReason); rh_drop_client(id, CVAR__SpecReason); return; } if (bPickTeam) { return; } // if (timeLeft - CVAR__SpectatorCheckTime < timeLeft <= CVAR__SpectatorMenuTime) if (timeLeft <= CVAR__SpectatorMenuTime) { showConfirmMenu(id); if (CVAR__Alert[0]) { // PlaySoundToClients(id, CVAR__Alert); } } } public CSGameRules_CheckWinConditions() { if (!CVAR__ScenarioMode) { return; } if (get_member_game(m_bRoundTerminating)) { return; } new AFKCount[TeamName]; new TeamName:team; // static AFKNotify[TeamName]; for (new i = MaxClients; i > 0; --i) { if (!is_user_alive(i)) { continue; } team = get_member(i, m_iTeam); if (afkc_is_user_afk(i)) { AFKCount[team]++; } else { AFKCount[team] = -1337; } } if (AFKCount[TEAM_TERRORIST] > 0) { // AFK_TERRORIST_LEFT = Все оставшийся игроки команды^3 TERRORIST^1 находятся^4 AFK !!! client_print_color(0, print_team_red, "%l %l", "AFK_PREFIX", "AFK_TERRORIST_LEFT", AFKCount[TEAM_TERRORIST]); if (CVAR__ScenarioMode == 2) { rg_round_end(get_cvar_float("mp_round_restart_delay"), WINSTATUS_CTS, ROUND_CTS_WIN, .trigger = true); } } if (AFKCount[TEAM_CT] > 0) { // AFK_CT_LEFT = Все оставшийся игроки команды^3 CT^1 находятся^4 AFK !!! client_print_color(0, print_team_blue, "%l %l", "AFK_PREFIX", "AFK_CT_LEFT", AFKCount[TEAM_CT]); if (CVAR__ScenarioMode == 2) { rg_round_end(get_cvar_float("mp_round_restart_delay"), WINSTATUS_TERRORISTS, ROUND_TERRORISTS_WIN, .trigger = true); } } } transfer_c4(const id) { // new aPlayers[32], iCount; // rg_initialize_player_counts(iCount, _, _, _); new Float:dist, Float:best_dist; new player; for (new i = MaxClients; i > 0; --i) { if (i == id) { continue; } if (!is_user_alive(i)) { continue; } if (get_member(i, m_iTeam) != TEAM_TERRORIST) { continue; } if (afkc_is_user_afk(i)) { continue; } dist = rg_entity_range(id, i); // aPlayers[iCount++] = i; if (!best_dist || dist < best_dist) { best_dist = dist; player = i; } } if (!player) { return false; } // SortIntegers(aPlayers, iCount, Sort_Random); // new pClient = aPlayers[random_num(0, iCount - 1)]; return rg_transfer_c4(id, player); } showConfirmMenu(const id) { new text[512]; new len; // AFK_MENU_TITLE = \r[yAFK\r] \wВы будете кикнуты через\r %.0f\w секунд!^nВы следите за игрой!^n^n // AFK_MENU_ITEM = \r1.\w ДА len = formatex(text, charsmax(text), "%l", "AFK_MENU_TITLE", CVAR__SpectatorMaxTime - (get_gametime() - g_flSpectatorThink[id])); len += formatex(text[len], charsmax(text) - len, "%l", "AFK_MENU_ITEM"); show_menu(id, 1<<0, text, -1, "Show_AfkControlMenu"); } public Handle_AfkControlMenu(id, key) { if (!is_user_connected(id)) { return 1; } if (VALID_TEAM(id)) { return 1; } if (key == 0) { switch (CVAR__SpecFunction) { case 0: { g_flSpectatorThink[id] = get_gametime(); } case 1: { g_flSpectatorThink[id] = 0.0; } default: { g_flSpectatorThink[id] = get_gametime() + float(CVAR__SpecFunction); } } // AFK_MENU_CONFIRM = Вы подтвердили что вы в игре! client_print_color(id, print_team_default, "%l %l", "AFK_PREFIX", "AFK_MENU_CONFIRM"); } return 1; } parseINI() { new path[PLATFORM_MAX_PATH]; get_configsdir(path, charsmax(path)); strcat(path, "/afk_control.ini", charsmax(path)); if (!file_exists(path)) { return false; } new INIParser:parser = INI_CreateParser(); if (parser == Invalid_INIParser) { return false; } INI_SetReaders(parser, "INI_Values"); INI_ParseFile(parser, path); INI_DestroyParser(parser); return true; } public bool:INI_Values(INIParser:handle, const key[], const value[]) { // server_print("key: %s | value: %s", key, value); if (equal(key, "SAVE_TIME")) { CVAR__SaveTime = str_to_num(value); } if (equal(key, "IMMUNITY")) { // copy(CVAR__Access, 15, value); g_pAFKFlag = read_flags_ex(value); } if (equal(key, "MIN_PLAYERS")) { CVAR__MinPlayers = str_to_num(value); } if (equal(key, "MAX_TIME")) { CVAR__MaxTime = str_to_float(value); } if (equal(key, "AFK_PERCENT")) { CVAR__AFKPercent = str_to_num(value); } if (equal(key, "WARNINGS")) { CVAR__NotifyTimes = str_to_num(value); } if (equal(key, "RESET_TIME")) { CVAR__ResetTime = read_flags(value); } if (equal(key, "KICK")) { CVAR__OnlyKick = str_to_num(value); } if (equal(key, "NOTIFICATION")) { CVAR__Notification = read_flags(value); } if (equal(key, "SAMPLE_NOTIFY")) { copy(CVAR__Notify, 63, value); } if (equal(key, "ALERT_NOTIFY") && value[0] != EOS) { if (!IS_MP3(value)) { server_print("[AFK Control] Только .mp3 формат доступен для настройки ALERT_NOTIFY"); return true; } copy(CVAR__Alert, 63, value); } if (equal(key, "ALERT_PERCENT")) { CVAR__AlertStage = str_to_num(value); } if (equal(key, "BOMB_TRANSFER")) { CVAR__TransferC4Mode = str_to_num(value); } if (equal(key, "MONEY_SAVE")) { CVAR__MoneySave = str_to_num(value); } if (equal(key, "SCENARIO_MODE")) { CVAR__ScenarioMode = str_to_num(value); } if (equal(key, "SPEC_MIN_PLAYERS")) { CVAR__SpecPlayers = str_to_num(value); } if (equal(key, "SPEC_CHECK")) { CVAR__SpectatorCheckTime = floatmax(1.0, str_to_float(value)); } if (equal(key, "SPEC_ACCESS")) { // copy(CVAR__SpecAccess, 15, value); g_pSPECFlag = read_flags_ex(value); } if (equal(key, "SPEC_MAX_TIME")) { CVAR__SpectatorMaxTime = str_to_float(value); } if (equal(key, "SPEC_MAX_TIME_VIP")) { CVAR__SpectatorMaxTimeVIP = str_to_float(value); } if (equal(key, "SPEC_MENU_TIME_LEFT")) { CVAR__SpectatorMenuTime = str_to_float(value); } if (equal(key, "SPEC_MENU_FUNCTION")) { CVAR__SpecFunction = str_to_num(value); } if (equal(key, "AFK_REASON")) { copy(CVAR__AFKReason, 63, value); } if (equal(key, "SPEC_REASON")) { copy(CVAR__SpecReason, 63, value); } return true; } bool:CheckActivityInGame(const id) { static Float:vecPos[3], Float:vecAngle[3]; get_entvar(id, var_origin, vecPos); get_entvar(id, var_v_angle, vecAngle); new bool:bAFK = true; if (CVAR__ResetTime & eReset_Button) { if (get_entvar(id, var_button) > 0) bAFK = false; } if (CVAR__ResetTime & eReset_Position) { if (!xs_vec_equal(vecPos, g_vecOldOrigin[id])) bAFK = false; } if (CVAR__ResetTime & eReset_Aim) { new Float:deltaPitch = (g_vecOldViewAngle[id][0] - vecAngle[0]); new Float:deltaYaw = (g_vecOldViewAngle[id][1] - vecAngle[1]); if (floatabs(deltaYaw) >= 0.1 && floatabs(deltaPitch) >= 0.1) bAFK = false; } if (CVAR__ResetTime & eReset_SayText) { if (get_gametime() - Float:get_member(id, m_flLastTalk) < 5.0) bAFK = false; } xs_vec_copy(vecPos, g_vecOldOrigin[id]); xs_vec_copy(vecAngle, g_vecOldViewAngle[id]); return !bAFK; } stock read_flags_ex(const flags[]) { if (!flags[0] || flags[0] == '0') { return ADMIN_ALL; } return read_flags(flags); } stock precache_sound_ex(sound[]) { if (!sound[0]) { return; } if (IS_MP3(sound)) { precache_generic(sound); } else { // precache_sound(sound[6]); precache_sound(sound); } } stock afkc_is_user_afk(const id) { if (g_AFKStage[id] >= GetAFKTime()) { return true; } return false; } PlaySoundToClients(const id, const sound[]) { if (IS_MP3(sound)) { client_cmd(id, "mp3 play ^"%s^"", sound); } else { client_cmd(id, "spk ^"%s^"", sound); } } GetAFKTime() { new perc = CVAR__AFKPercent; if (perc <= 0) { perc = 100 / CVAR__NotifyTimes; } return perc; } // Same as fm_entity_range (fakemeta_util.inc) stock Float:rg_entity_range(ent1, ent2) { static Float:origin1[3], Float:origin2[3]; get_entvar(ent1, var_origin, origin1); get_entvar(ent2, var_origin, origin2); return get_distance_f(origin1, origin2); } /** * Check if player is afk * * @param id Player index * * @return true on success, false otherwise */ public native_afkc_is_user_afk(plugin, argc) { new id = get_param(1); if (!VALID_PLAYER(id)) { return false; } return afkc_is_user_afk(id); } /** * Gets the current afk player status stage * * @param id Player index * * @return AFC stage as a percentage (from 0 to 100) */ public native_afkc_get_stage(plugin, argc) { new id = get_param(1); if (!VALID_PLAYER(id)) { return 0; } return g_AFKStage[id]; } /** * Instant update of the player's last activity time * * @note The second parameter should include local game time (func: get_gametime()) * Use 0 to reset activity time * * @note The activity time is calculated for each new frame of the player * * @param id Player index * @param time New time * * @return true on success, false otherwise */ public native_afkc_update_activity(plugin, argc) { new id = get_param(1); new Float:time = get_param_f(2); if (!VALID_PLAYER(id)) { return false; } g_LastActivity[id] = time; return true; }
C++
Инклуд от самого плагина на месте. Недавно и другие инк обновлял. На всякий случай прикреплю и сма и инк.
В этой теме было размещено решение! Перейти к решению.
Download all Attachments
-
17.2 KB Просмотры: 15
-
1.8 KB Просмотры: 11