AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How do i check if a map contains a word?[SOLVED] (https://forums.alliedmods.net/showthread.php?t=118203)

NiQu 02-08-2010 16:02

How do i check if a map contains a word?[SOLVED]
 
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.

Bugsy 02-08-2010 16:17

Re: How do i check if a map contains a word?
 
PHP Code:

new szMap32 ];
get_mapnameszMap charsmaxszMap ) );

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

//your code here 


Exolent[jNr] 02-08-2010 16:22

Re: How do i check if a map contains a word?
 
Quote:

Originally Posted by wrecked_ (Post 1083040)
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 }

NiQu 02-08-2010 16:22

Re: How do i check if a map contains a word?
 
Thanks guys :P Ill give it a try asap.

Bugsy 02-08-2010 16:23

Re: How do i check if a map contains a word?
 
63 -> charsmax() and no need for it to be global unless its being used elsewhere

Exolent[jNr] 02-08-2010 16:24

Re: How do i check if a map contains a word?
 
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.

NiQu 02-08-2010 16:25

Re: How do i check if a map contains a word?
 
@Bugsy , the one u gave i KNOW doesnt work because i tested it before posting this thread :P

wrecked_ 02-08-2010 16:25

Re: How do i check if a map contains a word?
 
Quote:

Originally Posted by Exolent[jNr] (Post 1083042)
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.

NiQu 02-08-2010 16:30

Re: How do i check if a map contains a word?
 
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 :P

PHP Code:

if( containiszMapName"jb" ) == -

---->
PHP Code:

if( containiszMapName"jb" ) == 


wrecked_ 02-08-2010 16:31

Re: How do i check if a map contains a word?
 
Quote:

Originally Posted by NiQu (Post 1083053)
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 :P

PHP Code:

if( containiszMapName"jb" ) == -

---->
PHP Code:

if( containiszMapName"jb" ) == 


... That's what I posted before. :evil:


All times are GMT -4. The time now is 07:19.

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