Raised This Month: $ Target: $400
 0% 

help me to find a better optimization for plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nightfall1
Senior Member
Join Date: Aug 2008
Old 05-08-2011 , 06:49   help me to find a better optimization for plugin
Reply With Quote #1

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
__________________
SIGNATURE

Last edited by Nightfall1; 05-08-2011 at 06:52.
Nightfall1 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-08-2011 , 07:41   Re: help me to find a better optimization for plugin
Reply With Quote #2

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")
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Nightfall1
Senior Member
Join Date: Aug 2008
Old 05-08-2011 , 08:03   Re: help me to find a better optimization for plugin
Reply With Quote #3

I need what custom_base touch all entitys on map include worldspawn, what you give my there is only for custom_base touch player
__________________
SIGNATURE
Nightfall1 is offline
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 05-08-2011 , 10:31   Re: help me to find a better optimization for plugin
Reply With Quote #4

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
   
}

__________________

SonicSonedit 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 04:18.


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