Raised This Month: $ Target: $400
 0% 

How to make code shorter?


Post New Thread Reply   
 
Thread Tools Display Modes
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 09-29-2011 , 16:09   Re: How to make code shorter?
Reply With Quote #11

Code:
public Showrod(id) {

    new mapname[ 32 ];
    get_mapname( mapname, charsmax(mapname) );

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

    show_menu (id, Keysrod, "Choose VIP guns:^n\w1. Get M4A1 and Deagle ^n\w2. Get AK47 and Deagle ^n3. Get Galil and Deagle ^n0. Exit^n", 10, "rod" ) // Display menu
}
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Elusive138
Senior Member
Join Date: Dec 2010
Old 09-30-2011 , 05:01   Re: How to make code shorter?
Reply With Quote #12

If you have a lot of mapnames, maybe use a Trie? Could be faster and makes it easier to read a file for a list of maps.
Elusive138 is offline
Evaldas.Grigas
Senior Member
Join Date: Sep 2011
Location: Lithuania
Old 09-30-2011 , 07:54   Re: How to make code shorter?
Reply With Quote #13

Quote:
Originally Posted by Emp` View Post
Code:
public Showrod(id) {

    new mapname[ 32 ];
    get_mapname( mapname, charsmax(mapname) );

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

    show_menu (id, Keysrod, "Choose VIP guns:^n\w1. Get M4A1 and Deagle ^n\w2. Get AK47 and Deagle ^n3. Get Galil and Deagle ^n0. Exit^n", 10, "rod" ) // Display menu
}
Ok. This code is better, but I think it won't stop player from taking weapons because there isn't cancel menu after maps? Or I am wrong?

EDIT: Sorry it works great. But I don't understand one, why you didin't use cancel menu after map list?

Last edited by Evaldas.Grigas; 09-30-2011 at 08:09.
Evaldas.Grigas is offline
Send a message via Skype™ to Evaldas.Grigas
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 09-30-2011 , 08:14   Re: How to make code shorter?
Reply With Quote #14

it doesent open the menu on those maps, so there is no need to close one
jimaway is offline
Evaldas.Grigas
Senior Member
Join Date: Sep 2011
Location: Lithuania
Old 09-30-2011 , 08:15   Re: How to make code shorter?
Reply With Quote #15

Oh, got it! Thanks!
Evaldas.Grigas is offline
Send a message via Skype™ to Evaldas.Grigas
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 19:31.


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