Lux, thanks.
xZk, can I ask you something about your code.
In OnEntityCreated you are using:
PHP Code:
SDKHook(entity, SDKHook_ThinkPost, OnThinkPost);
instead of SDKHook_OnSpawn to begin check for weapon and tracking.
Is it roughly speaking almost identical events in time for _weapon class to safe check its props?
PHP Code:
HookEvent("round_start", Event_RoundReset);
HookEvent("round_end", Event_RoundReset);
HookEvent("round_freeze_end", Event_RoundFreezeEnd);
you are using "round_freeze_end" to begin tracking. This event is happen slightly later than "round_start".
What kind of error that case prevents?
And a recommendation:
Use EntIndexToEntRef when you pass entity index to a timer function.
Like:
PHP Code:
DelayClean[entity] = CreateTimer(1.0, CleanWeapon, EntIndexToEntRef(entity), TIMER_REPEAT);
...
public Action:CleanWeapon(Handle:timer, any:entRef) {
int weapon = EntRefToEntIndex(entRef);
if (weapon == 0 || weapon == INVALID_ENT_REFERENCE || !IsValidEntity(weapon))
return Plugin_Stop;
Also, it looks like TIMER_FLAG_NO_MAPCHANGE flag is missing.
PHP Code:
case 3: { //Reset Timer on aiming
if (IsAimToPlayers(weapon)) {
_debug("Time: %d", ItemTime[weapon]);
return Plugin_Continue;
}
}
you missed:
PHP Code:
ItemTime[weapon] = delayclear;
Quote:
OnEntityCreated => tracking
OnWeaponDrop => tracking
|
Request.
Maybe, add ConVar to track only the case when weapon dropped (do not track all spawned entities). To increase CPU performance.
__________________