Beispiel #1
0
static cell_t GetPlayerMaxs(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->IsInGame()) {
        return pContext->ThrowNativeError("Client %d is not in game", client);
    }

    IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
    if (!pInfo)
    {
        return pContext->ThrowNativeError("IPlayerInfo not supported by game");
    }

    cell_t *pVec;
    pContext->LocalToPhysAddr(params[2], &pVec);

    float x, y, z;
    bridge->playerInfo->GetPlayerMaxs(pInfo, &x, &y, &z);
    pVec[0] = sp_ftoc(x);
    pVec[1] = sp_ftoc(y);
    pVec[2] = sp_ftoc(z);

    return 1;
}
	int __thiscall RevivedByDefib::OnRevived(CBaseEntity *pInitiator, void *deathModel)
	{
		CBaseEntity* pTarget = reinterpret_cast<CBaseEntity*>(this);
		cell_t client = gamehelpers->EntityToBCompatRef(pTarget);

		IGamePlayer* pGamePlayer = playerhelpers->GetGamePlayer(client);
		if(pGamePlayer) {
			IPlayerInfo* pInfo = pGamePlayer->GetPlayerInfo();
			if(pInfo) {
				r_nowAlive(pInfo->GetAbsOrigin(), g_dead_players, arraysize(g_dead_players));
				L4D_DEBUG_LOG("RevivedByDefib called for: %s", pInfo->GetName());
			}
		}


		return (this->*(GetTrampoline()))(pInitiator, deathModel);
	}
Beispiel #3
0
cell_t GetSurvivorScore(IPluginContext *pContext, const cell_t *params) {
	CBaseEntity *pPlayer = gamehelpers->ReferenceToEntity(params[1]);
	if (!pPlayer)
		return pContext->ThrowNativeError("Invalid client index %d", params[1]);

	cell_t client = gamehelpers->ReferenceToIndex(params[1]);

	IGamePlayer *pGamePlayer = playerhelpers->GetGamePlayer(client);
	if (!pGamePlayer || !pGamePlayer->IsInGame())
		return pContext->ThrowNativeError("Client index %d not in game", params[1]);

	IPlayerInfo* pInfo = pGamePlayer->GetPlayerInfo();
	if(!pInfo || pInfo->IsObserver() || pInfo->GetTeamIndex() != 2)
		return -1;

	return Detours::g_scores[client];
}
Beispiel #4
0
static cell_t GetArmorValue(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->IsInGame()) {
        return pContext->ThrowNativeError("Client %d is not in game", client);
    }

    IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
    if (!pInfo)
    {
        return pContext->ThrowNativeError("IPlayerInfo not supported by game");
    }

    return bridge->playerInfo->GetArmorValue(pInfo);
}
Beispiel #5
0
static cell_t GetWeaponName(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->IsInGame()) {
        return pContext->ThrowNativeError("Client %d is not in game", client);
    }

    IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
    if (!pInfo)
    {
        return pContext->ThrowNativeError("IPlayerInfo not supported by game");
    }

    const char *weapon = bridge->playerInfo->GetWeaponName(pInfo);
    pContext->StringToLocalUTF8(params[2], static_cast<size_t>(params[3]), weapon ? weapon : "", NULL);

    return 1;
}
Beispiel #6
0
bool SDKTools::ProcessCommandTarget(cmd_target_info_t *info)
{
	IGamePlayer *pAdmin = info->admin ? playerhelpers->GetGamePlayer(info->admin) : NULL;

	if (strcmp(info->pattern, "@aim") == 0)
	{
		/* The server can't aim, of course. */
		if (pAdmin == NULL)
		{
			return false;
		}

		int player_index;
		if ((player_index = GetClientAimTarget(pAdmin->GetEdict(), true)) < 1)
		{
			info->reason = COMMAND_TARGET_NONE;
			info->num_targets = 0;
			return true;
		}

		IGamePlayer *pTarget = playerhelpers->GetGamePlayer(player_index);

		if (pTarget == NULL)
		{
			info->reason = COMMAND_TARGET_NONE;
			info->num_targets = 0;
			return true;
		}

		info->reason = playerhelpers->FilterCommandTarget(pAdmin, pTarget, info->flags);
		if (info->reason != COMMAND_TARGET_VALID)
		{
			info->num_targets = 0;
			return true;
		}

		info->targets[0] = player_index;
		info->num_targets = 1;
		info->reason = COMMAND_TARGET_VALID;
		info->target_name_style = COMMAND_TARGETNAME_RAW;
		snprintf(info->target_name, info->target_name_maxlength, "%s", pTarget->GetName());
		return true;
	}
	else if (strcmp(info->pattern, "@spec") == 0)
	{
		const char *teamname = tools_GetTeamName(1);
		if (strcasecmp(teamname, "spectator") != 0)
			return false;
		info->num_targets = 0;
		for (int i = 1; i <= playerhelpers->GetMaxClients(); i++)
		{
			IGamePlayer *player = playerhelpers->GetGamePlayer(i);
			if (player == NULL || !player->IsInGame())
				continue;
			IPlayerInfo *plinfo = player->GetPlayerInfo();
			if (plinfo == NULL)
				continue;
			if (plinfo->GetTeamIndex() == 1 &&
			    playerhelpers->FilterCommandTarget(pAdmin, player, info->flags) ==
				COMMAND_TARGET_VALID)
			{
				info->targets[info->num_targets++] = i;
			}
		}
		info->reason = info->num_targets > 0 ? COMMAND_TARGET_VALID : COMMAND_TARGET_EMPTY_FILTER;
		info->target_name_style = COMMAND_TARGETNAME_ML;
		snprintf(info->target_name, info->target_name_maxlength, "all spectators");
		return true;
	}

	return false;
}