Raised This Month: $ Target: $400
 0% 

View Poll Results: Wich of this options is better at the moment of call a function very often?
simple set_task at 0.1 in the called funcion.. 1 8.33%
infinite set_task (and then remove it out) (id, _, _, "b") 2 16.67%
Client_prethink 4 33.33%
fm_prethink 3 25.00%
ham_prethink 2 16.67%
Voters: 12. You may not vote on this poll

Optimizing a plugin.Wich of these options is better?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-15-2009 , 04:10   Re: Optimizing a plugin.Wich of these options is better?
Reply With Quote #10

To execute something every 0.1 seconds, joaquim's way is really fine, you should consider it (you can also read Hawk552 tuts about tasks)

For your message code, this would be better :

-Don't use floats in you don't really need some
-> so use get_user_origin -> faster
-> message_begin -> faster
-> write_coord -> faster

- set_user_rendering vs fm_set_rendering should be ~ 7 times faster

PHP Code:
    static origin[3]            
    
get_user_origin(idorigin)

    
// Colored Aura
    
message_begin(MSG_PVSSVC_TEMPENTITYorigin)
    
write_byte(TE_DLIGHT// TE id
    
write_coord(origin[0]) // x
    
write_coord(origin[1]) // y
    
write_coord(origin[2]) // z
    
write_byte(13// radius asdasdasd
    
write_byte(255// r
    
write_byte(0// g
    
write_byte(0)  // b 
    
write_byte(2// life
    
write_byte(0// decay rate
    
message_end() 
                
    
//Glow
    
set_user_rendering(idkRenderFxGlowShell25500kRenderNormal35)

    
// Particle Burst
    
message_begin(MSG_PVSSVC_TEMPENTITYorigin)
    
write_byte(TE_PARTICLEBURST// TE id
    
write_coord(origin[0]) // x
    
write_coord(origin[1]) // y
    
write_coord(origin[2]) // z
    
write_short(20// radius
    
write_byte(208// color
    
write_byte(3// duration (will be randomized a bit)
    
message_end() 
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
 



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 02:21.


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