PHP Code:
#include <sdktools>
#include <sdkhooks>
#include <dhooks>
#pragma newdecls required
//DHook
Handle g_hGetSecondaryAttackActivity
//SDKCall
Handle g_hSDKPlayGesture;
public Plugin myinfo =
{
name = "[TF2] ",
author = "Pelipoika",
description = "",
version = "1.0",
url = "http://www.sourcemod.net/plugins.php?author=Pelipoika&search=1"
};
//tf_weapon_handgun_scout_primary
//ACT_MP_PUSH_STAND_SECONDARY 1817
//ACT_MP_PUSH_CROUCH_SECONDARY 1818
//ACT_MP_PUSH_SWIM_SECONDARY 1819
//CTFPlayer::PlayGesture "mp_playgesture: unknown sequence or act"
public void OnPluginStart()
{
//CTFPistol_ScoutPrimary::SecondaryAttack
g_hGetSecondaryAttackActivity = DHookCreate(279, HookType_Entity, ReturnType_Int, ThisPointer_CBaseEntity, CTFPistol_ScoutPrimary__SecondaryAttack);
DHookAddParam(g_hGetSecondaryAttackActivity, HookParamType_CBaseEntity);
StartPrepSDKCall(SDKCall_Player);
PrepSDKCall_SetSignature(SDKLibrary_Server, "\x55\x8B\xEC\x83\xEC\x30\x53\x56\x8B\x75\x08\x57\x56\x8B\xF9\xE8\x2A\x2A\x2A\x2A\x8B\xD8\x83\xFB\xFF\x74\x2A\x8B\x35\x2A\x2A\x2A\x2A\x8B\xCE\x8B\x16\xFF\x52\x64\x8B\x8F\xF0\x1F\x00\x00\x53\x6A\x14", 49);
PrepSDKCall_AddParameter(SDKType_String, SDKPass_Pointer);
if ((g_hSDKPlayGesture = EndPrepSDKCall()) == INVALID_HANDLE) SetFailState("Failed to create SDKCall for CTFPlayer::PlayGesture offset!");
}
public void OnEntityCreated(int ent, const char[] classname)
{
if(StrEqual(classname, "tf_weapon_handgun_scout_primary"))
{
SDKHook(ent, SDKHook_Spawn, OnCTFPistol_ScoutPrimarySpawn);
}
}
public void OnCTFPistol_ScoutPrimarySpawn(int wep)
{
DHookEntity(g_hGetSecondaryAttackActivity, true, wep);
}
public MRESReturn CTFPistol_ScoutPrimary__SecondaryAttack(int pThis, Handle hReturn, Handle hParams)
{
int client = GetEntPropEnt(pThis, Prop_Data, "m_hOwnerEntity");
if(client > 0)
{
if(GetEntProp(client, Prop_Send, "m_nWaterLevel") >= 2)
{
SDKCall(g_hSDKPlayGesture, client, "ACT_MP_PUSH_SWIM_SECONDARY");
}
else if(GetEntProp(client, Prop_Send, "m_bDucked"))
{
SDKCall(g_hSDKPlayGesture, client, "ACT_MP_PUSH_CROUCH_SECONDARY");
}
else
{
SDKCall(g_hSDKPlayGesture, client, "ACT_MP_PUSH_STAND_SECONDARY");
}
}
return MRES_Ignored;
}
DHooks and stuff, if you're gonna release this or something put the gamedata in a config
__________________