示例#1
0
static cell_t DispatchKeyValueFloat(IPluginContext *pContext, const cell_t *params)
{
	static ValveCall *pCall = NULL;
	if (!pCall)
	{
		ValvePassInfo pass[3];
		InitPass(pass[0], Valve_String, PassType_Basic, PASSFLAG_BYVAL);
		InitPass(pass[1], Valve_Float, PassType_Float, PASSFLAG_BYVAL);
		InitPass(pass[2], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL);
		if (!CreateBaseCall("DispatchKeyValueFloat", ValveCall_Entity, &pass[2], pass, 2, &pCall))
		{
			return pContext->ThrowNativeError("\"DispatchKeyValueFloat\" not supported by this mod");
		} else if (!pCall) {
			return pContext->ThrowNativeError("\"DispatchKeyValueFloat\" wrapper failed to initialized");
		}
	}

	bool ret;
	START_CALL();
	DECODE_VALVE_PARAM(1, thisinfo, 0);
	DECODE_VALVE_PARAM(2, vparams, 0);
	DECODE_VALVE_PARAM(3, vparams, 1);
	FINISH_CALL_SIMPLE(&ret);

	return (ret) ? 1 : 0;
}
示例#2
0
/* Dark Messiah specific version */
static cell_t IgniteEntity(IPluginContext *pContext, const cell_t *params)
{
	static ValveCall *pCall = NULL;
	if (!pCall)
	{
		ValvePassInfo pass[6];
		InitPass(pass[0], Valve_Float, PassType_Float, PASSFLAG_BYVAL);
		InitPass(pass[1], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL);
		InitPass(pass[2], Valve_Float, PassType_Float, PASSFLAG_BYVAL);
		InitPass(pass[3], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL);
		InitPass(pass[4], Valve_POD, PassType_Basic, PASSFLAG_BYVAL);
		InitPass(pass[5], Valve_POD, PassType_Basic, PASSFLAG_BYVAL);
		if (!CreateBaseCall("Ignite", ValveCall_Entity, NULL, pass, 6, &pCall))
		{
			return pContext->ThrowNativeError("\"Ignite\" not supported by this mod");
		} else if (!pCall) {
			return pContext->ThrowNativeError("\"Ignite\" wrapper failed to initialized");
		}
	}

	START_CALL();
	DECODE_VALVE_PARAM(1, thisinfo, 0);
	DECODE_VALVE_PARAM(2, vparams, 0);
	DECODE_VALVE_PARAM(3, vparams, 1);
	DECODE_VALVE_PARAM(4, vparams, 2);
	DECODE_VALVE_PARAM(5, vparams, 3);
	/* Not sure what these params do, but they appear to be the default values */
	*(int *)(vptr + 14) = 3;
	*(int *)(vptr + 18) = 0;
	FINISH_CALL_SIMPLE(NULL);

	return 1;
}
示例#3
0
static cell_t GiveNamedItem(IPluginContext *pContext, const cell_t *params)
{
	static ValveCall *pCall = NULL;
	if (!pCall)
	{
		ValvePassInfo pass[3];
		InitPass(pass[0], Valve_String, PassType_Basic, PASSFLAG_BYVAL);
		InitPass(pass[1], Valve_POD, PassType_Basic, PASSFLAG_BYVAL);
		InitPass(pass[2], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL);
		if (!CreateBaseCall("GiveNamedItem", ValveCall_Player, &pass[2], pass, 2, &pCall))
		{
			return pContext->ThrowNativeError("\"GiveNamedItem\" not supported by this mod");
		} else if (!pCall) {
			return pContext->ThrowNativeError("\"GiveNamedItem\" wrapper failed to initialize");
		}
	}

	CBaseEntity *pEntity = NULL;
	START_CALL();
	DECODE_VALVE_PARAM(1, thisinfo, 0);
	DECODE_VALVE_PARAM(2, vparams, 0);
	DECODE_VALVE_PARAM(3, vparams, 1);
	FINISH_CALL_SIMPLE(&pEntity);

	return gamehelpers->EntityToBCompatRef(pEntity);
}
示例#4
0
static cell_t CreateEntityByName(IPluginContext *pContext, const cell_t *params)
{
	if (!g_pSM->IsMapRunning())
	{
		return pContext->ThrowNativeError("Cannot create new entity when no map is running");
	}

	static ValveCall *pCall = NULL;
	if (!pCall)
	{
		ValvePassInfo pass[3];
		InitPass(pass[0], Valve_String, PassType_Basic, PASSFLAG_BYVAL);
		InitPass(pass[1], Valve_POD, PassType_Basic, PASSFLAG_BYVAL);
		InitPass(pass[2], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL);
		if (!CreateBaseCall("CreateEntityByName", ValveCall_Static, &pass[2], pass, 2, &pCall))
		{
			return pContext->ThrowNativeError("\"CreateEntityByName\" not supported by this mod");
		} else if (!pCall) {
			return pContext->ThrowNativeError("\"CreateEntityByName\" wrapper failed to initialize");
		}
	}

	CBaseEntity *pEntity = NULL;
	START_CALL();
	DECODE_VALVE_PARAM(1, vparams, 0);
	DECODE_VALVE_PARAM(2, vparams, 1);
	FINISH_CALL_SIMPLE(&pEntity);

	return gamehelpers->EntityToBCompatRef(pEntity);
}
示例#5
0
static cell_t IgniteEntity(IPluginContext *pContext, const cell_t *params)
{
	static ValveCall *pCall = NULL;
	if (!pCall)
	{
		ValvePassInfo pass[4];
		InitPass(pass[0], Valve_Float, PassType_Float, PASSFLAG_BYVAL);
		InitPass(pass[1], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL);
		InitPass(pass[2], Valve_Float, PassType_Float, PASSFLAG_BYVAL);
		InitPass(pass[3], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL);
		if (!CreateBaseCall("Ignite", ValveCall_Entity, NULL, pass, 4, &pCall))
		{
			return pContext->ThrowNativeError("\"Ignite\" not supported by this mod");
		} else if (!pCall) {
			return pContext->ThrowNativeError("\"Ignite\" wrapper failed to initialize");
		}
	}

	START_CALL();
	DECODE_VALVE_PARAM(1, thisinfo, 0);
	DECODE_VALVE_PARAM(2, vparams, 0);
	DECODE_VALVE_PARAM(3, vparams, 1);
	DECODE_VALVE_PARAM(4, vparams, 2);
	DECODE_VALVE_PARAM(5, vparams, 3);
	FINISH_CALL_SIMPLE(NULL);

	return 1;
}
示例#6
0
static cell_t DispatchKeyValueVector(IPluginContext *pContext, const cell_t *params)
{
	static ValveCall *pCall = NULL;
	if (!pCall)
	{
		ValvePassInfo pass[3];
		InitPass(pass[0], Valve_String, PassType_Basic, PASSFLAG_BYVAL);
#if SOURCE_ENGINE >= SE_ORANGEBOX
		InitPass(pass[1], Valve_Vector, PassType_Basic, PASSFLAG_BYVAL);
#else
		InitPass(pass[1], Valve_Vector, PassType_Object, PASSFLAG_BYVAL|PASSFLAG_OCTOR|PASSFLAG_OASSIGNOP);
#endif
		InitPass(pass[2], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL);
		if (!CreateBaseCall("DispatchKeyValueVector", ValveCall_Entity, &pass[2], pass, 2, &pCall))
		{
			return pContext->ThrowNativeError("\"DispatchKeyValueVector\" not supported by this mod");
		} else if (!pCall) {
			return pContext->ThrowNativeError("\"DispatchKeyValueVector\" wrapper failed to initialized");
		}
	}

	bool ret;
	START_CALL();
	DECODE_VALVE_PARAM(1, thisinfo, 0);
	DECODE_VALVE_PARAM(2, vparams, 0);
	DECODE_VALVE_PARAM(3, vparams, 1);
	FINISH_CALL_SIMPLE(&ret);

	return (ret) ? 1 : 0;
}
示例#7
0
static cell_t IgniteEntity(IPluginContext *pContext, const cell_t *params)
{
    static ValveCall *pCall = NULL;
    if (!pCall)
    {
#if SOURCE_ENGINE == SE_SDK2013
        if (!strcmp(g_pSM->GetGameFolderName(), "nmrih"))
        {
            ValvePassInfo pass[6];
            InitPass(pass[0], Valve_Float, PassType_Float, PASSFLAG_BYVAL);
            InitPass(pass[1], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL);
            InitPass(pass[2], Valve_Float, PassType_Float, PASSFLAG_BYVAL);
            InitPass(pass[3], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL);
            InitPass(pass[4], Valve_POD, PassType_Basic, PASSFLAG_BYVAL);
            InitPass(pass[5], Valve_POD, PassType_Basic, PASSFLAG_BYVAL);
            if (!CreateBaseCall("Ignite", ValveCall_Entity, NULL, pass, 6, &pCall))
            {
                return pContext->ThrowNativeError("\"Ignite\" not supported by this mod");
            }
            else if (!pCall) {
                return pContext->ThrowNativeError("\"Ignite\" wrapper failed to initialize");
            }
        }
        else
#endif // SDK2013
        {
            ValvePassInfo pass[4];
            InitPass(pass[0], Valve_Float, PassType_Float, PASSFLAG_BYVAL);
            InitPass(pass[1], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL);
            InitPass(pass[2], Valve_Float, PassType_Float, PASSFLAG_BYVAL);
            InitPass(pass[3], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL);
            if (!CreateBaseCall("Ignite", ValveCall_Entity, NULL, pass, 4, &pCall))
            {
                return pContext->ThrowNativeError("\"Ignite\" not supported by this mod");
            }
            else if (!pCall) {
                return pContext->ThrowNativeError("\"Ignite\" wrapper failed to initialize");
            }
        }
    }

    START_CALL();
    DECODE_VALVE_PARAM(1, thisinfo, 0);
    DECODE_VALVE_PARAM(2, vparams, 0);
    DECODE_VALVE_PARAM(3, vparams, 1);
    DECODE_VALVE_PARAM(4, vparams, 2);
    DECODE_VALVE_PARAM(5, vparams, 3);

#if SOURCE_ENGINE == SE_SDK2013
    if (!strcmp(g_pSM->GetGameFolderName(), "nmrih"))
    {
        *(int *) (vptr + 14) = 0;
        *(int *) (vptr + 18) = 0;
    }
#endif // SDK2013

    FINISH_CALL_SIMPLE(NULL);

    return 1;
}
示例#8
0
static cell_t GivePlayerAmmo(IPluginContext *pContext, const cell_t *params)
{
    static ValveCall *pCall = NULL;
    if (!pCall)
    {
        ValvePassInfo pass[3];
        InitPass(pass[0], Valve_POD, PassType_Basic, PASSFLAG_BYVAL);
        InitPass(pass[1], Valve_POD, PassType_Basic, PASSFLAG_BYVAL);
        InitPass(pass[2], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL);
        if (!CreateBaseCall("GiveAmmo", ValveCall_Player, &pass[0], pass, 3, &pCall))
        {
            return pContext->ThrowNativeError("\"GiveAmmo\" not supported by this mod");
        } else if (!pCall) {
            return pContext->ThrowNativeError("\"GiveAmmo\" wrapper failed to initialize");
        }
    }

    int ammoGiven;
    START_CALL();
    DECODE_VALVE_PARAM(1, thisinfo, 0);
    DECODE_VALVE_PARAM(2, vparams, 0);
    DECODE_VALVE_PARAM(3, vparams, 1);
    DECODE_VALVE_PARAM(4, vparams, 2);
    FINISH_CALL_SIMPLE(&ammoGiven);

    return ammoGiven;
}
示例#9
0
static cell_t TeleportEntity(IPluginContext *pContext, const cell_t *params)
{
	static ValveCall *pCall = NULL;
	if (!pCall)
	{
		ValvePassInfo pass[3];
		InitPass(pass[0], Valve_Vector, PassType_Basic, PASSFLAG_BYVAL, VDECODE_FLAG_ALLOWNULL);
		InitPass(pass[1], Valve_QAngle, PassType_Basic, PASSFLAG_BYVAL, VDECODE_FLAG_ALLOWNULL);
		InitPass(pass[2], Valve_Vector, PassType_Basic, PASSFLAG_BYVAL, VDECODE_FLAG_ALLOWNULL);
		if (!CreateBaseCall("Teleport", ValveCall_Entity, NULL, pass, 3, &pCall))
		{
			return pContext->ThrowNativeError("\"Teleport\" not supported by this mod");
		} else if (!pCall) {
			return pContext->ThrowNativeError("\"Teleport\" wrapper failed to initialized");
		}
	}

	START_CALL();
	DECODE_VALVE_PARAM(1, thisinfo, 0);
	DECODE_VALVE_PARAM(2, vparams, 0);
	DECODE_VALVE_PARAM(3, vparams, 1);
	DECODE_VALVE_PARAM(4, vparams, 2);
	FINISH_CALL_SIMPLE(NULL);

	return 1;
}
示例#10
0
static cell_t GetPlayerWeaponSlot(IPluginContext *pContext, const cell_t *params)
{
	static ValveCall *pCall = NULL;
	if (!pCall)
	{
		ValvePassInfo pass[2];
		InitPass(pass[0], Valve_POD, PassType_Basic, PASSFLAG_BYVAL);
		InitPass(pass[1], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL);
		if (!CreateBaseCall("Weapon_GetSlot", ValveCall_Player, &pass[1], pass, 1, &pCall))
		{
			return pContext->ThrowNativeError("\"Weapon_GetSlot\" not supported by this mod");
		} else if (!pCall) {
			return pContext->ThrowNativeError("\"Weapon_GetSlot\" wrapper failed to initialized");
		}
	}

	CBaseEntity *pEntity;
	START_CALL();
	DECODE_VALVE_PARAM(1, thisinfo, 0);
	DECODE_VALVE_PARAM(2, vparams, 0);
	FINISH_CALL_SIMPLE(&pEntity);

	if (pEntity == NULL)
	{
		return -1;
	}

	edict_t *pEdict = gameents->BaseEntityToEdict(pEntity);
	if (!pEdict)
	{
		return -1;
	}

	return IndexOfEdict(pEdict);
}
示例#11
0
static cell_t FindEntityByClassname(IPluginContext *pContext, const cell_t *params)
{
	static ValveCall *pCall = NULL;
	static bool bProbablyNoFEBC = false;

#if SOURCE_ENGINE >= SE_ORANGEBOX
	if (bProbablyNoFEBC)
	{
		return NativeFindEntityByClassname(pContext, params);
	}
#endif

	if (!pCall)
	{
		ValvePassInfo pass[3];
		InitPass(pass[0], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL, VDECODE_FLAG_ALLOWNULL|VDECODE_FLAG_ALLOWWORLD);
		InitPass(pass[1], Valve_String, PassType_Basic, PASSFLAG_BYVAL);
		InitPass(pass[2], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL);

		char error[256];
		error[0] = '\0';
		if (!CreateBaseCall("FindEntityByClassname", ValveCall_EntityList, &pass[2], pass, 2, &pCall))
		{
			g_pSM->Format(error, sizeof(error), "\"FindEntityByClassname\" not supported by this mod");
		} else if (!pCall) {
			g_pSM->Format(error, sizeof(error), "\"FindEntityByClassname\" wrapper failed to initialize");
		}

		if (error[0] != '\0')
		{
#if SOURCE_ENGINE >= SE_ORANGEBOX
			if (!bProbablyNoFEBC)
			{
				bProbablyNoFEBC = true;
				g_pSM->LogError(myself, "%s, falling back to IServerTools method.", error);
			}
			return NativeFindEntityByClassname(pContext, params);
#else
			return pContext->ThrowNativeError("%s", error);
#endif
		}
	}

	CBaseEntity *pEntity;
	START_CALL();
	*(void **)vptr = g_EntList; 
	DECODE_VALVE_PARAM(1, vparams, 0);
	DECODE_VALVE_PARAM(2, vparams, 1);
	FINISH_CALL_SIMPLE(&pEntity);

	return gamehelpers->EntityToBCompatRef(pEntity);
}
示例#12
0
/* :TODO: This is Team Fortress 2 specific */
static cell_t ForcePlayerSuicide(IPluginContext *pContext, const cell_t *params)
{
	static ValveCall *pCall = NULL;
	if (!pCall)
	{
		ValvePassInfo pass[2];
		InitPass(pass[0], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL);
		InitPass(pass[1], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL);
		if (!CreateBaseCall("CommitSuicide", ValveCall_Player, NULL, pass, 2, &pCall))
		{
			return pContext->ThrowNativeError("\"CommitSuicide\" not supported by this mod");
		}
		else if (!pCall)
		{
			return pContext->ThrowNativeError("\"CommitSuicide\" wrapper failed to initialized");
		}
	}

	START_CALL();
	DECODE_VALVE_PARAM(1, thisinfo, 0);
	*(bool *)(vptr + 4) = false;
	*(bool *)(vptr + 5) = false;
	FINISH_CALL_SIMPLE(NULL);

	return 1;
}
示例#13
0
static cell_t GiveNamedItem(IPluginContext *pContext, const cell_t *params)
{
    if (g_SdkTools.ShouldFollowCSGOServerGuidelines())
    {
        char *pWeaponName;
        pContext->LocalToString(params[2], &pWeaponName);

        // Don't allow knives other than weapon_knife,  weapon_knifegg, and wewapon_knife_t.
        // Others follow pattern weapon_knife_*
        size_t len = strlen(pWeaponName);
        if (len >= 14 && strnicmp(pWeaponName, "weapon_knife_", 13) == 0 && !(pWeaponName[13] == 't' && pWeaponName[14] == '\0'))
        {
            return pContext->ThrowNativeError("Blocked giving of %s due to core.cfg option FollowCSGOServerGuidelines", pWeaponName);
        }
    }

    static ValveCall *pCall = NULL;
    if (!pCall)
    {
        ValvePassInfo pass[5];
        InitPass(pass[0], Valve_String, PassType_Basic, PASSFLAG_BYVAL);
        InitPass(pass[1], Valve_POD, PassType_Basic, PASSFLAG_BYVAL);
        InitPass(pass[2], Valve_POD, PassType_Basic, PASSFLAG_BYVAL);
        InitPass(pass[3], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL);
        InitPass(pass[4], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL);
        if (!CreateBaseCall("GiveNamedItem", ValveCall_Player, &pass[4], pass, 4, &pCall))
        {
            return pContext->ThrowNativeError("\"GiveNamedItem\" not supported by this mod");
        } else if (!pCall) {
            return pContext->ThrowNativeError("\"GiveNamedItem\" wrapper failed to initialize");
        }
    }

    CBaseEntity *pEntity = NULL;
    START_CALL();
    DECODE_VALVE_PARAM(1, thisinfo, 0);
    DECODE_VALVE_PARAM(2, vparams, 0);
    DECODE_VALVE_PARAM(3, vparams, 1);
    *(CEconItemView **)(vptr + 12) = NULL;
    *(bool *)(vptr + 16) = false;
    FINISH_CALL_SIMPLE(&pEntity);

    return gamehelpers->EntityToBCompatRef(pEntity);
}
示例#14
0
static cell_t WeaponEquip(IPluginContext *pContext, const cell_t *params)
{
	static ValveCall *pCall = NULL;
	if (!pCall)
	{
		ValvePassInfo pass[1];
		InitPass(pass[0], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL);
		if (!CreateBaseCall("WeaponEquip", ValveCall_Player, NULL, pass, 1, &pCall))
		{
			return pContext->ThrowNativeError("\"WeaponEquip\" not supported by this mod");
		} else if (!pCall) {
			return pContext->ThrowNativeError("\"WeaponEquip\" wrapper failed to initialized");
		}
	}

	START_CALL();
	DECODE_VALVE_PARAM(1, thisinfo, 0);
	DECODE_VALVE_PARAM(2, vparams, 0);
	FINISH_CALL_SIMPLE(NULL);

	return 1;
}
示例#15
0
static cell_t CreateEntityByName(IPluginContext *pContext, const cell_t *params)
{
	static ValveCall *pCall = NULL;
	if (!pCall)
	{
		ValvePassInfo pass[4];
		InitPass(pass[0], Valve_String, PassType_Basic, PASSFLAG_BYVAL);
		InitPass(pass[1], Valve_POD, PassType_Basic, PASSFLAG_BYVAL);
		InitPass(pass[2], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL);
		InitPass(pass[3], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL);
		if (!CreateBaseCall("CreateEntityByName", ValveCall_Static, &pass[3], pass, 3, &pCall))
		{
			return pContext->ThrowNativeError("\"CreateEntityByName\" not supported by this mod");
		} else if (!pCall) {
			return pContext->ThrowNativeError("\"CreateEntityByName\" wrapper failed to initialized");
		}
	}

	CBaseEntity *pEntity = NULL;
	START_CALL();
	DECODE_VALVE_PARAM(1, vparams, 0);
	DECODE_VALVE_PARAM(2, vparams, 1);
	*(bool *)(vptr + 8) = true;
	FINISH_CALL_SIMPLE(&pEntity);

	if (pEntity == NULL)
	{
		return -1;
	}

	edict_t *pEdict = gameents->BaseEntityToEdict(pEntity);
	if (!pEdict)
	{
		return -1;
	}

	return IndexOfEdict(pEdict);
}
示例#16
0
static cell_t SetClientName(IPluginContext *pContext, const cell_t *params)
{
    if (iserver == NULL)
    {
        return pContext->ThrowNativeError("IServer interface not supported, file a bug report.");
    }

    IGamePlayer *player = playerhelpers->GetGamePlayer(params[1]);
    IClient *pClient = iserver->GetClient(params[1] - 1);

    if (player == NULL || pClient == NULL)
    {
        return pContext->ThrowNativeError("Invalid client index %d", params[1]);
    }
    if (!player->IsConnected())
    {
        return pContext->ThrowNativeError("Client %d is not connected", params[1]);
    }

    static ValveCall *pCall = NULL;
    if (!pCall)
    {
        ValvePassInfo params[1];
        InitPass(params[0], Valve_String, PassType_Basic, PASSFLAG_BYVAL);

        if (!CreateBaseCall("SetClientName", ValveCall_Entity, NULL, params, 1, &pCall))
        {
            return pContext->ThrowNativeError("\"SetClientName\" not supported by this mod");
        }
        else if (!pCall)
        {
            return pContext->ThrowNativeError("\"SetClientName\" wrapper failed to initialize");
        }
    }

    // The IClient vtable is +4 from the CBaseClient vtable due to multiple inheritance.
    void *pGameClient = (void *)((intptr_t)pClient - 4);

    // Change the name in the engine.
    START_CALL();
    void **ebuf = (void **)vptr;
    *ebuf = pGameClient;
    DECODE_VALVE_PARAM(2, vparams, 0);
    FINISH_CALL_SIMPLE(NULL);

    // Notify the server of the change.
    serverClients->ClientSettingsChanged(player->GetEdict());

    return 1;
}
示例#17
0
static cell_t RemovePlayerItem(IPluginContext *pContext, const cell_t *params)
{
	static ValveCall *pCall = NULL;
	if (!pCall)
	{
		ValvePassInfo pass[2];
		InitPass(pass[0], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL);
		InitPass(pass[1], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL);
		if (!CreateBaseCall("RemovePlayerItem", ValveCall_Player, &pass[1], pass, 1, &pCall))
		{
			return pContext->ThrowNativeError("\"RemovePlayerItem\" not supported by this mod");
		} else if (!pCall) {
			return pContext->ThrowNativeError("\"RemovePlayerItem\" wrapper failed to initialized");
		}
	}

	bool ret;
	START_CALL();
	DECODE_VALVE_PARAM(1, thisinfo, 0);
	DECODE_VALVE_PARAM(2, vparams, 0);
	FINISH_CALL_SIMPLE(&ret);
	return ret ? 1 : 0;
}
示例#18
0
static cell_t FindEntityByClassname(IPluginContext *pContext, const cell_t *params)
{
	static ValveCall *pCall = NULL;
	if (!pCall)
	{
		ValvePassInfo pass[3];
		InitPass(pass[0], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL, VDECODE_FLAG_ALLOWNULL|VDECODE_FLAG_ALLOWWORLD);
		InitPass(pass[1], Valve_String, PassType_Basic, PASSFLAG_BYVAL);
		InitPass(pass[2], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL);
		if (!CreateBaseCall("FindEntityByClassname", ValveCall_EntityList, &pass[2], pass, 2, &pCall))
		{
			return pContext->ThrowNativeError("\"FindEntityByClassname\" not supported by this mod");
		} else if (!pCall) {
			return pContext->ThrowNativeError("\"FindEntityByClassname\" wrapper failed to initialized");
		}
	}

	CBaseEntity *pEntity;
	START_CALL();
	*(void **)vptr = g_EntList; 
	DECODE_VALVE_PARAM(1, vparams, 0);
	DECODE_VALVE_PARAM(2, vparams, 1);
	FINISH_CALL_SIMPLE(&pEntity);

	if (pEntity == NULL)
	{
		return -1;
	}

	edict_t *pEdict = gameents->BaseEntityToEdict(pEntity);
	if (!pEdict)
	{
		return -1;
	}

	return IndexOfEdict(pEdict);
}
示例#19
0
static cell_t ForcePlayerSuicide(IPluginContext *pContext, const cell_t *params)
{
	static ValveCall *pCall = NULL;
	if (!pCall)
	{
		if (!CreateBaseCall("CommitSuicide", ValveCall_Player, NULL, NULL, 0, &pCall))
		{
			return pContext->ThrowNativeError("\"CommitSuicide\" not supported by this mod");
		} else if (!pCall) {
			return pContext->ThrowNativeError("\"CommitSuicide\" wrapper failed to initialized");
		}
	}

	START_CALL();
	DECODE_VALVE_PARAM(1, thisinfo, 0);
	FINISH_CALL_SIMPLE(NULL);

	return 1;
}
示例#20
0
static cell_t ExtinguishEntity(IPluginContext *pContext, const cell_t *params)
{
	static ValveCall *pCall = NULL;
	if (!pCall)
	{
		if (!CreateBaseCall("Extinguish", ValveCall_Entity, NULL, NULL, 0, &pCall))
		{
			return pContext->ThrowNativeError("\"Extinguish\" not supported by this mod");
		} else if (!pCall) {
			return pContext->ThrowNativeError("\"Extinguish\" wrapper failed to initialized");
		}
	}

	START_CALL();
	DECODE_VALVE_PARAM(1, thisinfo, 0);
	FINISH_CALL_SIMPLE(NULL);

	return 1;
}
示例#21
0
static cell_t DispatchSpawn(IPluginContext *pContext, const cell_t *params)
{
	static ValveCall *pCall = NULL;
	if (!pCall)
	{
		ValvePassInfo pass[2];
		InitPass(pass[0], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL);
		InitPass(pass[1], Valve_POD, PassType_Basic, PASSFLAG_BYVAL);
		if (!CreateBaseCall("DispatchSpawn", ValveCall_Static, &pass[1], pass, 1, &pCall))
		{
			return pContext->ThrowNativeError("\"DispatchSpawn\" not supported by this mod");
		} else if (!pCall) {
			return pContext->ThrowNativeError("\"DispatchSpawn\" wrapper failed to initialized");
		}
	}

	int ret;
	START_CALL();
	DECODE_VALVE_PARAM(1, vparams, 0);
	FINISH_CALL_SIMPLE(&ret);

	return (ret == -1) ? 0 : 1;
}
示例#22
0
static cell_t FindEntityByClassname(IPluginContext *pContext, const cell_t *params)
{
#if SOURCE_ENGINE == SE_TF2        \
	|| SOURCE_ENGINE == SE_DODS    \
	|| SOURCE_ENGINE == SE_HL2DM   \
	|| SOURCE_ENGINE == SE_CSS     \
	|| SOURCE_ENGINE == SE_BMS     \
	|| SOURCE_ENGINE == SE_SDK2013 \
	|| SOURCE_ENGINE == SE_NUCLEARDAWN

    static bool bHasServerTools3 = !!g_SMAPI->GetServerFactory(false)("VSERVERTOOLS003", nullptr);
    if (bHasServerTools3)
    {
        CBaseEntity *pStartEnt = NULL;
        if (params[1] != -1)
        {
            pStartEnt = gamehelpers->ReferenceToEntity(params[1]);
            if (!pStartEnt)
            {
                return pContext->ThrowNativeError("Entity %d (%d) is invalid",
                                                  gamehelpers->ReferenceToIndex(params[1]),
                                                  params[1]);
            }
        }

        char *searchname;
        pContext->LocalToString(params[2], &searchname);

        CBaseEntity *pEntity = servertools->FindEntityByClassname(pStartEnt, searchname);
        return gamehelpers->EntityToBCompatRef(pEntity);
    }
#endif

    static ValveCall *pCall = NULL;
    static bool bProbablyNoFEBC = false;

#if SOURCE_ENGINE >= SE_ORANGEBOX
    if (bProbablyNoFEBC)
    {
        return NativeFindEntityByClassname(pContext, params);
    }
#endif // >= SE_ORANGEBOX

    if (!pCall)
    {
        ValvePassInfo pass[3];
        InitPass(pass[0], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL, VDECODE_FLAG_ALLOWNULL|VDECODE_FLAG_ALLOWWORLD);
        InitPass(pass[1], Valve_String, PassType_Basic, PASSFLAG_BYVAL);
        InitPass(pass[2], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL);

        char error[256];
        error[0] = '\0';
        if (!CreateBaseCall("FindEntityByClassname", ValveCall_EntityList, &pass[2], pass, 2, &pCall))
        {
            g_pSM->Format(error, sizeof(error), "\"FindEntityByClassname\" not supported by this mod");
        } else if (!pCall) {
            g_pSM->Format(error, sizeof(error), "\"FindEntityByClassname\" wrapper failed to initialize");
        }

        if (error[0] != '\0')
        {
#if SOURCE_ENGINE >= SE_ORANGEBOX
            if (!bProbablyNoFEBC)
            {
                bProbablyNoFEBC = true;

                // CreateBaseCall above abstracts all of the gamedata logic, but we need to know if the key was even found.
                // We don't want to log an error if key isn't present (knowing falling back to native method), only throw
                // error if signature/symbol was not found.
                void *dummy;
                if (g_pGameConf->GetMemSig("FindEntityByClassname", &dummy))
                {
                    g_pSM->LogError(myself, "%s, falling back to IServerTools method.", error);
                }
            }
            return NativeFindEntityByClassname(pContext, params);
#else
            return pContext->ThrowNativeError("%s", error);
#endif // >= ORANGEBOX
        }
    }

    CBaseEntity *pEntity;
    START_CALL();
    *(void **)vptr = g_EntList;
    DECODE_VALVE_PARAM(1, vparams, 0);
    DECODE_VALVE_PARAM(2, vparams, 1);
    FINISH_CALL_SIMPLE(&pEntity);

    return gamehelpers->EntityToBCompatRef(pEntity);
}
示例#23
0
static cell_t SetClientInfo(IPluginContext *pContext, const cell_t *params)
{
	if (iserver == NULL)
	{
		return pContext->ThrowNativeError("IServer interface not supported, file a bug report.");
	}

	IGamePlayer *player = playerhelpers->GetGamePlayer(params[1]);
	IClient *pClient = iserver->GetClient(params[1] - 1);

	if (player == NULL || pClient == NULL)
	{
		return pContext->ThrowNativeError("Invalid client index %d", params[1]);
	}
	if (!player->IsConnected())
	{
		return pContext->ThrowNativeError("Client %d is not connected", params[1]);
	}

	static ValveCall *pCall = NULL;
	if (!pCall)
	{
		ValvePassInfo params[2];
		InitPass(params[0], Valve_String, PassType_Basic, PASSFLAG_BYVAL);
		InitPass(params[1], Valve_String, PassType_Basic, PASSFLAG_BYVAL);

		if (!CreateBaseCall("SetUserCvar", ValveCall_Entity, NULL, params, 2, &pCall))
		{
			return pContext->ThrowNativeError("\"SetUserCvar\" not supported by this mod");
		}
		else if (!pCall)
		{
			return pContext->ThrowNativeError("\"SetUserCvar\" wrapper failed to initialized");
		}
	}

/* TODO: Use UpdateUserSettings function for all engines */
#if SOURCE_ENGINE == SE_DARKMESSIAH
	static ValveCall *pUpdateSettings = NULL;
	if (!pUpdateSettings)
	{
		if (!CreateBaseCall("UpdateUserSettings", ValveCall_Entity, NULL, NULL, 0, &pUpdateSettings))
		{
			return pContext->ThrowNativeError("\"SetUserCvar\" not supported by this mod");
		}
		else if (!pUpdateSettings)
		{
			return pContext->ThrowNativeError("\"SetUserCvar\" wrapper failed to initialized");
		}
	}
#else
	static int changedOffset = -1;

	if (changedOffset == -1)
	{	
		if (!g_pGameConf->GetOffset("InfoChanged", &changedOffset))
		{
			return pContext->ThrowNativeError("\"SetUserCvar\" not supported by this mod");
		}
	}
#endif

	unsigned char *CGameClient = (unsigned char *)pClient - 4;

	START_CALL();
	/* Not really a CBaseEntity* but this works */
	CBaseEntity **ebuf = (CBaseEntity **)vptr;
	*ebuf = (CBaseEntity *)CGameClient;
	DECODE_VALVE_PARAM(2, vparams, 0);
	DECODE_VALVE_PARAM(3, vparams, 1);
	FINISH_CALL_SIMPLE(NULL);

#if SOURCE_ENGINE == SE_DARKMESSIAH
	unsigned char *args = pUpdateSettings->stk_get();
	*(void **)args = CGameClient;
	pUpdateSettings->call->Execute(args, NULL);
	pUpdateSettings->stk_put(args);
#else
	uint8_t* changed = (uint8_t *)(CGameClient + changedOffset);
	*changed = 1;
#endif

	return 1;
}