Ejemplo n.º 1
0
static cell_t KickClientEx(IPluginContext *pContext, const cell_t *params)
{
    int client = params[1];

    IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(client);
    if (!pPlayer)
    {
        return pContext->ThrowNativeError("Client index %d is invalid", client);
    }
    else if (!pPlayer->IsConnected())
    {
        return pContext->ThrowNativeError("Client %d is not connected", client);
    }

    g_pSM->SetGlobalTarget(client);

    char buffer[256];
    {
        DetectExceptions eh(pContext);
        g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2);
        if (eh.HasException())
            return 0;
    }

    pPlayer->Kick(buffer);

    return 1;
}
Ejemplo n.º 2
0
static cell_t KickClient(IPluginContext *pContext, const cell_t *params)
{
    int client = params[1];

    IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(client);
    if (!pPlayer)
    {
        return pContext->ThrowNativeError("Client index %d is invalid", client);
    }
    else if (!pPlayer->IsConnected())
    {
        return pContext->ThrowNativeError("Client %d is not connected", client);
    }

    /* Ignore duplicate kicks */
    if (pPlayer->IsInKickQueue())
    {
        return 1;
    }

    g_pSM->SetGlobalTarget(client);

    char buffer[256];
    {
        DetectExceptions eh(pContext);
        g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2);
        if (eh.HasException())
            return 0;
    }

    if (pPlayer->IsFakeClient())
    {
        // Kick uses the kickid command for bots. It is already delayed
        // until the next frame unless someone flushes command buffer
        pPlayer->Kick(buffer);
        return 1;
    }

    gamehelpers->AddDelayedKick(client, pPlayer->GetUserId(), buffer);

    return 1;
}