Implementing VFLadder - Action only shows up when pointing at object

Greetings,

I'm working on implementing VFLadder into my server. I've got it working... to a point. I've added this code to selfActions (Actual adds starts at if(_canDo) then ):

Code:
if (!isNull _nearLight) then {
    if (_nearLight distance player < 4) then {
        _canPickLight = isNull (_nearLight getVariable ["owner",objNull]);
    };
};
_canDo = (!r_drag_sqf and !r_player_unconscious and !_onLadder);

//Start DV add
if(_canDo) then {
    if (s_player_createladder <0) then {
        s_player_createladder  = player addAction [format["Create Small Ladder"], "VFladder\createladder.sqf",[player,0], 0, false, true, "",""];
        s_player_createladder2 = player addAction [format["Create Big Ladder"], "VFladder\createladder.sqf",[player,1], 0, false, true, "",""];
      };
};    
//End DV add

//##### BASE BUILDING 1.2 Custom Actions (CROSSHAIR IS TARGETING NOTHING) #####

I've got the if statement wide open except for canDo atm for testing purposes, although I intend to add scrap metal as a requirement to it.

However, the createladder actions only show up if I'm close enough to an object that (I assume) my cursor target is on it. As you can see, I've got base building installed, and the 'build recipes' menu shows up regardless of what my cursor target is so I know it's possible, but I can't figure out how it's doing it. Here's the build recipe code:

Code:
//##### BASE BUILDING 1.2 Custom Actions (CROSSHAIR IS TARGETING NOTHING) #####
_currentSkin = typeOf(player);
            // Get closest camonet since we cannot target with crosshair Base Building Script, got lazy here, didnt fix with array
            camoNetB_East = nearestObject [player, "Land_CamoNetB_EAST"];
            camoNetVar_East = nearestObject [player, "Land_CamoNetVar_EAST"];
            camoNet_East = nearestObject [player, "Land_CamoNet_EAST"];
            camoNetB_Nato = nearestObject [player, "Land_CamoNetB_NATO"];
            camoNetVar_Nato = nearestObject [player, "Land_CamoNetVar_NATO"];
            camoNet_Nato = nearestObject [player, "Land_CamoNet_NATO"];
    // Check mags in player inventory to show build recipe menu    
    _mags = magazines player;
    if ("ItemTankTrap" in _mags || "ItemSandbag" in _mags || "ItemWire" in _mags || "PartWoodPile" in _mags || "PartGeneric" in _mags) then {
        hasBuildItem = true;
    } else { hasBuildItem = false;};
    //Build Recipe Menu Action

    if((speed player <= 1) && hasBuildItem && _canDo) then {
        if (s_player_recipeMenu < 0) then {
            s_player_recipeMenu = player addaction [("<t color=""#0074E8"">" + ("Build Recipes") +"</t>"),"buildRecipeBook\build_recipe_dialog.sqf","",5,false,true,"",""];
        };
    } else {
        player removeAction s_player_recipeMenu;
        s_player_recipeMenu = -1;
    };

I must be missing something, but I can't for the life of me figure it out.
 
Okay, so I just spent over 2 hours trying to fix this, posted the thread, and 10 minutes later I figured it out. Typical.

I had, in typical fashion, added the new globals to the end of the file:

Code:
    player removeAction s_player_createladder;
    s_player_createladder = -1;   
    player removeAction s_player_createladder2;
    s_player_createladder2 = -1;

Which, in my newbieness, I assumed was initialization. And it does have that affect. But it gets called whenever an if check about 200 lines above it fails... which includes a check for !isNull CursorTarget.

So, I removed those lines and added createladder/createladder2 to the variables.sqf, and it works. Woo!

I've still got some things to do, but I'll post it as finished change instructions once I've got it all working properly (scrap metal, etc).
 
