Jump to content
yawdamper

HELP About Addaction

Recommended Posts

Hello guys.I wanna make bomb script and abort it.

 

I used addaction =>

bomb.sqf :

tasiyici removeaction patlat;
 _cancel = tasiyici addAction["<t color='4169e1'>CANCEL </t>", "execvm 'cancel.sqf'"];
 bomb="M_Titan_AA" createVehicle (getPos tasiyici);

cancel.sqf :

_cancel = [] execVM "cancel.sqf";	
		terminate _cancel;
		hint "Patlama Iptal Edildi";
		tasiyici removeaction cancel;
		bomb = tasiyici addAction["<t color='4169e1'>START</t>", "execvm 'bomb.sqf'"];

First Click to START.It's working.Second click to "abort action"(cancel) is doesn't work.Please help..

Share this post


Link to post
Share on other sites

Updated!

 

 

bomb.sqf

player removeAction patlat;
deactivate_bomb = player addAction["<t color='4169e1'>CANCEL </t>", "deactivate_bomb.sqf"];
bomb = "M_Titan_AA" createVehicle (getPos player);

cancel.sqf

player removeAction deactivate_bomb;
deleteVehicle bomb;
patlat = player addAction["<t color='4169e1'>Set Bomb </t>","bomb.sqf"];

This works fine for me, guess the issue was the syntax. You wrote

....addAction["<t color='4169e1'>CANCEL </t>", "execVM 'deactivate_bomb.sqf'"];

instead of

...addAction["<t color='4169e1'>CANCEL </t>", "deactivate_bomb.sqf"];

Just replace "player" with "tasiyici"

Share this post


Link to post
Share on other sites

bomb.sqf

tasiyici removeAction patlat;
deactivate_bomb = tasiyici addAction["<t color='4169e1'>CANCEL </t>", "execvm 'cancel.sqf'"];
bomb = "M_Titan_AA" createVehicle (getPos tasiyici);

cancel.sqf

tasiyici removeAction deactivate_bomb;
deleteVehicle bomb;
patlat = tasiyici addAction["<t color='4169e1'>Set Bomb </t>", "execVM 'bomb.sqf'"];

Try this.

It didn't work.

Share this post


Link to post
Share on other sites

I updated my last post, see above. The script itself is working now, however I don't think it's doing what you want it to do. The Titan AA explodes immediately and can't be aborted.

Share this post


Link to post
Share on other sites

I Tried but didn't work.
 

PATLAT.SQF
 

switch(playerSide) do
	{
		
		case west:
		{
			
		tasiyici removeaction patlat;
        bvazgec = tasiyici addAction["<t color='4169e1'>PATLATMAKTAN VAZGEC</t>", "patlatvazgec.sqf"];
		hintSilent "30";
		sleep 5;
		hintSilent "25";
		sleep 5;
		hintSilent "20";
		sleep 5;
		hintSilent "15";
		sleep 15;
		hintSilent "10";
		sleep 1;
		hintSilent "9";
		sleep 1;
		hintSilent "8";
		sleep 1;
		hintSilent "7";
		sleep 1;
		hintSilent "6";
		sleep 1;
		hintSilent "5";
		sleep 1;
		hintSilent "4";
		sleep 1;
		hintSilent "3";
		sleep 1;
		hintSilent "2";
		sleep 1;
		hintSilent "1";
		sleep 1;
        bomb="M_Titan_AA" createVehicle (getPos tasiyici);
        tasiyici setdamage 1;
			
		};
	};



PATLATVAZGEC.SQF
 

private ["_vazgec"];

switch(playerSide) do
	{
		
		case west:
		{
		
		hint "Patlama Iptal Edildi";
		tasiyici removeaction bvazgec;
		deleteVehicle bomb;
		patlat = tasiyici addAction["<t color='4169e1'>PATLAT</t>", "execvm 'patlat.sqf'"];
			
		};
	};

I dont know,Where is the mistake ?

Share this post


Link to post
Share on other sites

I updated my last post, see above. The script itself is working now, however I don't think it's doing what you want it to do. The Titan AA explodes immediately and can't be aborted.

What can I do now ?

Share this post


Link to post
Share on other sites

playerSide -> side player

Share this post


Link to post
Share on other sites

playerSide -> side player

Both should return the same side.

 

The bomb is created when the timer reaches 0, so the cancel action can't delete it before that. In other words: never.

 

You could add a global variable to check if the bomb is stopped and then skip the createVehicle. Or maybe put the timer hints in a loop which checks the variable before each hint.

Share this post


Link to post
Share on other sites

