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-07-15 20:00        
     
So Im trying to have the game check for to see if the cursorTarget is within 75 meters of the player and if so its going to check to see if that cursorTarget is a Man if so it executes below but if the distance is outside of 75 then it plays a sound. Now if the distance is within 75 meters but the cursorTarget is not a man i want it to play a sound. This is what I have:

if ((cursorTarget distance p1) <75) then {
	if (cursorTarget isKindOf "Man") then {
removeAllActions p1;
hammer enableAI "Target";
hammerG enableAI "TARGET";
hammerC enableAI "TARGET";

hammer doTarget cursorTarget;
sleep 2;
hammer doFire cursorTarget;
playsound"engage";

sleep 15;

p1 addAction ["Laser Target", {null=[]execVM'fire.sqf'}];
hammer disableAI "Target";
hammerG disableAI "TARGET";
hammerC disableAI "TARGET";
}else{
playsound"invalid"
}else{
playsound"range"}};
Its not working like that at all. But I have it set up in a different way but it just executes everything in the script:
if (cursorTarget isKindOf "MAN") then 
{
removeAllActions p1;
hammer enableAI "Target";
hammerG enableAI "TARGET";
hammerC enableAI "TARGET";

hammer doTarget cursorTarget;
sleep 2;
hammer doFire cursorTarget;
playsound"engage";

sleep 15;

p1 addAction ["Laser Target", {null=[]execVM'fire.sqf'}];
hammer disableAI "Target";
hammerG disableAI "TARGET";
hammerC disableAI "TARGET";
} else {
playsound"invalid"
}

if (cursorTarget isKindOf "House") then 
{
removeAllActions p1;
hammer enableAI "Target";
hammerG enableAI "TARGET";
hammerC enableAI "TARGET";

hammer doTarget cursorTarget;
sleep 2;
hammer doFire cursorTarget;
playsound"engageh";

sleep 15;

p1 addAction ["Laser Target", {null=[]execVM'fire.sqf'}];
hammer disableAI "Target";
hammerG disableAI "TARGET";
hammerC disableAI "TARGET";
} else {
playsound"invalid"
}

if ((cursorTarget distance player) < 75) then 
{
hint""
}else{
playsound"range"
};

Some one help please


Author Message


Posts: 1189
Rank:


Level: Member

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

 
#2 Posted at 2016-07-15 20:59        
     
If you properly indented your code it whould be easier for you to understand this.

if (cursorTarget distance p1 < 75) then {
    if (cursorTarget isKindOf "Man") then {
        playSound "engage";
    } else {
        playSound "invalid";
    };
} else {
    playSound "range";
};

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

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-07-15 22:39        
     
wak strikes again. Thanks again man. Much appreciated

This post was edited by SugarBear (2016-07-16 00:20, 460 days ago)






Tags: If, Statements, Then