Jump to content
Sign in to follow this  
cavemans

ambient civilian module

Recommended Posts

I am trying to get it so if a civilian made by the ambient civilian module is killed it sets damage to the player. I used this in the init of the module

[ bis_alice_mainscope, "ALICE_civilianinit", [{ _this addEventHandler ["killed",{_this exec "civ_killer.sqs"}] }] ] call bis_fnc_variablespaceadd;

Why isnt it working? I also want to get them to spawn on the airport strip on utes only.

Edited by cavemans

Share this post


Link to post
Share on other sites

try and change sqs files to sqf files. this might help if not im not sure

Share this post


Link to post
Share on other sites
try and change sqs files to sqf files. this might help if not im not sure

Is there a different format i have to use?

_killer = _this select 1

hint "you killed a civilian and have been killed."

_killer setdammage .90

exit

thats my sqs file. By the way when i use that the setdamage is there for a long time and i cant do any damage to the player afterwords including gunshots.

Share this post


Link to post
Share on other sites

if you change it to an sqf file, i think that will work, the "exit" shouldn't be needed however.

Also, you will have to call it with "execVM" rather than "exec" if you use sqf, because sqf gets compiled to bytecode that runs in a thread on the virtual machine (i think)

Share this post


Link to post
Share on other sites

Maybe this will work, though bear in mind i have no knowledge about the alice part.

[bis_alice_mainscope, "ALICE_civilianinit", [{_this addEventHandler ["killed",{
  _killer = _this select 1;
  hint "you killed a civilian and have been killed.";
  _killer setdammage .90;
}]}]] call bis_fnc_variablespaceadd;

Share this post


Link to post
Share on other sites
Maybe this will work, though bear in mind i have no knowledge about the alice part.

[bis_alice_mainscope, "ALICE_civilianinit", [{_this addEventHandler ["killed",{
  _killer = _this select 1;
  hint "you killed a civilian and have been killed.";
  _killer setdammage .90;
}]}]] call bis_fnc_variablespaceadd;

No its not working.

Share this post


Link to post
Share on other sites

bis_fnc_variablespaceadd requires the Functions Module. The Functions Module get automatically loaded by the Civilian Module itself, but AFTER the code in your init lines has been processed. You would need to put your code into a script where you can use a

WaitUntil{not isNil "bis_fnc_init"};

to make sure bis_fnc_variablespaceadd is available when you need it. However...

...bis_fnc_variablespaceadd just has the advantage you can use it multiple times in the row, adding your code each time instead of overriding the previous one.

If you want to set the civilianinit variable only once, forget about bis_fnc_variablespaceadd and write

this setVariable ["ALICE_civilianinit",[{_this addEventHandler ["killed",{_this exec "civ_killer.sqs"}]}]];

into the init line of the Civilian module.

Share this post


Link to post
Share on other sites
bis_fnc_variablespaceadd requires the Functions Module. The Functions Module get automatically loaded by the Civilian Module itself, but AFTER the code in your init lines has been processed. You would need to put your code into a script where you can use a

WaitUntil{not isNil "bis_fnc_init"};

to make sure bis_fnc_variablespaceadd is available when you need it. However...

...bis_fnc_variablespaceadd just has the advantage you can use it multiple times in the row, adding your code each time instead of overriding the previous one.

If you want to set the civilianinit variable only once, forget about bis_fnc_variablespaceadd and write

this setVariable ["ALICE_civilianinit",[{_this addEventHandler ["killed",{_this exec "civ_killer.sqs"}]}]];

into the init line of the Civilian module.

So what your saying is what i was using kept repeating the variable on the civilian over and over, so using

this setVariable ["ALICE_civilianinit",[{_this addEventHandler ["killed",{_this exec "civ_killer.sqs"}]}]];  

in the module will just add it once to each civilian unit created?

Edit: well i switch out my code with yours and its spawning 1 civilian. I dont get time to kill them to test it out becuase they usualy spawn to far and they disapear before i get to them.

Edited by cavemans

Share this post


Link to post
Share on other sites
So what your saying is what i was using kept repeating the variable on the civilian over and over

No I wasn't.

You use a setvariable once, all good. you use setvariable a second time, it overwrites the first one.

bis_fnc_variablespaceadd allows you to ADD the second code to the first code. That's all.

well i switch out my code with yours and its spawning 1 civilian. I dont get time to kill them to test it out becuase they usualy spawn to far and they disapear before i get to them.

I highly doubt that. For testing I suggest you place yourself in the middle of the biggest city, add a hint to the top of your "civ_killer.sqs", then start the preview.

Also civilians spawn when you enter a certain radius around the town and disappear if you leave this radius.

Share this post


Link to post
Share on other sites
No I wasn't.

You use a setvariable once, all good. you use setvariable a second time, it overwrites the first one.

bis_fnc_variablespaceadd allows you to ADD the second code to the first code. That's all.

I highly doubt that. For testing I suggest you place yourself in the middle of the biggest city, add a hint to the top of your "civ_killer.sqs", then start the preview.

Also civilians spawn when you enter a certain radius around the town and disappear if you leave this radius.

Why add a hint the civ_killrt only activates if they are killed.

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  

×