Raised This Month: $ Target: $400
 0% 

How do i check if a map contains a word?[SOLVED]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NiQu
Veteran Member
Join Date: Nov 2009
Old 02-08-2010 , 16:02   How do i check if a map contains a word?[SOLVED]
Reply With Quote #1

Hi, how do i check if a mapname contains "jb"?

Like: If the map is de_dust2, it will return PLUGIN_HANDLED, but if the map is jb_russia_v1, then it will return whatever code i put in there.

I prefer a very despritive answer..
I have tested with get_mapname and contain and containi, so i need more description on how to use those.

Last edited by NiQu; 02-08-2010 at 19:09.
NiQu is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-08-2010 , 16:17   Re: How do i check if a map contains a word?
Reply With Quote #2

PHP Code:
new szMap32 ];
get_mapnameszMap charsmaxszMap ) );

//map name does not contain jb
if ( strfindszMap "jb" ) == -)
     return 
PLUGIN_HANDLED;

//your code here 
__________________

Last edited by Bugsy; 02-08-2010 at 21:56.
Bugsy is offline
Old 02-08-2010, 16:19
wrecked_
This message has been deleted by wrecked_. Reason: can't read
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 02-08-2010 , 16:22   Re: How do i check if a map contains a word?
Reply With Quote #3

Quote:
Originally Posted by wrecked_ View Post
Specifically for your plugin, you'd want to do something like this:
PHP Code:
#include <amxmodx>

new sz_MapName[32]

public 
plugin_init()
{
    
register_plugin"Map Finder Example""9999.5""wrecked_" )
    
    
register_clcmd"say /shop""cmd_ShopHandler" // Just because I know you're using this for the VIP thing
}

public 
cmd_ShopHandlerid )
{
    
get_mapnamesz_MapNamecharsmaxsz_MapName ) )
    
    if( 
containisz_MapName"jb_" ) )
    {
        
// JB Shop Code Here
    
}
    else
    {
        
// Normal Shop Code Here
    
}

No you don't.

Code:
#include < amxmodx > public plugin_init( ) {     register_plugin( "Map plugin example", "0.0.1", "Exolent" );         new szMapName[ 64 ];     get_mapname( szMapName, 63 );         if( containi( szMapName, "jb" ) == -1 )     {         pause( "a" );         return;     }         // rest of plugin_init( ) code here }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
NiQu
Veteran Member
Join Date: Nov 2009
Old 02-08-2010 , 16:22   Re: How do i check if a map contains a word?
Reply With Quote #4

Thanks guys Ill give it a try asap.
NiQu is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-08-2010 , 16:23   Re: How do i check if a map contains a word?
Reply With Quote #5

63 -> charsmax() and no need for it to be global unless its being used elsewhere
__________________
Bugsy is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 02-08-2010 , 16:24   Re: How do i check if a map contains a word?
Reply With Quote #6

charsmax/sizeof are coding styles and aren't required.
It's only necessary to use those if the variables are going to be resized.
In this case, the size is known and isn't be a problem.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
NiQu
Veteran Member
Join Date: Nov 2009
Old 02-08-2010 , 16:25   Re: How do i check if a map contains a word?
Reply With Quote #7

@Bugsy , the one u gave i KNOW doesnt work because i tested it before posting this thread
NiQu is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 02-08-2010 , 16:25   Re: How do i check if a map contains a word?
Reply With Quote #8

Quote:
Originally Posted by Exolent[jNr] View Post
No you don't.

Code:
#include < amxmodx > public plugin_init( ) { register_plugin( "Map plugin example", "0.0.1", "Exolent" );

new szMapName[ 64 ];
get_mapname( szMapName, 63 );

if( containi( szMapName, "jb" ) == -1 ) { pause( "a" );
return;
} // rest of plugin_init( ) code here }

My bad, thought he was relating it to the way he asked in his previous post. Didn't read the return PLUGIN_HANDLED part.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT

Last edited by wrecked_; 02-08-2010 at 16:28.
wrecked_ is offline
NiQu
Veteran Member
Join Date: Nov 2009
Old 02-08-2010 , 16:30   Re: How do i check if a map contains a word?
Reply With Quote #9

wrecked_,
acutally it was like this:

If the map was a jb_ map it would be a vip shop with jb items in it, if it wasnt it would be a vip shop with other items.

Anyways, exolents code ALMOST worked

PHP Code:
if( containiszMapName"jb" ) == -
---->
PHP Code:
if( containiszMapName"jb" ) == 
NiQu is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 02-08-2010 , 16:31   Re: How do i check if a map contains a word?
Reply With Quote #10

Quote:
Originally Posted by NiQu View Post
wrecked_,
acutally it was like this:

If the map was a jb_ map it would be a vip shop with jb items in it, if it wasnt it would be a vip shop with other items.

Anyways, exolents code ALMOST worked

PHP Code:
if( containiszMapName"jb" ) == -
---->
PHP Code:
if( containiszMapName"jb" ) == 
... That's what I posted before.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ 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 07:19.


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