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
01101101
BANNED
Join Date: Nov 2009
Location: 9`su 09`n0n7e`r0f76a
Old 07-28-2010 , 01:44   Is using "entity think" faster than set_task and remove_task?
Reply With Quote #1

I need to "reset" task really often (by reset I mean remove the task and set it to a new time). Is worth creating an entity just for changing to pev_nextthink and hooking the think? If so, which is the proper way to hook it. Because with FM I hook all entities think and have to check the classname/whatevervalue. I think there was another hook which already filtered the think.
01101101 is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 07-28-2010 , 01:51   Re: Is using "entity think" faster than set_task and remove_task?
Reply With Quote #2

It is basically a choice between letting AMXX handle the timing or letting the HL engine deal with it.

You can use a global entity with a FM hook and then do an easy check to see if it is the same entity.

The other option would be to use a custom classname and use engine's register_think native.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
01101101
BANNED
Join Date: Nov 2009
Location: 9`su 09`n0n7e`r0f76a
Old 07-28-2010 , 02:55   Re: Is using "entity think" faster than set_task and remove_task?
Reply With Quote #3

Quote:
Originally Posted by Emp` View Post
It is basically a choice between letting AMXX handle the timing or letting the HL engine deal with it.

You can use a global entity with a FM hook and then do an easy check to see if it is the same entity.

The other option would be to use a custom classname and use engine's register_think native.
So, which do you suggest? It's called very often btw (remove and settask together around 10 times/second)
01101101 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-28-2010 , 06:44   Re: Is using "entity think" faster than set_task and remove_task?
Reply With Quote #4

You can also create an entity with a not often used classname and register the think with Ham.
If you have only 1 ent in the plugin, filter by entity index.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
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 #5

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 #6

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 #7

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 #8

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


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