Jump to content
Sign in to follow this  
Royal_Blackwatch

Functions in addons

Recommended Posts

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

<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
<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
<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

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

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 crazy_o.gif about this because started from within a mission and preprocessfile all worked correct.

But problems are there to be solved biggrin_o.gif

Share this post


Link to post
Share on other sites

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

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
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.

smile_o.gif

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
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.

smile_o.gif

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}}; wink_o.gif

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  

×