AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Is using "entity think" faster than set_task and remove_task? (https://forums.alliedmods.net/showthread.php?t=133709)

01101101 07-28-2010 01:44

Is using "entity think" faster than set_task and remove_task?
 
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.

Emp` 07-28-2010 01:51

Re: Is using "entity think" faster than set_task and remove_task?
 
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.

01101101 07-28-2010 02:55

Re: Is using "entity think" faster than set_task and remove_task?
 
Quote:

Originally Posted by Emp` (Post 1253859)
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)

ConnorMcLeod 07-28-2010 06:44

Re: Is using "entity think" faster than set_task and remove_task?
 
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.

Hunter-Digital 07-28-2010 08:14

Re: Is using "entity think" faster than set_task and remove_task?
 
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.

tm. 07-28-2010 13:05

Re: Is using "entity think" faster than set_task and remove_task?
 
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.

wrecked_ 07-28-2010 14:56

Re: Is using "entity think" faster than set_task and remove_task?
 
Quote:

Originally Posted by tm. (Post 1254247)
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.

tm. 07-28-2010 15:44

Re: Is using "entity think" faster than set_task and remove_task?
 
Quote:

Originally Posted by wrecked_ (Post 1254347)
One task, then loop through all players in the function.

Thanks.


All times are GMT -4. The time now is 00:11.

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