Raised This Month: $12 Target: $400
 3% 

Solved How do I set a client's buttons?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
LordHotPocketHomicide
Member
Join Date: Aug 2016
Location: This Realm of Existence
Old 07-02-2021 , 00:51   How do I set a client's buttons?
Reply With Quote #1

So I did some looking around on this topic, and I eventually found this helpful thread. I followed Powerlord's suggestion, and I wound up with the following code:

If you're curious, IsValidMulti is a custom stock that checks if a client is valid, as well as if they meet various conditions depending on what's passed to it. In this case, I use it to make sure the possessed player is alive, and to make sure the possessor is both alive and a boss (this is meant as part of a Freak Fortress ability pack).
Code:
public Action:possessed(client) //PreThink hook, used to set the client's buttons each frame.
{
	if (IsValidMulti(client, true, true, false) && IsValidMulti(possession_Possessor[client]) && FF2_HasAbility(FF2_GetBossIndex(possession_Possessor[client]), SPOOK, POSSESSION))
	{
		new buttons = GetClientButtons(possession_Possessor[client]); //Grab the buttons of whoever is controlling this player
		SetClientButtons(client, buttons); //Set the possessed player's buttons in accordance with the above
	}
}

public void SetClientButtons(int client, int buttons) //Borrowed from entity_prop_stocks and modified
{
	if (IsValidClient(client))
	{
		char datamap[32];
		GameData gc = new GameData("core.games");
		bool exists = gc.GetKeyValue("m_nButtons", datamap, sizeof(datamap));
		delete gc;

		if (!exists)
		{
			strcopy(datamap, sizeof(datamap), "m_nButtons");
		}

		SetEntProp(client, Prop_Data, datamap, buttons);
	}
}
The code is successful in letting me control when the possessed player shoots or uses alt-fire, but it doesn't do anything else. Does anyone have 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!

Last edited by LordHotPocketHomicide; 07-07-2021 at 23:17.
LordHotPocketHomicide is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:36.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode