Raised This Month: $ Target: $400
 0% 

Is using "entity think" faster than set_task and remove_task?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-28-2010 , 08:14   Re: Is using "entity think" faster than set_task and remove_task?
Reply With Quote #1

If I understood right, you can easily do that with engine:

Code:
public plugin_init()
{
   register_think("myGlobalThink", "ent_think")

   /* you don't have to create the entity here if you don't want */

   new ent = create_entity("info_target")

   if(ent)
   {
      entity_set_string(ent, EV_SZ_classname, "myGlobalThink")
      entity_set_float(ent, EV_FL_nextthink, get_gametime() + 0.01)

      /* There's no need for call_think() or DispatchSpawn() */
   }
}

public ent_think(ent)
{
   /* do stuff... */

   entity_set_float(ent, EV_FL_nextthink, get_gametime() + 0.01)
}
If you really need something done really fast or verry accurate use that.

From my experience, set_task() is not too reliable on accurate timeline and can be set to a minimum of 0.1 seconds.
__________________

Last edited by Hunter-Digital; 07-28-2010 at 08:19.
Hunter-Digital is offline
tm.
Member
Join Date: Apr 2010
Old 07-28-2010 , 13:05   Re: Is using "entity think" faster than set_task and remove_task?
Reply With Quote #2

I have a question related to this subject. What is more eficient (less resources) if you need to run a loop task on all players: to set individual task for each player at connection, or to set one task/entity that loops through all players and executes the function. This question might sound stupid, but I'm just curious.

Last edited by tm.; 07-28-2010 at 13:13.
tm. is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 07-28-2010 , 14:56   Re: Is using "entity think" faster than set_task and remove_task?
Reply With Quote #3

Quote:
Originally Posted by tm. View Post
I have a question related to this subject. What is more eficient (less resources) if you need to run a loop task on all players: to set individual task for each player at connection, or to set one task/entity that loops through all players and executes the function. This question might sound stupid, but I'm just curious.
One task, then loop through all players in the function.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
tm.
Member
Join Date: Apr 2010
Old 07-28-2010 , 15:44   Re: Is using "entity think" faster than set_task and remove_task?
Reply With Quote #4

Quote:
Originally Posted by wrecked_ View Post
One task, then loop through all players in the function.
Thanks.
tm. 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 00:11.


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