View Single Post
DarkPyro
Member
Join Date: Aug 2013
Old 08-15-2019 , 10:07   Re: [TF2] Multiplying Percents (Decimals) & EmitSound
Reply With Quote #7

Quote:
Originally Posted by kking117 View Post
Element in this case seems to mean the entity number. Which means it's trying to get the max health of something that isn't a client (probably). Just to make sure, does your code look something like this?

Code:
new MaxHealth = GetClientMaxHealth(iEntity);
SetEntProp(iEntity, Prop_Send, "m_iHealth", RoundToNearest(MaxHealth * 0.2));
Yeah it does, it did have a 4 after the RoundToNearest function but I removed it and it didn't make a difference. This is the check that it does in that Touch function.

Code:
	if ( iEntity > 0 && iEntity <= MaxClients && IsPlayerAlive( iEntity ) && CurHealth < MaxHealth )
And this is the code that calls the Touch function

Code:
SDKHook( Mushroom, SDKHook_StartTouch, MushroomTouch );
The thing is, I create those health checks BEFORE I call the Touch check that I posted above, and that could be the reason why it's also targeting other things it's not supposed to (I also created the same function to check for current health, albeit redundant, I wanted to be consistent. But, it was yielding the same errors before and after I did that):

Code:
public MushroomTouch( iMushroom, iEntity ) {
	new CurHealth = GetClientCurrentHealth( iEntity );
	new MaxHealth = GetClientMaxHealth( iEntity );

	// Continue only if the touching entity is a player
	if ( iEntity > 0 && iEntity <= MaxClients && IsPlayerAlive( iEntity ) && CurHealth < MaxHealth ) {
I'm not sure if that would be the issue. I'll check it out in a little bit if placing CurHealth and MaxHealth after the touching check would solve it.

EDIT: After I moved CurHealth and MaxHealth after the check, all the errors have stopped (as far as I tested anyway). Thanks for all the help!
__________________



Last edited by DarkPyro; 08-15-2019 at 10:49.
DarkPyro is offline