Jump to content

Recommended Posts

Hey guys,

im plenty new at scripting so pls dont be to harsh ^^ however the problem im facing is that my script just runs the else part and idk why

Thank u guys for ur time and help :)  

 

init :

this setVariable["bis_disabled_Door_1",1,true]; this addAction ["Tür aufbrechen", "test.sqf",[this,player]];

 

 

test.sqf:

_tuer=_this select 3 select 0;
_unit=_this select 3 select 1;


_items = items _unit;

//if (["ToolKit"] in backpackItems _player) then {
if ("ToolKit" in _items) then {

	_tuer setVariable["bis_disabled_Door_1",0,true];
	hint "Das Schloss ist geknackt";
}
else{
	hint "Du hast kein Werkzeug",;
};



 

Share this post


Link to post
Share on other sites
1 hour ago, SporeLamm21 said:

Hey guys,

im plenty new at scripting so pls dont be to harsh ^^ however the problem im facing is that my script just runs the else part and idk why

Thank u guys for ur time and help 🙂  

 

init :


this setVariable["bis_disabled_Door_1",1,true]; this addAction ["Tür aufbrechen", "test.sqf",[this,player]];

 

 

test.sqf:


_tuer=_this select 3 select 0;
_unit=_this select 3 select 1;


_items = items _unit;

//if (["ToolKit"] in backpackItems _player) then {
if ("ToolKit" in _items) then {

	_tuer setVariable["bis_disabled_Door_1",0,true];
	hint "Das Schloss ist geknackt";
}
else{
	hint "Du hast kein Werkzeug",;
};



 

Not a scripter or an expert, but those "//" before 

if (["ToolKit"] in backpackItems _player) then {
if ("ToolKit" in _items) then {

	_tuer setVariable["bis_disabled_Door_1",0,true];
	hint "Das Schloss ist geknackt";
}

are for? Usually the void the whole line of code after them.

2nd: it's unclear the ""if/then""part of the script.

There are 2 "if" without the "then" ending correctly IMO.

 

if (["ToolKit"] in backpackItems _player) then { if? ("ToolKit" in _items) then { _tuer setVariable["bis_disabled_Door_1",0,true]; hint "Das Schloss ist geknackt"; }

 

Try erasing "{ if? ("ToolKit" in _items) then " from the middle and see if it work.

Again, not an expert, but something isn't right there.

 

reference: https://community.bistudio.com/wiki/if

 

 

 

 

Share this post


Link to post
Share on other sites

Your if statement looks fine to me.  Run your mission from the editor, hit escape and paste the following into one of the debug variables and see what is returned.  Do you see "Toolkit" in the array of returned items?

items player

 

  • Like 1

Share this post


Link to post
Share on other sites

Yes, check your items as JBoy said.

 

Passing such parameters:

- player which is already the caller in addAction,

- and <this> which is already the target (house)

has no sense here.

this setVariable["bis_disabled_Door_1",1,true]; this addAction ["Tür aufbrechen", "test.sqf"];

 

test.sqf:

params ["_tuer","_unit"];
if ("ToolKit" in items _unit) then {
  _tuer setVariable ["bis_disabled_Door_1",0,true];

  hint "Das Schloss ist geknackt";

} else{

  hint "Du hast kein Werkzeug";

};

 

  • Like 1

Share this post


Link to post
Share on other sites

Alternatively you can expand upon this:

 

 

 

Should have the functionality covered and get you started.

 

Cheers

  • Like 4

Share this post


Link to post
Share on other sites
5 hours ago, johnnyboy said:

Your if statement looks fine to me. 

 

 

3 hours ago, pierremgi said:

Yes, check your items as JBoy said.

 

3 hours ago, Grumpy Old Man said:

Alternatively you can expand upon this:

 

😜Damn....this is what's happen when you take a break  from Arma , even a short one. Looks like I opened my mouth before connecting it to the brain. Sorry!!!!!

 

Ps: Could my previous post pass for an April fool thing? 

OK..OK..I shut up!!!

  • Haha 3

Share this post


Link to post
Share on other sites

I'm not sure if this is an April Fool's Day trick or what but the 2 forward slashes (//) indicate a comment. Specifically that kind of comment will cause the rest of the line to be ignored.

All comments are removed during preprocessing before the sqf is run, so, in effect, the scripting engine never sees them

Share this post


Link to post
Share on other sites
7 hours ago, dreadedentity said:

I'm not sure if this is an April Fool's Day trick or what but the 2 forward slashes (//) indicate a comment. Specifically that kind of comment will cause the rest of the line to be ignored.

All comments are removed during preprocessing before the sqf is run, so, in effect, the scripting engine never sees them

From what I can tell he just comments out the first if line, maybe to switch around for testing purposes, no idea.

 

Cheers

Share this post


Link to post
Share on other sites
14 hours ago, dreadedentity said:

I'm not sure if this is an April Fool's Day trick or what but the 2 forward slashes (//) indicate a comment. Specifically that kind of comment will cause the rest of the line to be ignored.

All comments are removed during preprocessing before the sqf is run, so, in effect, the scripting engine never sees them

As i mentioned above, i notice that as well, and was wondering the same thing.That's where I got confused with the double "if" statement.....probably as @Grumpy Old Man mentioned, he just left it in for testing purposes.

Share this post


Link to post
Share on other sites
On 4/1/2019 at 9:55 AM, zagor64bz said:

Not a scripter or an expert, but those "//" before 

are for? Usually the void the whole line of code after them.

2nd: it's unclear the ""if/then""part of the script.

There are 2 "if" without the "then" ending correctly IMO.

Guys, I know what a comment is. My post was actually specifically for you, zagor, in reference to this earlier post. But if anyone else reads this and learns what a comment is, that's good too

 

EDIT: I guess I didn't really understand the rest of your earlier post the first time I read it, but yes, what you're describing is exactly what he did

Edited by dreadedentity
for general derpiness
  • Haha 1

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

×