Jump to content

L.Trale

Member
  • Content Count

    45
  • Joined

  • Last visited

  • Medals

  • Medals

Posts posted by L.Trale


  1. I would rethink your variables.

     

    You have "handInUse" as a boolean and you store the item on your belt in a variable, yet for some reason you don't store the item in hand in a variable. That would make things easier, especially since you don't have to rely on nearestObject.

     

    Personally I would just use these:

    "HandItem"

    "BeltSlot1"

     

     

    Way I see it you wouldn't even have to differentiate between the tooltypes in that code. Just make a universal function for putting items from belt to hand and the other way around.

    Furthermore, don't use global variables for playerspecific information. Objectspace is more useful and gives you better options for server/client interaction.

     

    Here is what I would do:

    beltSlots = [
    	["BeltSlot1",[0.2,0,0],"Pelvis"],
    	["BeltSlot2",[-0.2,0,0],"Pelvis"]
    ];
    
    fnc_useBelt = {
    	param ["_unit","_slotnum"];
            private ["_slot","_slotname","_slotpos","_slotpoint","_beltItem","_handItem","_beltitem","_InHand","_isInCargo"];
    
    	_slot = beltSlots select _slotnum;
    	_slotname = _slot select 0;
    	_slotpos = _slot select 1;
    	_slotpoint = _slot select 2;
    
    	_beltItem = _unit getVariable [_slotname,objNull];
    	_handItem = _unit getVariable ["handItem",objNull];
    
    	if (isNull _handItem) then {
    		// empty hand -> try to grab item from belt
    		if (isNull _beltItem) then {
    			_unit setVariable ["tool", "", true];
    			"no Item in that slot."
    		} else {
    			_unit setVariable ["handItem", _beltItem, true];
    			_unit setVariable [_slotname, objNull, true];
    			_unit setVariable ["tool", typeOf _beltitem, true];
    
    			_beltitem setVariable ["_InHand", true, true];
    			_beltitem setVariable ["_isInCargo", false, true];
    
    			[_unit,"AmovPercMstpSrasWpstDnon_AmovPercMstpSnonWnonDnon"] remoteExec ["playMove", 0, false];
    			sleep 1;
    			_beltItem attachTo [_unit, [0,0,0], "righthandmiddle1"];
    
    			"took item from " + _slotname
    		};
    	} else {
    		// item in hand -> check belt
    		if (isNull _beltItem) then {
    			_unit setVariable ["handItem", objNull, true];
    			_unit setVariable [_slotname, _handItem, true];
    			_unit setVariable ["tool", "", true];
    			
    			_handItem setVariable ["_InHand", false, true];
    			_handItem setVariable ["_isInCargo", true, true];
    			
    			[_unit,"AmovPercMstpSrasWpstDnon_AmovPercMstpSnonWnonDnon"] remoteExec ["playMove", 0, false];
    			sleep 1;
    			_handItem attachTo [_unit, _slotpos, _slotpoint];
    
    			"item stored in " + _slotname
    		} else {
    			"this slot is full."
    		};
    	};
    };
    

    This easily allows for multiple beltslots and doesn't care what Items you put on them.

    Use like this:

     

    _callback = [player,0] call fnc_useBelt;

     

    _callback will give you a response of the function. Note that beltslot1 has id 0.

     

     

     

     

     

    - - - - -

    @HazJ

     

    Why would you use this?

    if (isNil {player getVariable "Item_In_Hand"}) then {
    	_Unit setVariable ["Item_In_Hand", [false, ""], true];
    };
    

    When this is enough:

    _Unit getVariable ["Item_In_Hand", [false, ""]];
    

    There is no need to check for "isNil" with getVariable. Just put the default value as second parameter.

     

    Ah, thank you very much for your help guys  :)


  2. Hi All,

    I am using ACE 3 and RHS. 

    My goal is to paradrop some crates when C130 reaches a waypoint.

    I created a box which is on ground and want to load it into C130 by a code.

    Any idea how to do this with ACE3 load?

    I thought loadcargo [box, c130, false] 

    Should do the trick but didn't work out.

    In addition to that simple unload cargo will drop the box with parachute right?

     

    You could attach the crate to the plane, detect when the plane is near the waypoint, and then detach the crate when its near.

     

    Put this in the init of the crate and name your crate something like "Crate1" and name the plane something like "Plane".

    this disableCollisionWith plane; //Just in case they collide, no boom
    this attachTo [plane,[0,0,-1]]; //attach it to the plane, fiddle with the position
    

    You can use a trigger to make the plane drop the crate.

    Put this in the condition field of the trigger:

    Plane in thisList;
    

    Put this in the act field of the trigger:

    detach Crate1; //off it goes
    Chute = "B_Parachute_02_F" createVehicle position Crate1; //Create the chute
    Chute attachTo [Crate1, [0,0,1]]; // attach the chute to the crate
    

    You'll have to mess around with it, its not tested but should work.


  3. I would take a serious look at switch case commads as it's easier to read for this sort of stuff.

    I did try it but couldn't get very far as I can't seem to set it up correctly and a bit short of time.

     

    Are the type of objects correct, "Land_Saw_F" seems to appear right at the end.

     

    I did look into switch case, but It gives the same results.

    The objects are correct, the saw part is to check if the item the player has in their hands is a saw. I'm trying to get it to check in this order:

     

    1. Does the player have an item in their hands and the belt slot is empty?

    Yes (go to 1a), No (go to 2)

     

    1a. Does the player have a Hammer in their hands?

    Yes (Put item in belt), No (go to 1b)

     

    1b. Does the player have a Saw in their hands?

    Yes (Put item in belt)

     

    2. Does the player have no item in their hand and a Hammer in their belt?

    Yes (Take the item out of belt and into hand), No (go to 2a)

     

    2a. Does the player have no item in their hand and a Saw in their belt?

    Yes (Take the item out of belt and into hand) 


  4. Hello,

     

    I'm trying to make a script that uses multiple if then else statements, but for some reason it won't change a variable.

     

    (Messy code, sorry, still using notepad  :D )

    //Inventory Slot 1.
    _Item = nearestObject [player, "Thing"]; 
    if ((HandInUse) && (BeltSlot1 == "isEmpty") && (_Item isKindOf "Land_Hammer_F")) then { //HandInUse is a bool variable on the player, BeltSlot1 is a string on the player
    	_Item setVariable ["_isInCargo", true]; //_isInCargo is a bool variable on the object, same with below.
    	_Item setVariable ["_InHand", false];
    	BeltSlot1 = typeOf ItemInHand; //Setting the value of BeltSlot1 to the detected item in players hand. ItemInHand is  on the player
    	player playMove "AmovPercMstpSrasWpstDnon_AmovPercMstpSnonWnonDnon";
    	sleep 0.9;
    	Tool = 0; //Located on player
    	HandInUse = false;
    	sleep 0.1;
    	_Item attachTo [player, [0.2,0,0], "Pelvis"];
    	exit;
    } else {
    	if ((HandInUse) && (BeltSlot1 == "isEmpty") && (_Item isKindOf "Land_Axe_F")) then { //If its not hammer time, check if its a saw
    	_Item setVariable ["_isInCargo", true];
    	_Item setVariable ["_InHand", false];
    	BeltSlot1 = typeOf ItemInHand;
    	player playMove "AmovPercMstpSrasWpstDnon_AmovPercMstpSnonWnonDnon";
    	sleep 0.9;
    	Tool = 0;
    	HandInUse = false;
    	sleep 0.1;
    	_Item attachTo [player, [0.2,0,0], "Pelvis"];
    	exit;
    } else {
    	if ((!HandInUse) && (BeltSlot1 == "Land_Hammer_F") && (_Item isKindOf "Land_Hammer_F")) then { //If you've got an item on your belt, take it into your hands
    	_Item setVariable ["_isInCargo", false];
    	_Item setVariable ["_InHand", true];
    	BeltSlot1 = "isEmpty";
    	HandInUse = true; //Where it goes south. Won't change this to true for some reason?
    	player playMove "AmovPercMstpSrasWpstDnon_AmovPercMstpSnonWnonDnon";
    	sleep 0.9;
    	Tool = 1;
    	sleep 0.1;
    	_Item attachTo [player, [0,0,0], "righthandmiddle1"];
    	exit;
    } else {
    	if ((!HandInUse) && (BeltSlot1 == "Land_Saw_F") && (_Item isKindOf "Land_Saw_F")) then { //same as above, except for Saw
    	_Item setVariable ["_isInCargo", false];
    	_Item setVariable ["_InHand", true];
    	BeltSlot1 = "isEmpty";
    	HandInUse = true;
    	player playMove "AmovPercMstpSrasWpstDnon_AmovPercMstpSnonWnonDnon";
    	sleep 0.9;
    	Tool = 3;
    	sleep 0.1;
    	_Item attachTo [player, [0,0,0], "righthandmiddle1"];
    	exit;
    };
    };
    };
    };
    
    

    I know the code isn't very efficient, I'm just experimenting for the most part. The problem is that everything else works except for changing the "HandInUse" variable.

     

    Any ideas on whats going on?

     

    Update:

    I've neatened up the code a little bit to make it a little bit less of an eye sore and changed some things around, but still have the same result. I'm calling this from the init, when the player presses the 1 key (shown below). 

    waituntil {!isnull (finddisplay 46)};
    (findDisplay 46) displayAddEventHandler ["KeyDown","_this select 1 call MY_KEYDOWN_FNC;false;"];
    
    MY_KEYDOWN_FNC = {
        switch (_this) do {
    
    //Key 1
            case 2: {
                nul = [] execVM "Mechanics\Inventory\Belt_Slot1.sqf";
    
    };
    };
    };
    

    Updated Code:

    //File: Belt_Slot1.sqf
    //Desc: Action for putting item on tool belt.
    
    _Item = nearestObject [player, "Thing"];
    
    if ((HandInUse) && (BeltSlot1 == "isEmpty")) then
    {	
    	if (_Item isKindOf "Land_Hammer_F") then
    	{
    	_Item setVariable ["_isInCargo", true];
    	_Item setVariable ["_InHand", false];
    	BeltSlot1 = typeOf ItemInHand;
    	player playMove "AmovPercMstpSrasWpstDnon_AmovPercMstpSnonWnonDnon";
    	sleep 0.9;
    	Tool = 0;
    	HandInUse = false;
    	sleep 0.1;
    	_Item attachTo [player, [0.2,0,0], "Pelvis"];
    	} else
    		{
    		if (_Item isKindOf "Land_Axe_F") then {
    		_Item setVariable ["_isInCargo", true];
    		_Item setVariable ["_InHand", false];
    		BeltSlot1 = typeOf ItemInHand;
    		player playMove "AmovPercMstpSrasWpstDnon_AmovPercMstpSnonWnonDnon";
    		sleep 0.9;
    		Tool = 0;
    		HandInUse = false;
    		sleep 0.1;
    		_Item attachTo [player, [0.2,0,0], "Pelvis"];
    		};
    	};
    } else 
    	{
    	if ((!HandInUse) && (BeltSlot1 == "Land_Hammer_F")) then
    	{
    	_Item setVariable ["_isInCargo", false];
    	_Item setVariable ["_InHand", true];
    	BeltSlot1 = "isEmpty";
    	HandInUse = true;
    	player playMove "AmovPercMstpSrasWpstDnon_AmovPercMstpSnonWnonDnon";
    	sleep 0.9;
    	Tool = 1;
    	sleep 0.1;
    	_Item attachTo [player, [0,0,0], "righthandmiddle1"];
    	} else 
    		{
    		if ((!HandInUse) && (BeltSlot1 == "Land_Saw_F") && (_Item isKindOf "Land_Saw_F")) then
    		{
    		_Item setVariable ["_isInCargo", false];
    		_Item setVariable ["_InHand", true];
    		BeltSlot1 = "isEmpty";
    		HandInUse = true;
    		player playMove "AmovPercMstpSrasWpstDnon_AmovPercMstpSnonWnonDnon";
    		sleep 0.9;
    		Tool = 3;
    		sleep 0.1;
    		_Item attachTo [player, [0,0,0], "righthandmiddle1"];
    		};
    	};
    };
    

  5. I'm having a problem selecting an option for a module. I'm trying to use the Zeus Game Master Module, and trying to change the default addons to "NONE", but when I select it and select OK, it sets the default addons to default. It works for every other option except for "NONE". Anyone else having problems with Eden Dialog?


  6. Hello, I've been using this script for a while and back in the Alpha/Beta it worked properly. 

    attack = false;
    "Alsatian_Sandblack_F" createUnit [getPos player, group player];
    dog = nearestobject [getpos player,"animal"];
    dog setVariable ["BIS_fnc_animalBehaviour_disable", true];
    [dog] join grpNull;
    null=[] spawn { while {alive dog} do 
    {waituntil {!attack};
    sleep 2;
    dog domove getpos player}};
    

    The dog doesn't follow the player anymore like it used to. After doing some research, I found this: 

    dog setVariable ["BIS_fnc_animalBehaviour_disable", true];
    

    This is supposed to override the default AI of the dog. This to is not working.

     

    I've tried to disable the dogs animations and FSM but no luck, still the same problem.

    I've also tried using createAgent instead of createUnit.


  7. Hello,

    I'm making a mission which includes a lot of Arrays. So I made this simple script:

    cost=1;  
    yourmoney = myVariable2; 
    if (yourmoney  < cost) then {hint "You don't have any Tomato Seeds!"} else { yourmoney = yourmoney - cost;hint  format ["%1 Tomato Seed(s) Remaining", myVariable2];
    
    Plant = "Land_BottlePlastic_V1_F" createVehiclelocal position player;
    Plant attachTo [item, [0, 0, 0] ];
    player playMove "AinvPknlMstpSnonWnonDnon_1";
    sleep 1;
    deleteVehicle Item;
    Detach Plant;
    Plant addAction ["Check State", "Actions\CheckState.sqf"];
    execVM "Plant_init\Tomato_init.sqf";
    myVariable2 = yourmoney; };

    It works great but there is only one problem; If you use the script more than once, it breaks. i.e I plant a Tomato, then I plant another one. Everything is good until this next part:

    hint "You've planted a Tomato Plant.";
    sleep 10;
    PlantS2 = "Sign_Pointer_F" createVehiclelocal position Plant;
    PlantS2 attachTo [Plant, [0, 0, 0.2] ];
    sleep 20;
    DeleteVehicle PlantS2;
    PlantS3 = "Sign_Pointer_Pink_F" createVehiclelocal position Plant;
    PlantS3 attachTo [Plant, [0, 0, 0.2] ];
    sleep 20;
    DeleteVehicle PlantS3;
    PlantS4 = "Sign_Pointer_Yellow_F" createVehiclelocal position Plant;
    PlantS4 attachTo [Plant, [0, 0, 0.2] ];
    sleep 30;
    DeleteVehicle PlantS4;
    PlantS5 = "Sign_Pointer_Green_F" createVehiclelocal position Plant;
    PlantS5 attachTo [Plant, [0, 0, 0.2] ];
    Plant addAction ["Harvest Tomato", "Actions\Harvest_Tomato.sqf"];

    Then the only one plant grows, and the other just sits there. I've tried createVehiclelocal, but no luck.

    I've also tried to use private arrays:

     private ["Plant", "PlantS2", "PlantS3", "PlantS4"]; [code]

    Any help? Thanks.


  8. Tried to explain this the best I could in the title. (Obviously, something is wrong, right?)

    Here's the code I'm working on. I'm trying to teleport players to a random marker on the map.

    _Place = ["Basecamp", "Shacks"] call BIS_fnc_selectRandom;
    sleep 1;
    hint format ["Map Selected: %1", _Place];
    sleep 1;
    Alpha1 setPosATL (getMarkerPos "_Place");

    Everything goes good until It teleports the player. When it does, it teleports them to the bottom of the Ocean.

    I've tried using getPos and setPos, and I've searched for an answer. Any help would be greatly appreciated. :)


  9. Thank you so much. I also made a few embarrassing errors. Forgot the "format" after hint and the "%1". Thanks!

    ---------- Post added at 21:49 ---------- Previous post was at 21:42 ----------

    Quick question; how do I add an action the the person selected? Thanks

    ---------- Post added at 21:58 ---------- Previous post was at 21:49 ----------

    Scratch that, found it. Another quick question; how do you add an action to just the player? For example, I want A to have an action "Wave", but other players can use the action on him.

×