Easy_tiger 0 Posted February 22, 2007 Hi, can someone please post some code snippets for using preproccess file in ArmA. I have tried everything possible but cannot get the damn function to execute!!!!! heres what im doing below, can anyone help please this is driving me up the wall! init.sqs: ReArmOpfor = preprocessfile "ReArmOpFor.sqf" ------------------------------------------- ReArmOpfor.sqf: hint "executing"; return true ---------------------------------------- player init: [player] call ReArmOpfor Share this post Link to post Share on other sites
t_d 47 Posted February 22, 2007 Try to use preprocessFile in connection with compile, because call command needs code instead of strings. For example: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">fMyFunction = compile preprocessFile "myFunc.sqf"; [parameter] call fMyFunction Share this post Link to post Share on other sites
Easy_tiger 0 Posted February 22, 2007 Thanks for the info T_D i will try this later on this evening. have you got your example to work in ArmA? Share this post Link to post Share on other sites
Easy_tiger 0 Posted February 22, 2007 Hi, Thanks again for the info, the function now compiles however i still cant get it to execute! heres what ive got: init.sqs ------- ReArmEast = compile preprocessFile "ReArmOpfor.sqf" ReArmOpfor.sqf --------------- /* take arg[0] */ _OPFORunit = (_this select 0); /* remove default weapon (_OPFORunit) removeWeapon "AK74"; Init field for player R1 --------------------- [R1] call ReArmEast Are you restricted to a subset of functions with sqf files? i.e unable to call removeWeapon() etc... Help Share this post Link to post Share on other sites
t_d 47 Posted February 22, 2007 Should be correct besides the fact that an ending of the second comment is missing, so the removeWeapon command isn't interpreted. Share this post Link to post Share on other sites
dr_eyeball 16 Posted February 23, 2007 Yeah I asked the same problem here. Some suggested that the Initialization fields of units possibly get executed before the init.sqs script. Not sure if it's true, but the way you did it won't work. Just change your initialization field to: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">ReArmEast = compile preprocessFile "ReArmOpfor.sqf"; [R1] call ReArmEast Or if you have too many of those sort of calls, you can move all the code into your init.sqf file. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">ReArmEast = compile preprocessFile "ReArmOpfor.sqf"; { [_x] call call ReArmEast; } forEach [R1, R2, R3, R4]; Share this post Link to post Share on other sites
Easy_tiger 0 Posted February 23, 2007 oops sorry T_D forgot to end the comment in the example, however the real code is commented correctly. Thanks for the info Dr_Eyeball i will try your suggestion this weekend. I dont remeber seeing a init.sqf only init.sqs is it just a case of creating the file and adding code and is its compilation automatic or something i have to perform? Share this post Link to post Share on other sites
dr_eyeball 16 Posted February 23, 2007 Yes it's that simple, there's nothing special about using an init.sqf file except that it allows you to use the new sqf syntax (great for multi line statements). It seems to get automatically called at the same time as init.sqs, not sure what order though, but I don't use init.sqs anymore, when possible. Share this post Link to post Share on other sites
Easy_tiger 0 Posted February 23, 2007 wicked! slightly off topic but do functions support recursion? Share this post Link to post Share on other sites