[HELP]C++ COD4 class generator

Posts 15 of 5 · Page 1 of 1
[HELP]C++ COD4 class generator
hi im having some problems coding my class generator. what it does is takes arrays (about 12 i think) 1 containing assault guns antother containg smg,antother containg lmg,antother containg sniper,antother containg shotgun,antother containg special grenades, antother containg perk slot 1 antother containg perk slot 2, antother containg perk slot 3. the thing im having trouble with is:
(i will put what the array is in () next to it)
cout<<"What main gun do you want?((A)ssasult/(S)ub machinegun/(L)LMG/(G)Shot gun/(N) Sniper): ";
cin>>gunsel;
if(gunsel=='a' || gunsel =='A')
{
system("CLS");
cout<<"Your gun is: "<<arr1[a]<<endl;
cout<<"Your attachment is: "<<arr2[b]<<endl;
if(arr2[b]==arr2[1])
{
cout<<"Perk 1: None"<<endl;
cout<<"Perk 2: "<<arr4[d]<<endl;
cout<<"Perk 3: "<<arr5[e]<<endl;
else
{
cout<<"Perk 1: "<<arr7[a]<<endl;
cout<<"Perk 2: "<<arr4[a]<<endl;
cout<<"Perk 3: "<<arr5[a]<<endl;
cout<<"Would you like a new gun(Y/N): ";
cin>>newg;
if(newg=='y'||newg=='Y')
{
cout<<"What gun?(A,S,L,G,N): ";
cin>>gunsel;
}


so for my problem:
lets say the output is:
your gun is: M4A1
your attacment is: RDS
Perk 1: 3x grenade
perk 2: Overkill
perk 3: deep impact
special: stun

so as u can see perk 2 is overkill... where would i put in the code to say:
if perk 2 equals arr4[1](1 is overkill) then display a message saying your secondary gun is:..... and move on to perk 3 and special grenade...
when i get this app fineshed i will post it and i will start on a mw2 class generator... THANKS FOR TH HELP!
You never declared the array from what i can see in your code.

And if the array is an int

[php]int arrayForCoolKids[over 9000];[/php]

you cant have values in the array of another variable type

no i did that i only posted a section of my code tho heres all of it:
#include <cstdlib>
#include <iostream>
#include <windows.h>
#include <ctime>
using namespace std;
int main()
{
char gunsel;
char newg;
srand((unsigned)time(0));
int a=rand()%6;
int b=rand()%5;
int c=rand()%5;
int d=rand()%6;
int e=rand()%7;
int f=rand()%3;
int g=rand()%7;
int h=rand()%5;
int i=rand()%3;
int j=rand()%2;
int k=rand()%7;
int l=rand()%2;
string arr1[6];
string arr2[5];
string arr3[5];
string arr4[6];
string arr5[7];
string arr6[3];
string arr7[7];
string arr8[5];
string arr9[3];
string arr10[2];
string arr11[7];
string arr12[2];
arr1[0]="M16";
arr1[1]="Ak-47";
arr1[2]="M4A1";
arr1[3]="G3";
arr1[4]="G36C";
arr1[5]="M14";
arr2[0]="NONE";
arr2[1]="Noob Tube";
arr2[2]="RDS";
arr2[3]="Silencer";
arr2[4]="ACOG";
arr3[0]="USP";
arr3[1]="M9";
arr3[2]="M1911";
arr3[3]="Deagle";
arr3[4]="Gold Deagle";
arr4[0]="Stopping Power";
arr4[1]="Jugger";
arr4[2]="Sleight of Hand";
arr4[3]="Double Tap";
arr4[4]="UAV Jam";
arr4[5]="Sonic Boom";
arr5[0]="Extreme Conditioning";
arr5[1]="Steady Aim";
arr5[2]="Last Stand";
arr5[3]="Martydom";
arr5[4]="Deep Impact";
arr5[5]="Dead Silence";
arr5[6]="Eavesdrop";
arr6[0]="Flash";
arr6[1]="Stun";
arr6[2]="Smoke";
arr7[0]="C4X2";
arr7[1]="Spec Grenades X3";
arr7[2]="RPG X2";
arr7[3]="Claymore X2";
arr7[4]="Frag X3";
arr7[5]="Bandolier";
arr7[6]="Bomb Squad";
arr8[0]="MP5";
arr8[1]="Skorpion";
arr8[2]="Mini-Uzi";
arr8[3]="AK-47u";
arr8[4]="P90";
arr9[0]="M249";
arr9[1]="RPD";
arr9[2]="M60E4";
arr10[0]="W1200";
arr10[1]="M1014";
arr11[2]="M40A3";
arr11[3]="M21";
arr11[4]="Dragunov";
arr11[5]="R700";
arr11[6]=".50 Cal";
arr12[0]="RDS";
arr12[1]="Grip";
char ans;
cout<<"Welcome to COD4 Rand. Class!"<<endl;
cout<<"Would you like to start?(y/n): ";
cin>>ans;
if(ans=='n'||ans=='N')
{
exit(0);
}
else if(ans=='y' || ans=='Y')
{
system("CLS");
cout << "_ _ _ ____ _ ____ ____ _ _ ____ /"<<endl;
cout << "| | | |___ | | | | |\\/| |___ / "<<endl;
cout << "|_|_| |___ |___ |___ |__| | | |___ . "<<endl;

cout << "_ ____ ___ ____ ___ ____ ____ _ _ _ /"<<endl;
cout << "| |___ | [__ |__] |___ | __ | |\\ | / "<<endl;
cout << "|___ |___ | ___] |__] |___ |__] | | \\| . "<<endl;
cout<<"What main gun do you want?((A)ssasult/(S)ub machinegun/(L)LMG/(G)Shot gun/(N) Sniper): ";
cin>>gunsel;
if(gunsel=='a' || gunsel =='A')
{
system("CLS");
cout<<"Your gun is: "<<arr1[a]<<endl;
cout<<"Your attachment is: "<<arr2[b]<<endl;
if(arr2[b]==arr2[1])
{
cout<<"Perk 1: None"<<endl;
cout<<"Perk 2: "<<arr4[d]<<endl;
cout<<"Perk 3: "<<arr5[e]<<endl;
cout<<"Would you like a new gun(Y/N): ";
cin>>newg;
if(newg=='y'||newg=='Y')
{
cout<<"What gun?(A,S,L,G,N): ";
cin>>gunsel;
}
}
else
{
cout<<"Perk 1: "<<arr7[a]<<endl;
cout<<"Perk 2: "<<arr4[a]<<endl;
cout<<"Perk 3: "<<arr5[a]<<endl;
cout<<"Would you like a new gun(Y/N): ";
cin>>newg;
if(newg=='y'||newg=='Y')
{
cout<<"What gun?(A,S,L,G,N): ";
cin>>gunsel;
}
}
system("PAUSE");
return(0);
}
}
}
Why don't you just declare multidimensional arrays? So easier and efficient.

It'd also help to name the arrays accordingly, nobody knows what the hell arr4 could be.
i have no idea how to do that xD im doing this cuz i just got back from a class and im working on this to keep my knoladge of what i learned up
Posts 15 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?