View Single Post
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 03-20-2019 , 12:09   Re: [L4D/L4D2]Weapon Cleaner
Reply With Quote #4

Lux, thanks.
xZk, can I ask you something about your code.

In OnEntityCreated you are using:
PHP Code:
SDKHook(entitySDKHook_ThinkPostOnThinkPost); 
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.0CleanWeaponEntIndexToEntRef(entity), TIMER_REPEAT);
...
public 
Action:CleanWeapon(Handle:timerany:entRef) { 
    
int weapon EntRefToEntIndex(entRef);    
    if (
weapon == || 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.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 03-20-2019 at 12:09.
Dragokas is offline