Jump to content
Sign in to follow this  
B00Ts-SA

What a battle been trying for 3 days to get this to work. cant get script to run

Recommended Posts

What a battle been trying for 3 days to try get this to work. This is a simple zombie AI script by BlueBar thanks to him.

To get it to work you spawn as many civilians units as you want then in the initialization field you add null = [this] execVM "shaun.sqf"; so far so good it works no issue.

Well here is my problem if I want to do it by script to spawn units that's the easy part, now the spawned units I cant get to execVM "shaun.sqf" script. I must of tried hundreds of ways to try get this to work by script.

I am still new at scripting, also been searching to try help myself.

Thanks in advance

Share this post


Link to post
Share on other sites

_newUnit = "className" createUnit ......;
null = [_newUnit] execVM "shaun.sqf";

You would have to post code if you wanted more help. I would also recommend that you use "compile preprocessFileLineNumbers" in your init and call that instead of execvm, so it doesn't have to compile the code every time you call it.

Share this post


Link to post
Share on other sites

it probably need to be launch from the server though.

the best ( to emulate the same as when placed in the editor) would be to create the unit and call the shaun.sqf script within the same function ran on the server with MP_Exec

try to look at the MP_Exec in the wiki. with this there is a way to exec code on server only, (or also everyone including server) ...

edit: by Mp_Exec I meant BIS_fnc_MP ... I don't know where I've seen MP_Exec... maybe an old version or script... anyway it is BIS_fnc_MP

here : https://community.bistudio.com/wiki/BIS_fnc_MP

Edited by holo89

Share this post


Link to post
Share on other sites

Hi

Thanks for replying,

The code I use in the initialization field of the Civilians units when using the editor and it works is :)

null = [this] execVM "shaun.sqf";  

Then I spawned Civilian units with this code in script also works :)

_mygroup = [getmarkerpos "mygroupstart", civilian,["C_man_w_worker_F","C_man_w_worker_F"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;

Then I tried all these codes to get the spawned Civilians units to exec with the above code "shaun.sqf" but not one worked :(

{ null = [this] execVM "shaun.sqf"} foreach units _mygroup;

then this


	if (side _x == civilian) then
	{
null = [this] execVM "shaun.sqf"	_x;
	};
}
forEach allUnits;

and many other different ways :( .This last code I must of tried every way I could

Thank you guys for trying to help

Share this post


Link to post
Share on other sites

{		
     if (side _x == civilian) then {
        _null = [_x] execVM "shaun.sqf";
     };
} forEach allUnits; // or forEach _mygroup

You were close.

Edited by Fight9

Share this post


Link to post
Share on other sites

:jump_clap: Fight9 thank you so much for 3 days I tried every combination on that code and many others and you solved it.

thank you all again :)

Share this post


Link to post
Share on other sites

I have a similar issue with the same "shaun.sqf" file.

So Ive used this code for the civilians INIT field (which works great)

null = [this] execVM "shaun.sqf"; this addEventHandler ["HandleDamage", {((_this select 2)/2)}];this setunitpos "up";0 = this spawn {sleep 1; removeHeadgear _this; removeGoggles _this};enableSentences false;

But i want to be able to spawn a civilian in via a trigger like this (which also works when i set spawn points ie. spawn1, spawn2, spawn2 ect)

GroupOne_X = Creategroup Civilian;  "C_man_1" createUnit [getMarkerPos "spawn1",GroupOne_X,"this allowFleeing 0",random 1, "Private"]; 

The problem is i want to be able to spawn a civilian in with the INIT field filled in with the top code.. any ideas?

---------- Post added at 03:20 ---------- Previous post was at 02:29 ----------

this works

GroupOne_X = Creategroup Civilian;  "C_man_1" createUnit [getMarkerPos "spawn1",GroupOne_X, "removeAllItems this; removeAllWeapons this;  enableradio false; _nul = [this] execVM ""shaun.sqf"";", 0.5, "private"];

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  

×