Quote:
Originally Posted by DeagLe.Studio
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 ) { }