| | |
Help with what should be a very simple code task.
Thread Solved
![]() |
•
•
Join Date: Jan 2009
Posts: 8
Reputation:
Solved Threads: 0
I'm looking for some help with some C++ code. I have working knowledge and understanding of code and coding in general, but don't actually program myself.
I have 2 files
TFGame
and
TFMenuConsole
In TFGame I put
and later put
To my knowledge, this will create the variable ToggleWarhead and then add a check box to the settings menu to toggle this variable true or false (default being true) and also display the string value that is set for SIGPropsDisplayText for the setting name.
In TFMenuConsole I put
Which should Check if the variable ToggleWarhead in the File TFGame is true, if it is then it will execute array number 6, if not then it should skip it and Warhead should be left out of the Array.
When I try to compile I get this
So I have 2 questions
1. Should my code for the if statement on the array include the difference in array size like so?:
and 2. What am I doing wrong? why is it not working?
I'm sure it is because of the format I put the if statement in, I am not used to C++ and I only understand code, I don't actually know how to code.
Any help would be greatly appreciated.
I can also provide the source files if your willing to help me solve this.
Thanks,
Grim
I have 2 files
TFGame
and
TFMenuConsole
In TFGame I put
C++ Syntax (Toggle Plain Text)
var config bool ToggleWarhead;
C++ Syntax (Toggle Plain Text)
PlayInfo.AddSetting(default.GameGroup, "ToggleWarhead", default.SIGPropsDisplayText[i++], 0, 1, "Check", ,, , true);
To my knowledge, this will create the variable ToggleWarhead and then add a check box to the settings menu to toggle this variable true or false (default being true) and also display the string value that is set for SIGPropsDisplayText for the setting name.
In TFMenuConsole I put
C++ Syntax (Toggle Plain Text)
case SMS_Construction: SMNameArray[0] = "Shield (50/30)"; SMIndexArray[0] = 1; SMNameArray[1] = "Protector (200/30)"; SMIndexArray[1] = 2; SMNameArray[2] = "Portal (200/30)"; SMIndexArray[2] = 3; SMNameArray[3] = "Armory (200/60)"; SMIndexArray[3] = 4; SMNameArray[4] = "Generator (300/60)"; SMIndexArray[4] = 5; SMNameArray[5] = "Outpost (600/90)"; SMIndexArray[5] = 6; if(tfgame.ToggleWarhead == True) { SMNameArray[6] = "Warhead (3000/180)"; SMIndexArray[6] = 7; } SMArraySize=7; break;
When I try to compile I get this
C++ Syntax (Toggle Plain Text)
"Error, Bad or Missing Expression in 'if'
So I have 2 questions
1. Should my code for the if statement on the array include the difference in array size like so?:
C++ Syntax (Toggle Plain Text)
case SMS_Construction: SMNameArray[0] = "Shield (50/30)"; SMIndexArray[0] = 1; SMNameArray[1] = "Protector (200/30)"; SMIndexArray[1] = 2; SMNameArray[2] = "Portal (200/30)"; SMIndexArray[2] = 3; SMNameArray[3] = "Armory (200/60)"; SMIndexArray[3] = 4; SMNameArray[4] = "Generator (300/60)"; SMIndexArray[4] = 5; SMNameArray[5] = "Outpost (600/90)"; SMIndexArray[5] = 6; if(tfgame.ToggleWarhead == True) { SMNameArray[6] = "Warhead (3000/180)"; SMIndexArray[6] = 7; SMArraySize=7; } SMArraySize=6; break;
and 2. What am I doing wrong? why is it not working?
I'm sure it is because of the format I put the if statement in, I am not used to C++ and I only understand code, I don't actually know how to code.
Any help would be greatly appreciated.
I can also provide the source files if your willing to help me solve this.
Thanks,
Grim
dono what this does really but who knows its worth a try
maybe replace True with true?
just to be safe just make it:
maybe that works?
C++ Syntax (Toggle Plain Text)
if(tfgame.ToggleWarhead == True) { SMNameArray[6] = "Warhead (3000/180)"; SMIndexArray[6] = 7; SMArraySize=7; }
maybe replace True with true?
just to be safe just make it:
C++ Syntax (Toggle Plain Text)
if(tfgame.ToggleWarhead) { SMNameArray[6] = "Warhead (3000/180)"; SMIndexArray[6] = 7; SMArraySize=7; }
Last edited by u8sand; Jan 3rd, 2009 at 10:36 am.
•
•
Join Date: Jan 2009
Posts: 8
Reputation:
Solved Threads: 0
Thanks for the responses.
OS: V Extreme
Compiler: UCC
I tried running with the True uncapitalized
Same Error
I tried with the new array size in the if statement
Same Error
I tried without the == true
Same Error
I also tried putting the whole array into the if
I added
to the beginning of the TFMenuConsole file to test if the error is when the variable is being called from the other file and when I tried to compile it returned
[/CODE]Error, Type mismatch in 'if'[/CODE]
Just found out that Bool meant True or False so I changed it to
and i get
It has to be the code itself, if someone could just lo ok at it for me and tell me what im doing wrong
OS: V Extreme
Compiler: UCC
I tried running with the True uncapitalized
Same Error
I tried with the new array size in the if statement
Same Error
I tried without the == true
Same Error
I also tried putting the whole array into the if
C++ Syntax (Toggle Plain Text)
if(tfgame.ToggleWarhead == true) { case SMS_Construction: SMNameArray[0] = "Shield (50/30)"; SMIndexArray[0] = 1; SMNameArray[1] = "Protector (200/30)"; SMIndexArray[1] = 2; SMNameArray[2] = "Portal (200/30)"; SMIndexArray[2] = 3; SMNameArray[3] = "Armory (200/60)"; SMIndexArray[3] = 4; SMNameArray[4] = "Generator (300/60)"; SMIndexArray[4] = 5; SMNameArray[5] = "Outpost (600/90)"; SMIndexArray[5] = 6; SMArraySize=6; else case SMS_Construction: SMNameArray[0] = "Shield (50/30)"; SMIndexArray[0] = 1; SMNameArray[1] = "Protector (200/30)"; SMIndexArray[1] = 2; SMNameArray[2] = "Portal (200/30)"; SMIndexArray[2] = 3; SMNameArray[3] = "Armory (200/60)"; SMIndexArray[3] = 4; SMNameArray[4] = "Generator (300/60)"; SMIndexArray[4] = 5; SMNameArray[5] = "Outpost (600/90)"; SMIndexArray[5] = 6; SMNameArray[6] = "Warhead (3000/180)"; SMIndexArray[6] = 7; SMArraySize=7; }
I added
C++ Syntax (Toggle Plain Text)
var string ToggleWarhead;
[/CODE]Error, Type mismatch in 'if'[/CODE]
Just found out that Bool meant True or False so I changed it to
C++ Syntax (Toggle Plain Text)
var bool ToggleWarhead;
C++ Syntax (Toggle Plain Text)
Error, class is not allowed here
Last edited by Grimshad; Jan 3rd, 2009 at 6:21 pm.
In the latest code you posted, you're using the case keyword after an if statement. case is intended to be used in conjunction with switch, and is meaningless on its own.
Perhaps you could also show the declaration of your
Perhaps you could also show the declaration of your
tfgame object, and the declaration for ToggleWarhead ¿umop apisdn upside down? •
•
Join Date: Jan 2009
Posts: 8
Reputation:
Solved Threads: 0
I've attached the 2 files
In TFGame the Variable ToggleWarhead is added on line 15
In TFMenuConsole the variable needs to be used on line 1068
In TFGame the variable is created and used in Pre game settings menu where a check box toggles it true/false
In TFMenuConsole the If statement I am trying to impliment will remove the Warhead entry from the in game menu if ToggleWarhead is true, and will leave it there if it is false.
I noticed you said "tfgame object" I exported all objects from my file and there is a tfgame object and tfgame.ToggleWarhead object, they say:
and
I don't think this has anything to do with my problem though.
I appreciate the help Bench
In TFGame the Variable ToggleWarhead is added on line 15
In TFMenuConsole the variable needs to be used on line 1068
In TFGame the variable is created and used in Pre game settings menu where a check box toggles it true/false
In TFMenuConsole the If statement I am trying to impliment will remove the Warhead entry from the in game menu if ToggleWarhead is true, and will leave it there if it is false.
I noticed you said "tfgame object" I exported all objects from my file and there is a tfgame object and tfgame.ToggleWarhead object, they say:
C++ Syntax (Toggle Plain Text)
Begin Object Class=Class Name=TFGame End Object
and
C++ Syntax (Toggle Plain Text)
Begin Object Class=BoolProperty Name=ToggleWarhead End Object
I appreciate the help Bench
Last edited by Grimshad; Jan 3rd, 2009 at 6:38 pm.
•
•
Join Date: Jan 2009
Posts: 8
Reputation:
Solved Threads: 0
This was quoted by someone who knows C++
"you are trying to use a class without firstly implementig it's creation, or loading it from somewhere"
but to my knowledge its creation is in the file TFGame
he also said
"you can't just put filename.variable and expect the compiler to know what your talking about"
"you are trying to use a class without firstly implementig it's creation, or loading it from somewhere"
but to my knowledge its creation is in the file TFGame
he also said
"you can't just put filename.variable and expect the compiler to know what your talking about"
•
•
Join Date: Jan 2009
Posts: 8
Reputation:
Solved Threads: 0
I changed it to
Still gives me the same error, Bad or Missing Expression in 'if'
C++ Syntax (Toggle Plain Text)
if(TFGame.ToggleWarhead == true) { case SMS_Construction: SMNameArray[0] = "Shield (50/30)"; SMIndexArray[0] = 1; SMNameArray[1] = "Protector (200/30)"; SMIndexArray[1] = 2; SMNameArray[2] = "Portal (200/30)"; SMIndexArray[2] = 3; SMNameArray[3] = "Armory (200/60)"; SMIndexArray[3] = 4; SMNameArray[4] = "Generator (300/60)"; SMIndexArray[4] = 5; SMNameArray[5] = "Outpost (600/90)"; SMIndexArray[5] = 6; SMArraySize=6; else case SMS_Construction: SMNameArray[0] = "Shield (50/30)"; SMIndexArray[0] = 1; SMNameArray[1] = "Protector (200/30)"; SMIndexArray[1] = 2; SMNameArray[2] = "Portal (200/30)"; SMIndexArray[2] = 3; SMNameArray[3] = "Armory (200/60)"; SMIndexArray[3] = 4; SMNameArray[4] = "Generator (300/60)"; SMIndexArray[4] = 5; SMNameArray[5] = "Outpost (600/90)"; SMIndexArray[5] = 6; SMNameArray[6] = "Warhead (3000/180)"; SMIndexArray[6] = 7; SMArraySize=7; }
Still gives me the same error, Bad or Missing Expression in 'if'
Last edited by Grimshad; Jan 3rd, 2009 at 10:07 pm.
![]() |
Similar Threads
- Starting wxPython (GUI code) (Python)
- Simple Fork code (C)
- Need help making simple random images (PHP)
- Code to Hide TaskBar etc? (HTML and CSS)
- C#,system tray, wont go from task bar. (C#)
- This has to be a simple question to answer. (Visual Basic 4 / 5 / 6)
- Help with writing a bit of code (C)
- Use sys calls fork(),pipe(),open()..... (C)
- Need help writing a program (C++)
- Help! Errors in program (average characters) (C++)
Other Threads in the C++ Forum
- Previous Thread: XP Window Hide
- Next Thread: How do I create a program that creates a file that stores the variables data?
| Thread Tools | Search this Thread |
action api array auto based beginner binary bitmap c++ c/c++ calculator challenge char class classes code coding compile console conversion count createcopyofanyfileinc delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game garbage givemetehcodez graph gui hmenu homeworkhelp homeworkhelper iamthwee ifstream input insert int integer java lib linkedlist linker loop looping loops map math matrix memory multiple news node noob output parameter pointer primenumbersinrange problem program programming project python random read recursion reference rpg sockets string strings temperature template test text text-file tree url variable vector video win32 windows winsock wordfrequency wxwidgets






