I'm trying to make a small script which allows player to get themselves up using Adrenaline. Well, it seems that I've already got to this part, my script now revives player with the CTerrorPlayer::OnRevived function. But what I want to do next is make it so a player gets a speed boost after getting themselves up, pretty much like a normal use of adrenaline with all the effects afterwards. And now I'm stuck on it. I'm guessing CItem_Adrenaline::CompleteUse is just what I'm looking for, but it requires CTerrorPlayer* as a parameter and I have no idea how to pass that parameter to it. I've tried CBaseEntity::GetBaseEntity, but whatever, plugin just refuses to load and every single time shines with an "<Error>" prefix in console.
In error logs I get something like "CompleteUse requires pointer to an entity; none specified" or "Invalid handle", it varies, I'm confused already.
I have this gamedata file.
Code:
"Games"
{
"left4dead2"
{
"Offsets"
{
"CBaseEntity_GetBaseEntity"
{
"windows" "5"
"linux" "6"
}
"CTerrorPlayer_OnRevived"
{
"windows" "582"
"linux" "584"
}
"CItem_Adrenaline_CompleteUse"
{
"windows" "446"
"linux" "448"
}
}
}
}
And this script.
Code:
// CBaseEntity_GetBaseEntity
StartPrepSDKCall (SDKCall_Player)
if (!PrepSDKCall_SetFromConf (config, SDKConf_Virtual, "CBaseEntity_GetBaseEntity")) {
CloseHandle (config);
SetFailState ("There's been an error.");
}
PrepSDKCall_SetReturnInfo (SDKType_CBaseEntity, SDKPass_ByRef);
CloseHandle (config);
getBaseEntity = EndPrepSDKCall ();
if (getBaseEntity == INVALID_HANDLE) SetFailState ("There's been an error.");
// CTerrorPlayer_OnRevived
StartPrepSDKCall (SDKCall_Player);
if (!PrepSDKCall_SetFromConf (config, SDKConf_Virtual, "CTerrorPlayer_OnRevived")) {
CloseHandle (config);
SetFailState ("There's been an error.");
}
CloseHandle (config);
revive = EndPrepSDKCall ();
if (revive == INVALID_HANDLE) SetFailState ("There's been an error.");
// CItem_Adrenaline_CompleteUse
StartPrepSDKCall (SDKCall_Entity);
if (!PrepSDKCall_SetFromConf (config, SDKConf_Virtual, "CItem_Adrenaline_CompleteUse")) {
CloseHandle (config);
SetFailState ("There's been an error.");
}
PrepSDKCall_AddParameter (SDKType_CBaseEntity, SDKPass_Pointer);
CloseHandle (config);
useAdrenaline = EndPrepSDKCall ();
if (useAdrenaline == INVALID_HANDLE) SetFailState ("There's been an error.");
And here I'm calling SDKCall's.
Code:
public Action OnPlayerRunCmd (int client, int& buttons, int& impulse, float vel[3], float angles[3], int& weapon) {
if (!IsSurvivor (client) /*|| !IsSurvivorIncapacitated (client)*/) return Plugin_Continue;
//new medkit = GetPlayerWeaponSlot (client, KIT_SLOT);
if (buttons & IN_USE /*&& medkit != -1*/) {
// RemoveEdict (medkit);
// if (CVAR_SetDyingState) SetEntProp (client, Prop_Send, "m_currentReviveCount", 2);
// SDKCall (revive, client);
SDKCall (useAdrenaline, client, SDKCall (getBaseEntity, client));
}
return Plugin_Continue;
}