Hi! I've been messing around with a plugin for my tf2 server and I needed to mimic the characteristics of a health kit dropping on death, only except I can't really do that correctly with the small and medium health kits because for some reason when I try and take a percentage of health from a player (e.g. 125 * 0.2) it gives them 112500... health. The only reason I'm creating a "physical" prop entity instead of the actual med kit entity is because the med kit dropped has a custom model, and when Halloween is forced on, it overrides that model. No plugin that has tried to fix the game overriding the health model has been successful, so I opted to go this path, and I'm very close to having it perfect, just these 2 issues are present. I'm more of a glua coder so some of my old habits don't work in SourcePawn, plus I haven't coded in a really long time.
Yes, this code is kinda poop and I'm embarrassed over sharing how much copy paste happened but I just need a working plugin, nothing more or less
Code:
(iEntity = client)
--
new MaxHealth = GetEntData( iEntity, FindDataMapOffs( iEntity, "m_iMaxHealth" ), 4 );
SetEntProp( iEntity, Prop_Send, "m_iHealth", MaxHealth * 0.2, 4 );
Then the 2nd issue is with EmitSound. The sound is precached during map start and is downloaded correctly and plays fine with other versions of this plugin, including being able to play the sound using the "play items/asdf.wav" command. But, for some reason, whenever I use the version that I edited, it just will not play the sound no matter what I do.
Code:
(iEntity = client)
(iMushroom = the health prop entity being dropped)
--
new Float:pos[ 3 ];
decl String:ModelName[ PLATFORM_MAX_PATH ];
GetEntPropString( iMushroom, Prop_Data, "m_ModelName", ModelName, sizeof( ModelName ) );
if ( StrEqual( MDL_MUSHSMALL, ModelName, false ) )
{
GetEntPropVector( iMushroom, Prop_Send, "m_vecOrigin", pos );
EmitSoundToAll( SND_MUSH, 0, _, _, _, _, _, _, pos );
SetEntProp( iEntity, Prop_Send, "m_iHealth", 65, 4 );
AcceptEntityInput( iMushroom, "Kill" );
}
I've spent hours trying to do this without asking for help but I've spent so much time into such a non-essential plugin, I need advice lol. Thanks for reading!
__________________