Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: Refueling with Jerry can problems. Trigger not attaching to vehicle.

  1. #1
    Private First Class
    Join Date
    Jun 29 2012
    Location
    Edmonton, Alberta, Canada
    Posts
    12

    Refueling with Jerry can problems. Trigger not attaching to vehicle.

    Allo allo people,
    I'm fairly new to scripting (but made some major strides by dissecting some missions) and I came to small standstill with a mission I've been working on. I've set a trigger up to set fuel on a car to 0. Now what I had planned was the player to find a jerry can and bring it over to the car to fill it up again.

    I was thinking on setting up a trigger to check if the jerry can was within the trigger range (but I am not sure how to activate triggers on specialized objects, if this is even possible).
    If there are any alternatives to this I am more than happy to hear.
    ------------
    After some trial and error I got it working!
    -----
    And not so much anymore. I've set up an object and grouped it with a trigger. It shoots off a hint once it is detected in the area, now my problem comes when I attach the trigger to a vehicle, it doesn't want to fire out the OnAct commands for some reason. I'm stumped.


    Trigger
    Con: this
    Onact : u1 setFuel 1; titleText ["Truck refueled","PLAIN"]; gas attachto [u1,[0,0,0]];

    that is grouped up with a fuel can.

    u1 refers to the vehicle, I also tested making the trigger extremely large. I also suspected that the trigger might not be attaching to the vehicle for some reason (I tried walking towards the vehicle and then walked to where I originally placed the trigger and it shot the onact)

  2. #2
    I wouldn't do it that way but it does work. I had the same problem until I realised I'd used ul instead of u1 on one item.

    I'd use addaction.

    Place the addaction in the vehicles init box

    PHP Code:
    u1 addaction ["Refuel truck","fill.sqf","",1,false,true,"","gas distance u1 <= 5   and player distance u1 <= 5"]; 
    code save as fill.sqf

    PHP Code:
    titleText ["refueling","PLAIN"];

    u1 removeaction (_this select 2);

    sleep 5;

    u1 setfuel 0.3;

    gas attachto [u1,[0,0,0]];

    titleText ["Truck refueled","PLAIN"]; 

  3. #3
    Private First Class
    Join Date
    Jun 29 2012
    Location
    Edmonton, Alberta, Canada
    Posts
    12
    Author of the Thread
    Worked like a charm F2k Sel! Cheers mate

  4. #4
    Private First Class
    Join Date
    Jun 29 2012
    Location
    Edmonton, Alberta, Canada
    Posts
    12
    Author of the Thread
    Edit: Figured it out
    Edit: Nope!
    Last edited by Allanp; Jun 30 2012 at 00:16.

  5. #5
    Private First Class
    Join Date
    Jun 29 2012
    Location
    Edmonton, Alberta, Canada
    Posts
    12
    Author of the Thread
    Ok new problem. I made a case switch to attach the jerrycan onto the back of the truck. Problem is that the previous actions found in the carry.sqf still appears ( I used yours F2k Sel). Which causes the add action menu to go crazy and start cluttering the action menu with double or even triple commands of the same thing. I can't seem to figure out how to disable it or how to combine it into one major sqf. I was thinking about using an if statement to check if the player was even closer to the truck or behind (not sure how to get that, perhaps it can check if the player is near the rear wheel or boot of the truck?)

    Carry
    PHP Code:
    switch (take) do
    {
        case 
    0:
        {
         
    _scase _this select 0;
          
    _man _this select 1;
        
    _scase attachto [_man, [-0.23,0,-0.15],"Pelvis"];
           
    _scase setdir 75;
            
    _scase removeAction act1;
             
    act1 _man addaction ["Drop Jerry Can","carry.sqf","",1,false,true,""];
              
    take=1;scase _scase;taken=true;
        }; 

        case 
    1:
        {
           
    _man _this select 0;
             
    detach scase;
              
    scase setvelocity[0,0,-.3];
               
    _man removeAction act1;
                
    act1 scase addaction ["Take Jerry Can","carry.sqf","",1,false,true,""];
                 
    take=0;
        };
    }; 
    ATTACH

    PHP Code:
    switch (take) do
    {


        case 
    0:
        {
           
    _truck u1;
             
    detach gas;
              
    gas setvelocity[0,0,-.3];
             
    titleText ["Fastening Jerry Can to Truck","PLAIN"]; 
             
    sleep 5;
            
    gas attachTo [u1,[-0.9,-3.1875,-0.5]]; 
            
    titleText ["Jerry Can is secured","PLAIN"]; 
               
    _truck removeAction act2;
                
    act2 _truck addaction ["Remove from Truck","attachtruck.sqf","",1,false,true,""];
                 
    take=1;
        };  
          case 
    1:
        {
        
    _gas gas;
        
    _truck u1;
         
    detach gas;
           
    _gas setvelocity[0,0,-.3];
        
    _man player;
         
    _gas attachto [_man, [-0.23,0,-0.15],"Pelvis"];
            
    _truck removeAction act2;
             
    act2 _truck addaction ["Attach to back of Truck","attachtruck.sqf","",1,false,true,""];
              
    take=0;taken=true;
        }; 
    }; 
    Maybe the player has to drop the jerry can near the truck and use it via the action of the jerry can? (stumped..)

  6. #6
    The problem is that the script needs redoing using setvariable ect but I just don't have the time.

    I did tidy it up a little and it does work, I had to go back to my own previous script and add your bits to it.
    Spoiler:




    Known problems obviously the global variables and poor names of items.
    There is also a problem where the second time around you can attach the can from a great distance, I can't see why this happens as it's set to less than 2meters.

  7. #7
    Private First Class
    Join Date
    Jun 29 2012
    Location
    Edmonton, Alberta, Canada
    Posts
    12
    Author of the Thread
    F2k Sel: Fixed being able to attach from a long distance. Only problem I am facing now is that sometimes act1 in act2 doesn't initialize and I end up sticking the jerry can with the player attached to it to the truck.
    I also changed the names and added a few comments. I also want to say thanks for being such a big help, any contribution is fine and you have gone far beyond what I expected to be contributed.

    Carry
    PHP Code:
    //////////////////////////////////////////////////////////////////
    // Function file for Armed Assault
    // Created by: TODO: Author Name
    //////////////////////////////////////////////////////////////////


    //init: take=0;  act1 = this addaction ["Take Fuel Can","carry.sqf",[0],1,false,true,"","player distance scase < 2"]  
    //Jerry Can starts at case 0 so first the player can pick it up
    switch (take) do
    {
        
    //pick up jerry can
        
    case 0:
        {
         
    _scase _this select 0;
          
    _man _this select 1;
        
    _scase attachto [_man, [-0.23,0,-0.15],"Pelvis"];
          
    _scase setdir 75;
          
    _scase removeAction act1;
           
    act1 _man addaction ["Drop Jerry Can","carry.sqf","",1,false,true,""];
           
    take=1;scase _scase;taken=true;
        }; 

        case 
    1:
        {
           
    _man _this select 0;
            
    detach scase;
            
    scase setvelocity[0,0,-.3];
           
    _man removeAction act1;
            
    act1 scase addaction ["Take Jerry Can","carry.sqf","",1,false,true,""];
            
    take=0;
        };
    }; 
    Attach
    PHP Code:
    //////////////////////////////////////////////////////////////////
    // Function file for Armed Assault
    // Created by: TODO: Author Name
    //////////////////////////////////////////////////////////////////

    //init: truck_start addaction ["Refuel truck","fill.sqf","",1,false,true,"","scase distance truck_start <= 5  and player distance truck_start <= 5"]; 
    //act2 = truck_start addaction ["Attach Options","attachtruck.sqf",[1],1,false,true,"","player distance truck_start < 4 and player distance scase < 4"];

    player removeAction act1;

    switch (
    take) do
    {
        
    //Fasten jerry can to back of truck
       
    case 0:
        {
          
    titleText ["Fastening Fuel Can to Truck","PLAIN"]; 
          
    truck_start removeAction act2;
          
    detach scase;
          
    sleep 5;
          
    scase attachTo [truck_start,[-0.9,-3.1875,-0.5]]; 
          
    titleText ["Jerry Can is secured","PLAIN"]; 
          
    truck_start removeAction act2;//remove action so that player doesn't select it again
          
    act2 scase addaction ["Remove from Truck","attachtruck.sqf","",1,false,true,"","player distance scase < 2"]; //change action for next case
          
    take=1;
        };  
        
    //Attach Jerry Can to hip after removing jerry can from back of truck
       
    case 1:
        {
         
    _man player
        titleText 
    ["Unfastening Fuel Can","PLAIN"];
        
    sleep 5;
          
    detach scase;
          
    sleep 1;
          
    act2 truck_start addaction ["Attach to back of Truck","attachtruck.sqf","",1,false,true,"player distance truck_start < 2 and player distance scase < 2"];
          
    act1 _man addaction ["Drop Jerry Can","carry.sqf",[1],1,false,true,"",""];
          
    take=0;
        };
    }; 

  8. #8
    OK I've had a run through it and it seems better now.

    I've changed a fair bit, a part from at the start there are no actions on the truck. Now they are on the man and Jerry can. I'm using take==0 to stop actions when you don't have the can.


    See how you go.

    Spoiler:

  9. #9
    Private First Class
    Join Date
    Jun 29 2012
    Location
    Edmonton, Alberta, Canada
    Posts
    12
    Author of the Thread
    Fiddled around with it some more, but for some reason the scripterror is showing that line 20 ( the if statement) is missing a ")" but it is clearly there, unless I am missing something else.
    A problem I found is that when I have attached the Jerry Can to the truck the "Take Jerry Can" option is still present and it can really mess up the player by creating multiple instances in the action menu. I think it is the init when on the Fuel Can. I'll have to play around with it some more, but I'll post what I have here for anyone else interested in taking a crack at this code for themselves or for their missions. These few days have been a blast trying to get this thing to work, even though it is a hair puller I am learning loads. Gathering more ideas on making a simple mission...

    PHP Code:
    //////////////////////////////////////////////////////////////////
    // Function file for Armed Assault
    // Created by: TODO: Author Name
    //////////////////////////////////////////////////////////////////

    //Init for Vehicle below
    //act3 = truck_start addaction ["Refuel truck","fill.sqf","",1,false,true,"","scase distance truck_start <= 5  and player distance truck_start <= 5 and take==0"]; 
    //act4 = truck_start addaction ["Attach Options","attachtruck.sqf",[1],1,false,true,"","player distance truck_start < 4 and player distance scase < 4  and take==0"]; 

    player removeAction act1;
    truck_start removeAction act2;// remove initial action on truck.
    _man player;
    _removeAttachOption 0;


    switch (
    take) do
    {  
    //Remove the "Attach Option".
     
    case 0:
        {
             if ( 
    _removeAttachOption then
           
    {
            
    act2 _man addaction ["Attach to back of Truck","attachtruck.sqf","",1,false,true,"","player distance truck_start < 5 and scase distance truck_start < 5 "];
            
    take=1;
           }
           else
           {
          
    _removeAttachOption =1;
          
    player removeAction act4;
          
    titleText ["Seems like you can attach the Jerry Can to the Truck","PLAIN"];
        };
                 
        };
        
    //Fasten jerry can to back of truck 
       
    case 1:
        {
          
    detach scase;
           
    titleText ["Fastening Jerry Can to Truck","PLAIN"]; 
            
    player removeAction act2;
             
    sleep 5;
              
    scase attachTo [truck_start,[-0.9,-3.1875,-0.5]]; // attach to vehicle
               
    titleText ["Jerry Can is secured","PLAIN"];          
                 
    act2 scase addaction ["Remove from Truck","attachtruck.sqf","",1,false,true,"","player distance scase < 2"];//change action for next case 
                  
    take=2;
        };  
        
      
    //Attach Jerry Can to hip after removing jerry can from back of truck     
     
       
    case 2:
        {
         
    detach scase;
           
    titleText ["Unfastening Jerry Can","PLAIN"]; 
            
    scase removeAction act2;
             
    sleep 5;
             
    titleText ["You place the Jerry Can by your side","PLAIN"];
              
    scase attachto [_man, [-0.23,0,-0.15],"Pelvis"]; // attach to player
               
    scase setdir 75;           
                 
    act2 _man addaction ["Attach to back of Truck","attachtruck.sqf","",1,false,true,"","player distance truck_start < 5 and scase distance truck_start < 5 and take==0"];
                  
    act1 _man addaction ["Drop Jerry Can","carry.sqf",[1],1,false,true,"",""];
                   
    take=1;
        }; 
         
    }; 

  10. #10
    OK I changed the approach I was using, I was attaching and detaching the Can directly to the truck and palyer.
    I've changed this now to where you drop it close then the option to attach to truck action shows.
    Really needs a sound effect of can hitting the ground.


    Spoiler:
    Last edited by F2k Sel; Jul 1 2012 at 11:46.

Page 1 of 3 123 LastLast

Similar Threads

  1. Attaching trigger to moving object
    By braincrush in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 5
    Last Post: Sep 3 2010, 14:38
  2. Trigger isn't attaching to Wreck
    By Devil Dogs SF in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 3
    Last Post: Jul 12 2010, 00:31
  3. Attaching a Trigger to a vehicle
    By JDMT in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 8
    Last Post: Mar 16 2010, 22:23
  4. Attaching a Trigger to a Vehicle
    By Schwab in forum ARMA - MISSION EDITING & SCRIPTING
    Replies: 0
    Last Post: Jul 4 2007, 09:30
  5. Attaching a camera to a vehicle
    By [TheOne] in forum OFP : MISSION EDITING & SCRIPTING
    Replies: 7
    Last Post: Jul 11 2006, 10:46

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •