AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   C++ help.. (https://forums.alliedmods.net/showthread.php?t=54243)

Da_sk8rboy 04-20-2007 20:47

C++ help..
 
Well.. I'm currently having the issue with wondering how to display all three choices in the beginning.
Like for Example:

Code:

Pick an option:
1
2
3

if option 1 picked display the cs4$ if 2 display only Mo0se Community an 3 display only theend.


But i did mine in ifstatements mostly.. I thought i could get around it but i got lost. Here's my current Source Code:
It compiles correctly but doesnt do what i wanted it to do.. Help would be appreciated. Also i'm uploading the .exe file so an can see the software in action..

LittleDude 04-20-2007 21:28

Re: C++ help..
 
try something like this, i dunno if the syntax is right or not though

PHP Code:

#include <iostream>

using namespace std;

void ShowFirstOption();
void ShowSecondOption();
void ShowThirdOption();

int main()
{

    
int choice;

    
cout << "This is a menu to pick choices" << endl;

    
cin >> choice;

    if( 
choice || choice )
    {
        exit(
0);
    }
    else
    {

    switch(
choice)
    {
        case 
1ShowFirstOption();
        break;
        
        case 
2ShowSecondOption();
        break;
        
        case 
3ShowThirdOption();
        break;

        default: exit(
0);
        break;
    }
    }

    return 
0;
}

void ShowFirstOption()
{
    
cout << "This is the first option" << endl;
}

void ShowSecondOption()
{
    
cout << "This is the second option" << endl;
}

void ShowThirdOption()
{
    
cout << "This is the third option" << endl;



LittleDude 04-20-2007 21:42

Re: C++ help..
 
ya but right after that part you say cout << "1: Show First Option Information" << endl; or whatever and cout << "2: Show Whatever Else" << endl; and cout << "3: Option 3 Information" << endl;

you gotta add that too it and if they pick option 1-3 it should go to those functions, and if you pick option 0 it should quit

also it checks if they entered any numbers less than 0 or greater than 3 which you dont even need, because the default case handles it anyway but do you get what im saying?

ill edit this in a sec to show you what i mean

LittleDude 04-20-2007 21:44

Re: C++ help..
 
Here ill just edit this, sorry for double post but whatever

PHP Code:

#include <iostream>

using namespace std;

void ShowFirstOption();
void ShowSecondOption();
void ShowThirdOption();

int main()
{

    
int choice;

    
cout << "\tThis is a menu to pick choices" << endl;
            
cout << "1: This is option 1" << endl;
            
cout << "2: This is option 2" << endl;
            
cout << "3: This is option 3" << endl;
            
cout << "0: Exit" << endl;

    
cin >> choice;

    
/*if( choice < 0 || choice > 3 ) // dont really need to check this because the default case will handle it
    {
        exit(0);
    }
    else
    {*/

    
switch(choice)
    {
        case 
1ShowFirstOption();
        break;
        
        case 
2ShowSecondOption();
        break;
        
        case 
3ShowThirdOption();
        break;

        default: exit(
0);
        break;
    }
    }

    return 
0;
}

void ShowFirstOption()
{
    
cout << "This is the first option" << endl;
}

void ShowSecondOption()
{
    
cout << "This is the second option" << endl;
}

void ShowThirdOption()
{
    
cout << "This is the third option" << endl;



Da_sk8rboy 04-20-2007 22:44

Re: C++ help..
 
hmm. when i click to display it it shut's the program down.
EDIT:
nevermind.. i just added a system("PAUSE")

LittleDude 04-20-2007 22:56

Re: C++ help..
 
so it works?

Da_sk8rboy 04-20-2007 23:06

Re: C++ help..
 
not completely done with it.

Zenith77 04-21-2007 12:38

Re: C++ help..
 
What's the point of this program? Or future use if any.

stupok 04-22-2007 00:14

Re: C++ help..
 
It looks like he's trying to do something called learnding.

http://simpsonspedia.net/images/thum...lph_Wiggum.png

Da_sk8rboy 04-22-2007 18:01

Re: C++ help..
 
Quote:

Originally Posted by LittleDude (Post 467773)
so it works?

Yes. i got it to work, but now i'm wondering another thing.
When you select a choice it displays the output. Then it say's:
"Press any key to close..." or whatever. How can i add the other 3 choices instead of press any key to close.."

LIke ex:

YOU'VE SELECTED #2

blah blah blah

1. CS4$
3. Credits
4. Program info
0. Exit


(Like what im saying if you dont understand is, after you have already selected one an the output has came up on the program, under it bring the menu choice back up then after you've completely gone through the menu choices be able to press any key to close.

Here's the code now:

Code:

#include <iostream>

using namespace std;

void ShowFirstOption();
void ShowSecondOption();
void ShowThirdOption();
void ShowFourthOption();

int main()
{

    int choice;

    cout << "\t\n\n+-----------------------------------------------------------------------+"
            "\n|                                                                      |"
            "\n|        C++ Code / Program written Brit no0bsawcE! Jamerson!          |"
            "\t|        Software under-developement! :)                                | "
            "\n|        visit us at www.mo0seclan.xanimos.com                          |"
            "\t|                                                                      |"
            "\n+-----------------------------------------------------------------------+\n"
            "\n\n\t Select a choice that you would like to learn more information about:\n\n"
            "1: CS4$!\n"
            "2: <Mo0se> Clan Community!\n"
            "3: Credits!\n"
            "4: Program info!\n"
            "0: Exit!\n\n";

    cin >> choice;

    /*if( choice < 0 || choice > 3 ) // dont really need to check this because the default case will handle it
    {
        exit(0);
    }
    else
    {*/

    switch(choice)
    {
        case 1: ShowFirstOption();
        break;
       
        case 2: ShowSecondOption();
        break;
       
        case 3: ShowThirdOption();
        break;

        case 4: ShowFourthOption();
        break;
       
        default: exit(0);
        break;
    }
    return 0;
    }


void ShowFirstOption()
{
    cout << "YOU'VE SELECTED OPTION #1\n\n"
            "\t[---------------------------CS4$--------------------------------]\n"
            "\t  Counter-Strike4Cash is an online arena for cash and prizes.\n"
            "\t  Everyone will risk the same amount of\n"
            "\t  cash PR(Per Round.)\n"
            "\t  When you take a portion of someones HP, you recieve an equal portion\n"
            "\t  of cash from them.\n"
            "\t  You Can Check them out at www.counter-strike4cash.com!\n"
            "\t[---------------------------CS4$--------------------------------]\n\n\t\t";
       
            system("PAUSE");
}

void ShowSecondOption()
{
    cout << "YOU'VE SELECTED OPTION #2\n\n"
            "\t[---------------------------Mo0se--------------------------------]\n"
            "\t  <Mo0se> Clan was founded by myself an THEpro.\n"
            "\t  We are currently Recruiting only expierenced CSS Surf Players."
            "\t          Check out our site @ www.mo0seclan.xanimos.com !\n"
            "\t[---------------------------Mo0se--------------------------------]\n\n\n"
            "[---------------------------Members--------------------------------]\n\n"
            "  1. no0bsawcE! <Mo0se> - Brit Jamerson."
            "\n  2. THEpro <Mo0se> - Brad Duke."
            "\n  3. Chinese <Mo0se> - Dustin Lum.\n"
            "\b  4. TiM <Mo0se> - Tim.\n"
            "[---------------------------Members--------------------------------]\n\n\t";
    system("PAUSE");
}

void ShowThirdOption()
{
    cout << "YOU'VE SELECTED OPTION #3\n\n"
            "\t[---------------------------Credits--------------------------------]\t"
            "\t  1. no0bsawcE! <Mo0se> - Brit Jamerson(Me)\n"
            "\t  2. LittleDude @ Amxmodx forums for some assistance with code.\n"
            "\t[---------------------------Credits--------------------------------]\n\n\n\t\t\t";
    system("PAUSE");
}

void ShowFourthOption()
{
    cout << "YOU'VE SELECTED OPTION #4\n\n"
            "\t[---------------------------Program Info-----------------------------]\n"
            "\t  Version        = 1.0b.\n"
            "\t  Current State  = Beta.\n"
            "\t  Update1(1.0a)  = Removed all if elsestatements.\n"
            "\t  Update2(1.0b)  = Rebuilt the back-bone of the code.\n"
            "\t  Lead Developer = Brit no0bsawcE! Jamerson\n"
            "\t[---------------------------Program Info-----------------------------]\n\n\n\t\t";
    system("PAUSE");
}



All times are GMT -4. The time now is 06:35.

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