Thanks again Darrik for working with me on this!!! Ive been racking my brain on our final problem of the two ladders part. What if we used something like this instead?
Code:
s_player_createladder  = player addAction [format["Create Small Ladder"], "VFladder\createladder.sqf",[player,0], 0, false, true, "",""];
}else{
s_player_createladder2 = player addAction [format["Create Big Ladder"], "VFladder\createladder.sqf",[player,1], 0, false, true, "",""];
would the "else" create the break and decipher between the two stopping both ladders from being built at the same time? It doesnt look right so I havnt tried it yet. What do you think?
 
This may make you giggle but what about this?
Code:
if ("PartGeneric" in _mags) then {
        hasGenericPart = true;
    } else { hasGenericPart = false;};
    if((speed player <= 1) && hasGenericPart && _canDo) then {
        if (s_player_createladder <0) then {
            s_player_createladder  = player addAction [format["Create Small Ladder"], "VFladder\createladder.sqf",[player,0], 0, false, true, "",""];
        if ((s_player_createladder <0) and ("Create Small Ladder", false")) then {
            s_player_createladder2 = player addAction [format["Create Big Ladder"], "VFladder\createladder.sqf",[player,1], 0, false, true, "",""];
          };
    } else {
        player removeAction s_player_createladder;
        s_player_createladder = -1;   
        player removeAction s_player_createladder2;
        s_player_createladder2 = -1;
Theres gotta be a fairly simple command for one to block the other.
 
UGH! Maybe? Cant test these at the moment cause theres players in. Need a test server, lol.
Code:
if((speed player <= 1) && hasGenericPart && "Create Small Ladder", false && _canDo) then {
        if (s_player_createladder <0) then {
            s_player_createladder  = player addAction [format["Create Small Ladder"], "VFladder\createladder.sqf",[player,0], 0, false, true, "",""];
            s_player_createladder2 = player addAction [format["Create Big Ladder"], "VFladder\createladder.sqf",[player,1], 0, false, true, "",""];
          };
 
I have an expiring subscription on a server (not the one in my sig). Maybe 2 weeks left. I could add this and you'd be more than welcome to test stuff out? This looks really cool, and just what a map like Taviana could use, with all the big cities and rows of houses.
 
Thanks for that offer and ill let ya know but we did get it working. We just have a small issue of being able to pop up both the big and small ladder at the same time.
 
Gary, I don't think the problem is that - the if checks there just check whether the action is already on your mouse menu. It doesn't check in selfAction at the moment that there is a ladder up and waiting to be placed (when you are moving around to place it with it visible in front of you). I think the place ladder script might offer a clue. I haven't really looked at it since last night, but I think that place ladder sqf (lad_place?) sets a variable to 1. Look for where it sets the initial value, and check for that. If it sets that variable to 0 when you call create ladder, that's what you want to check for in the script. I definitely won't be doing any work on it tonight, but if I get any further tomorrow I'll let you know. It's a global variable, but I think it's local to the client. But if that works for you, you may want to ask someone else to help test to see if it interferes with two ladders being placed on the server at the same time.
 
Ahhhh, makes sense my friend. Thank you again and you are the man! Ill give it a whack tomorrow. Thanks again!
 
Hey all, just wanted to drop in with an update about this script. Players are reporting a teleport bug with it. I haven't tried it yet so ill update the exact action as soon as I can.
 
None yet. I honestly havnt been on to check it out. Im going to try to dig into it later tonight because ill be pretty booked the rest of the weekend. Let me know if you find anything out?

Darrik, I have another one I had played with a few days ago also. Any interest in working on it with me? Let me know and ill inbox you the details.
 
Hey bro, you had any chance to mess with this? I haven't but may have time later this week. Just curious.
 
Negative. I've gotten it working as we discussed, but haven't even added the multi-ladder check to see if that works. Since I don't know when the teleport issue is happening, I can't really test for that. I played around with placing ladders, and didn't get teleported, so without more info I can't reproduce the problem.
 
I tried and can't get it to do what my players reported it doing either. Ill update as soon as one of them is on and can show me.
 
got it to do the teleport bug yesterday. Once player selects the ladder to build and it appears in front of them, the player will get the mount arrow sometimes before getting the drop ladder option. If they select to mount the ladder they will drop into the ground and start skipping across the map. Im looking now into an "if" statement to put into play for the drop action. The other one needed is for raise, lower, and flip. If player places the ladder, then mounts, they can still select to raise, lower, or flip. Ive scaled buildings (takes a while) while testing this.
 
Might try removing the 'climb ladder' action from the ladder itself while it's being placed, then put it back on when it's dropped. No idea if it'll work or not.

Sorry, I haven't been around much over the last couple weeks - been distracted.
 
No need to apologize my friend. I'm just getting to it now myself. I'm not sure there's a climb ladder in the script as its a game function already.
 
Back
Top