Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <dhooks>
- new Handle:hSequenceSet;
- public Plugin:myinfo =
- {
- name = "L4D2 DHook Test",
- author = "DeathChaos25",
- description = "",
- version = "",
- url = ""
- }
- public OnPluginStart()
- {
- new Handle:temp = LoadGameConfigFile("l4d2_direct");
- if (temp == INVALID_HANDLE)
- {
- SetFailState("Error: Gamedata not found");
- }
- new offset;
- offset = GameConfGetOffset(temp, "CTerrorPlayer::SelectWeightedSequence");
- if (offset == -1)
- {
- CloseHandle(temp);
- LogError("Unable to get offset for CTerrorPlayer::SelectWeightedSequence");
- return;
- }
- hSequenceSet = DHookCreate(offset, HookType_Entity, ReturnType_Void, ThisPointer_CBaseEntity, OnSequenceSet);
- DHookAddParam(hSequenceSet, HookParamType_Int);
- }
- public MRESReturn:OnSequenceSet(client, Handle:hParams)
- {
- if (IsSurvivor(client))
- {
- PrintToChat(client, "Current Sequence: #%i", DHookGetParam(hParams, 1));
- }
- return MRES_Ignored;
- }
- bool:IsSurvivor(client)
- {
- return (client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2);
- }
- public OnClientPutInServer(client)
- {
- if (!IsFakeClient(client))DHookEntity(hSequenceSet, false, client);
- }
- public OnAllPluginsLoaded()
- {
- for (new client = 1; client <= MaxClients; client++)
- {
- if (!IsFakeClient(client) && IsSurvivor(client))DHookEntity(hSequenceSet, false, client);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment