Raised This Month: $ Target: $400
 0% 

Map check


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ke3ller
Member
Join Date: Feb 2013
Old 06-05-2013 , 14:55   Map check
Reply With Quote #1

Pls tell me how to check for a specific map, I want to give an item in a map
Ex:
PHP Code:
public fwHamPlayerSpawnPostid ) {
        if ( 
map_is_35hp ) {
                
give_itemid "weapon_m4a1" )
        }

ke3ller is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 06-05-2013 , 14:58   Re: Map check
Reply With Quote #2

Get the map name and then compare it
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 06-05-2013 , 15:01   Re: Map check
Reply With Quote #3

Quote:
Originally Posted by YamiKaitou View Post
Get the map name and then compare it
Code:
static MapName[ 32 ]; get_mapname( MapName, charsmax( MapName ) ); if( equal( MapName, "35hp" ) ) {         // Do something         give_item( id , "weapon_m4a1" ) }

Last edited by TheDS1337; 06-05-2013 at 15:02.
TheDS1337 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-05-2013 , 16:16   Re: Map check
Reply With Quote #4

Only enable this plugin on that particular map using the map specific plugin files.
__________________
fysiks is offline
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
bibu
Veteran Member
Join Date: Sep 2010
Old 06-05-2013 , 15:00   Re: Map check
Reply With Quote #6

Seriously... search.
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu 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 16:16.


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