wyattwic 38 Posted April 25, 2017 Hey guys, For some reason, CreateVehicle below isn't throwing any errors, but isn't creating anything. I changed everything to public variables and inspected it, it is being passed the correct string. If I change to the alternate syntax, I get an error as if I passed nil for a string on the original syntax. Any suggestions would be awesome! player setVariable ["NadeIsActive","wait"]; _currentNade = ((currentThrowable player) select 0); _special = ["I_IR_Grenade","O_IR_Grenade","B_IR_Grenade","MiniGrenade","HandGrenade","HandGrenade_Stone"]; if (_currentNade in _special) then { _specialtypes = [["I_IR_Grenade","I_IRStrobe"],["O_IR_Grenade","O_IRStrobe"],["B_IR_Grenade","B_IRStrobe"],["MiniGrenade","mini_Grenade"],["HandGrenade","GrenadeHand"],["HandGrenade_Stone","GrenadeHand_stone"]]; { if (_currentNade isequalto (_x select 0)) then { _spawnthisnade = _x select 1; }; } foreach _specialtypes; } else { _spawnthisnade = _currentNade; }; _nade = _spawnthisnade createVehicle position player; Share this post Link to post Share on other sites
pierremgi 4737 Posted April 26, 2017 You need to spawn a "groundWeaponHolder" (a sort of invisible recipient), instead of your grenades. Then fill it with your grenade (addItemCargoGlobal does the job). Share this post Link to post Share on other sites
wyattwic 38 Posted April 26, 2017 (edited) 42 minutes ago, pierremgi said: You need to spawn a "groundWeaponHolder" (a sort of invisible recipient), instead of your grenades. Then fill it with your grenade (addItemCargoGlobal does the job). Thanks Piereemgi, but I am not trying to place an inactive grenade. I am trying to create an active one. The above code, when I have a hand grenade in my inventory as my actively selected grenade, should produce this "GrenadeHand" createVehicle position player and that works. Edited April 26, 2017 by wyattwic Share this post Link to post Share on other sites
Larrow 2794 Posted April 26, 2017 Your variable _spawnthisnade is undefined where the createVehcile command is used, as it is inside the scope of the IF statement. Either private the variable outside of the IF statement.. private [ "_spawnthisnade" ]; //rest of code as is or use the return from the statement... _spawnthisnade = if (_currentNade in _special) then { _specialtypes = [["I_IR_Grenade","I_IRStrobe"],["O_IR_Grenade","O_IRStrobe"],["B_IR_Grenade","B_IRStrobe"],["MiniGrenade","mini_Grenade"],["HandGrenade","GrenadeHand"],["HandGrenade_Stone","GrenadeHand_stone"]]; { if (_currentNade isEqualTo (_x select 0)) exitWith { _x select 1; }; }forEach _specialtypes; } else { _currentNade; }; 1 Share this post Link to post Share on other sites
wyattwic 38 Posted April 26, 2017 Thank you @Larrow! IDK how I missed that. I'll give it a try after lunch and release it when I am done. This is part of a cook/carry grenade script I've been working on. Share this post Link to post Share on other sites
killzone_kid 1326 Posted April 26, 2017 10 hours ago, Larrow said: private [ "_spawnthisnade" ]; Just want to mention that on very rare occasion this might not be enough. If possible, it is always better to assign default value too. private _spawnthisnade = ""; 1 Share this post Link to post Share on other sites
pierremgi 4737 Posted April 26, 2017 2 hours ago, killzone_kid said: Just want to mention that on very rare occasion this might not be enough. If possible, it is always better to assign default value too. private _spawnthisnade = ""; Please, could you explain what could be the difference between: private _spawnthisnade = ""; and _spawnthisnade = ""; Thanks. Share this post Link to post Share on other sites
Larrow 2794 Posted April 26, 2017 4 hours ago, killzone_kid said: Just want to mention that on very rare occasion this might not be enough. Really. In what conditions does it fail? I mean I know it will be nil if its never given a value but I have never seen it fail to define a variable in a higher scope from where it has its value set. Can you elaborate KK? Share this post Link to post Share on other sites
killzone_kid 1326 Posted April 26, 2017 31 minutes ago, Larrow said: Really. In what conditions does it fail? I mean I know it will be nil if its never given a value but I have never seen it fail to define a variable in a higher scope from where it has its value set. Can you elaborate KK? I don't remember exact circumstance, but it involved a few scopes. Even though private ["_blahblah"] was used before all of those scopes it wasn't enough somehow. Only after forcing value on it I was able to solved it. So I just added this to Arma "perks" in my mind under, "safe way of doing things" category ;) Share this post Link to post Share on other sites