Jump to content
Sign in to follow this  
Stubbinz

Newbie at SQF, trying to spawn people within a certain range...

Recommended Posts

Okay, essentially i have multiplayers but i'm going to explain with _player1. Basically i have a bunch of invisible helipads laid about, and what i want is some zombies (using UNDEAD MOD) to spawn in a random radius around one of these helipad's using nearestobjects. My script im using at the moment doesnt' seem to work, advise appreciated.

_player1 = players select 0;
_spawnground = getpos nearestobject [_player1, "HeliH"];


while {spawn_zeds} do {
_group = createGroup resistance;
"CHN_ZOMBIE_Policeman" createunit [_spawnground,__group,this addEventHandler ["killed",{(vehicle (_this select 0)) addAction 

["Loot Corpse","corpse_loot.sqs"];}], 1, "COLONEL"];
"CHN_ZOMBIE_Rocker2" createunit [_spawnground,__group,this addEventHandler ["killed",{(vehicle (_this select 0)) addAction 

["Loot Corpse","corpse_loot.sqs"];}], 1, "COLONEL"];
"CHN_ZOMBIE_citizen1" createunit [_spawnground,__group,this addEventHandler ["killed",{(vehicle (_this select 0)) addAction 

["Loot Corpse","corpse_loot.sqs"];}], 1, "COLONEL"];
"CHN_ZOMBIE_Citizen2" createunit [_spawnground,__group,this addEventHandler ["killed",{(vehicle (_this select 0)) addAction 

["Loot Corpse","corpse_loot.sqs"];}], 1, "COLONEL"];
"CHN_ZOMBIE_Citizen3" createunit [_spawnground,__group,this addEventHandler ["killed",{(vehicle (_this select 0)) addAction 

["Loot Corpse","corpse_loot.sqs"];}], 1, "COLONEL"];
"CHN_ZOMBIE_Priest" createunit [_spawnground,__group,this addEventHandler ["killed",{(vehicle (_this select 0)) addAction 

["Loot Corpse","corpse_loot.sqs"];}], "COLONEL"];
"CHN_ZOMBIE_Profiteer4" createunit [_spawnground,__group,this addEventHandler ["killed",{(vehicle (_this select 0)) addAction 

["Loot Corpse","corpse_loot.sqs"];}], 1, "COLONEL"];
"CHN_ZOMBIE_Profiteer3" createunit [_spawnground,__group,this addEventHandler ["killed",{(vehicle (_this select 0)) addAction 

["Loot Corpse","corpse_loot.sqs"];}], 1, "COLONEL"];
"CHN_ZOMBIE_Profiteer2" createunit [_spawnground,__group,this addEventHandler ["killed",{(vehicle (_this select 0)) addAction 

["Loot Corpse","corpse_loot.sqs"];}], 1, "COLONEL"];
"CHN_ZOMBIE_Profiteer1" createunit [_spawnground,__group,this addEventHandler ["killed",{(vehicle (_this select 0)) addAction 

["Loot Corpse","corpse_loot.sqs"];}], 1, "COLONEL"];
"CHN_ZOMBIE_Policeman" createunit [_spawnground,__group,this addEventHandler ["killed",{(vehicle (_this select 0)) addAction 

["Loot Corpse","corpse_loot.sqs"];}], 1, "COLONEL"];
"CHN_ZOMBIE_Policeman" createunit [_spawnground,__group,this addEventHandler ["killed",{(vehicle (_this select 0)) addAction 

["Loot Corpse","corpse_loot.sqs"];}], 1, "COLONEL"];
(leader _group) setpos getpos _spawnground;
};
sleep (random 300);
};

Share this post


Link to post
Share on other sites

Hi,

do you have a center for resistance?

Just place one Resistance aka Independent unit somewhere on the map. Without a center you cannot spawn units.

Any errors in your RPT?

Edit:

- You have one }; too much at the end.

- Your sleep 300 should be inside the loop.

- Your first two lines should be inside the loop too, otherwise the nearestObject won't be refreshed.

Like this:

