Raised This Month: $ Target: $400
 0% 

optimization for equali


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Debesėlis
Senior Member
Join Date: Aug 2008
Location: Lithuania
Old 10-25-2013 , 10:43   optimization for equali
Reply With Quote #1

How to optimize that code?

PHP Code:
        if ( equaliName"fy_") || equaliName"awp_") || 
            
equaliName"cs_deagle5" ) || equaliName"cs_max" ) || 
            
equaliName"cs_pf_dust" ) || equaliName"cs_pf_train" ) || 
            
equaliName"aim_") || equaliName"35hp_") || 
            
equaliName"de_dust2_3x3") || equaliName"de_mirage_2x2") || 
            
equaliName"de_nuke_2x2") || equaliName"de_inferno_2x2") || 
            
equaliName"de_tuscan_2x2") || equaliName"de_snow_2x2") || 
            
equaliName"de_dust2_2x2" ) || equaliName"mini_dust2" ) ) 
Can i use it like this?
PHP Code:
equaliName"_2x2"
Debesėlis is offline
DWIGHTpN
Senior Member
Join Date: Jan 2013
Location: Romania.
Old 10-25-2013 , 10:54   Re: optimization for equali
Reply With Quote #2

Code:
new const maps[][] = {
 "cs_deagle5",
 "bla..."
} // etc

public function() {
         for(new i;i<sizeof maps;i++) {
              if( containi(maps[i], "_2x2") != -1 ) {
                 // do..
                 break;
              }
          }
}
DWIGHTpN is offline
Debesėlis
Senior Member
Join Date: Aug 2008
Location: Lithuania
Old 10-25-2013 , 11:14   Re: optimization for equali
Reply With Quote #3

Can you check my code? i think i'm doing something wrong.

PHP Code:
new const smallmaps[][] = {
    
"aim_",
    
"fy_",
    
"35hp_",
    
"awp_",
    
"cs_max",
    
"de_dust2_3x3",
    
"cs_pf_dust",
    
"cs_pf_train",
    
"cs_deagle5",
    
"mini_dust2"
}

new const 
bigmaps[][] = {
    
"de_",
    
"cs_office",
    
"cs_italy"

if now is small map server will use set_task ?
PHP Code:
            for ( new isizeof smallmapsi++ )
            {
                if ( 
containismallmaps], "_2x2") != -)
                    
set_task10.0"InfoMapBig" );
            } 
if now is big map ( de_ ) and isn't de_dust2_2x2 then use set_task ...
PHP Code:
            for ( new isizeof bigmapsi++ )
            {
                for ( new 
isizeof smallmapsi++ )
                    if ( 
containismallmaps], "_2x2") != -) return;
                
                
set_task10.0"InfoMapSmall" );
            } 
Debesėlis is offline
DWIGHTpN
Senior Member
Join Date: Jan 2013
Location: Romania.
Old 10-25-2013 , 11:46   Re: optimization for equali
Reply With Quote #4

use task for what?

You want to advertise admins when is small map on server and so much players?
Explain what do you want
DWIGHTpN is offline
Debesėlis
Senior Member
Join Date: Aug 2008
Location: Lithuania
Old 10-25-2013 , 12:03   Re: optimization for equali
Reply With Quote #5

task going for map change.

This code will check nice if map is big and isn't _2x2 ?
Quote:
Originally Posted by Debesėlis View Post
if now is big map ( de_ ) and isn't de_dust2_2x2 then use set_task ...
PHP Code:
            for ( new isizeof bigmapsi++ )
            {
                for ( new 
isizeof smallmapsi++ )
                    if ( 
containismallmaps], "_2x2") != -) return;
                
                
set_task10.0"InfoMapSmall" );
            } 

do i need to us break; ?
Quote:
Originally Posted by DWIGHTpN View Post
Code:
              if( containi(maps[i], "_2x2") != -1 ) {
                 // do..
                 break;

Last edited by Debesėlis; 10-25-2013 at 12:04.
Debesėlis is offline
DWIGHTpN
Senior Member
Join Date: Jan 2013
Location: Romania.
Old 10-25-2013 , 12:25   Re: optimization for equali
Reply With Quote #6

If you want to see if the actual map on server is small or big, check it out..
Code:
new const smallmaps[][] = {
    "aim_",
    "fy_",
    "35hp_",
    "awp_",
    "cs_max",
    "de_dust2_3x3",
    "cs_pf_dust",
    "cs_pf_train",
    "cs_deagle5",
    "mini_dust2"
}

new const bigmaps[][] = {
    "de_",
    "cs_office",
    "cs_italy"
}

new bool:IsSmallMap;

public plugin_init() {
         new map_name[64];
         get_mapname( map_name, charsmax( map_name ) );
         for(new i;i<sizeof smallmaps;i++)
             if( containi(map_name, smallmaps[i]) != -1 ) {
                   IsSmallMap= true;
                   break; // get out from for()
          }
}
Quote:
task going for map change.
This isn't correct, if you change map, all plugins (including tasks) will restart.
DWIGHTpN is offline
alan_el_more
Veteran Member
Join Date: Jul 2008
Location: amxmodx-es.com
Old 10-25-2013 , 12:27   Re: optimization for equali
Reply With Quote #7

The best method is using tries
__________________
alan_el_more is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-25-2013 , 12:51   Re: optimization for equali
Reply With Quote #8

If you check this only once in plugin_init, it's not really important.

But anyway, you should also say what you want to do with this information.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Debesėlis
Senior Member
Join Date: Aug 2008
Location: Lithuania
Old 10-25-2013 , 12:59   Re: optimization for equali
Reply With Quote #9

Quote:
Originally Posted by ConnorMcLeod View Post
If you check this only once in plugin_init, it's not really important.

But anyway, you should also say what you want to do with this information.
I want change the map when in server is more or less than (example 10 players). What i need is get current map (small this map or no).

In big map (de_dust2) i need to check that is (de_) map and isn't small (_2x2) then change the map to small.

Last edited by Debesėlis; 10-25-2013 at 13:00.
Debesėlis is offline
Debesėlis
Senior Member
Join Date: Aug 2008
Location: Lithuania
Old 10-25-2013 , 12:56   Re: optimization for equali
Reply With Quote #10

Quote:
Originally Posted by alan_el_more View Post
The best method is using tries
can you please give me any example?
Debesėlis 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 23:18.


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