Changing Aura Model Lags for a Second?

NOT IN THE MANGA™
★ Black Lounger ★
✔️ HL Verified
🚂 Steam Linked
💻 Oldtimer
Joined
Jan 5, 2008
Messages
3,276
Best answers
0
Location
Lithuania
Hello. I have created a plugin which changes default aura model to custom one. Then, some pro told me that it lags for a milisecond when you turn on the turbo/swoop. I didn't believe him at first because I haven't noticed anything strange with the aura.

Then, after losing 1 vs. 1 against him 10-1 (I've left him 9 HP) he told me that I might not notice the short lag, but he does. He plays ESF from the very beginning (at least he said so) and that's why he does notice the short lag.

This is the code I'm using:
Code:
#include <amxmodx>
#include <fakemeta>

new CustomAuraModel[] = "models/newaura.mdl";

public plugin_precache()
	engfunc(EngFunc_PrecacheModel, CustomAuraModel);

public plugin_init()
{
	register_plugin("Custom Aura Model", "1.0", "hleV");

	register_forward(FM_EmitSound, "EmitSoundForward");
}

public EmitSoundForward(ClientID, ChannelID, SoundName[])
{
	if (contain(SoundName, "swoop") != -1 || contain(SoundName, "aura") != -1) // Maybe I should use equal()
	{
		static EntityID;
		EntityID = FM_NULLENT;

		while ((EntityID = engfunc(EngFunc_FindEntityByString, EntityID, "model", "models/aura.mdl")) > 0)
			if (pev(EntityID, pev_owner) == ClientID)
			{
				engfunc(EngFunc_SetModel, EntityID, CustomAuraModel);

				break; // Not sure if it's needed here
			}
	}
}
So, can this result in a like 0.05 (more or less) sec lag? If so, can I optimize the code somehow?

EDIT: That pro is pharaoh.
 
Last edited:
New Member
Joined
Jan 3, 2008
Messages
21
Best answers
0
Perhaps you can use clientpostthink to check for the aura model instead of an emitsound callback func.
 
NOT IN THE MANGA™
★ Black Lounger ★
✔️ HL Verified
🚂 Steam Linked
💻 Oldtimer
Joined
Jan 5, 2008
Messages
3,276
Best answers
0
Location
Lithuania
dutchmeat[nl];935676 said:
Perhaps you can use clientpostthink to check for the aura model instead of an emitsound callback func.
Don't you think that it would increase the lag even more? Post Think is called much more often and there's no point in setting the model if it's already set. That's why I'm setting it only once, when the aura appears. Maybe doing it with Engine module would be less expensive.
 
New Member
Joined
Jan 3, 2008
Messages
21
Best answers
0
you're right on that,
but why are you looping FindEntityByString ? Can't you call it just once?
 

Users who are viewing this thread

Top Bottom