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

Allowing a client to use plugin depending on health


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Frizzel
New Member
Join Date: May 2011
Old 06-05-2011 , 20:53   Allowing a client to use plugin depending on health
Reply With Quote #1

Is there any way, to check the clients health, in Team Fortress 2, to see if its full, to allow them to use the plugin? Ive been looking around, and all ive found are plugins to change the clients health. Thanks in advance
Frizzel is offline
Cookies.net
Senior Member
Join Date: Jan 2011
Old 06-06-2011 , 03:56   Re: Allowing a client to use plugin depending on health
Reply With Quote #2

Not sure but i think this should work
PHP Code:
if (GetEntProp(clientProp_Send"m_iHealth") >= GetEntProp(clientProp_Send"m_iMaxHealth"))
{
    
//do stuff here

untested though
Cookies.net is offline
Frizzel
New Member
Join Date: May 2011
Old 06-06-2011 , 15:50   Re: Allowing a client to use plugin depending on health
Reply With Quote #3

Well, i gave that a try, and i got this

L 06/06/2011 - 15:42:47: [SM] Native "GetEntProp" reported: Property "m_iMaxHeal
th" not found (entity 1/player)
L 06/06/2011 - 15:42:47: [SM] Displaying call stack trace for plugin "tele.smx":
L 06/06/2011 - 15:42:47: [SM] [0] Line 47, G:\pstudio-0.8.3\sourcemod\scripti
ng\tele.sp::Teleport_User()
Frizzel is offline
Afronanny
Veteran Member
Join Date: Aug 2009
Old 06-06-2011 , 15:57   Re: Allowing a client to use plugin depending on health
Reply With Quote #4

I don't recall a prop named m_iMaxHealth existing

Last edited by Afronanny; 06-06-2011 at 15:59.
Afronanny is offline
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 06-06-2011 , 16:00   Re: Allowing a client to use plugin depending on health
Reply With Quote #5

TF2_GetPlayerResourceData(client, TFResource_MaxHealth);
?

-----
Update, talking to him on steamchat, a long time friend.....he needed a realtime example.

Sorry you newb lol:
Code:
#include <tf2_stocks>

#define LOLDEBUG
public FUHQ(client)
{
	new hp = GetEntProp(client, Prop_Send, "m_iHealth");
	new hpm = TF2_GetPlayerResourceData(client, TFResource_MaxHealth);
	#if defined LOLDEBUG
	PrintToChatAll("client#[%i] - HP[%i/%i]",client,hp,hpm);
	#endif
	if ( hp >=  hpm) 
	{ 
		//do stuff here 
	}  
}
Heres your other block of code you wanted
Code:
	if(GetConVarInt(c_Enabled)) 
	{
		if(IsPlayerAlive(client)) 
		{
			if(GetEntProp(client, Prop_Send, "m_iHealth") >= TF2_GetPlayerResourceData(client, TFResource_MaxHealth)) 
			{
				//(g_Location[client][1] != 0)
				TeleportEntity(client, g_Location[client], NULL_VECTOR, NULL_VECTOR);
				ReplyToCommand (client, "You have been teleported to the skybox!");
			}
			else
			{
				PrintToChat(client,"Your health needs to be at max health or higher to use teleport.");
			}
		} 
		else 
		{
			ReplyToCommand (client, "You're dead, do you really think its possible to teleport while being dead?");
		}
	}
Here's the other block:
Code:
	stock GetEntityOrigin(entity,Float:fOrigin[3])
	{
		GetEntPropVector(entity,Prop_Send,"m_vecOrigin",fOrigin);
	}  
	stock FindEntityByTargetname(const String:targetname[], const String:classname[])
	{
		decl String:namebuf[32];
		new index = -1;
		namebuf[0] = '\0';
		while(strcmp(namebuf, targetname) != 0 && (index = FindEntityByClassname(index, classname)) != -1) GetEntPropString(index, Prop_Data, "m_iName", namebuf, sizeof(namebuf));
		return(index);
	}
__________________


Last edited by mysticssjgoku4; 06-06-2011 at 16:39. Reason: frizzel is a nubcaek
mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
Cookies.net
Senior Member
Join Date: Jan 2011
Old 06-07-2011 , 03:02   Re: Allowing a client to use plugin depending on health
Reply With Quote #6

Quote:
Originally Posted by Afronanny View Post
I don't recall a prop named m_iMaxHealth existing
*facepalm* scrolled too far down without noticing >.<
Cookies.net is offline
Reply



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 07:58.


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