AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Can EngFunc_PlaybackEvent cause lags/cpu usage? (https://forums.alliedmods.net/showthread.php?t=87397)

xPaw 03-11-2009 04:58

Can EngFunc_PlaybackEvent cause lags/cpu usage?
 
PHP Code:

#include <amxmodx>
#include <fakemeta>

#define FEV_GLOBAL (1<<2)

public plugin_init() {
    
register_plugin"Decal Remover""1.0""xPaw" );
    
    
set_task5.0"removeDecals"_,_,_"b" );
}

public 
removeDecals() {    // original stock from fakemeta_util
    
static eventindex_decal_reset;
    if ( !
eventindex_decal_reset )
        
eventindex_decal_reset engfunc(EngFunc_PrecacheEvent1"events/decal_reset.sc");
    
    
engfunc(EngFunc_PlaybackEventFEV_GLOBAL0eventindex_decal_reset0.0Float:{0.00.00.0}, Float:{0.00.00.0}, 0.00.00000);


i have this code, i've done it for my csdm, i'm asking will it cause lags or something because of task?

BOYSplayCS 03-11-2009 06:47

Re: Can EngFunc_PlaybackEvent cause lags/cpu usage?
 
It may cause a lag when the task is being operated, but other than that, no.

anakin_cstrike 03-11-2009 06:50

Re: Can EngFunc_PlaybackEvent cause lags/cpu usage?
 
Quote:

i'm asking will it cause lags or something because of task?
Yes, i think...
Maybe this will be better
Code:
#include <amxmodx> #include <fakemeta> new const g_sEvent[ ] = "events/decal_reset.sc"; new g_sEventIndex; public plugin_init()     register_forward( FM_PlaybackEvent, "Fw_PlaybackEvent" ); public plugin_precache()     g_sEventIndex = engfunc( EngFunc_PrecacheEvent, 1, g_sEvent );     public Fwd_PlaybackEvent( Flags, Id, EventIndex )     if( EventIndex == g_sEventIndex )         engfunc( EngFunc_PlaybackEvent, FEV_GLOBAL, 0, EventIndex, 0.0, Float:{ 0.0, 0.0, 0.0 }, Float:{ 0.0, 0.0, 0.0 }, 0.0, 0.0, 0, 0, 0, 0 );

Exolent[jNr] 03-11-2009 07:40

Re: Can EngFunc_PlaybackEvent cause lags/cpu usage?
 
From my experience, a 5-second repeated task will not lag a server.

anakin_cstrike 03-11-2009 07:45

Re: Can EngFunc_PlaybackEvent cause lags/cpu usage?
 
Opss...i saw 0.5 not 5.0 :crab:

Arkshine 03-11-2009 07:53

Re: Can EngFunc_PlaybackEvent cause lags/cpu usage?
 
Well, would be better to create an entiy which think each x seconds instead of using set_task.

xPaw 03-11-2009 08:49

Re: Can EngFunc_PlaybackEvent cause lags/cpu usage?
 
ok thanks for answers

@arkshine: ill do that ;)

ConnorMcLeod 03-11-2009 14:03

Re: Can EngFunc_PlaybackEvent cause lags/cpu usage?
 
Or use the magic ent, it thinks every 0.3sec, so use a counter and launch the code when the counter %15 = 0, every 4.5 sec decals will be removed.

Tested and working :

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN "remove decals"
#define AUTHOR "ConnorMcLeod"
#define VERSION "0.0.1"

#define FEV_RELIABLE (1<<1)
#define FEV_GLOBAL (1<<2)

new g_iDecalReset
new g_iTaskEnt

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
RegisterTask()

    
g_iDecalReset engfunc(EngFunc_PrecacheEvent1"events/decal_reset.sc")
}

RegisterTask()
{
    new 
iEnt
    
new iMaxEnts global_get(glb_maxEntities)
    new 
szClassName[2]
    
// without amxx, the ent id is maxplayers + 1
    // but if a plugin creates some entities during precache it won't
    // so use this code to retrieve the ent
    
for(iEnt get_maxplayers() + 1iEnt<iMaxEntsiEnt++)
    {
        if( 
pev_valid(iEnt) )
        {
            
pev(iEntpev_classnameszClassNamecharsmax(szClassName))
            if( !
szClassName[0] )
            {
                
g_iTaskEnt iEnt
                RegisterHamFromEntity
(Ham_ThinkiEnt"Task_RemoveDecals"1)
                return
            }
        }
    }
}

public 
Task_RemoveDecalsiEnt )
{
    if( 
iEnt != g_iTaskEnt )
    {
    
/*    new szClassName[32]
        pev(iEnt, pev_classname, szClassName, charsmax(szClassName))
        log_to_file("ClassLessEnt", szClassName)*/
        
return
    }

    static 
iCount
    
if( ++iCount 15 == )
    {
        
engfunc(EngFunc_PlaybackEventFEV_RELIABLE|FEV_GLOBAL0g_iDecalReset0.0Float:{0.00.00.0}, Float:{0.00.00.0}, 0.00.00000)
    }



xPaw 03-11-2009 14:10

Re: Can EngFunc_PlaybackEvent cause lags/cpu usage?
 
wow, thanks! :p


All times are GMT -4. The time now is 08:50.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.