Scopey 10 Posted February 2, 2010 (edited) i trying to get a user defined variable in intgr form to be shared between scripts. example. _amountofbombs = ctrlText 4; if (!(_amountofbombs call ISSE_str_isInteger)) then {_amountofbombs = "0";}; _amountofbombs = _amountofbombs call ISSE_str_StrToInt; if (_amountofbombs < 0) then {_amountofbombs = 0;}; gets the user input fine. then buttonSetAction [3, format["if ((lbCurSel 1) >= 0) then {[(lbData [1, (lbCurSel 1)]), %1, ctrlText 4] execVM ""createbombs.sqf""; closedialog 0; [0,0,0,[%1]] execVM ""bombshopdialog.sqf"";};", _bombshopNum] ]; calls the next script to activate when button pressed. but the next script wont get any variables from previous scripts. should i define as follows? in first script: _bombcounter setVariable ["mycounter", _amountofbombs, true]; in script that activates on button: _amountofbombs = _bombcounter getVariable "mycounter"; and do i need to define _bombcounter in my init.sqf? or am i just having a brain fart? any help welcomed Edited February 2, 2010 by Scopey Share this post Link to post Share on other sites
Scopey 10 Posted February 3, 2010 bump... any help?? as in will my idea work or another way i can code for the end result.. id be happier if there was a way the variable could be sent when button pressed Share this post Link to post Share on other sites
noubernou 77 Posted February 3, 2010 The function setVariable only works on objects in the game world. :) You want to use public variables, which are any variable that doesnt start with an underscore. Also you should prefix any of the variables you use in the public namespace with something unique. For example, for my personal projects i prefix all public variables with "NOU_" and for ACE2 its "ACE_" that way you do not get variable conflicts. :) To make sure you are not stepping on someone elses toes register your prefix tag here: http://www.ofpec.com/tags/ Share this post Link to post Share on other sites
Monsada 10 Posted February 3, 2010 (edited) Hi scopy, 1-Try using global variables, instead of using _amountofbombs try SCOPY_amountofbombs for example. 2- too u could try using the player as a container of your variables player setVariable ["SCOPY_mycounter", _amountofbombs, true]; _amountofbombs = player getVariable "SCOPY_mycounter"; 3- U can pas the variable as a parameter to each function NOTE:is important that if u use global variables or variables in objects u personalize this like "SCOPY..." to minimice the risk of other script of other people can use the same name. I hope this will help u Edited February 3, 2010 by Monsada Share this post Link to post Share on other sites
noubernou 77 Posted February 3, 2010 Yes, when I said public, I meant global in arma 2 terms... :) I keep thinking of their scope, but thats not really correct... Share this post Link to post Share on other sites
Scopey 10 Posted February 3, 2010 thanx guys... testing now :D Share this post Link to post Share on other sites
noubernou 77 Posted February 3, 2010 Also for your IDC for your controls, remember to make them something unique. You might run into conflicts if you are down in the single digit range. Try something in the 4 or 5 digit range. :) Share this post Link to post Share on other sites
Scopey 10 Posted February 3, 2010 im tired and brain dieing... setting it global??? publicvariable "SCOPY_mycounter"; ???? defining to player didnt work... player setVariable ["SCOPY_mycounter", SCOPY_amountofbombs, true]; SCOPY_amountofbombs = player getVariable "SCOPY_mycounter"; i have even tired defining it in init.sqf 10 hours scripting for a release this weekend...grr still the first problem is stopping me... but i have made about 20 new scripts working... Share this post Link to post Share on other sites
noubernou 77 Posted February 3, 2010 //set.sqf SCOPY_mycounter = 10; //get.sqf player sideChat format["test: %1", SCOPY_mycounter]; // should spit out: TEST: 10 in game chat As long as you don't need to send those variables to all the other clients (as in you only care about the player having his own counter number, whatever), that should work. Share this post Link to post Share on other sites
Scopey 10 Posted February 3, 2010 thankyou soo much... that how i had it in the begining... but a spelling mistake and a sore head destroyed me for over 2 hours...lol Share this post Link to post Share on other sites
Monsada 10 Posted February 3, 2010 (edited) im tired and brain dieing... setting it global???publicvariable "SCOPY_mycounter"; ???? defining to player didnt work... public variable is that begins other than "_" such as: SCOPY_mycounter = 10; //this is a global variable Local variable are all ones that begins with "_" visibility of this variables is only in the current script or function. _SCOPY_mycounter = 10; //this is a local variable Edited February 3, 2010 by Monsada Share this post Link to post Share on other sites