Royal_Blackwatch 0 Posted November 4, 2003 I tried to use a function in an addon but it doesn`t work. OFP shows me an errormessage all the time "Script \addonname\function.sqf not found" The Function is called from within the Init-Eventhandler as follows variable = preprocessfile "\addonname\function.sqf" I´ve tried almost every variant of the path I can imagine and all with the same result. I don´t know where my mistake is or isn´t it possible to do so. Could anyone give me a hint plz Share this post Link to post Share on other sites
raedor 8 Posted November 4, 2003 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">init = {variable = _this call loadFile "fct.sqf"}this has to work... Share this post Link to post Share on other sites
BraTTy 0 Posted November 4, 2003 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">init = {variable = _this call loadFile "fct.sqf"}this has to work...I can't say whether that will work or not ,but within the .cpp you do need double quotes: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">init = {variable = _this call loadFile ""fct.sqf""} Share this post Link to post Share on other sites
dinger 1 Posted November 5, 2003 preprocessfile does not work in addons. Use loadfile. Share this post Link to post Share on other sites
Royal_Blackwatch 0 Posted November 5, 2003 Well errormessages changed but the function appear to be loaded. Thank you Share this post Link to post Share on other sites
raedor 8 Posted November 5, 2003 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">init = {variable = _this call loadFile "fct.sqf"}this has to work... I can't say whether that will work or not ,but within the .cpp you do need double quotes: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">init = {variable = _this call loadFile ""fct.sqf""} sure? you only need double quotes if u wanna use them "in" quotes. so "_x setBehaviour ""SAFE""", but {_x setBehaviour "SAFE"} works also. i forgot the ";". so the whole thing has to look like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">class Eventhandlers { init = {variable = _this call loadFile "fct.sqf"}; }; Share this post Link to post Share on other sites
BraTTy 0 Posted November 5, 2003 Well you put it that way ,i'm not sure,lol. You sound pretty adequate at scripting and your prolly correct,I was just thinking it was like C language and needed the double quotes for it to distinguish the single quotes Share this post Link to post Share on other sites
Royal_Blackwatch 0 Posted November 6, 2003 The function is now loading and working. The problem is that I get the wrong results (In fact I get an empty variable as a result). I need to track this problem down first but this may take quite some time. Im really about this because started from within a mission and preprocessfile all worked correct. But problems are there to be solved Share this post Link to post Share on other sites
BraTTy 0 Posted November 6, 2003 could try this too: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> class Eventhandlers { init = {variable = (_this select 0) call loadFile ""fct.sqf""}; }; Share this post Link to post Share on other sites
raedor 8 Posted November 7, 2003 it's no problem to solve your prob, but you've to post your function. Share this post Link to post Share on other sites
bn880 5 Posted November 7, 2003 could try this too:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> class Eventhandlers { init = {variable = (_this select 0) call loadFile ""fct.sqf""}; }; Well yes but you do not need the double double quotes "" when encompassing a string in braces {}. If you put the outer string in quotes then you would use double quotes to 'escape' that. And variable will become the result of the function. If you want the function stored in variable do: init = {function = loadFile {\addonname\fct.sqf}}; Share this post Link to post Share on other sites
raedor 8 Posted November 7, 2003 could try this too:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> class Eventhandlers { init = {variable = (_this select 0) call loadFile ""fct.sqf""}; }; Well yes but you do not need the double double quotes "" when encompassing a string in braces {}. If you put the outer string in quotes then you would use double quotes to 'escape' that. exactly what i said. And variable will become the result of the function.If you want the function stored in variable do: init = {function = loadFile {\addonname\fct.sqf}}; nope, you meant <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">init = {variable = loadFile {\addonname\fct.sqf}}; Share this post Link to post Share on other sites