Forum Jump :

Author Message


Posts: 39
Rank:


Level: Member

Country: us
Location: Miami
Occupation: US Air Force Active Duty
Age: 22
In-game name: SugarBear125

 
#1 Posted at 2016-02-23 01:51        
     
ft=ft+1
_scost=1
_mcost=2
_ecost=3

if (ft<=_scost)
then {
playsound"found1";
[]execVM"flytrap2.sqf";

}else{

[]execVM"flytrap2.sqf";

};

Back Story:
I have an eventhandler that executes this script everytime I hit an Enemy and everytime I hit an Enemy it +1FT.
I have another sqf just like this but it checks to see if ft=2 and it indead does because you get +1FT this first script is called and it plays the sound sound

Problem:
Now the problems is that, if FT=1 it plays the sound and executes the script perfectly. Now when FT=2 it execute the then statement of this script instead of the "else". So it leads me to believe that I think my game indeed thinks that 2 does equal to 1. Because It plays the second script where it says:

_scost=1
_mcost=2
_ecost=3

if (ft=_mcost)
then {
playsound"found2";
[]execVM"flytrap3.sqf";

}else{

hint"";

};

That script is being calling for perfectly.

Long story short... Arma 3 thinks 2=1 and I cant find a way to fix it... Can someone please help


Author Message


Posts: 59
Rank:


Level: Member

Country: ca
Location: Quebec
Occupation:
Age:
In-game name:

 
#2 Posted at 2016-02-23 03:29        
     
You might want to merge all SQF files and try from there.
This is my guess:

ft = ft+1;
_scost = 1;
_mcost = 2;
_ecost = 3;

if (ft <= _scost) then {playsound "found1"; ft = ft+1};
if (ft == _mcost) then {playsound "found2"; ft = ft+1};
if (ft == _ecost) then {playsound "found3"; ft = ft+1};

However, "ft = ft+1" should probably be called from within the eventHandler rather than this script.


Advertisement


Author Message


Posts: 39
Rank:


Level: Member

Country: us
Location: Miami
Occupation: US Air Force Active Duty
Age: 22
In-game name: SugarBear125

 
#3 Posted at 2016-02-23 03:53        
     
I'll give this a go and get back to you :D

Added 49 minutes later:
So I did what you said... I added the FT=FT+1 to and eventhandler... and this is what my new script looks like:

_scost = 1;
_mcost = 2;
_ecost = 3;


_nep = parseText format ["%1<br/><t color='#FF0000' size='1.5'>Find the remaining bunny(s)</t>"];
_ep = parseText format ["%1<br/><t color='#49C41F' size='1.5'>Congrats?...</t>"];


if (ft <= _scost)
then {
playsound "found1";
hint _nep;

}else{

hint"";

};

if (ft == _mcost)
then {
playsound "found2";
hint _nep;

}else{

hint"";

};

if (ft == _ecost)
then {
playsound "youwin";
hint _ep;

}else{

hint"";

};

I figured out how to call that script... But now it just plays everything at once... It like the game is ignoring the If Statements in all

This post was edited by SugarBear (2016-02-23 05:24, 605 days ago)


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#4 Posted at 2016-02-23 06:57        
     
It seems to me, Wak already answered for a similar (same) post. You didn't take into account the fact it's useless to multiply the if else statement.

I don't know what _scost, _mcost _ ecost are, and why multiply these variables?? they are locals, so they works inside this script. But I'm not sure it's the entire script... So, instead of great consideration about what Arma could "think", you'd had a better way to say what you want exactly. Be sure Arma doesn't think 2=1. With several thousands of scripts, this should be discovered for a while!

Playing a sound different for each FT values, FT coming from the EH as suggested by Pwner Actual, is simple as:

_nep = parseText "<t color='#FF0000' size='1.5'>Find the remaining bunny(s)</t>";
_ep = parseText "<t color='#49C41F' size='1.5'>Congrats?...</t>";

call {
if (FT <= 1) exitwith {playsound "found1"; hint _nep};
if (FT == 2) exitwith {playsound "found2"; hint _nep};
if (FT == 3) exitwith {playsound "found3"; hint _ep};
};
It's faster as this little call {} is exited to the rest of the script at the first true occurrence. If then else are all checked even if the true condition is early met.

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 39
Rank:


Level: Member

Country: us
Location: Miami
Occupation: US Air Force Active Duty
Age: 22
In-game name: SugarBear125

 
#5 Posted at 2016-02-23 11:36        
     
Pierre,

I know that indeed the game knows whether 2 does not equal to 1.. If that was the case the whole game would be broken... It was a joke and it was also a better way of explaining the situation. Now _scost,_mcost and _ecost are for me... I know that they are local and only be recognized inside the script that they are in... They are just for me to remember what is what and what I sent is all of the script. Now I'll try your way and get back to you... Thanks in advance


Author Message


Posts: 59
Rank:


Level: Member

Country: ca
Location: Quebec
Occupation:
Age:
In-game name:

 
#6 Posted at 2016-02-23 14:13        
     
I don't know if this is meant for Multiplayer, but what does your EH look like?
It should probably be something like this or similar, give or take some conditions...
{_x addMPEventHandler ["mpkilled",{ft = ft+1; publicVariable "ft = ft+1";}]} forEach allUnits;

