AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   help me to find a better optimization for plugin (https://forums.alliedmods.net/showthread.php?t=156542)

Nightfall1 05-08-2011 06:49

help me to find a better optimization for plugin
 
I have this
PHP Code:

new const custom_base[][] = { "info_target",  "hostage_entity""monster_scientist""player" }
public 
plugin_init()
{
 for (new 
nsizeof custom_basen++)
 
RegisterHam(Ham_Touchcustom_base[n], "touch_item")



PHP Code:

public touch_item(enttouched)
{
if(
<= touched <= 32
// code


i think is will be COMPARE+BRANCH


PHP Code:

public touch_item(enttouched)
{
if(
touched <= 32 && touched 0)
// code


i think is will be COMPARE, COMPARE+BRANCH


or this
PHP Code:

public touch_item(enttouched)
{
if(
<= touched <= get_maxplayers()) 
// code


CALL get_maxplayers() and COMPARE+BRANCH

ConnorMcLeod 05-08-2011 07:41

Re: help me to find a better optimization for plugin
 
Code:
new g_iMaxPlayers #define IsPlayer(%0)  (1<=%0<=g_iMaxPlayers) public plugin_init() {  g_iMaxPlayers = get_maxplayers() } public item_touch(iEnt, id) {  if( IsPlayer(id) && is_user_alive(id) )  {  } }

I don't think that info_target are touchable, but may be you alter their size.
Also if you alter their classname, then you could consider using register_touch(new_classname, "player", "callback")

Nightfall1 05-08-2011 08:03

Re: help me to find a better optimization for plugin
 
I need what custom_base touch all entitys on map include worldspawn, what you give my there is only for custom_base touch player

SonicSonedit 05-08-2011 10:31

Re: help me to find a better optimization for plugin
 
ConnorMcLeod
They are touchable. Even sprite entities can be touchable.

Nightfall1
Yep, these statements are all the same.
Little advice - don't call get_maxplayers(), store it in g_maxplayers variable on plugin_init and use
PHP Code:

public touch_item(enttouched)
{
   if(
<= touched <= g_maxplayers
   {
      
// code
   
}




All times are GMT -4. The time now is 04:18.

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