AFK Control первая проверка

Сообщения
11
Реакции
1
Ошибка
Первая проверка на афк не работает.Суть в том,что с момента респавна игрока идет проверка игрока на афк,но первая проверка по кварам проходит мимо,и его убивает дольше.
ОС
Windows
Amx Mod X
AMX Mod X 1.9.0.5294 (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: Dec 3 2021 22:52:28
Built from: https://github.com/alliedmodders/amxmodx/commit/363871a8
Build ID: 5294:363871a8
Core mode: JIT+ASM32
Билд
AMX Mod X 1.9.0.5294 (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: Dec 3 2021 22:52:28
Built from: https://github.com/alliedmodders/amxmodx/commit/363871a8
Build ID: 5294:363871a8
Core mode: JIT+ASM32
ReGamedll
ReGameDLL version: 5.21.0.546-dev
Build date: 15:32:37 Dec 28 2021
Build from: https://github.com/s1lentq/ReGameDLL_CS/commit/09a6c61
Версия Metamod
Metamod-r v1.3.0.128, API (5:13)
Metamod-r build: 15:47:38 Aug 24 2018
Metamod-r from: https://github.com/theAsmodai/metamod-r/commit/0cf2f70
Список метамодулей
[ 1] AMX Mod X        RUN   -    amxmodx_mm.dll        v1.9.0.5294      ini  Start ANY
[ 2] Reunion RUN - reunion_mm.dll v0.1.92d ini Start Never
[ 3] YaPB RUN - yapb.dll v4.2.671 ini Chlvl ANY
[ 4] SafeNameAndChat RUN - safenameandchat.dll v1.2 Beta 3 ini ANY ANY
[ 5] mmtimer RUN - mmtimer.dll v1.6 ini ANY Never
[ 6] FakeMeta RUN - fakemeta_amxx.dll v1.9.0.5294 pl1 ANY ANY
[ 7] CStrike RUN - cstrike_amxx.dll v1.9.0.5294 pl1 ANY ANY
[ 8] Ham Sandwich RUN - hamsandwich_amxx.dll v1.9.0.5294 pl1 ANY ANY
[ 9] ReAPI RUN - reapi_amxx.dll v5.21.0.252-dev pl1 ANY Never
[10] MySQL RUN - mysql_amxx.dll v1.9.0.5294 pl1 ANY ANY
[11] Engine RUN - engine_amxx.dll v1.9.0.5294 pl1 ANY ANY
[12] Fun RUN - fun_amxx.dll v1.9.0.5294 pl1 ANY ANY
Список плагинов
name                    version     author            file             status
[ 1] Admin Base 1.9.0.5294 AMXX Dev Team admin.amxx running
[ 2] Admin Commands 1.9.0.5294 AMXX Dev Team admincmd.amxx running
[ 3] Multi-Lingual System 1.9.0.5294 AMXX Dev Team multilingual.am running
[ 4] Menus Front-End 1.9.0.5294 AMXX Dev Team menufront.amxx running
[ 5] Commands Menu 1.9.0.5294 AMXX Dev Team cmdmenu.amxx running
[ 6] Players Menu 1.9.0.5294 AMXX Dev Team plmenu.amxx running
[ 7] Maps Menu 1.9.0.5294 AMXX Dev Team mapsmenu.amxx running
[ 8] Admin Chat 1.9.0.5294 AMXX Dev Team adminchat.amxx running
[ 9] Anti Flood 1.9.0.5294 AMXX Dev Team antiflood.amxx running
[ 10] Admin Votes 1.9.0.5294 AMXX Dev Team adminvote.amxx running
[ 11] NextMap 1.9.0.5294 AMXX Dev Team nextmap.amxx running
[ 12] Nextmap Chooser 1.9.0.5294 AMXX Dev Team mapchooser.amxx running
[ 13] TimeLeft 1.9.0.5294 AMXX Dev Team timeleft.amxx running
[ 14] Advanced Kill Assists 1.3c Xelson next21_kill_ass debug
[ 15] CSStatsX SQL 0.7.4+2 serfreeman1337 csstatsx_sql.am debug
[ 16] CSXSQL: Onlinetime Awa 0.2 serfreeman1337 csstatsx_playti running
[ 17] AES: StatsX 0.5+1 serfreeman1337 aes_statsx_cstr debug
[ 18] AES: Bonus CSTRIKE 0.5.9.1 [R serfreeman1337/s aes_bonus_cstri running
[ 19] AES: Bonus System 0.5.9 Vega serfreeman1337/s aes_bonus_syste running
[ 20] Advanced Experience Sy 0.5.9 [REA serfreeman1337/s aes_main.amxx running
[ 21] AES: CStrike Addon 0.5.9 [REA serfreeman1337/s aes_exp_cstrike debug
[ 22] AES: Informer 0.5.9 [REA serfreeman1337/s aes_informer.am debug
[ 23] VIP 1.5 by4udilo admin_vip.amxx running
[ 24] draw off 0.7 by4udilo no_draw.amxx running
[ 25] FPS Meter 1.1 neygomon fps.amxx running
[ 26] unknown unknown unknown sv_restart.amxx running
[ 27] [ReAPI] Block 'Fire in 0.0.1 sergrib reapi_block_FIT running
[ 28] Bomb Taker 0.0.1b Vaqtincha c4_taker.amxx stopped
[ 29] AFK Control ReNew 1.2(a) neygomon afk_control.amx running
[ 30] Chat Manager: Addon 0.0.4-70 Mistrick chatmanager_add running
[ 31] Chat Manager 1.1.2-16 Mistrick chatmanager.amx running
Автор плагина
neygomon
Версия плагина
AFK Control ReNew 1.2(a)
Исходный код
#include <amxmodx>
#include <amxmisc>
#include <reapi>
#include <xs>

#define CHAT_PREFIX "^4[^3DP AFK MANAGER^4]"

enum _:cvars {
MAX_AFK_WARNS,
MAX_SPEC_WARNS,
Float:TIME_AFK_CHECK,
MIN_SPEC_PLAYERS_CHECK,
IMMUNITY_FLAGS,
TRANSFER_BOMB
}
enum coords {
Float:ORIGIN[3],
Float:ANGLES[3]
}
enum warns {
AFK,
SPEC
}

new Float:g_fCoords[MAX_PLAYERS + 1][coords];
new g_iPlayerWarn[MAX_PLAYERS + 1][warns];
new bool:g_IsBot[MAX_PLAYERS + 1];

new g_Cvar[cvars];

public plugin_init()
{
register_plugin("AFK Control ReNew", "1.2(a)", "neygomon");
register_dictionary("afk_control.txt");

RegisterHookChain(RG_CSGameRules_PlayerSpawn, "CSGameRules_PlayerSpawn_Post", true);
RegisterHookChain(RG_CBasePlayer_Killed, "CBasePlayer_Killed_Post", true);

bind_pcvar_num(
create_cvar(
"afk_max_afk_warns",
"3",
.description = fmt("%l", "DESC_MAX_AFK_WARNS"),
.has_min = true,
.min_val = 1.0
),
g_Cvar[MAX_AFK_WARNS]
);
bind_pcvar_num(
create_cvar(
"afk_max_spec_warns",
"2",
.description = fmt("%l", "DESC_MAX_SPEC_WARNS"),
.has_min = true,
.min_val = 1.0
),
g_Cvar[MAX_SPEC_WARNS]
);
bind_pcvar_num(
create_cvar(
"afk_min_spec_players",
"30",
.description = fmt("%l", "DESC_MIN_SPEC_PLRS")
),
g_Cvar[MIN_SPEC_PLAYERS_CHECK]
);
bind_pcvar_num(
create_cvar(
"afk_transfer_bomb",
"1",
.description = fmt("%l", "DESC_TRANSFER_BOMB")
),
g_Cvar[TRANSFER_BOMB]
);
bind_pcvar_float(
create_cvar(
"afk_time_afk_check",
"10.0",
.description = fmt("%l", "DESC_TIME_AFK_CHECK"),
.has_min = true,
.min_val = 5.0
),
g_Cvar[TIME_AFK_CHECK]
);

new pCvar1 = create_cvar(
"afk_time_spec_check",
"15.0",
.description = fmt("%l", "DESC_TIME_SPEC_CHECK"),
.has_min = true,
.min_val = 10.0
)

new pCvar2 = create_cvar(
"afk_immunity_flags",
"a",
.description = fmt("%l", "DESC_IMMUNITY_FLAGS")
);

AutoExecConfig();
hook_cvar_change(pCvar2, "hook__cvar_change");
new szFlags[32]; get_pcvar_string(pCvar2, szFlags, charsmax(szFlags));
read__flags(szFlags);

set_task_ex(get_pcvar_float(pCvar1), "check_spectators", .flags = SetTask_Repeat);
}

public client_putinserver(id)
{
g_IsBot[id] = bool:(is_user_hltv(id) || is_user_bot(id));
g_iPlayerWarn[id][SPEC] = 0;
}

public client_disconnected(id)
remove_task(id);

public hook__cvar_change(pCvar, szOldValue[], szNewValue[])
read__flags(szNewValue);

public CSGameRules_PlayerSpawn_Post(const id)
{
if(g_IsBot[id]/* || !is_user_alive(id)*/ || get_user_flags(id) & g_Cvar[IMMUNITY_FLAGS])
return;

g_iPlayerWarn[id][AFK] = 0;
get_entvar(id, var_origin, g_fCoords[id][ORIGIN]);
get_entvar(id, var_angles, g_fCoords[id][ANGLES]);
// server_cmd("say 1:id:%d or: %d ang:%d",id,g_fCoords[id][ORIGIN],g_fCoords[id][ANGLES])

remove_task(id);

set_task_ex(g_Cvar[TIME_AFK_CHECK], "check_afk", id, .flags = SetTask_Repeat);
}

public CBasePlayer_Killed_Post(const id)
remove_task(id);

public check_afk(id)
{
if(!is_user_alive(id))
remove_task(id);
else
{
static Float:fOrigin[3], Float:fAngles[3];
get_entvar(id, var_origin, fOrigin);
get_entvar(id, var_angles, fAngles);
// server_cmd("say 2:id:%d or: %d ang:%d",id,fOrigin,fAngles)

if(!xs_vec_equal(g_fCoords[id][ORIGIN], fOrigin) || !xs_vec_equal(g_fCoords[id][ANGLES], fAngles))
{
g_iPlayerWarn[id][AFK] = 0;
xs_vec_copy(fOrigin, g_fCoords[id][ORIGIN]);
xs_vec_copy(fAngles, g_fCoords[id][ANGLES]);
}
else if(++g_iPlayerWarn[id][AFK] >= g_Cvar[MAX_AFK_WARNS])
{
user_kill(id, 1);
rg_internal_cmd(id, "jointeam", "6");
rg_send_audio(id, "sound/events/friend_died.wav");
client_print_color(0, id, "%s %l", CHAT_PREFIX, "MSG_TRANSFER_PLAYER", id);
}
else
{
if(rg_has_item_by_name(id, "weapon_c4"))
{
new players[MAX_PLAYERS], pnum;
get_players_ex(players, pnum, GetPlayers_ExcludeDead|GetPlayers_MatchTeam, "TERRORIST");

client_print_color(0, id, "%s %l", CHAT_PREFIX, "MSG_TRANSFER_BOMB", id);

if(g_Cvar[TRANSFER_BOMB])
if(pnum > 1)
rg_transfer_c4(id, 0);
else rg_drop_items_by_slot(id, C4_SLOT);
else rg_drop_items_by_slot(id, C4_SLOT);
}

rg_send_audio(id, "sound/events/tutor_msg.wav");
client_print_color(id, print_team_default, "%s %l", CHAT_PREFIX, "MSG_PLAYER_CHECK_ACTIVITY", g_iPlayerWarn[id][AFK], g_Cvar[MAX_AFK_WARNS]);
}
}
}

public check_spectators()
{
if(get_playersnum() < g_Cvar[MIN_SPEC_PLAYERS_CHECK])
return;

new players[MAX_PLAYERS], pnum;
get_players_ex(players, pnum, GetPlayers_ExcludeBots|GetPlayers_ExcludeHLTV|GetPlayers_MatchTeam, "SPECTATOR");
for(new i, id; i < pnum; i++)
{
id = players[i];

if(get_user_flags(id) & g_Cvar[IMMUNITY_FLAGS])
continue;

switch(get_member(id, m_iTeam))
{
case TEAM_UNASSIGNED, TEAM_SPECTATOR:
{
if(++g_iPlayerWarn[id][SPEC] >= g_Cvar[MAX_SPEC_WARNS])
{
client_print_color(0, id, "%s %l", CHAT_PREFIX, "MSG_KICK_SPEC_REASON", id);
server_cmd("kick #%d %l", get_user_userid(id), "MSG_KICK_PLAYER_REASON");
}
}
}
}
}

read__flags(str[])
g_Cvar[IMMUNITY_FLAGS] = read_flags(str);
Кикает с запозданием.
 
Последнее редактирование:
Сообщения
11
Реакции
1
Проблема в картах,спавн происходит чуть выше земли,и игрок смещается немного,тем самым сбрасывая счетчик.
Код:
public CSGameRules_PlayerSpawn_Post(id)
{   
    remove_task(id);
    remove_task(id+983);
    set_task_ex(0.5, "task_spawn", id+983);
}
public task_spawn(taskid)
{
    new id = taskid-983
    if(g_IsBot[id] || !is_user_alive(id) || get_user_flags(id) & g_Cvar[IMMUNITY_FLAGS])
        return;

    g_iPlayerWarn[id][AFK] = 0;
    get_entvar(id, var_origin, g_fCoords[id][ORIGIN]);
    get_entvar(id, var_angles, g_fCoords[id][ANGLES]);
    
    remove_task(id);

    set_task_ex(g_Cvar[TIME_AFK_CHECK], "check_afk", id, .flags = SetTask_Repeat);
}
Решил маленькой задержкой в пол секунды,не уверен что её хватит для всех карт,но для $2000$ хватило.
 
Сообщения
397
Реакции
221
Помог
13 раз(а)
by4udilo, Сделайте таск с проверкой на то "находится ли игрок на земле". Если да, даёте добро на начало проверки, если нет таск повторяется.
Код:
if(get_entvar(pPlayer,var_flags) & FL_ONGROUND)
 

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

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