Both should return the same side.

 

The bomb is created when the timer reaches 0, so the cancel action can't delete it before that. In other words: never.

 

You could add a global variable to check if the bomb is stopped and then skip the createVehicle. Or maybe put the timer hints in a loop which checks the variable before each hint.

 

How can please tell me ? 

I need a script active and deactivate to bomb.

Share this post


Link to post
Share on other sites

What exactly doesn't work? Give us as much information as possible.

Share this post


Link to post
Share on other sites

The first script is , "Active Bomb" is working.
But the second script is "deactivate" is not working.

 

After clicking deactivate button; I see hint "Patlama Iptal Edildi"after 30 sec. I see explosion

Share this post


Link to post
Share on other sites

I might be misunderstanding but the object named bomb is not created untill the countdown is complete? If that is the case then deleteVehicle bomb; would not work since bomb does not exist yet.

Share this post


Link to post
Share on other sites

Whatabout something like this? (see changes in bold)

 

I still dont really understand the creating of a "M_Titan_AA". Can you explain this? 

I Tried but didn't work.
 

PATLAT.SQF
 

switch(playerSide) do
	{
		
		case west:
		{
			
		tasiyici removeaction patlat;
        bvazgec = tasiyici addAction["<t color='4169e1'>PATLATMAKTAN VAZGEC</t>", "patlatvazgec.sqf"];

                bombActive = true;

		hintSilent "30";
		sleep 5;
		hintSilent "25";
		sleep 5;
		hintSilent "20";
		sleep 5;
		hintSilent "15";
		sleep 15;
		hintSilent "10";
		sleep 1;
		hintSilent "9";
		sleep 1;
		hintSilent "8";
		sleep 1;
		hintSilent "7";
		sleep 1;
		hintSilent "6";
		sleep 1;
		hintSilent "5";
		sleep 1;
		hintSilent "4";
		sleep 1;
		hintSilent "3";
		sleep 1;
		hintSilent "2";
		sleep 1;
		hintSilent "1";
		sleep 1;
        if(bombActive) then {bomb="M_Titan_AA" createVehicle (getPos tasiyici);
        tasiyici setdamage 1;};
			
		};
	};



PATLATVAZGEC.SQF
 

private ["_vazgec"];

switch(playerSide) do
	{
		
		case west:
		{
		
		hint "Patlama Iptal Edildi";
		tasiyici removeaction bvazgec;
		bombActive = false;
		patlat = tasiyici addAction["<t color='4169e1'>PATLAT</t>", "execvm 'patlat.sqf'"];
			
		};
	};

I dont know,Where is the mistake ?

Share this post


Link to post
Share on other sites
I might be misunderstanding but the object named bomb is not created untill the countdown is complete? If that is the case then deleteVehicle bomb; would not work since bomb does not exist yet.

 

 

Don't think  that's the case, he's already got a variable to make sure it won't get spawned if it was cancelled.

Share this post


Link to post
Share on other sites

Don't think  that's the case, he's already got a variable to make sure it won't get spawned if it was cancelled.

Altsor added that part in there.

 

And if you want to stop the timer when bomb is cancelled, replace the hint/sleep sequence with:

        _time = 30;
        while {bombActive && _time >0} do {
            if (_time > 10) then {
                hintSilent str _time;
                _time = _time - 5;
                sleep 5;
                } else {
                hintSilent str _time;
                _time = _time - 1;
                sleep 1;
            };
        };
  • Like 1

Share this post


Link to post
Share on other sites
tasiyici addAction [ "Activate bomb", {

    params [ "_target", "_caller", "_ID" ];
    _bombActive = _target getVariable [ "bombActive", nil ];

    if ( isNil "_bombActive" ) then {

        _target setVariable [ "bombActive", _this spawn {
            params[ "_target", "_caller", "_id" ];
            _countDown = 30;
            while { _countDown > 0 } do {
                hint format[ "%1", _countDown ];
                if ( _countDown > 10 ) then {
                    sleep 5;
                    _countDown = _countDown - 5;
                }else{
                    sleep 1;
                    _countDown = _countDown - 1;
                };
            };
            "M_Titan_AA" createVehicle (getPos _target);
            hint "BOOOM!";
            _target setDamage 1;
            _target removeAction _id;
        }];
        
        _target setUserActionText [ _id, "Deactivate Bomb" ];

    }else{

        terminate _bombActive;
        _target setUserActionText [ _id, "Activate Bomb" ];
        _target setVariable [ "bombActive", nil ];
        hint "Bomb Deactivated";

    };
}];
  • Like 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

×