Raised This Month: $ Target: $400
 0% 

Can EngFunc_PlaybackEvent cause lags/cpu usage?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 03-11-2009 , 04:58   Can EngFunc_PlaybackEvent cause lags/cpu usage?
Reply With Quote #1

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?
__________________
xPaw is offline
BOYSplayCS
BANNED
Join Date: Apr 2008
Location: Gainesville, FL
Old 03-11-2009 , 06:47   Re: Can EngFunc_PlaybackEvent cause lags/cpu usage?
Reply With Quote #2

It may cause a lag when the task is being operated, but other than that, no.
BOYSplayCS is offline
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 03-11-2009 , 06:50   Re: Can EngFunc_PlaybackEvent cause lags/cpu usage?
Reply With Quote #3

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 );
__________________

anakin_cstrike is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-11-2009 , 07:40   Re: Can EngFunc_PlaybackEvent cause lags/cpu usage?
Reply With Quote #4

From my experience, a 5-second repeated task will not lag a server.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 03-11-2009 , 07:45   Re: Can EngFunc_PlaybackEvent cause lags/cpu usage?
Reply With Quote #5

Opss...i saw 0.5 not 5.0
__________________

anakin_cstrike is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 03-11-2009 , 07:53   Re: Can EngFunc_PlaybackEvent cause lags/cpu usage?
Reply With Quote #6

Well, would be better to create an entiy which think each x seconds instead of using set_task.
Arkshine is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 03-11-2009 , 08:49   Re: Can EngFunc_PlaybackEvent cause lags/cpu usage?
Reply With Quote #7

ok thanks for answers

@arkshine: ill do that ;)
__________________
xPaw is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-11-2009 , 14:03   Re: Can EngFunc_PlaybackEvent cause lags/cpu usage?
Reply With Quote #8

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)
    }

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 03-11-2009 , 14:10   Re: Can EngFunc_PlaybackEvent cause lags/cpu usage?
Reply With Quote #9

wow, thanks! :p
__________________
xPaw is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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