Raised This Month: $ Target: $400
 0% 

Is this code right?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Evaldas.Grigas
Senior Member
Join Date: Sep 2011
Location: Lithuania
Old 10-27-2011 , 14:56   Is this code right?
Reply With Quote #1

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") ) 
__________________
Please enter this website everyday: http://forums.alliedmods.net/showthread.php?t=169067

Last edited by Evaldas.Grigas; 10-27-2011 at 15:06.
Evaldas.Grigas is offline
Send a message via Skype™ to Evaldas.Grigas
Flipper_SPb
Senior Member
Join Date: Jun 2009
Location: Worldspawn
Old 10-27-2011 , 15:12   Re: Is this code right?
Reply With Quote #2

PHP Code:
if ( equali(mapname"mapnames") ) 
Wrong.

What do you want to do?
__________________
Полный похуизм.

Last edited by Flipper_SPb; 10-27-2011 at 15:13.
Flipper_SPb is offline
Send a message via ICQ to Flipper_SPb
Evaldas.Grigas
Senior Member
Join Date: Sep 2011
Location: Lithuania
Old 10-27-2011 , 15:15   Re: Is this code right?
Reply With Quote #3

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; 
__________________
Please enter this website everyday: http://forums.alliedmods.net/showthread.php?t=169067
Evaldas.Grigas is offline
Send a message via Skype™ to Evaldas.Grigas
Flipper_SPb
Senior Member
Join Date: Jun 2009
Location: Worldspawn
Old 10-27-2011 , 16:46   Re: Is this code right?
Reply With Quote #4

Why do you useregister_clcmd?
__________________
Полный похуизм.
Flipper_SPb is offline
Send a message via ICQ to Flipper_SPb
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 10-27-2011 , 20:36   Re: Is this code right?
Reply With Quote #5

Quote:
Originally Posted by Evaldas.Grigas View Post
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.
__________________

Last edited by Hunter-Digital; 10-27-2011 at 20:37.
Hunter-Digital is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-27-2011 , 21:40   Re: Is this code right?
Reply With Quote #6

?
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;
   }

__________________

Last edited by Bugsy; 10-27-2011 at 21:42.
Bugsy is offline
Evaldas.Grigas
Senior Member
Join Date: Sep 2011
Location: Lithuania
Old 10-28-2011 , 00:39   Re: Is this code right?
Reply With Quote #7

what break; means?
__________________
Please enter this website everyday: http://forums.alliedmods.net/showthread.php?t=169067
Evaldas.Grigas is offline
Send a message via Skype™ to Evaldas.Grigas
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 10-28-2011 , 01:02   Re: Is this code right?
Reply With Quote #8

It terminates the loop.
__________________
Achievements API - a simple way for you to create your OWN custom achievements!
Xellath is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-28-2011 , 01:44   Re: Is this code right?
Reply With Quote #9

You make it very hard for us to help you. Help us Help you:

Quote:
Originally Posted by Hunter-Digital View Post
... you should tell what you're trying to do
__________________
fysiks is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-28-2011 , 02:01   Re: Is this code right?
Reply With Quote #10

http://wiki.amxmodx.org/Configuring_...ecific_Plugins
__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 14:27.


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