And just in case, before defining your variables, maybe declare them if they are used within a scope:
private ["_scost","_mcost","_ecost"];

_scost = 1;
_mcost = 2;
_ecost = 3;


Author Message


Posts: 39
Rank:


Level: Member

Country: us
Location: Miami
Occupation: US Air Force Active Duty
Age: 22
In-game name: SugarBear125

 
#7 Posted at 2016-02-23 23:47        
     
My Eventhandler looks like this addeventhandler ["hit",{_this execVM"fly.sqf"}]; ...Thats sorta what it looks like I cant remember but know it's an single player Hit EH


Author Message

Tajin  



Posts: 433
Rank:


Level: Member

Country: de
Location: Bavaria
Occupation: Communications Designer
Age: 33
In-game name: Tajin

 
#8 Posted at 2016-02-24 18:02        
     
Maybe you can describe what the whole thing should do, instead of just parts of it.
I get the feeling that this is way more complex than it needs to be. ;)

There are a lot of very capable people on this forum, willing to spend some of their time to help you out. So if you have a problem, it surely isn't too much to ask that you atleast take the time to describe it properly. Thanks.

Author Message


Posts: 39
Rank:


Level: Member

Country: us
Location: Miami
Occupation: US Air Force Active Duty
Age: 22
In-game name: SugarBear125

 
#9 Posted at 2016-02-25 13:41        
     
OK sorry for the late response I've been off Armaholic for a while.. I'm still working on this script trying to get it to work....

So this is what I'm trying to do in FULL detail:

I have 3 bunnies on the map that you have to find. When you find one and kill it, it will playsound"found1". The second bunny is the same, when you kill the second bunny it playsound"found2". Now the third bunny is alittle different... When you kill the last bunny it will playsound"youwin" and execute a script...

Now you may say just have each bunny call for a specific stript. But that won't work because I can't have the first bunny playing a sound that is supposed to be called when you find 2 bunnies, and I can't have the "you win" sound playing when you have only found 1 bunny. So I'de decided on using the If and Then statements... When you kill a bunny it adds 1FT and checks to see is FT=1 and if it does then it plays the playsound"found1". When you kill another bunny it adds another FT and checks to see if FT=2 and if it does then it playsound"found2". When you kill the third bunny it adds another FT and checks to see if FT=3 and if it does it playsound"youwin" and executes a script...

I've been trying to figure this out for the longest... I figured out how to execute them but my problem is as stated ABOVE... MANY THANKS TO ALL HELPING. I really appreciate your kindness.


Author Message

Tajin  



Posts: 433
Rank:


Level: Member

Country: de
Location: Bavaria
Occupation: Communications Designer
Age: 33
In-game name: Tajin

 
#10 Posted at 2016-02-25 13:57        
     
Fair enough, then this should suffice:

// init line for every bunny
nul=[this] execVM "";

// bunny.sqf
_bunny = _this select 0;
FT = 0;

_bunny addEventHandler ["Killed",{
    FT = FT + 1;
    switch (FT) do {
        case 1: { 
            hint parseText format ["%1<br/><t color='#FF0000' size='1.5'>Find the remaining bunnys</t>"];
            playsound "found1";
        };
        case 2: {
            hint parseText format ["%1<br/><t color='#FF0000' size='1.5'>Find the remaining bunny</t>"];
            playsound "found2";
        };
        case 3: {
            hint parseText format ["%1<br/><t color='#49C41F' size='1.5'>Congrats?...</t>"];
            playsound "youwin";
        };
    };
}];


Or, for a more flexible approach just place down as many rabbits as you like (no init) and add the following to your init.sqf:
BC = 0 // BunnyCount
{
    BC = BC + 1;
    _x addEventHandler ["Killed",{
        BC = BC - 1;
        if (BC > 1) then {
            hint parseText format ["<br/><t color='#FF0000' size='1.5'>%1 bunnys remaining</t>",BC];
        } else {
            if (BC > 0) then {
                hint parseText format ["<br/><t color='#FF0000' size='1.5'>Find the remaining bunny</t>"];
            } else {
                hint parseText format ["<br/><t color='#49C41F' size='1.5'>Congrats?...</t>"];
                playsound "youwin";
            };
        };
    }];
} forEach (allMissionObjects "Rabbit_F");

This post was edited by Tajin (2016-02-25 14:06, 603 days ago)

There are a lot of very capable people on this forum, willing to spend some of their time to help you out. So if you have a problem, it surely isn't too much to ask that you atleast take the time to describe it properly. Thanks.

Author Message


Posts: 39
Rank:


Level: Member

Country: us
Location: Miami
Occupation: US Air Force Active Duty
Age: 22
In-game name: SugarBear125

 
#11 Posted at 2016-02-25 15:51        
     
YOU SIR ARE A GOD Lol
Now I've added on to it in order to execute another script when I kill the last bunny
case 3: {
hint parseText format ["%1<br/><t color='#49C41F' size='1.5'>Congrats?...</t>"];
playsound "youwin"; null=[]execVM"done.sqf";

and it works perfectly.. *TIPS HAT*


Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 20
In-game name: Wak

 
#12 Posted at 2016-02-25 18:00        
     
# SugarBear : ...*TIPS HAT*

*TIPS BUNNY SKIN HAT**

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage





Tags: If, Statement, Then