AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Is this code right? (https://forums.alliedmods.net/showthread.php?t=170670)

Evaldas.Grigas 10-27-2011 14:56

Is this code right?
 
Is this right?
PHP Code:

new const mapnames[][] =
{
    
"awp_india""awp_dust""cs_deagle5""awp_map"
}
/*...*/
    
for(new 0sizeof mapnamesi++)
    
register_clcmd(mapnames[i], "mapnames")
/*...*/
    
get_mapnamemapnamecharsmax(mapname) );
    if ( 
equali(mapname"mapnames") ) 


Flipper_SPb 10-27-2011 15:12

Re: Is this code right?
 
PHP Code:

if ( equali(mapname"mapnames") ) 

Wrong.

What do you want to do?

Evaldas.Grigas 10-27-2011 15:15

Re: Is this code right?
 
Word mapnames should read const mapnames. Like I want to make this code easyer to use, just add custom maps in new const mapnames.
PHP Code:

get_mapnamemapnamecharsmax(mapname) );
        
    if ( 
equali(mapname"awp_india") || equali(mapname"awp_dust") || equali(mapname"awp_map") || equali(mapname"cs_deagle5") )
        return; 


Flipper_SPb 10-27-2011 16:46

Re: Is this code right?
 
Why do you useregister_clcmd?

Hunter-Digital 10-27-2011 20:36

Re: Is this code right?
 
Quote:

Originally Posted by Evaldas.Grigas (Post 1584437)
Word mapnames should read const mapnames. Like I want to make this code easyer to use, just add custom maps in new const mapnames.

There's a big difference between words (strings) and variables.
A quick-solve would be to loop through the constant values, like you did with the clcmd registering... but you should tell what you're trying to do, I'm sure there's a simple, easy and efficient way to do it.

Bugsy 10-27-2011 21:40

Re: Is this code right?
 
?
PHP Code:

new const mapnames[][] =
{
    
"awp_india""awp_dust""cs_deagle5""awp_map"
}

new 
szMap20 ];
get_mapnameszMap charsmaxszMap ) );
for( new 
sizeofmapnames ) ; i++ )
{
   if ( 
equalszMap mapnames] ) )
   {
      
//current map in list
      
break;
   }



Evaldas.Grigas 10-28-2011 00:39

Re: Is this code right?
 
what break; means?

Xellath 10-28-2011 01:02

Re: Is this code right?
 
It terminates the loop.

fysiks 10-28-2011 01:44

Re: Is this code right?
 
You make it very hard for us to help you. Help us Help you:

Quote:

Originally Posted by Hunter-Digital (Post 1584587)
... you should tell what you're trying to do


ConnorMcLeod 10-28-2011 02:01

Re: Is this code right?
 
http://wiki.amxmodx.org/Configuring_...ecific_Plugins


All times are GMT -4. The time now is 14:27.

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