Quote:
Originally Posted by Silvers
Would suggest doing "static GameData gc" and checking if "gc != null" before reading the gamedata, especially if this stock is being used over and over.
Anyway, have a look at "OnPlayerRunCmd" and set client buttons there? That should give full control I think.
|
Thanks, man! Turns out I was already using OnPlayerRunCmd, I just thought it wasn't working; turns out my validity checks were wrong, so it wasn't doing anything. Anyway, I fixed up the validity checks and added the following:
Code:
public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3])
{
if (IsValidMulti(client, true, true, false) && IsValidMulti(possession_Possessor[client])) //If the client running the command is possessed, replace their buttons with the possessor's.
{
buttons = GetClientButtons(possession_Possessor[client]);
CPrintToChatAll("{purple}Attempting to set %N's buttons to that of %N...", client, possession_Possessor[client]);
return Plugin_Changed;
}
else if (IsValidMulti(client) && IsValidMulti(possession_Host[client], true, true, false)) //If the client running the command is a boss using this ability, force their inputs on their "host" (player they are possessing).
{
CPrintToChatAll("{purple}Attempting to force %N's buttons on %N...", client, possession_Host[client]);
SetClientButtons(possession_Host[client], buttons);
}
}
I also went ahead and removed the PreThink hook, then fixed up SetClientButtons as you suggested. The result was an improvement: in addition to controlling when the host fires or uses alt-fire, it now allows the possessor to control when their host jumps, crouches, or uses their special attack, though there is a small delay. However, it
doesn't allow the possessor to control the victim's movement or control when the victim switches weapons, which sort of renders the whole thing useless. I was thinking I could probably do some manual movement control using velocity, then mess around with m_hActiveWeapon to fix the weapon swap issue, but I feel like this would be somewhat hacky and would look/feel weird in-game. Any ideas?
__________________
Professional retard. I might borrow some code, but I always try to give credit when I do! If you've noticed I've borrowed some of your code, and you have a problem with that, please
add me on Steam and let me know so I can correct the problem as soon as possible!