clydefrog 3 Posted December 13, 2014 I'm getting the "undefined variable in expression" error on line 19 of my script which is the following code: switch (_unitrole) do { Here is part of the script: _unit = _this select 0; _unitrole = _this select 1; waitUntil {!isNull player}; switch (_unitrole) do { case "BluRifleman": { // remove everything from player except uniform removeAllWeapons _unit; removeUniform _unit; removeVest _unit; removeBackpackGlobal _unit; removeGoggles _unit; removeHeadgear _unit; }; }; How do I properly define _unitrole in this case? Share this post Link to post Share on other sites
dreadedentity 278 Posted December 13, 2014 _this select 1 doesn't exist so the game sets _unitrole to nil. Basically it looks like this: _unitrole = nil; Check the other script where you call this one and make sure all of the parameters are filled in Share this post Link to post Share on other sites
clydefrog 3 Posted December 13, 2014 _this select 1 doesn't exist so the game sets _unitrole to nil. Basically it looks like this: _unitrole = nil; Check the other script where you call this one and make sure all of the parameters are filled in There isn't another script, this is a script that is executed in a players init. Share this post Link to post Share on other sites
Jona33 51 Posted December 13, 2014 How are you calling the script? Share this post Link to post Share on other sites
dreadedentity 278 Posted December 14, 2014 There isn't another script, this is a script that is executed in a players init. I'm assuming the players init looks something like this, then? [this] execVM "myScript.sqf"; this is a magic variable that refers to the object itself, but that's it, just that one element. You should change it to something like: [this, "Pilot"] execVM "myScript.sqf"; Share this post Link to post Share on other sites
jshock 513 Posted December 14, 2014 Just an FYI, but the comment in your code block above states "Remove everything from the player execpt the uniform", but there is the removeUniform statement in the code, not sure if that was just a copy paste mistake, but figured I would point it out :p. Share this post Link to post Share on other sites
clydefrog 3 Posted December 25, 2014 I'm assuming the players init looks something like this, then? [this] execVM "myScript.sqf"; this is a magic variable that refers to the object itself, but that's it, just that one element. You should change it to something like: [this, "Pilot"] execVM "myScript.sqf"; That's exactly how it's called in the player init. Anyways somehow this issue resolved itself. I didn't change anything but the error just stopped coming up. And yeah Jshock I had a few different versions as I heard using add/removeUniform could be a bit dodgy and cause uniforms to disappear, in the end I got rid of any code to add or remove uniforms. Share this post Link to post Share on other sites
austin_medic 109 Posted December 25, 2014 That's exactly how it's called in the player init. Anyways somehow this issue resolved itself. I didn't change anything but the error just stopped coming up.And yeah Jshock I had a few different versions as I heard using add/removeUniform could be a bit dodgy and cause uniforms to disappear, in the end I got rid of any code to add or remove uniforms. You sure you didn't just get rid of the -showscripterrors launch param (or steam didn't get rid of it)? Problems like that don't just magically erase themselves. Anyhow if you want to be safe with scripts like this you could add a check to see if the second variable at the top doesn't exist, then you could create it with a default value: _unit = _this select 0; _unitrole = _this select 1; if(isNull _unitrole) then { _unitrole = "BluRifleman"; }; waitUntil {!isNull player}; switch (_unitrole) do { case "BluRifleman": { // remove everything from player except uniform removeAllWeapons _unit; removeUniform _unit; removeVest _unit; removeBackpackGlobal _unit; removeGoggles _unit; removeHeadgear _unit; }; }; Share this post Link to post Share on other sites
jshock 513 Posted December 25, 2014 I have my redress script, and never had any reports on issues with uniforms disappearing, so as far as my experience, your information is off. Share this post Link to post Share on other sites
clydefrog 3 Posted December 27, 2014 I have my redress script, and never had any reports on issues with uniforms disappearing, so as far as my experience, your information is off. https://www.google.co.uk/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=arma%203%20uniform%20disappears Share this post Link to post Share on other sites
jshock 513 Posted December 27, 2014 Ok, and you realize that issue was put up over a year ago right, I'm pretty sure by now it's fixed. Share this post Link to post Share on other sites