| | |
Help with what should be a very simple code task.
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
The case statements are irrelevent -- they do absolutely nothing, so you should just delete them.
C++ Syntax (Toggle Plain Text)
if(TFGame.ToggleWarhead == true) { 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 { 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; }
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
•
•
Join Date: May 2008
Posts: 560
Reputation:
Solved Threads: 90
The if and else need to be 'inside' the case, and the if block and else block need their own set of braces { }.
But this should work too and be a lot smaller:
PS- please use c++ language code tags when posting c++ source
[code=c++]
// your code here
[/code]
if (test) { // code } else { // more code } c++ Syntax (Toggle Plain Text)
case SMS_Construction: if(tfgame.ToggleWarhead == true) { 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 { 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; }
But this should work too and be a lot smaller:
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; SMArraySize=6; if(tfgame.ToggleWarhead == true) { SMNameArray[6] = "Warhead (3000/180)"; SMIndexArray[6] = 7; SMArraySize=7; }
PS- please use c++ language code tags when posting c++ source
[code=c++]
// your code here
[/code]
•
•
Join Date: Jan 2009
Posts: 8
Reputation:
Solved Threads: 0
Ok I found out some more info.
All of the other variables listed at the top of TFGame are in this format when being pulled by other files
When i use
the compiler returns
If i add
to the rest of the locals in TFMenuConsole
and then use
then the code compiles fine, but it doesn't actually do anything in the game. I'm assuming this is because the local object I just created is blank.
All of the other variables listed at the top of TFGame are in this format when being pulled by other files
c++ Syntax (Toggle Plain Text)
if(tfgame(level.Game).variable == true)
c++ Syntax (Toggle Plain Text)
if(tfgame(level.Game).ToggleWarhead == true)
C++ Syntax (Toggle Plain Text)
Error, Bad or Missing Expression in 'if'
c++ Syntax (Toggle Plain Text)
local tfgame warhead
and then use
c++ Syntax (Toggle Plain Text)
if(warhead.ToggleWarhead == true)
Last edited by Grimshad; Jan 4th, 2009 at 1:53 am.
•
•
Join Date: Jan 2009
Posts: 8
Reputation:
Solved Threads: 0
Ok, first ide like to thank everyone here
second, ide like to say im sorry because I didn't know what i was talking about
third, its fixed
that worked, cuz there are no global variables in this script
second, ide like to say im sorry because I didn't know what i was talking about
third, its fixed
c++ Syntax (Toggle Plain Text)
if(class 'TFGame'.default.ToggleWarhead == True)
that worked, cuz there are no global variables in this script
![]() |
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 |
api array arrays based beginner binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






