Th3xpl0iT wrote:When I say "It does the same thing", I mean exactly that - It constantly would send "HELLO WORLD" if the code was:
Code: Select all
int i = 0;
if (i==0) {
m_game->SendChatMessage("HELLO WORLD", CHATCHANNEL_PUBLIC);
i++;
}
This would become handy because I want my bot to say to the Alliance what to do according to the Defcon level (I know how to do it, except the repeat problem).
So, you have your single instance of code which will repeat any time it's call for the reason I described yet you don't want it doing it the same thing? By "It does the same thing" do you actually mean it keeps executing the PlaceStructure code when you only want it to be called once? So basically, you're trying to ask how to have a piece of code only execute once? By "single instance" I thought you were talking about how many times a piece of code appeared in your project, i.e. refactor a piece of code to loop over the available units to place them.
If it is the case of you wanting to execute code only once then you can either check the value of the tick, or use global flags that get set to true or false when you want to trigger certain events, or a slight variant of the global boolean would be a global integer which gives a finer degree than Defcon level. An example of the first method can be found
hereTh3xpl0iT wrote:And I suppose my most important question/problem (along with ordering an Airbase to send fighters to an x,y location >_<): Fleets. How the hell can I put a fleet into the water? It's been driving me nuts - The Constants .pdf file said that '8' was Battleship, so I would do:
Code: Select all
m_game->PlaceFleet(test_x, test_y, 8, 8, 8, 8, 8, 8);
And it wouldn't appear.
EDIT: Learned how to put boats in the water lmao. Now to learn how to order Airbases, as well as switching my Silos to Nuke mode and having them launch against the enemy.
As I previously said, don't use the numeric value for selecting units. Use the name defined in enums.h. So rather than 8, use TypeBattleShip in the same way you're suppose to use CHATCHANNEL_PUBLIC rather than 100