Raised This Month: $ Target: $400
 0% 

Map check


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 06-06-2013 , 02:23   Re: Map check
Reply With Quote #5

Quote:
Originally Posted by DeagLe.Studio View Post
Code:
static MapName[ 32 ]; get_mapname( MapName, charsmax( MapName ) ); if( equal( MapName, "35hp" ) ) {         // Do something         give_item( id , "weapon_m4a1" ) }

Since the get_mapname function should be called only once, it's better to check it only once and save the result in a variable. You also shouldn't make the variable static but rather global and cache it only once; your way re-caches the value in MapName static each time the function is called, so either check if the first symbol has been set with

Code:
static MapName[ 32 ] if( !MapName[ 0 ] )    get_mapname( MapName, charsmax( MapName ) )


Or just do it this way, which is overally more efficient:

Code:
new bool: g_IsMap35Hp public plugin_init( ) {    new szMapName[ 32 ]    get_mapname( szMapName, charsmax( szMapName ) )    g_IsMap35Hp = equali( szMapName, "35hp" ) } // ... if( g_IsMap35Hp ) { }

Last edited by Backstabnoob; 06-06-2013 at 02:29.
Backstabnoob is offline
 



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 16:16.


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