3 Commando Brigade

Realism. Tactics. Fun.

+ New Topic + Post Reply
4 posts in this topic
Posted: Sat Nov 16, 2013 1:19 pm     Super secret spam barrier
Quote
Offline
Major
Major
Other duties:
Site Admin
Game Admin
Modder
Founder

Posts: 3774
Location: London, UK
Ribbons:
Service Medal (7)

Script issues


When running a mission locally (e.g. testing the mission on your own PC), you are the server. Therefore, using isServer in a script will cause anything within that scope to not run. Instead, use isDedicated - this will run anything within that scope on a dedicated server only (which I'm guessing is what you want).

Also, as a faster and more efficient method, you should use createUnit array instead of createUnit. Like this:

// Slower method
"O_mas_afr_Rebel1_F" createUnit [getMarkerPos "spawnHQ",Rebel_find_wreck,"",0.85, "Private"];

// Faster method
Rebel_find_wreck2 createUnit ["O_mas_afr_Rebel1_F", getMarkerPos "spawnHQ", [], 0, "FORM"];
 

And if you want to be really clever, why not put the spawning of units in a for loop with a random unit type every time, like this:

_spawnCount = 7; // However many you want to spawn
for "_i" from 1 to _spawnCount do {
   Rebel_find_wreck createUnit [format["O_mas_afr_Rebel%1_F", ceil(random 5)], getMarkerPos "spawnHQ", [], 0, "FORM"];
};


Let me know how it goes ;)

"To achieve great things, two things are needed; a plan, and not quite enough time." - Leonard Bernstein
3CB ops in a nutshell.

PC Specs


Posted: Sat Nov 16, 2013 2:07 pm     Super secret spam barrier
Quote
Offline
Major
Major
Other duties:
Site Admin
Game Admin
Modder
Founder

Posts: 3774
Location: London, UK
Ribbons:
Service Medal (7)
_spawnCount is a constant (fixed variable) and so will never change unless you redefine it. So yes - you can reuse _spawnCount whenever you want. For example:
_spawnCount = 7; // However many you want to spawn
for "_i" from 1 to _spawnCount do {
   Rebel_find_wreck createUnit [format["O_mas_afr_Rebel%1_F", ceil(random 5)], getMarkerPos "spawnHQ", [], 0, "FORM"];
};

sleep 300;

// Will still spawn 7 units
for "_i" from 1 to _spawnCount do {
   Rebel_find_wreck createUnit [format["O_mas_afr_Rebel%1_F", ceil(random 5)], getMarkerPos "spawnHQ", [], 0, "FORM"];
};

sleep 300;

_spawnCount = 12; // Redefining how many I want to spawn
for "_i" from 1 to _spawnCount do {
   Rebel_find_wreck createUnit [format["O_mas_afr_Rebel%1_F", ceil(random 5)], getMarkerPos "spawnHQ", [], 0, "FORM"];
};

Also, ceil(random 5) will return (at random) either 1,2,3,4, or 5. You can read more about the command here.

"To achieve great things, two things are needed; a plan, and not quite enough time." - Leonard Bernstein
3CB ops in a nutshell.

PC Specs


Posted: Mon Nov 18, 2013 11:33 am     Super secret spam barrier
Quote
Offline
Major
Major
Other duties:
Site Admin
Game Admin
Modder
Founder

Posts: 3774
Location: London, UK
Ribbons:
Service Medal (7)
I can't test this myself at the moment, but from the error you gave me I don't think the code you posted is what's causing the error. Have a look at your if statements, make sure you aren't mission any brackets or curly braces.

"To achieve great things, two things are needed; a plan, and not quite enough time." - Leonard Bernstein
3CB ops in a nutshell.

PC Specs


Posted: Mon Nov 18, 2013 11:44 am     Super secret spam barrier
Quote
Offline
Marine
Marine
Other duties:
Modder
Founder

Posts: 6832
Ribbons:
Service Medal (7) Donator (1) Modding Team (1)
Frag of the match (1) Operation Medal (1)
Ah, the attack of the brackets.
Curly ones too, the worst kind.


+ New Topic + Post Reply


Who is online

Users browsing this forum: No registered users and 72 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

cron
phpBB © Forum Software
© 3 Commando Brigade Gaming Community
All images belong to their respective owners


3CB Modern design by Jamie Goodson
WysiBB