Jump to content

L.Trale

Member
  • Content Count

    45
  • Joined

  • Last visited

  • Medals

  • Medals

Everything posted by L.Trale

  1. 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"]; }; }; };
  2. Ah, thank you very much for your help guys :)
  3. L.Trale

    Paradrop Boxes

    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.
  4. 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)
  5. So you're just trying to change the accuracy of the units with RPGs? Heres a few things I found: http://www.armaholic.com/forums.php?m=posts&q=22942 https://community.bistudio.com/wiki/setSkill_array Hope this helps
  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. 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?
  8. L.Trale

    Help with Dog Script

    Thanks for the heads up. In the meantime, you can use this to stop the looping animal animations: _animal disableAI "ANIM";
  9. 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.
  10. _Stab = if (player == _Selector) then {player addaction ["STAB", "Stab.sqf"]} else {}; is working fine, but I might need this for something else. Thanks for the help! :D
  11. I'm a bit rusty at scripting as I took a few months off. Can someone help me with this? _Select1 = ["A", "B", "C", "D", "E"]; _Select2 = floor random count _Select1; hint ["1%", _Select1]; The Letters are the names of AIs. Thanks.
  12. So I should add something similar to if (_Selector == this) then {_Selector addaction ["STAB", "Stab.sqf"]} else {}; Think I've gotten the answer: _Stab = if (player == _Selector) then {player addaction ["STAB", "Stab.sqf"]} else {}; It seems to work, but I'll have to do more testing.
  13. Yes. The problem is that any unit can walk up to the "_Selector" and use the addaction. I've tried _Stab = _Selector addAction ["STAB", "Stab.sqf", nil, 1.5, True, True, "", "this == _Selector"]; but It doesn't work.
  14. Yes, they are the same names.
  15. I've done this, still doesn't work. I've tried messing around with the parameters for addaction but no luck. Thanks for the help though :bounce3:
  16. Do you mean _Selector = [Alpha,Bravo,Charlie,Delta,Echo] call BIS_fnc_selectRandom; _action = _Selector addAction ["Wave", "Wave.sqf"];
  17. You could open up Intel, (Crtl + W in map Editor) and switch the "Independents are friendly to: Everyone"
  18. Wow, thank you so much! ---------- Post added at 03:48 ---------- Previous post was at 03:15 ---------- Quick question; I want to make a simple Melee script. I'm using Stab_him attachto [_Alpha,[0,1,0]]; as the action, and the trigger has {_x setdamage 1} foreach thislist;. It doesn't seem to be working. (Note: It may be because the player is given a name via script, not sure)
  19. 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. :)
  20. L.Trale

    Civilians using UAV

    I'm pretty sure you can't make Civilians use UAVs. http://forums.bistudio.com/showthread.php?170303-allowing-civilian-to-use-UAV Use the search function.
  21. Maybe try using createVehicle instead of BIS_fnc_spawnvehicle? I don't use fncs that much so I'm not sure.
  22. Yeah, I know. Thanks for being helpful though. (I'm not trying to remove the action, I'm trying to hide it from other players)
  23. You don't need the "_action" part. The rest I have and it still allows other players to use that action.
  24. 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.
×