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?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
_lol_
Senior Member
Join Date: Apr 2009
Old 04-14-2009 , 22:12   Re: Optimizing a plugin.Wich of these options is better?
Reply With Quote #1

1-that is just called on a player id...all the time...

2- ok.

PD:please dont quote my codes, because i will delete my posts when this thread be solved, i dont want to show my codes to every one...or only for a time?lol! xd
_lol_ is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 04-14-2009 , 22:22   Re: Optimizing a plugin.Wich of these options is better?
Reply With Quote #2

Quote:
Originally Posted by _lol_ View Post
1-that is just called on a player id...all the time...

2- ok.

PD:please dont quote my codes, because i will delete my posts when this thread be solved, i dont want to show my codes to every one...or only for a time?lol! xd
Its stupid to delete your posts because people lose time helping you and that help can be useful to others.
__________________
joaquimandrade is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-14-2009 , 22:29   Re: Optimizing a plugin.Wich of these options is better?
Reply With Quote #3

One method is not the best solution to all situations.

To find player's buttons, use FM_CmdStart.
To do something every frame and have it for a specific player, use client_PreThink().
To do something every frame for the whole server, use server_frame().
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
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 #4

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
_lol_
Senior Member
Join Date: Apr 2009
Old 04-15-2009 , 12:20   Re: Optimizing a plugin.Wich of these options is better?
Reply With Quote #5

Quote:
Originally Posted by ConnorMcLeod View Post
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() 
thank you very much...
_lol_ is offline
Reply



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