while {spawn_zeds} do {

_player1 = players select 0;
_spawnground = getpos nearestobject [_player1, "HeliH"];

   _group = createGroup resistance;
   "CHN_ZOMBIE_Policeman" createunit [_spawnground,__group,this addEventHandler ["killed",{(vehicle (_this select 0)) addAction 

["Loot Corpse","corpse_loot.sqs"];}], 1, "COLONEL"];
	"CHN_ZOMBIE_Rocker2" createunit [_spawnground,__group,this addEventHandler ["killed",{(vehicle (_this select 0)) addAction 

["Loot Corpse","corpse_loot.sqs"];}], 1, "COLONEL"];
	"CHN_ZOMBIE_citizen1" createunit [_spawnground,__group,this addEventHandler ["killed",{(vehicle (_this select 0)) addAction 

["Loot Corpse","corpse_loot.sqs"];}], 1, "COLONEL"];
	"CHN_ZOMBIE_Citizen2" createunit [_spawnground,__group,this addEventHandler ["killed",{(vehicle (_this select 0)) addAction 

["Loot Corpse","corpse_loot.sqs"];}], 1, "COLONEL"];
	"CHN_ZOMBIE_Citizen3" createunit [_spawnground,__group,this addEventHandler ["killed",{(vehicle (_this select 0)) addAction 

["Loot Corpse","corpse_loot.sqs"];}], 1, "COLONEL"];
	"CHN_ZOMBIE_Priest" createunit [_spawnground,__group,this addEventHandler ["killed",{(vehicle (_this select 0)) addAction 

["Loot Corpse","corpse_loot.sqs"];}], "COLONEL"];
	"CHN_ZOMBIE_Profiteer4" createunit [_spawnground,__group,this addEventHandler ["killed",{(vehicle (_this select 0)) addAction 

["Loot Corpse","corpse_loot.sqs"];}], 1, "COLONEL"];
	"CHN_ZOMBIE_Profiteer3" createunit [_spawnground,__group,this addEventHandler ["killed",{(vehicle (_this select 0)) addAction 

["Loot Corpse","corpse_loot.sqs"];}], 1, "COLONEL"];
	"CHN_ZOMBIE_Profiteer2" createunit [_spawnground,__group,this addEventHandler ["killed",{(vehicle (_this select 0)) addAction 

["Loot Corpse","corpse_loot.sqs"];}], 1, "COLONEL"];
	"CHN_ZOMBIE_Profiteer1" createunit [_spawnground,__group,this addEventHandler ["killed",{(vehicle (_this select 0)) addAction 

["Loot Corpse","corpse_loot.sqs"];}], 1, "COLONEL"];
	"CHN_ZOMBIE_Policeman" createunit [_spawnground,__group,this addEventHandler ["killed",{(vehicle (_this select 0)) addAction 

["Loot Corpse","corpse_loot.sqs"];}], 1, "COLONEL"];
	"CHN_ZOMBIE_Policeman" createunit [_spawnground,__group,this addEventHandler ["killed",{(vehicle (_this select 0)) addAction 

["Loot Corpse","corpse_loot.sqs"];}], 1, "COLONEL"];
(leader _group) setpos getpos _spawnground;

sleep (random 300);
};

To locate errors please take a look at your RPT file.

Or/And start your game with the -showScriptErrors parameter

Edit2:

You have a _ too much in all createUnit lines.

__group should be _group

Edit3:

There's so much wrong :(

Again: You really need to take a look at the RPT file to sort out all these silly mistakes. ;)

I've got it working now like this:

p1 is the name of my unit.

spawn_zeds=true;

players = [p1];

while {spawn_zeds} do {
   _player1 = players select 0;
   _spawnground = getpos nearestobject [_player1, "HeliH"];
_group = createGroup resistance; 
   "US_Soldier_AMG_EP1" createunit [_spawnground,_group,'this addEventHandler ["killed",{(vehicle (_this select 0)) addAction ["Loot Corpse","corpse_loot.sqs"];}]', 1, "COLONEL"];
   (leader _group) setpos _spawnground;

   sleep (random 300);
};  

Edited by sxp2high

Share this post


Link to post
Share on other sites

Quick question, how would i keep the condition between two variables?

while {spawn_zeds} do {
   _player1 = players select 0;
   _player2 = players select 1;
   _spawnground_p1 = getpos nearestobject [_player1, "HeliH"];
   _spawn_p1 = floor (random 20);
   _spawn_p2 = floor (random 10);
   if (_spawn_p1 >= 0) && (_spawn_p1 <= 10) then {_group = createGroup WEST; 
   "US_Soldier_AMG_EP1" createunit [_spawnground_p1,_group,'this addEventHandler 

["killed",{(vehicle (_this select 0)) addAction ["Loot 

Corpse","corpse_loot.sqs"];}]', 1, "COLONEL"];};


   if (_spawn_p1 >= 11) && (_spawn_p1 <= 20) then {_group1 = createGroup WEST; 
   "GER_Soldier_EP1" createunit [_spawnground_p1,_group1,'this addEventHandler 

["killed",{(vehicle (_this select 0)) addAction ["Loot 

Corpse","corpse_loot.sqs"];}]', 1, "COLONEL"];};


   sleep (random 10);
}; 

When i remove the condition after the && symbols it spawns the unit, but if the variable is over 11, it spawns both units which i don't want. I want it to spawn one or the other.

---------- Post added at 01:34 AM ---------- Previous post was at 01:26 AM ----------

Nevermind. I'm a tard. ha

I realize i gotta have the AND inside the single (condition) area with the conditions. ha

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×