Бессмертие не афк игроков

Статус
В этой теме нельзя размещать новые ответы.

рпар

Участник
Сообщения
27
Реакции
0
у меня IDLE сервер как сделать чтобы те кто не афк были бесмертные?
 

Madness aka null138

Участник
Сообщения
713
Реакции
734
C++:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

#pragma newdecls required

bool bAfk[MAXPLAYERS + 1] = { false, ... };

public void OnMapStart()
{
    CreateTimer(5.0, OnTimerCheckAfks, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
}

public void OnClientPutInServer(int client)
{
    bAfk[client] = false;
    SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
}

public Action OnTimerCheckAfks(Handle timer)
{
    for (int i = 1; i <= MaxClients; ++i)
    {
        if(IsClientInGame(i)) bAfk[i] = true;
    }
}

public Action OnPlayerRunCmd(int client, int &buttons)
{
    if(IsClientInGame(client) && IsPlayerAlive(client))
    {
        if(buttons & IN_WALK || buttons & IN_ATTACK || buttons & IN_ATTACK2)
        {
            bAfk[client] = false;
        }
    }
}

public Action OnTakeDamage(int client, int &attacker, int &inflictor, float &damage, int &damagetype, int &weapon, float damageForce[3], float damagePosition[3])
{
    if(attacker > 0 && attacker <= MaxClients)
    {
        return bAfk[client] ? Plugin_Continue : Plugin_Handled;
    }
    return Plugin_Continue;
}
 
Статус
В этой теме нельзя размещать новые ответы.
Сверху Снизу