No announcement yet.

addAction issues need help

  • Filter
  • Time
  • Show
Clear All
new posts

  • addAction issues need help

    I've got a mission the requires three bridges to be blown up. I've written a script to blow the bridges, but I want to require the player(s) to move to the bridges, where there are explosives (notional at this point) already planted, and insert blasting caps. Once they have inserted the blasting caps they will then be able to remote detonate the bridge.

    I've been tooling around trying to figure out a way to give the player an action "plant blasting caps" once they are within a few meters of the explosives, then once they have planted the blasting caps I need an action given to them that enables them to blow the bridge (which is a simple call on an existing script).

    To better illustrate what I want, the satchel charge is a great analogy. It has the following properties:

    1. An action menu item is added that allows a player to place a satchel charge wherever he wants
    2. Once the satchel is place, another action is added, this time to detonate the charge.
    3. The player then moves a safe distance away and executes the action, which blows up the charge.

    I want exactly the same thing, except in my example I need the following:

    1. An action menu item that is enabled once the player is close enough to a certain object (within 2m), it will be called "insert blasting caps"
    2. Once the "blasting caps" are set, another action is added that, instead of blowing up a certain item, will execute the script I have already written to blow up the bridge, (exec "blowbridge.sqf")
    3. The player will then be able to move a safe distance away and execute the action, which will blow up the bridge via the script that I have already written.

    So you see, all I need is essentially what is already in the game with the satchel charge. I just can't figure out how to make it work...

    Thanks to whomever cares to lend a hand.

    |TG-1st|Rustic 4-1


    "Do not pray for easier lives. Pray to be stronger men." John F. Kennedy

  • #2
    Re: addAction issues need help

    You'll want to do it like this:
    1. Add an action to the "certain object" that runs the script or code that you want to be run when inserting the blasting caps. Have the code to remove the action once it's run.
    2. Have the above code add the "Blow up bridge" action to whoever runs it(use player addAction ...)

    Something like this... I don't remember what the default distance for the action is, but it's a few meters max. If you want the "place caps"-action to show up only to certain players you can use the new "condition" part of addAction. Consult the comref for the exact syntax.
    "Certain object's" init
    if (isServer) then
    	this addAction ["Plant blasting caps", "place_caps.sqf"];
    #define arg(x) (_this select x)
    if (local arg(1)) then
    	//Remove the "place caps" action
    	arg(0) removeAction arg(2);
    	//Play an animation to simulate doing something
    	player playMove "AinvPknlMstpSlayWrflDnon_medic";
    	sleep 5;
    	//Add the new action
    	player addAction ["Detonate charges", "blowbridge.sqf"];
    Finally, remove the action when the bridges are blown:

    player removeAction (_this select 2);
    Last edited by Fincuan; 11-03-2009, 03:15 AM.




    TeamSpeak 3 Server


    Twitter Feed